diff --git a/src/contractTest/java/uk/gov/hmcts/reform/lrdapi/provider/LrdApiProviderTest.java b/src/contractTest/java/uk/gov/hmcts/reform/lrdapi/provider/LrdApiProviderTest.java index 37173c6b3..e87e8d8f3 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/lrdapi/provider/LrdApiProviderTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/lrdapi/provider/LrdApiProviderTest.java @@ -306,7 +306,7 @@ public void toReturnCourtVenuesBySearchString() { courtType.setCourtVenues(courtVenues); when(courtVenueRepository.findBySearchStringAndCourtTypeId( - any(),any(),any(),any(),any(),any())).thenReturn(courtVenues); + any(),any(),any(),any(),any(),any(),any())).thenReturn(courtVenues); } private CourtVenue getCourtVenue(Cluster cluster, Region region, CourtType courtType) { diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringFunctionalTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringFunctionalTest.java index f0b669c0c..f8b7bac83 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringFunctionalTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringFunctionalTest.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.ErrorConstants.INVALID_REQUEST_EXCEPTION; +import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.EXCEPTION_MSG_INVALID_SERVICE_CODE; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.SEARCH_STRING_VALUE_ERROR_MESSAGE; @SerenityTest @@ -71,6 +72,8 @@ void shouldRetrieveCourtVenues_By_SearchStringWithHyphen_WithStatusCode_200() { } + + @Test @ToggleEnable(mapKey = mapKey, withFeature = true) void shouldRetrieveCourtVenues_By_CourtTypeIdAndSearchString_WithStatusCode_200() { @@ -125,6 +128,22 @@ void shouldRetrieveCourtVenues_By_NoSearchString_WithStatusCode_400() { assertEquals(String.format(SEARCH_STRING_VALUE_ERROR_MESSAGE, ""), response.getErrorDescription()); } + @Test + @ToggleEnable(mapKey = mapKey, withFeature = true) + void shouldReturn400_WhenServiceCodeContainsSpecialCharacters() { + ErrorResponse response = (ErrorResponse) + lrdApiClient.retrieveResponseForGivenRequest( + HttpStatus.BAD_REQUEST, + "?search-string=Abe&service_code=AB$", + LrdCourtVenueResponse[].class, + path + ); + + assertThat(response).isNotNull(); + assertEquals(INVALID_REQUEST_EXCEPTION.getErrorMessage(), response.getErrorMessage()); + assertEquals(String.format(EXCEPTION_MSG_INVALID_SERVICE_CODE, "AB$"), response.getErrorDescription()); + } + @Test @ToggleEnable(mapKey = mapKey, withFeature = true) void shouldReturnEmptyList_WhenNoDataFound() { diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveBuildingLocationIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveBuildingLocationIntegrationTest.java index be1c9f17a..0b3949a26 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveBuildingLocationIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveBuildingLocationIntegrationTest.java @@ -523,6 +523,7 @@ private static LrdBuildingLocationResponse buildingLocation1() { .postcode("AB11 7KT") .courtAddress("AB2, 49 HUNTLY STREET, ABERDEEN") .courtVenueId("2") + .serviceCode("AAA3") .build(); courtVenueResponses.add(response3); @@ -581,6 +582,7 @@ private static LrdBuildingLocationResponse buildingLocation2() { .locationType("Court") .parentLocation("366559") .welshVenueName("testVenue") + .serviceCode("AAA2") .build(); courtVenueResponses.add(response3); @@ -610,6 +612,7 @@ private static LrdBuildingLocationResponse buildingLocation3() { .postcode("AB11 4RT") .courtAddress("AB4, 51 HUNTLY STREET, ABERDEEN") .courtVenueId("4") + .serviceCode("ABA4") .build(); courtVenueResponses.add(response3); @@ -647,6 +650,7 @@ private static LrdBuildingLocationResponse buildingLocation4() { .postcode("AB11 3RP") .courtAddress("AB9, 56 HUNTLY STREET, ABERDEEN") .courtVenueId("9") + .serviceCode("AAA2") .build(); courtVenueResponses.add(response3); @@ -686,6 +690,7 @@ private LrdBuildingLocationResponse getBuildingLocationSampleResponse() { .postcode("AB11 8IP") .courtAddress("AB3, 50 HUNTLY STREET, ABERDEEN") .courtVenueId("3") + .serviceCode("AAA6") .build(); courtVenueResponses.add(response3); diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenueDetailsIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenueDetailsIntegrationTest.java index b694aa745..2d9ae8475 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenueDetailsIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenueDetailsIntegrationTest.java @@ -506,4 +506,64 @@ void shouldReturn200WhenParameterEpmIdsValueAllWithYAndSpacePassed() throws assertThat(response).isNotEmpty().hasSize(1); } + + @Test + @SuppressWarnings("unchecked") + void retrieveCourtVenues_WithEpimmsId_ShouldReturnServiceCodeInResponse() throws JsonProcessingException { + + final var response = (List) + lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=123456789", + LrdCourtVenueResponse[].class, path); + + assertThat(response).isNotEmpty().hasSize(1); + LrdCourtVenueResponse venueResponse = response.get(0); + assertNotNull(venueResponse.getServiceCode()); + assertTrue(venueResponse.getServiceCode().matches("[A-Z0-9]+")); + } + + @ParameterizedTest + @CsvSource({ + "123456789,AAA6", + "123461,AAA2", + "123462,AAA3" + }) + @SuppressWarnings("unchecked") + void retrieveCourtVenues_WithEpimmsId_ShouldReturnCorrectServiceCode(String epimmsId, String expectedServiceCode) + throws JsonProcessingException { + + final var response = (List) + lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=" + epimmsId, + LrdCourtVenueResponse[].class, path); + + assertThat(response).isNotEmpty().hasSize(1); + assertEquals(expectedServiceCode, response.get(0).getServiceCode()); + } + + @Test + @SuppressWarnings("unchecked") + void retrieveCourtVenues_AllVenues_ShouldAllHaveServiceCode() throws JsonProcessingException { + + final var response = (List) + lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=ALL", + LrdCourtVenueResponse[].class, path); + + assertThat(response).isNotEmpty(); + assertTrue(response.stream().allMatch(venue -> venue.getServiceCode() != null + && !venue.getServiceCode().isEmpty())); + } + + @Test + @SuppressWarnings("unchecked") + void retrieveCourtVenues_WithEpimmsIdAndServiceCode_ShouldEnforceUniqueConstraint() throws JsonProcessingException { + + final var response = (List) + lrdApiClient.retrieveCourtVenueResponseForGivenRequest("?epimms_id=123456789", + LrdCourtVenueResponse[].class, path); + + assertThat(response).isNotEmpty().hasSize(1); + LrdCourtVenueResponse venueResponse = response.get(0); + assertNotNull(venueResponse.getEpimmsId()); + assertNotNull(venueResponse.getServiceCode()); + assertEquals("123456789", venueResponse.getEpimmsId()); + } } diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringIntegrationTest.java index 2bd13024a..207b0ead7 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringIntegrationTest.java @@ -94,6 +94,22 @@ void shouldRetrieveCourtVenues_For_SearchString_And_CourtTypeId_WithStatusCode_2 assertEquals("Welsh External Short Name", response[12].getWelshExternalShortName()); } + @Test + @SuppressWarnings("unchecked") + void shouldRetrieveCourtVenues_For_SearchString_And_ServiceCode_WithStatusCode_200() + throws JsonProcessingException { + final var response = (LrdCourtVenueResponse[]) + lrdApiClient.findCourtVenuesBySearchString( + "?search-string=Abe&service_code=AAA3", + LrdCourtVenueResponse[].class, + path + ); + + assertThat(response).isNotEmpty().hasSize(4); + assertTrue(Arrays.stream(response).allMatch(venue -> "AAA3".equals(venue.getServiceCode()))); + responseVerification(new ArrayList<>(Arrays.asList(response))); + } + @ParameterizedTest @ValueSource(strings = {"?search-string=abc--", "?search-string=ab__c", "?search-string=___c", "?search-string=___", "?search-string=@@@", "?search-string=---", "?search-string='''", @@ -109,6 +125,20 @@ void shouldReturn400_WhenInvalidParamsPassed(String parameter) throws JsonProces assertThat(errorResponseMap).containsEntry(HTTP_STATUS_STR, HttpStatus.BAD_REQUEST); } + @Test + @SuppressWarnings("unchecked") + void shouldReturn400_WhenServiceCodeContainsSpecialCharacters() throws JsonProcessingException { + Map errorResponseMap = (Map) + lrdApiClient.findCourtVenuesBySearchString( + "?search-string=Abe&service_code=AB$", + ErrorResponse.class, + path + ); + + assertNotNull(errorResponseMap); + assertThat(errorResponseMap).containsEntry(HTTP_STATUS_STR, HttpStatus.BAD_REQUEST); + } + @Test @SuppressWarnings("unchecked") void shouldReturnEmptyList_WhenCourtTypeIdIsInvalid() throws JsonProcessingException { @@ -217,6 +247,7 @@ void shouldReturn200_WhenIsCaseManagementLocationContainY() throws JsonProcessin assertThat(response).isNotEmpty().hasSize(3); responseVerification(new ArrayList<>(Arrays.asList(response))); + assertServiceCodePresent(response); } @Test @@ -231,6 +262,7 @@ void shouldReturn200_WhenIsCaseManagementLocationContainY_lowerCase() throws Jso assertThat(response).isNotEmpty().hasSize(3); responseVerification(new ArrayList<>(Arrays.asList(response))); + assertServiceCodePresent(response); } @Test @@ -245,6 +277,7 @@ void shouldReturn200_WhenLocationTypeContainValue() throws JsonProcessingExcepti assertThat(response).isNotEmpty().hasSize(1); responseVerification(new ArrayList<>(Arrays.asList(response))); + assertServiceCodePresent(response); } @Test @@ -258,6 +291,23 @@ void shouldReturn200_WhenLocationTypeContainValue_lowercase() throws JsonProcess ); assertThat(response).isNotEmpty().hasSize(1); responseVerification(new ArrayList<>(Arrays.asList(response))); + assertServiceCodePresent(response); + } + + @Test + @SuppressWarnings("unchecked") + void shouldReturn200_WhenServiceCodeAndIsHearingLocationProvided() throws JsonProcessingException { + final var response = (LrdCourtVenueResponse[]) + lrdApiClient.findCourtVenuesBySearchString( + "?search-string=Abe&service_code=AAA3&is_hearing_location=Y", + LrdCourtVenueResponse[].class, + path + ); + + assertThat(response).isNotEmpty(); + assertTrue(Arrays.stream(response).allMatch(venue -> "AAA3".equals(venue.getServiceCode()))); + assertTrue(Arrays.stream(response).allMatch(venue -> "Y".equalsIgnoreCase(venue.getIsHearingLocation()))); + assertServiceCodePresent(response); } void responseVerification(ArrayList courtVenueResponse) { @@ -287,4 +337,10 @@ void errorResponseVerification(Map errorResponseMap, String expe expectedErrorDescription)); } + private void assertServiceCodePresent(LrdCourtVenueResponse[] response) { + assertTrue(Arrays.stream(response) + .map(LrdCourtVenueResponse::getServiceCode) + .allMatch(code -> code != null && !code.isBlank())); + } + } diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesByServiceCodeIntegrationTest.java b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesByServiceCodeIntegrationTest.java index e77d1010b..7a141a5a3 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesByServiceCodeIntegrationTest.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesByServiceCodeIntegrationTest.java @@ -128,6 +128,7 @@ private List buildCourtVenueResponses() { .isHearingLocation("N") .locationType("NBC") .isTemporaryLocation("N") + .serviceCode("AAA6") .build(); LrdCourtVenueResponse response2 = LrdCourtVenueResponse.builder() @@ -149,6 +150,7 @@ private List buildCourtVenueResponses() { .isHearingLocation("N") .locationType("NBC") .isTemporaryLocation("N") + .serviceCode("ABA4") .build(); expectedCourtVenueResponses.add(response1); diff --git a/src/integrationTest/resources/db/testmigration/V1_32__alter_court_venue_add_service_code_composite_pk.sql b/src/integrationTest/resources/db/testmigration/V1_32__alter_court_venue_add_service_code_composite_pk.sql new file mode 100644 index 000000000..aab08ddef --- /dev/null +++ b/src/integrationTest/resources/db/testmigration/V1_32__alter_court_venue_add_service_code_composite_pk.sql @@ -0,0 +1,12 @@ +-- Add service_code column to court_venue table +ALTER TABLE court_venue ADD COLUMN IF NOT EXISTS service_code VARCHAR(16); + +-- Drop the existing unique constraint on (epimms_id, court_type_id) +ALTER TABLE court_venue DROP CONSTRAINT IF EXISTS court_location_unique; + +-- Add a new unique constraint with epimms_id and service_code +ALTER TABLE court_venue ADD CONSTRAINT court_location_unique UNIQUE (epimms_id, service_code); + +-- Add foreign key constraint for service_code +ALTER TABLE court_venue ADD CONSTRAINT court_venue_service_code_fk FOREIGN KEY (service_code) REFERENCES SERVICE (service_code); + diff --git a/src/integrationTest/resources/db/testmigration/V1_33__update_court_venue_service_code.sql b/src/integrationTest/resources/db/testmigration/V1_33__update_court_venue_service_code.sql new file mode 100644 index 000000000..643e8cad9 --- /dev/null +++ b/src/integrationTest/resources/db/testmigration/V1_33__update_court_venue_service_code.sql @@ -0,0 +1,16 @@ +UPDATE court_venue SET service_code = 'AAA2' WHERE court_venue_id = 1; +UPDATE court_venue SET service_code = 'AAA3' WHERE court_venue_id = 2; +UPDATE court_venue SET service_code = 'AAA6' WHERE court_venue_id = 3; +UPDATE court_venue SET service_code = 'ABA4' WHERE court_venue_id = 4; +UPDATE court_venue SET service_code = 'AAA2' WHERE court_venue_id = 5; +UPDATE court_venue SET service_code = 'AAA3' WHERE court_venue_id = 6; +UPDATE court_venue SET service_code = 'AAA6' WHERE court_venue_id = 7; +UPDATE court_venue SET service_code = 'ABA4' WHERE court_venue_id = 8; +UPDATE court_venue SET service_code = 'AAA2' WHERE court_venue_id = 9; +UPDATE court_venue SET service_code = 'AAA3' WHERE court_venue_id = 10; +UPDATE court_venue SET service_code = 'AAA6' WHERE court_venue_id = 11; +UPDATE court_venue SET service_code = 'ABA4' WHERE court_venue_id = 12; +UPDATE court_venue SET service_code = 'AAA2' WHERE court_venue_id = 13; +UPDATE court_venue SET service_code = 'AAA3' WHERE court_venue_id = 14; +UPDATE court_venue SET service_code = 'AAA6' WHERE court_venue_id = 15; +COMMIT; diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueController.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueController.java index b89411422..04513bfac 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueController.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueController.java @@ -58,6 +58,7 @@ import static uk.gov.hmcts.reform.lrdapi.util.ValidationUtils.validateCourtTypeId; import static uk.gov.hmcts.reform.lrdapi.util.ValidationUtils.validateCourtVenueFilters; import static uk.gov.hmcts.reform.lrdapi.util.ValidationUtils.validateSearchString; +import static uk.gov.hmcts.reform.lrdapi.util.ValidationUtils.validateServiceCodes; @RequestMapping( @@ -265,6 +266,10 @@ public ResponseEntity> retrieveCourtVenuesBySearchSt @Parameter(name = "court-type-id", description = "Alphabets and Numeric values only allowed in comma separated format") String courtTypeId, + @RequestParam(value = "service_code", required = false) + @Parameter(name = "service_code", + description = "Alphabets and Numeric values only allowed in comma separated format") + String serviceCode, @RequestParam(value = "is_hearing_location", required = false) @Parameter(name = "is_hearing_location", description = "Allowed values are \"Y\" or \"N\"") @@ -289,6 +294,10 @@ public ResponseEntity> retrieveCourtVenuesBySearchSt validateCourtTypeId(courtTypeId); } + if (StringUtils.isNotBlank(serviceCode)) { + validateServiceCodes(serviceCode); + } + CourtVenueRequestParam requestParam = CourtVenueRequestParam .builder() .isHearingLocation(isHearingLocation) @@ -299,7 +308,7 @@ public ResponseEntity> retrieveCourtVenuesBySearchSt log.info("{} : Calling retrieveCourtVenuesBySearchString", loggingComponentName); var lrdCourtVenueResponses = courtVenueService.retrieveCourtVenuesBySearchString( - trimmedSearchString, courtTypeId, requestParam); + trimmedSearchString, courtTypeId, serviceCode, requestParam); return ResponseEntity.status(HttpStatus.OK).body(lrdCourtVenueResponses); } } diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/constants/LocationRefConstants.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/constants/LocationRefConstants.java index f628f56bc..2f4b8bb57 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/constants/LocationRefConstants.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/constants/LocationRefConstants.java @@ -48,6 +48,7 @@ private LocationRefConstants() { "No Building Location found for the given building location name: %s"; public static final String EXCEPTION_MSG_SERVICE_CODE_SPCL_CHAR = "Invalid service code. " + "Please provide service code without special characters"; + public static final String EXCEPTION_MSG_INVALID_SERVICE_CODE = "Invalid service codes: %s"; public static final String LD_FLAG = "lrd_location_api"; @@ -77,6 +78,8 @@ private LocationRefConstants() { public static final String COURT_TYPE_ID_START_END_WITH_COMMA = "Invalid court type ids: %s"; + public static final String SERVICE_CODE_START_END_WITH_COMMA = + "Invalid service codes: %s"; public static final String IS_HEARING_LOCATION_Y = "Y"; public static final String IS_HEARING_LOCATION_N = "N"; @@ -148,7 +151,7 @@ private LocationRefConstants() { public static final String RET_LOC_VEN_NOTES_7 = "with the requested court_type_id are returned as a list.
"; public static final String RET_LOC_VEN_NOTES_7_1 = """ - request param 'epimms_id' can be passed with 'court_type_id' . Court venues associated with the epimmsId and + request param 'epimms_id' can be passed with 'court_type_id' . Court venues associated with the epimmsId and court type id returned as list. """; public static final String RET_LOC_VEN_NOTES_8 = "For the request param 'region_id', the value needs to be a " diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenueResponse.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenueResponse.java index a303f7d03..378c51f53 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenueResponse.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenueResponse.java @@ -25,6 +25,9 @@ public class LrdCourtVenueResponse implements Serializable { @JsonProperty("epimms_id") private String epimmsId; + @JsonProperty("service_code") + private String serviceCode; + @JsonProperty("site_name") private String siteName; @@ -151,6 +154,7 @@ public LrdCourtVenueResponse(CourtVenue courtVenue) { this.courtType = courtVenue.getCourtType().getTypeOfCourt(); this.dxAddress = courtVenue.getDxAddress(); this.epimmsId = courtVenue.getEpimmsId(); + this.serviceCode = courtVenue.getServiceCode(); this.openForPublic = Boolean.TRUE.equals(courtVenue.getOpenForPublic()) ? "YES" : "NO"; this.phoneNumber = courtVenue.getPhoneNumber(); this.welshCourtAddress = courtVenue.getWelshCourtAddress(); diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenue.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenue.java index cb1d907b2..e1fe6c0f9 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenue.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenue.java @@ -29,7 +29,7 @@ @Setter @Builder @EqualsAndHashCode -@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"epimms_id","site_name","court_type_id"})) +@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"epimms_id","service_code"})) public class CourtVenue implements Serializable { @Id @@ -42,6 +42,9 @@ public class CourtVenue implements Serializable { @Column(name = "epimms_id") private String epimmsId; + @Column(name = "service_code") + private String serviceCode; + @CreatedDate private LocalDateTime createdTime; diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/repository/CourtVenueRepository.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/repository/CourtVenueRepository.java index 6df189ccc..9982d0f34 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/repository/CourtVenueRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/repository/CourtVenueRepository.java @@ -52,6 +52,7 @@ where cv.epimmsId in (:epimmsIdList) and cv.courtTypeId = :courtTypeId and cv.co + " LEFT JOIN FETCH cv.cluster LEFT JOIN FETCH cv.region " + "where cv.courtStatus='Open' " + "and (coalesce(:courtTypeId) is null or (cv.courtTypeId in (:courtTypeId))) " + + "and (coalesce(:serviceCode) is null or (cv.serviceCode in (:serviceCode))) " + "and ((:isCaseManagementLocation) is null or (cv.isCaseManagementLocation in (:isCaseManagementLocation))) " + "and ((:isHearingLocation) is null or (cv.isHearingLocation in (:isHearingLocation))) " + "and ((:locationType) is null or (cv.locationType in (:locationType))) " @@ -61,6 +62,7 @@ where cv.epimmsId in (:epimmsIdList) and cv.courtTypeId = :courtTypeId and cv.co + "or upper(cv.postcode) like %:searchString% " + "or upper(cv.courtAddress) like %:searchString%)") List findBySearchStringAndCourtTypeId(String searchString, List courtTypeId, - String isCaseManagementLocation, String isHearingLocation, - String locationType, String isTemporaryLocation); + List serviceCode,String isCaseManagementLocation, + String isHearingLocation,String locationType, + String isTemporaryLocation); } diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/service/CourtVenueService.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/service/CourtVenueService.java index 25fc39c4a..7ca6eed5a 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/service/CourtVenueService.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/service/CourtVenueService.java @@ -26,5 +26,6 @@ List retrieveCourtVenueDetails(String epimmsId, Integer c CourtVenueRequestParam courtVenueRequestParam); List retrieveCourtVenuesBySearchString(String searchString, String courtTypeId, + String serviceCode, CourtVenueRequestParam requestParam); } diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImpl.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImpl.java index 304a870ff..eae55981d 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImpl.java @@ -103,11 +103,12 @@ public LrdCourtVenuesByServiceCodeResponse retrieveCourtVenuesByServiceCode(Stri @Override public List retrieveCourtVenuesBySearchString(String searchString, String courtTypeId, + String serviceCodes, CourtVenueRequestParam requestParam) { log.info("{} : Obtaining court venue for search String: searchString: {}, courtTypeId: {}, " + "isHearingLocation: {}, isCaseManagementLocation: {}, locationType: {}, " + "isTemporaryLocation: {} ", - loggingComponentName, searchString, courtTypeId, requestParam.getIsHearingLocation(), + loggingComponentName, searchString, courtTypeId,serviceCodes, requestParam.getIsHearingLocation(), requestParam.getIsCaseManagementLocation(), requestParam.getLocationType(), requestParam.getIsTemporaryLocation()); @@ -117,6 +118,9 @@ public List retrieveCourtVenuesBySearchString(String sear List courtTypeIdList = StringUtils.isEmpty(courtTypeId) ? null : Arrays.stream(courtTypeId.split(COMMA)).map(String::strip).toList(); + List serviceCodeList = StringUtils.isEmpty(serviceCodes) ? null : + Arrays.stream(serviceCodes.split(COMMA)).map(String::strip).toList(); + String isCaseManagementLocation = (StringUtils.isNotEmpty(result.getIsCaseManagementLocation())) ? result.getIsCaseManagementLocation().toUpperCase() : result.getIsCaseManagementLocation(); @@ -133,14 +137,17 @@ public List retrieveCourtVenuesBySearchString(String sear ? result.getIsTemporaryLocation().toUpperCase() : result.getIsTemporaryLocation(); - return getCourtVenueListResponse(courtVenueRepository.findBySearchStringAndCourtTypeId( + List courtVenues = courtVenueRepository.findBySearchStringAndCourtTypeId( searchString.toUpperCase(), courtTypeIdList, + serviceCodeList, isCaseManagementLocation, isHearingLocation, locationType, isTemporaryLocation - )); + ); + + return getCourtVenueListResponse(courtVenues); } @Override diff --git a/src/main/java/uk/gov/hmcts/reform/lrdapi/util/ValidationUtils.java b/src/main/java/uk/gov/hmcts/reform/lrdapi/util/ValidationUtils.java index a85aad337..9e4ba93c3 100644 --- a/src/main/java/uk/gov/hmcts/reform/lrdapi/util/ValidationUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/lrdapi/util/ValidationUtils.java @@ -15,6 +15,7 @@ import static org.apache.commons.lang3.ObjectUtils.isEmpty; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.ALPHA_NUMERIC_REGEX; +import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.ALPHA_NUMERIC_REGEX_WITHOUT_UNDERSCORE; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.ALPHA_NUMERIC_WITH_SPECIAL_CHAR_REGEX; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.COMMA; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.COURT_TYPE_ID_START_END_WITH_COMMA; @@ -32,6 +33,7 @@ import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.REG_EXP_SPCL_CHAR; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.REG_EXP_WHITE_SPACE; import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.SEARCH_STRING_VALUE_ERROR_MESSAGE; +import static uk.gov.hmcts.reform.lrdapi.controllers.constants.LocationRefConstants.SERVICE_CODE_START_END_WITH_COMMA; public class ValidationUtils { @@ -79,6 +81,15 @@ public static void validateCourtTypeId(String courtTypeId) { }); } + public static void validateServiceCodes(String serviceCodes) { + checkIfStringStartsAndEndsWithComma(serviceCodes, SERVICE_CODE_START_END_WITH_COMMA); + Arrays.stream(serviceCodes.strip().split(REG_EXP_COMMA_DILIMETER)).forEach(c -> { + if (!isRegexSatisfied(c.trim(), ALPHA_NUMERIC_REGEX_WITHOUT_UNDERSCORE)) { + throw new InvalidRequestException(String.format(SERVICE_CODE_START_END_WITH_COMMA, serviceCodes)); + } + }); + } + /** * Method to check if the passed {@link String} varargs contains a single value. * If more than one value is present, this method throws an {@link InvalidRequestException} diff --git a/src/main/resources/db/migration/V1_32__alter_court_venue_add_service_code_composite_pk.sql b/src/main/resources/db/migration/V1_32__alter_court_venue_add_service_code_composite_pk.sql new file mode 100644 index 000000000..aab08ddef --- /dev/null +++ b/src/main/resources/db/migration/V1_32__alter_court_venue_add_service_code_composite_pk.sql @@ -0,0 +1,12 @@ +-- Add service_code column to court_venue table +ALTER TABLE court_venue ADD COLUMN IF NOT EXISTS service_code VARCHAR(16); + +-- Drop the existing unique constraint on (epimms_id, court_type_id) +ALTER TABLE court_venue DROP CONSTRAINT IF EXISTS court_location_unique; + +-- Add a new unique constraint with epimms_id and service_code +ALTER TABLE court_venue ADD CONSTRAINT court_location_unique UNIQUE (epimms_id, service_code); + +-- Add foreign key constraint for service_code +ALTER TABLE court_venue ADD CONSTRAINT court_venue_service_code_fk FOREIGN KEY (service_code) REFERENCES SERVICE (service_code); + diff --git a/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueControllerTest.java b/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueControllerTest.java index 318d80fbd..db8401a1f 100644 --- a/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueControllerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueControllerTest.java @@ -152,7 +152,7 @@ void testGetCourtVenues_WithMultipleParams_Returns400() { void testGetCourtVenuesBySearchString() { var param = new CourtVenueRequestParam(); ResponseEntity> responseEntity = - lrdCourtVenueController.retrieveCourtVenuesBySearchString("MAN", null, + lrdCourtVenueController.retrieveCourtVenuesBySearchString("MAN", null,null, param.getIsHearingLocation(), param.getIsCaseManagementLocation(), param.getLocationType(), @@ -163,6 +163,7 @@ void testGetCourtVenuesBySearchString() { verify(courtVenueServiceMock, times(1)).retrieveCourtVenuesBySearchString( anyString(), isNull(), + isNull(), any(CourtVenueRequestParam.class) ); } @@ -172,6 +173,7 @@ void testGetCourtVenuesBySearchStringWithHyphen() { var param = new CourtVenueRequestParam(); ResponseEntity> responseEntity = lrdCourtVenueController.retrieveCourtVenuesBySearchString("Stoke-", null, + null, param.getIsHearingLocation(), param.getIsCaseManagementLocation(), param.getLocationType(), @@ -183,6 +185,7 @@ void testGetCourtVenuesBySearchStringWithHyphen() { verify(courtVenueServiceMock, times(1)).retrieveCourtVenuesBySearchString( anyString(), isNull(), + isNull(), any(CourtVenueRequestParam.class) ); } @@ -190,31 +193,63 @@ void testGetCourtVenuesBySearchStringWithHyphen() { @Test void testGetCourtVenuesBySearchStringWithInvalidString() { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString("$AB_C", null, null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString("$AB_C", null, + null,null, + null, null, + null)); } @Test void testGetCourtVenuesBySearchStringWithStringLessThan3Char() { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString("AB", null, null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString("AB", null, + null,null, + null, null, + null)); } @Test void testGetCourtVenuesBySearchStringWithInvalidCourtTypeId() { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", "1,2,*", null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", "1,2,*", + null,null, + null, null, + null)); + } + + @Test + void testGetCourtVenuesBySearchStringWithInvalidServiceCode() { + assertThrows(InvalidRequestException.class, () -> + lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", null, + "1,2,*", null, + null, null, + null)); + } + + @Test + void testGetCourtVenuesBySearchStringWithInvalidServiceCodeWithComma() { + assertThrows(InvalidRequestException.class, () -> + lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", null, + ",1,2,", null, + null, null, + null)); } @Test void testGetCourtVenuesBySearchStringWithInvalidCourtTypeIdWithComma() { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", ",1,2,", null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", ",1,2,", + null,null, + null, null, + null)); } @Test void testGetCourtVenuesBySearchStringWithEmptyString() { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString("", null, null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString("", null, null, + null,null, + null, null)); } @ParameterizedTest @@ -224,6 +259,8 @@ void testGetCourtVenuesBySearchStringWithEmptyString() { "?search-string=)))"}) void testGetCourtVenuesBySearchStringWithConsecutiveSpecialCharacters(String param) { assertThrows(InvalidRequestException.class, () -> - lrdCourtVenueController.retrieveCourtVenuesBySearchString(param, ",1,2,", null, null, null, null)); + lrdCourtVenueController.retrieveCourtVenuesBySearchString(param, ",1,2,", null, + null, null, + null, null)); } } diff --git a/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenuesByServiceCodeResponseTest.java b/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenuesByServiceCodeResponseTest.java index dc39dd0af..0095a2ab0 100644 --- a/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenuesByServiceCodeResponseTest.java +++ b/src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/response/LrdCourtVenuesByServiceCodeResponseTest.java @@ -41,6 +41,7 @@ void testCourtVenuesByServiceCodeResponse() { .venueName("venueName") .isCaseManagementLocation("Y") .isHearingLocation("Y") + .serviceCode("ABC1") .build(); courtType.setCourtVenues(Collections.singletonList(courtVenue)); @@ -57,6 +58,6 @@ void testCourtVenuesByServiceCodeResponse() { assertNotNull(courtVenuesByServiceCodeResponse.getCourtVenues().get(0).getVenueName()); assertNotNull(courtVenuesByServiceCodeResponse.getCourtVenues().get(0).getIsCaseManagementLocation()); assertNotNull(courtVenuesByServiceCodeResponse.getCourtVenues().get(0).getIsHearingLocation()); - + assertEquals("ABC1", courtVenuesByServiceCodeResponse.getCourtVenues().get(0).getServiceCode()); } } diff --git a/src/test/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenueTest.java b/src/test/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenueTest.java index d700108fb..8eb412e3f 100644 --- a/src/test/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenueTest.java +++ b/src/test/java/uk/gov/hmcts/reform/lrdapi/domain/CourtVenueTest.java @@ -59,6 +59,7 @@ void testCourtVenue() { courtVenue.setIsNightingaleCourt("N"); courtVenue.setLocationType("Court"); courtVenue.setParentLocation(""); + courtVenue.setServiceCode("AAA2"); assertEquals("1", courtVenue.getCourtVenueId().toString()); assertEquals("siteName", courtVenue.getSiteName()); @@ -66,24 +67,25 @@ void testCourtVenue() { assertEquals(courtType, courtVenue.getCourtType()); assertEquals(cluster, courtVenue.getCluster().get()); assertTrue(courtVenue.getOpenForPublic()); - assertEquals("courtAddress",courtVenue.getCourtAddress()); - assertEquals("AB EYZ",courtVenue.getPostcode()); - assertEquals("122324234",courtVenue.getPhoneNumber()); - assertEquals("courtLocationCode",courtVenue.getCourtLocationCode()); - assertEquals("dxAddress",courtVenue.getDxAddress()); - assertEquals("welshSiteName",courtVenue.getWelshSiteName()); - assertEquals("welshCourtAddress",courtVenue.getWelshCourtAddress()); - assertEquals("Open",courtVenue.getCourtStatus()); - assertEquals("courtName",courtVenue.getCourtName()); - assertEquals("venueName",courtVenue.getVenueName()); - assertEquals("Y",courtVenue.getIsCaseManagementLocation()); - assertEquals("Y",courtVenue.getIsHearingLocation()); - assertEquals("",courtVenue.getWelshVenueName()); - assertEquals("N",courtVenue.getIsTemporaryLocation()); - assertEquals(now,courtVenue.getClosedDate().get()); - assertEquals(now,courtVenue.getCourtOpenDate().get()); + assertEquals("courtAddress", courtVenue.getCourtAddress()); + assertEquals("AB EYZ", courtVenue.getPostcode()); + assertEquals("122324234", courtVenue.getPhoneNumber()); + assertEquals("courtLocationCode", courtVenue.getCourtLocationCode()); + assertEquals("dxAddress", courtVenue.getDxAddress()); + assertEquals("welshSiteName", courtVenue.getWelshSiteName()); + assertEquals("welshCourtAddress", courtVenue.getWelshCourtAddress()); + assertEquals("Open", courtVenue.getCourtStatus()); + assertEquals("courtName", courtVenue.getCourtName()); + assertEquals("venueName", courtVenue.getVenueName()); + assertEquals("Y", courtVenue.getIsCaseManagementLocation()); + assertEquals("Y", courtVenue.getIsHearingLocation()); + assertEquals("", courtVenue.getWelshVenueName()); + assertEquals("N", courtVenue.getIsTemporaryLocation()); + assertEquals(now, courtVenue.getClosedDate().get()); + assertEquals(now, courtVenue.getCourtOpenDate().get()); assertEquals(now, courtVenue.getCreatedTime()); assertEquals(now, courtVenue.getUpdatedTime()); + assertEquals("AAA2", courtVenue.getServiceCode()); } @@ -104,4 +106,95 @@ void testCourtVenueRequestParam() { } + @Test + void testCourtVenueBuilderWithServiceCode() { + Region region = new Region(); + region.setDescription("Region ABC"); + region.setRegionId("789"); + + CourtType courtType = new CourtType(); + courtType.setCourtTypeId("20"); + courtType.setTypeOfCourt("District Court"); + + Cluster cluster = new Cluster(); + cluster.setClusterId("789"); + cluster.setClusterName("ClusterABC"); + + LocalDateTime now = LocalDateTime.now(); + + CourtVenue courtVenue = CourtVenue.builder() + .courtVenueId(2L) + .siteName("London Court") + .region(region) + .courtType(courtType) + .cluster(cluster) + .openForPublic(Boolean.FALSE) + .courtAddress("123 Main Street") + .postcode("SW1A 1AA") + .phoneNumber("0207946253") + .courtLocationCode("LON001") + .dxAddress("55 Strand") + .welshSiteName("Llys Llundain") + .welshCourtAddress("123 Heol Fawr") + .courtStatus("Open") + .courtOpenDate(now) + .courtName("LONDON COURT") + .createdTime(now) + .updatedTime(now) + .venueName("London Venue") + .isCaseManagementLocation("N") + .isHearingLocation("Y") + .welshVenueName("Lleoliad Llundain") + .isTemporaryLocation("Y") + .isNightingaleCourt("N") + .locationType("Nightingale") + .parentLocation("100") + .serviceCode("AAA3") + .build(); + + assertEquals(2L, courtVenue.getCourtVenueId()); + assertEquals("London Court", courtVenue.getSiteName()); + assertEquals("789", courtVenue.getRegion().get().getRegionId()); + assertEquals("20", courtVenue.getCourtType().getCourtTypeId()); + assertEquals("789", courtVenue.getCluster().get().getClusterId()); + assertTrue(!courtVenue.getOpenForPublic()); + assertEquals("123 Main Street", courtVenue.getCourtAddress()); + assertEquals("SW1A 1AA", courtVenue.getPostcode()); + assertEquals("0207946253", courtVenue.getPhoneNumber()); + assertEquals("LON001", courtVenue.getCourtLocationCode()); + assertEquals("55 Strand", courtVenue.getDxAddress()); + assertEquals("Llys Llundain", courtVenue.getWelshSiteName()); + assertEquals("123 Heol Fawr", courtVenue.getWelshCourtAddress()); + assertEquals("Open", courtVenue.getCourtStatus()); + assertEquals("LONDON COURT", courtVenue.getCourtName()); + assertEquals("London Venue", courtVenue.getVenueName()); + assertEquals("N", courtVenue.getIsCaseManagementLocation()); + assertEquals("Y", courtVenue.getIsHearingLocation()); + assertEquals("Lleoliad Llundain", courtVenue.getWelshVenueName()); + assertEquals("Y", courtVenue.getIsTemporaryLocation()); + assertEquals("N", courtVenue.getIsNightingaleCourt()); + assertEquals("Nightingale", courtVenue.getLocationType()); + assertEquals("100", courtVenue.getParentLocation()); + assertEquals("AAA3", courtVenue.getServiceCode()); + } + + @Test + void testCourtVenueServiceCodeValidation() { + CourtVenue courtVenue1 = new CourtVenue(); + courtVenue1.setServiceCode("AAA2"); + assertEquals("AAA2", courtVenue1.getServiceCode()); + + CourtVenue courtVenue2 = CourtVenue.builder() + .courtVenueId(1L) + .serviceCode("AAA6") + .build(); + assertEquals("AAA6", courtVenue2.getServiceCode()); + + CourtVenue courtVenue3 = CourtVenue.builder() + .courtVenueId(2L) + .serviceCode("ABA4") + .build(); + assertEquals("ABA4", courtVenue3.getServiceCode()); + } + } diff --git a/src/test/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImplTest.java b/src/test/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImplTest.java index 859ec3ebf..dd0fd504a 100644 --- a/src/test/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImplTest.java +++ b/src/test/java/uk/gov/hmcts/reform/lrdapi/service/impl/CourtVenueServiceImplTest.java @@ -79,6 +79,7 @@ void testRetrieveCourtVenuesByServiceCode() { .mrdVenueId("765") .serviceUrl("https://serviceurl.com") .factUrl("https://facturl.com") + .serviceCode("ABC1") .build(); List courtVenues = Collections.singletonList(courtVenue); @@ -381,6 +382,7 @@ void test_RetrieveCourtVenuesByCourtVenueName_NotFound() { @Test void test_RetrieveCourtVenuesBySearchString() { when(courtVenueRepository.findBySearchStringAndCourtTypeId(anyString(), + anyList(), anyList(), anyString(), anyString(), @@ -394,7 +396,7 @@ void test_RetrieveCourtVenuesBySearchString() { List courtVenueResponses = courtVenueService - .retrieveCourtVenuesBySearchString("ABC", "1,2", param); + .retrieveCourtVenuesBySearchString("ABC", "1,2","AAA2", param); LrdCourtVenueResponse courtVenueResponse = courtVenueResponses.get(0); @@ -408,11 +410,12 @@ void test_GetCourtVenuesBySearchStringWhenCourtTypeIdIsNull() { null, null, null, + null, null)).thenReturn(prepareCourtVenue()); var param = new CourtVenueRequestParam(); List courtVenueResponses = courtVenueService - .retrieveCourtVenuesBySearchString("ABC", null, param); + .retrieveCourtVenuesBySearchString("ABC", null, null,param); LrdCourtVenueResponse courtVenueResponse = courtVenueResponses.get(0); @@ -425,7 +428,7 @@ void test_GetCourtVenuesBySearchStringWhenInvalidHearingLocation() { param.setIsHearingLocation("YN"); assertThrows(InvalidRequestException.class, () -> courtVenueService - .retrieveCourtVenuesBySearchString("ABC", null, param)); + .retrieveCourtVenuesBySearchString("ABC", null,null, param)); } @Test @@ -435,17 +438,19 @@ void test_GetCourtVenuesBySearchString_NotFound() { null, null, null, + null, null)).thenReturn(new ArrayList<>()); var param = new CourtVenueRequestParam(); List courtVenueResponses = courtVenueService - .retrieveCourtVenuesBySearchString("ABC", null, param); + .retrieveCourtVenuesBySearchString("ABC", null,null, param); assertEquals(0,courtVenueResponses.size()); verify(courtVenueRepository, times(1)).findBySearchStringAndCourtTypeId("ABC", null, null, null, null, + null, null); } @@ -465,6 +470,7 @@ private void verifyMultiResponse(List courtVenueResponses assertThat(courtVenueResponse.getVenueName()).isEqualTo("venueName"); assertThat(courtVenueResponse.getIsCaseManagementLocation()).isEqualTo("Y"); assertThat(courtVenueResponse.getIsHearingLocation()).isEqualTo("Y"); + assertThat(courtVenueResponse.getServiceCode()).isEqualTo("AAA2"); } else { assertThat(courtVenueResponse.getEpimmsId()).isEqualTo("1234"); assertThat(courtVenueResponse.getClusterId()).isEqualTo("1"); @@ -476,6 +482,7 @@ private void verifyMultiResponse(List courtVenueResponses assertThat(courtVenueResponse.getVenueName()).isEqualTo("venueName1"); assertThat(courtVenueResponse.getIsCaseManagementLocation()).isEqualTo("N"); assertThat(courtVenueResponse.getIsHearingLocation()).isEqualTo("N"); + assertThat(courtVenueResponse.getServiceCode()).isEqualTo("AAA3"); } }); } @@ -493,6 +500,7 @@ private void verifySingleResponse(LrdCourtVenueResponse lrdCourtVenueResponse) { assertThat(lrdCourtVenueResponse.getVenueName()).isEqualTo("venueName"); assertThat(lrdCourtVenueResponse.getIsCaseManagementLocation()).isEqualTo("Y"); assertThat(lrdCourtVenueResponse.getIsHearingLocation()).isEqualTo("Y"); + assertThat(lrdCourtVenueResponse.getServiceCode()).isEqualTo("AAA2"); } private List prepareCourtVenue() { @@ -526,6 +534,7 @@ private List prepareCourtVenue() { .mrdVenueId("765") .serviceUrl("https://serviceurl.com") .factUrl("https://facturl.com") + .serviceCode("AAA2") .build()); return courtVenues; @@ -559,6 +568,7 @@ private List prepareMultiCourtVenueResponse() { .mrdVenueId("765") .serviceUrl("https://serviceurl.com") .factUrl("https://facturl.com") + .serviceCode("AAA3") .build()); return courtVenues;