Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
965dd14
pom version
arcadius Jun 4, 2026
71f3aef
Restriction int tests fix
arcadius Jun 3, 2026
af3df32
further int test fixes
arcadius Jun 4, 2026
210292e
Merge pull request #172 from hmcts/tmp/LPT-2325-restrict-int-tests-fix
arcadiushmcts Jun 4, 2026
afb0b3e
further int test fixes
arcadius Jun 4, 2026
b071c1a
Merge branch 'team/LPT-2325-int-tests-fix' into tmp/LPT-2325-restrict…
arcadiushmcts Jun 4, 2026
e14d9f9
Merge pull request #173 from hmcts/tmp/LPT-2325-restrict-int-tests-fix
arcadiushmcts Jun 4, 2026
7312be9
New 17.104.170-lpt2325-SNAPSHOT
Jun 4, 2026
3d02a5a
Update README.md
arcadiushmcts Jun 4, 2026
ffe25c3
Merge pull request #175 from hmcts/arcadiushmcts-patch-dummy-pr
arcadiushmcts Jun 4, 2026
7052ce5
further int test fixes
arcadius Jun 5, 2026
e0b7532
Merge branch 'team/LPT-2325-int-tests-fix' into tmp/LPT-2325-restrict…
arcadiushmcts Jun 5, 2026
bbbd463
Merge pull request #178 from hmcts/tmp/LPT-2325-restrict-int-tests-fix
arcadiushmcts Jun 5, 2026
77ff7a5
further int test fixes
arcadius Jun 5, 2026
fda6933
Merge branch 'team/LPT-2325-int-tests-fix' into tmp/LPT-2325-restrict…
arcadiushmcts Jun 5, 2026
4fb9273
Merge pull request #180 from hmcts/tmp/LPT-2325-restrict-int-tests-fix
arcadiushmcts Jun 5, 2026
9a3fc42
further2 int test fixes
arcadius Jun 5, 2026
e4c90d8
Merge branch 'team/LPT-2325-int-tests-fix' into tmp/LPT-2325-restrict…
arcadiushmcts Jun 5, 2026
6bc45a6
Merge pull request #181 from hmcts/tmp/LPT-2325-restrict-int-tests-fix
arcadiushmcts Jun 5, 2026
8053c2f
New 17.104.171-lpt2325-SNAPSHOT
Jun 5, 2026
b61b891
int test fixes
arcadius Jun 8, 2026
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 @@ -294,8 +294,8 @@ protected void stubProsecutionCases(final Hearing hearing) {
hearing.getProsecutionCases().forEach(prosecutionCase -> stubGetProgressionProsecutionCases(prosecutionCase.getId()));
}

protected void cleanDatabase(final String dbTableName) {
protected void cleanDatabase(final String dbTableName, final String... additionalTables) {
final DatabaseCleaner databaseCleaner = new DatabaseCleaner();
databaseCleaner.cleanViewStoreTables(CONTEXT_NAME, dbTableName);
databaseCleaner.cleanViewStoreTables(CONTEXT_NAME, dbTableName, additionalTables);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.moj.cpp.hearing.it;

import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasNoJsonPath;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.isJson;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.withJsonPath;
import static java.util.Optional.of;
Expand All @@ -11,6 +12,10 @@
import static org.hamcrest.Matchers.is;
import static uk.gov.moj.cpp.hearing.it.PublishLatestCourtCentreHearingEventsIT.XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26;
import static uk.gov.moj.cpp.hearing.steps.HearingEventStepDefinitions.OPEN_CASE_PROSECUTION_EVENT_DEFINITION_ID;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.awaitNewFile;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.awaitNewSentXmlForPubDisplay;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.countFilesAt;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.countSentXmlForPubDisplay;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.getFileForPath;
import static uk.gov.moj.cpp.hearing.utils.WebDavStub.getSentXmlForPubDisplay;

Expand All @@ -35,9 +40,30 @@ public class CourtListRestrictionIT extends AbstractPublishLatestCourtCentreHear

private ZonedDateTime eventTime;

/**
* Clean every table that can carry state across tests in this class. All five tests bind
* their hearings to the SAME static {@code caseId} (see
* {@link AbstractPublishLatestCourtCentreHearingIT}), so residual
* {@code is_court_list_restricted=true} on {@code ha_case} (the {@code ProsecutionCase}
* entity's table — see its {@code @Table} annotation) or {@code ha_defendant} from one
* test poisons the next. The {@code court_list_publish_status} row is also dropped so the
* FIRST publish in this class cannot inherit {@code EXPORT_SUCCESSFUL} from a prior test
* class's publish — without this,
* {@code verifyCourtListPublishStatusReturnedWhenQueryingFromAPI} returns on the stale
* status before the current publish has produced a file.
*/
private void cleanRestrictionTables() {
cleanDatabase("ha_hearing",
"ha_case",
"ha_defendant",
"ha_hearing_day",
"ha_hearing_event",
"court_list_publish_status");
}

@BeforeEach
public void setUpTest() {
cleanDatabase("ha_hearing");
cleanRestrictionTables();
eventTime = new UtcClock().now().minusMinutes(5L);
}

Expand All @@ -54,7 +80,7 @@ public void setUpTest() {
*/
@AfterEach
public void tearDownTest() {
cleanDatabase("ha_hearing");
cleanRestrictionTables();
}

@Test
Expand All @@ -71,6 +97,10 @@ public void shouldRequestToPublishCourtListWithCaseRestriction() throws Exceptio
withJsonPath("$.caseIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(true)))));

// Wait for the restriction projection to land before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails", hasSize(0)));

JsonObject publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final PublishCourtListSteps publishCourtListSteps = new PublishCourtListSteps();
Expand All @@ -96,11 +126,20 @@ public void shouldRequestToPublishCourtListWithCaseRestriction() throws Exceptio
withJsonPath("$.caseIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(false)))));

// Wait for the un-restriction projection to land before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails", hasSize(1)));

publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final int webPageCountBeforeSecondPublish = countFilesAt(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
final int pubDisplayCountBeforeSecondPublish = countSentXmlForPubDisplay();

courtCentreId = sendPublishCourtListCommand(publishCourtListJsonObject, courtCentreId);

publishCourtListSteps.verifyCourtListPublishStatusReturnedWhenQueryingFromAPI(courtCentreId);
awaitNewFile(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26, webPageCountBeforeSecondPublish);
awaitNewSentXmlForPubDisplay(pubDisplayCountBeforeSecondPublish);

filePayload = getFileForPath(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
filePayloadForPubDisplay = getSentXmlForPubDisplay();
Expand All @@ -127,6 +166,10 @@ public void shouldRequestToPublishCourtListWithDefendantRestrictionOnOff() throw
withJsonPath("$.defendantIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(true)))));

// Wait for defendant restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails[0].defendants", hasSize(0)));

final JsonObject publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");
final PublishCourtListSteps publishCourtListSteps = new PublishCourtListSteps();

Expand Down Expand Up @@ -155,8 +198,17 @@ public void shouldRequestToPublishCourtListWithDefendantRestrictionOnOff() throw
withJsonPath("$.defendantIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(false)))));

// Wait for defendant un-restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails[0].defendants", hasSize(1)));

final int webPageCountBeforeSecondPublish = countFilesAt(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
final int pubDisplayCountBeforeSecondPublish = countSentXmlForPubDisplay();

courtCentreId = sendPublishCourtListCommand(publishCourtListJsonObject, courtCentreId);
publishCourtListSteps.verifyCourtListPublishStatusReturnedWhenQueryingFromAPI(courtCentreId);
awaitNewFile(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26, webPageCountBeforeSecondPublish);
awaitNewSentXmlForPubDisplay(pubDisplayCountBeforeSecondPublish);

filePayload = getFileForPath(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
filePayloadForPubDisplay = getSentXmlForPubDisplay();
Expand Down Expand Up @@ -191,6 +243,10 @@ public void shouldRequestToPublishCourtListForApplicationRestrictionOnOff() thro
withJsonPath("$.courtApplicationIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(true)))));

// Wait for application restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails", hasSize(0)));

JsonObject publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final PublishCourtListSteps publishCourtListSteps = new PublishCourtListSteps();
Expand All @@ -216,11 +272,20 @@ public void shouldRequestToPublishCourtListForApplicationRestrictionOnOff() thro
withJsonPath("$.courtApplicationIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(false)))));

// Wait for application un-restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails", hasSize(1)));

publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final int webPageCountBeforeSecondPublish = countFilesAt(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
final int pubDisplayCountBeforeSecondPublish = countSentXmlForPubDisplay();

courtCentreId = sendPublishCourtListCommand(publishCourtListJsonObject, courtCentreId);

publishCourtListSteps.verifyCourtListPublishStatusReturnedWhenQueryingFromAPI(courtCentreId);
awaitNewFile(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26, webPageCountBeforeSecondPublish);
awaitNewSentXmlForPubDisplay(pubDisplayCountBeforeSecondPublish);

filePayload = getFileForPath(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
filePayloadForPubDisplay = getSentXmlForPubDisplay();
Expand Down Expand Up @@ -249,6 +314,10 @@ public void shouldRequestToPublishCourtListForApplicationApplicantRestrictionOnO
withJsonPath("$.courtApplicationApplicantIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(true)))));

// Wait for applicant restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
hasNoJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails[0].defendants[0].firstName"));

JsonObject publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final PublishCourtListSteps publishCourtListSteps = new PublishCourtListSteps();
Expand All @@ -274,11 +343,20 @@ public void shouldRequestToPublishCourtListForApplicationApplicantRestrictionOnO
withJsonPath("$.courtApplicationApplicantIds", hasSize(1)),
withJsonPath("$.restrictCourtList", is(false)))));

// Wait for applicant un-restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails[0].defendants[0].firstName", org.hamcrest.CoreMatchers.notNullValue()));

publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");

final int webPageCountBeforeSecondPublish = countFilesAt(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
final int pubDisplayCountBeforeSecondPublish = countSentXmlForPubDisplay();

courtCentreId = sendPublishCourtListCommand(publishCourtListJsonObject, courtCentreId);

publishCourtListSteps.verifyCourtListPublishStatusReturnedWhenQueryingFromAPI(courtCentreId);
awaitNewFile(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26, webPageCountBeforeSecondPublish);
awaitNewSentXmlForPubDisplay(pubDisplayCountBeforeSecondPublish);

filePayload = getFileForPath(XHIBIT_GATEWAY_SEND_WEB_PAGE_TO_XHIBIT_FILE_NAME_26);
filePayloadForPubDisplay = getSentXmlForPubDisplay();
Expand Down Expand Up @@ -308,6 +386,10 @@ public void shouldRequestToPublishCourtListWhenYoungDefendantIsRestrictedOnIniti
caseId, randomUUID(), courtRoom2Id, randomUUID().toString(),
OPEN_CASE_PROSECUTION_EVENT_DEFINITION_ID, eventTime, of(hearingTypeId), courtCentreId, eventTime.toLocalDate());

// Wait for the young-defendant restriction to land in the projection before publishing
courtListRestrictionSteps.waitForRestrictionProjection(courtCentreId, eventTime.toLocalDate(),
withJsonPath("$.court.courtSites[0].courtRooms[0].cases.casesDetails[0].defendants", hasSize(0)));

final JsonObject publishCourtListJsonObject = buildPublishCourtListJsonString(courtCentreId, "26");
final PublishCourtListSteps publishCourtListSteps = new PublishCourtListSteps();

Expand Down
Loading
Loading