Skip to content

Commit 3ab5c0e

Browse files
authored
DTSRD-261: tests (#557)
* DTSRD-261: initial implementation * DTSRD-261: rename test * DTSRD-261: add extra assertion * DTSRD-261: add unit test
1 parent de0cbdc commit 3ab5c0e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/integrationTest/java/uk/gov/hmcts/reform/lrdapi/RetrieveCourtVenuesBySearchStringIntegrationTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ void shouldRetrieveCourtVenues_For_SearchString_WithStatusCode_200()
4545
responseVerification(new ArrayList<>(Arrays.asList(response)));
4646
}
4747

48+
@Test
49+
@SuppressWarnings("unchecked")
50+
void shouldReturn400_WhenSearchStringIsEmpty()
51+
throws JsonProcessingException {
52+
Map<String, Object> errorResponseMap = (Map<String, Object>)
53+
lrdApiClient.findCourtVenuesBySearchString(
54+
"",
55+
ErrorResponse.class,
56+
path
57+
);
58+
59+
assertNotNull(errorResponseMap);
60+
assertThat(errorResponseMap).containsEntry(HTTP_STATUS_STR, HttpStatus.BAD_REQUEST);
61+
}
62+
4863
@ParameterizedTest
4964
@ValueSource(strings = {"?search-string=Stoke-on-Trent", "?search-string=Stoke-", "?search-string=stoke-on",
5065
"?search-string=stoke-on-"})

src/test/java/uk/gov/hmcts/reform/lrdapi/controllers/LrdCourtVenueControllerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ void testGetCourtVenuesBySearchStringWithInvalidCourtTypeIdWithComma() {
211211
lrdCourtVenueController.retrieveCourtVenuesBySearchString("ABC", ",1,2,", null, null, null, null));
212212
}
213213

214+
@Test
215+
void testGetCourtVenuesBySearchStringWithEmptyString() {
216+
assertThrows(InvalidRequestException.class, () ->
217+
lrdCourtVenueController.retrieveCourtVenuesBySearchString("", null, null, null, null, null));
218+
}
219+
214220
@ParameterizedTest
215221
@ValueSource(strings = {"?search-string=abc--", "?search-string=ab__c", "?search-string=___c",
216222
"?search-string=___", "?search-string=@@@", "?search-string=---", "?search-string='''",

0 commit comments

Comments
 (0)