From afb0b3efca3a1b072768012756ea80f97f7ad083 Mon Sep 17 00:00:00 2001 From: Arcadius Ahouansou Date: Thu, 4 Jun 2026 09:10:33 +0100 Subject: [PATCH] further int test fixes --- .../cpp/hearing/steps/CourtListRestrictionSteps.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hearing-integration-test/src/test/java/uk/gov/moj/cpp/hearing/steps/CourtListRestrictionSteps.java b/hearing-integration-test/src/test/java/uk/gov/moj/cpp/hearing/steps/CourtListRestrictionSteps.java index aa7743c5a..849e1b598 100644 --- a/hearing-integration-test/src/test/java/uk/gov/moj/cpp/hearing/steps/CourtListRestrictionSteps.java +++ b/hearing-integration-test/src/test/java/uk/gov/moj/cpp/hearing/steps/CourtListRestrictionSteps.java @@ -11,6 +11,7 @@ import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static uk.gov.justice.services.common.http.HeaderConstants.USER_ID; import static uk.gov.justice.services.test.utils.core.http.BaseUriProvider.getBaseUri; import static uk.gov.justice.services.test.utils.core.http.RequestParamsBuilder.requestParams; @@ -106,6 +107,12 @@ public JsonPath hearingEventsCourtListRestrictedReceived(final Matcher matche * Required because {@link #hearingEventsCourtListRestrictedReceived(Matcher)} only confirms the * hearing event was emitted; the listener that projects it into the JPA entity runs in a * separate transaction and may lag behind the publish command if not waited for. + *

+ * A hearing-visibility precondition ({@code courtRoomId notNullValue}) is prepended to the + * caller's matcher to prevent the poll from short-circuiting on the empty/not-yet-projected + * state — without this, lenient matchers such as {@code hasNoJsonPath(...)} or + * {@code withJsonPath(..., hasSize(0))} would match an empty {@code {}} response and return + * before the restriction event has actually been processed. */ public void waitForRestrictionProjection(final String courtCentreId, final LocalDate hearingDate, @@ -118,7 +125,9 @@ public void waitForRestrictionProjection(final String courtCentreId, .withHeader(USER_ID, getLoggedInSystemUserHeader())) .timeout(60, SECONDS) .pollInterval(1, SECONDS) - .until(status().is(OK), payload().isJson(expectedPayload)); + .until(status().is(OK), payload().isJson(allOf( + withJsonPath("$.court.courtSites[0].courtRooms[0].courtRoomId", notNullValue()), + expectedPayload))); } private void sendListingPublicEvent(final JsonObject restrictCourtListDataObject) {