Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
* <p>
* 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,
Expand All @@ -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) {
Expand Down
Loading