-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDCC-5070 handling special characters in searchString(/search endpoin…
…t). (#348) * RDCC-5070 handling special characters in searchString(/search endpoint). * RDCC-5070 updated the error message and fixed sonarlint regex expression * RDCC-5070 fixed checkstyle issue * RDCC-5070 fixed checkstyle issue * RDCC-5070 updated the error message for searchString * RDCC-5070 updated the error message for searchString
- Loading branch information
1 parent
3bd3fa3
commit 404f4d5
Showing
3 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,7 +135,8 @@ void shouldReturn400WhenSearchStringDoesNotContainRequiredLength(String role) { | |
userSearchRequest, role, false); | ||
assertThat(response).containsEntry("http_status", "400"); | ||
var responseBody = (String) response.get("response_body"); | ||
assertTrue(responseBody.contains("should have atleast 3 characters")); | ||
assertTrue(responseBody.contains("searchString must be at least 3 characters including letters, " | ||
+ "apostrophe, hyphen")); | ||
} | ||
|
||
@ParameterizedTest | ||
|
@@ -150,7 +151,8 @@ void shouldReturn400WhenSearchStringContainsOtherThanLetters(String role) { | |
userSearchRequest, role, false); | ||
assertThat(response).containsEntry("http_status", "400"); | ||
var responseBody = (String) response.get("response_body"); | ||
assertTrue(responseBody.contains("should contains letters only")); | ||
assertTrue(responseBody.contains("searchString must be at least 3 characters including letters, " | ||
+ "apostrophe, hyphen")); | ||
} | ||
|
||
@ParameterizedTest | ||
|
@@ -196,5 +198,93 @@ void shouldReturn200WhenUserProfileRequestedForGivenSearchStringWithEmptyAdditio | |
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileApostropheString(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("Am'") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("Am'ar", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileApostropheStrings(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("O'j") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("O'jas", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileHyphenString(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("Li-a") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("Li-am", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileHyphenStrings(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("V-e") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("V-ed", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileEmptySpace(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("J Ro") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("J Rock", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { "jrd-system-user","jrd-admin"}) | ||
void shouldReturn200WhenUserProfileEmptySpaces(String role) { | ||
UserSearchRequest userSearchRequest = UserSearchRequest.builder() | ||
.searchString("To N") | ||
.build(); | ||
var response = judicialReferenceDataClient.searchUsers( | ||
userSearchRequest, role, false); | ||
var profiles = (List<Map<String, String>>)response.get("body"); | ||
assertEquals(1, profiles.size()); | ||
assertEquals("[email protected]", profiles.get(0).get("emailId")); | ||
assertEquals("To Nick", profiles.get(0).get("knownAs")); | ||
assertThat(response).containsEntry("http_status", "200 OK"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,25 @@ last_working_date, active_flag, extracted_date, created_date, | |
last_loaded_date, object_id, sidam_id, is_judge, is_panel_member, is_magistrate) | ||
VALUES('9001', 'A123', 'Sample_KA_1', 'Sample_SN_1', 'Sample_FN_1', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'900', '900', true, false, true); | ||
'900', '900', true, false, true), | ||
('8002', 'A124', 'Am''ar', 'Pamet', 'Am''ar Pamet', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'802', '802', true, false, true), | ||
('8003', 'A125', 'O''jas', 'Baet', 'O''jas Baet', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'803', '803', true, false, true), | ||
('8004', 'A126', 'Li-am', 'Kate', 'Li-am Kate', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'804', '804', true, false, true), | ||
('8005', 'A127', 'V-ed', 'Prakasscs', 'V-ed Prakasscs', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'805', '805', true, false, true), | ||
('8006', 'A128', 'J Rock', 'Brian', 'J Rock Brian', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'806', '806', true, false, true), | ||
('8007', 'A129', 'To Nick', 'Cruz', 'To Nick Cruz', 'Ms', 'No Work Pattern (M to F)', '[email protected]', '2022-03-01', NULL, true, | ||
'2022-03-01 12:25:28.763', '2022-03-01 09:10:44.682', '2022-03-01 09:10:44.682', | ||
'807', '807', true, false, true); | ||
|
||
INSERT INTO judicial_office_appointment | ||
(judicial_office_appointment_id, per_id, base_location_id, region_id, is_prinicple_appointment, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters