Skip to content

Commit 83ceb34

Browse files
awkoyclaude
andcommitted
[OPIK-7159] test: assert reaper job is Guice-constructible (@config wiring)
Self-review gap: the reaper-job unit test constructs the job with `new`, so it never exercised the Guice/Quartz @config("optimizationStalledReaper") injection — which is the exact fragility the explicit-@Inject-ctor change guards against. Add an injector resolution assertion (reusing the reaper service test's booted app) so a broken @config qualifier fails the build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent dc5b76f commit 83ceb34

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

apps/opik-backend/src/test/java/com/comet/opik/domain/OptimizationStalledReaperServiceTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import com.comet.opik.api.resources.utils.TestUtils;
1414
import com.comet.opik.api.resources.utils.WireMockUtils;
1515
import com.comet.opik.api.resources.utils.resources.OptimizationResourceClient;
16+
import com.comet.opik.api.resources.v1.jobs.OptimizationStalledReaperJob;
1617
import com.comet.opik.extensions.DropwizardAppExtensionProvider;
1718
import com.comet.opik.extensions.RegisterApp;
1819
import com.comet.opik.podam.PodamFactoryUtils;
1920
import com.google.common.eventbus.EventBus;
21+
import com.google.inject.Injector;
2022
import com.redis.testcontainers.RedisContainer;
2123
import org.apache.commons.lang3.RandomStringUtils;
2224
import org.junit.jupiter.api.BeforeAll;
@@ -120,18 +122,29 @@ class OptimizationStalledReaperServiceTest {
120122

121123
private OptimizationResourceClient optimizationResourceClient;
122124
private OptimizationService optimizationService;
125+
private Injector injector;
123126

124127
@BeforeAll
125-
void beforeAll(ClientSupport client, OptimizationService optimizationService) {
128+
void beforeAll(ClientSupport client, OptimizationService optimizationService, Injector injector) {
126129
var baseURI = TestUtils.getBaseUrl(client);
127130
ClientSupportUtils.config(client);
128131

129132
this.optimizationResourceClient = new OptimizationResourceClient(client, baseURI, podamFactory);
130133
this.optimizationService = optimizationService;
134+
this.injector = injector;
131135

132136
mockTargetWorkspace(wireMock.server(), API_KEY, TEST_WORKSPACE_NAME, WORKSPACE_ID, USER);
133137
}
134138

139+
@Test
140+
@DisplayName("reaper job is constructible via Guice (@Config qualifier wiring)")
141+
void reaperJobIsInjectableFromGuice() {
142+
// The reaper is disabled/unscheduled in config-test.yml, but the bean is still bound — so this
143+
// proves the explicit @Inject constructor + @Config("optimizationStalledReaper") qualifier wire
144+
// correctly at boot (the Quartz/Guice fragility the explicit-ctor change guards against).
145+
assertThat(injector.getInstance(OptimizationStalledReaperJob.class)).isNotNull();
146+
}
147+
135148
static Stream<Arguments> stalledRuns() {
136149
return Stream.of(
137150
// INITIALIZED matched by the initialized branch (running timeout kept long so only the

0 commit comments

Comments
 (0)