Skip to content

Commit

Permalink
CCMSPUI-379 Made request params in client search mandatory
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
  • Loading branch information
Jamie Briggs committed Feb 19, 2025
1 parent 619fa4a commit 06bbcff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions data-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1078,16 +1078,19 @@ paths:
parameters:
- name: 'first-name'
in: 'query'
required: true
schema:
type: 'string'
example: 'john'
- name: 'surname'
in: 'query'
required: true
schema:
type: 'string'
example: 'smith'
- name: 'date-of-birth'
in: 'query'
required: true
schema:
type: 'string'
example: "2017-01-01"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void shouldReturnData() throws Exception {

// Then
String jsonContent = objectMapper.writeValueAsString(details);
mockMvc.perform(get("/clients"))
mockMvc.perform(get("/clients?first-name=first&surname=last&date-of-birth=2010-01-01"))
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().json(jsonContent));
Expand All @@ -125,9 +125,37 @@ void shouldReturnData() throws Exception {
@DisplayName("Should return not found")
void shouldReturnNotFound() throws Exception {
// Then
mockMvc.perform(get("/clients"))
mockMvc.perform(get("/clients?first-name=first&surname=last&date-of-birth=2010-01-01"))
.andDo(print())
.andExpect(status().isNotFound());
}


@Test
@DisplayName("Should return bad request when missing first name")
void shouldReturnBadRequestWhenMissingFirstName() throws Exception {
// Then
mockMvc.perform(get("/clients?surname=last&date-of-birth=2010-01-01"))
.andDo(print())
.andExpect(status().isBadRequest());
}

@Test
@DisplayName("Should return bad request when missing surname")
void shouldReturnBadRequestWhenMissingSurname() throws Exception {
// Then
mockMvc.perform(get("/clients?first-name=first&date-of-birth=2010-01-01"))
.andDo(print())
.andExpect(status().isBadRequest());
}

@Test
@DisplayName("Should return bad request when missing date of birth")
void shouldReturnBadRequestWhenMissingDateOfBirth() throws Exception {
// Then
mockMvc.perform(get("/clients?first-name=firstsurname=last"))
.andDo(print())
.andExpect(status().isBadRequest());
}
}
}

0 comments on commit 06bbcff

Please sign in to comment.