From 029a5d6fc7775028e00886898fea9aef4283c41a Mon Sep 17 00:00:00 2001 From: DavidHLP Date: Sat, 10 Oct 2026 23:28:40 -0700 Subject: [PATCH 1/2] test(judge): restore migrated source and harness contracts --- services/judge-runtime/pom.xml | 15 +++++ .../ConfiguredJudgingCaseSourceTest.java | 64 +++++++++++++++++-- .../contract/DFormEnvelopeContractTest.java | 14 ++-- 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/services/judge-runtime/pom.xml b/services/judge-runtime/pom.xml index 6cfdcd9e73..309b0b41d1 100644 --- a/services/judge-runtime/pom.xml +++ b/services/judge-runtime/pom.xml @@ -81,6 +81,21 @@ + + + src/test/resources + + + ${project.basedir}/../../docker/sandbox/harness/contract + contract + + input.schema.json + envelope.schema.json + golden/input.json + golden/envelope.json + + + org.apache.maven.plugins diff --git a/services/judge-runtime/src/test/java/com/ulticode/modules/queue/pipeline/source/ConfiguredJudgingCaseSourceTest.java b/services/judge-runtime/src/test/java/com/ulticode/modules/queue/pipeline/source/ConfiguredJudgingCaseSourceTest.java index 294b80f3ef..c5426227c1 100644 --- a/services/judge-runtime/src/test/java/com/ulticode/modules/queue/pipeline/source/ConfiguredJudgingCaseSourceTest.java +++ b/services/judge-runtime/src/test/java/com/ulticode/modules/queue/pipeline/source/ConfiguredJudgingCaseSourceTest.java @@ -1,13 +1,67 @@ package com.ulticode.modules.queue.pipeline.source; -import org.junit.jupiter.api.Disabled; +import com.ulticode.modules.queue.port.JudgingCase; +import com.ulticode.modules.queue.port.adapter.ProblemExampleJudgingCaseSource; +import com.ulticode.modules.queue.port.adapter.TestCaseJudgingCaseSource; +import com.ulticode.modules.submission.port.JudgeConfigPort; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -@Disabled("P7 migration: port signature changes; re-enable after P7-RELOCATE-INFRA-001") -@DisplayName("Configured judging case source (disabled)") +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +@DisplayName("Configured judging case source") class ConfiguredJudgingCaseSourceTest { + @Mock private TestCaseJudgingCaseSource canonicalSource; + @Mock private ProblemExampleJudgingCaseSource legacySource; + @Mock private JudgeConfigPort configuration; + @InjectMocks private ConfiguredJudgingCaseSource source; + @Test - @DisplayName("placeholder") - void placeholder() {} + void selectsCanonicalCasesWhenEnabled() { + var cases = List.of(new JudgingCase("hidden", "hidden", "42", List.of(), true, false)); + when(configuration.isUseTestCases()).thenReturn(true); + when(canonicalSource.loadCases(42L)).thenReturn(cases); + + assertThat(source.loadCases(42L)).isSameAs(cases); + verifyNoInteractions(legacySource); + } + + @Test + void selectsLegacyCasesWhenDisabled() { + var cases = List.of(new JudgingCase("example", "example", "42", List.of(), false, true)); + when(configuration.isUseTestCases()).thenReturn(false); + when(legacySource.loadCases(42L)).thenReturn(cases); + + assertThat(source.loadCases(42L)).isSameAs(cases); + verifyNoInteractions(canonicalSource); + } + + @Test + void doesNotFallBackWhenCanonicalCasesAreEmpty() { + when(configuration.isUseTestCases()).thenReturn(true); + when(canonicalSource.loadCases(42L)).thenReturn(List.of()); + + assertThat(source.loadCases(42L)).isEmpty(); + verifyNoInteractions(legacySource); + } + + @Test + void propagatesCanonicalFailureWithoutFallingBack() { + var failure = new IllegalStateException("canonical source unavailable"); + when(configuration.isUseTestCases()).thenReturn(true); + when(canonicalSource.loadCases(42L)).thenThrow(failure); + + assertThatThrownBy(() -> source.loadCases(42L)).isSameAs(failure); + verifyNoInteractions(legacySource); + } } diff --git a/services/judge-runtime/src/test/java/com/ulticode/modules/submission/contract/DFormEnvelopeContractTest.java b/services/judge-runtime/src/test/java/com/ulticode/modules/submission/contract/DFormEnvelopeContractTest.java index d6c42372fb..2498bfc2e6 100644 --- a/services/judge-runtime/src/test/java/com/ulticode/modules/submission/contract/DFormEnvelopeContractTest.java +++ b/services/judge-runtime/src/test/java/com/ulticode/modules/submission/contract/DFormEnvelopeContractTest.java @@ -26,16 +26,13 @@ * *

Authoritative source: {@code docker/sandbox/harness/contract/CONTRACT.md}. * The schemas and golden files live next to that spec; they are also - * mirrored into {@code src/test/resources/contract/} so the JVM test lane - * can read them off the classpath without needing the harness source tree. + * copied into the test classpath by Maven from that canonical directory. * *

Scope (additive — no runtime change): *

    *
  1. Decoding: a real-shaped envelope (golden) decodes via - * {@link CodeExecutionHelperImpl#parseDEnvelope} into the expected - * per-case {@link RunResultDTO.RunCaseResult} values.
  2. - *
  3. Encoding: {@link CodeExecutionHelperImpl#buildDBatchInputsJson} - * and {@link CodeExecutionHelperImpl#buildDInputsJson} emit JSON + * {@code DFormEnvelopeCodec} into the expected per-case response values.
  4. + *
  5. Encoding: the codec's batch and single-case methods emit JSON * that contains every field the input schema requires.
  6. *
  7. Vocabulary: every {@code status} value in the contract is * decodable by {@link SubmissionStatusCodec#fromWire(String)}.
  8. @@ -45,7 +42,6 @@ * judge path. It runs in the regular unit-test lane. */ @DisplayName("D-form envelope contract parity (backend ↔ harness)") -@org.junit.jupiter.api.Disabled("Test fixtures not relocated; re-enable after resource migration") class DFormEnvelopeContractTest { private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -238,7 +234,7 @@ private JsonNode parseOrFail(String json) { } /** - * Synthesise a {@link RunSubmissionDTO.RunTestCase} list shaped after + * Synthesise a {@link JudgeRunRequest.TestCase} list shaped after * the golden input.json. Uses {@code UuidGenerator.newId() == "test-uuid"} * via the test-only generator wired into {@code helper}. */ @@ -266,4 +262,4 @@ private List buildTestCasesFromGoldenInput() throws Ex } return out; } -} \ No newline at end of file +} From e76c3efd50e487eacd880dcd54667af1058c6c42 Mon Sep 17 00:00:00 2001 From: DavidHLP Date: Sun, 11 Oct 2026 01:14:24 -0700 Subject: [PATCH 2/2] test(contest): retire obsolete migration placeholder --- .../projection/DefaultContestProjectionTest.java | 13 ------------- .../service/impl/ContestServiceImplTest.java | 6 ++---- 2 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 services/app/app-web/src/test/java/com/ulticode/modules/contest/projection/DefaultContestProjectionTest.java diff --git a/services/app/app-web/src/test/java/com/ulticode/modules/contest/projection/DefaultContestProjectionTest.java b/services/app/app-web/src/test/java/com/ulticode/modules/contest/projection/DefaultContestProjectionTest.java deleted file mode 100644 index a14c18cc54..0000000000 --- a/services/app/app-web/src/test/java/com/ulticode/modules/contest/projection/DefaultContestProjectionTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.ulticode.modules.contest.projection; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; - -@Disabled("P7 migration: port signature changes; re-enable after P7-RELOCATE-INFRA-001") -@DisplayName("Default contest projection (disabled)") -class DefaultContestProjectionTest { - @Test - @DisplayName("placeholder") - void placeholder() {} -} diff --git a/services/app/app-web/src/test/java/com/ulticode/modules/contest/service/impl/ContestServiceImplTest.java b/services/app/app-web/src/test/java/com/ulticode/modules/contest/service/impl/ContestServiceImplTest.java index c8b0c25b63..8d44f197f0 100644 --- a/services/app/app-web/src/test/java/com/ulticode/modules/contest/service/impl/ContestServiceImplTest.java +++ b/services/app/app-web/src/test/java/com/ulticode/modules/contest/service/impl/ContestServiceImplTest.java @@ -49,10 +49,8 @@ import com.ulticode.common.auth.CurrentUserProvider; /** - * Write-side unit tests for {@link ContestServiceImpl}. The read-cluster cases - * (findUpcoming / findRunning / getContestProblemSubmissions) moved to - * {@link com.ulticode.modules.contest.projection.DefaultContestProjectionTest} - * when the read paths were lifted into {@link ContestProjection}. What remains + * Write-side unit tests for {@link ContestServiceImpl}. Read paths belong to + * {@link ContestProjection}. What remains * here is the contest state machine: createContest field/slug/end-time * computation (its return value is shaped by a mocked projection.toVO echo) and * the submitContestProblem guard matrix.