Skip to content

Commit

Permalink
Add ITs for validation callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-saunders-cts committed Dec 11, 2024
1 parent 2be7ab8 commit deb64c7
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,59 @@ public boolean matches(Object actual) {
}
}

/*
* There is no distinction between PP and PA at the point this error occurs. We use PP only because it exists.
*/
@Test
void shouldAcceptPdfValidateAmendLegalStatement() throws Exception {
String payload = testUtils.getStringFromFile("uploadAmendedLegalStatement_PP.json");

// unclear why when(sU.gST()).thenReturn("sA"); doesn't work, but this does.
doReturn("serviceAuth").when(securityUtils).generateServiceToken();

final uk.gov.hmcts.reform.ccd.document.am.model.Document mockDocument =
uk.gov.hmcts.reform.ccd.document.am.model.Document.builder()
.mimeType(MediaType.APPLICATION_PDF_VALUE)
.build();
when(caseDocumentClient.getMetadataForDocument(any(), any(), anyString())).thenReturn(mockDocument);

final var request = post("/document/validateAmendLegalStatement")
.header("authorization", "authToken")
.content(payload)
.contentType(MediaType.APPLICATION_JSON);

mockMvc.perform(request)
.andExpect(status().isOk());
}

/*
* There is no distinction between PP and PA at the point this error occurs. We use PP only because it exists.
*/
@Test
void shouldRejectNonPdfValidateAmendLegalStatement() throws Exception {
String payload = testUtils.getStringFromFile("uploadAmendedLegalStatement_PP.json");

// unclear why when(sU.gST()).thenReturn("sA"); doesn't work, but this does.
doReturn("serviceAuth").when(securityUtils).generateServiceToken();

final uk.gov.hmcts.reform.ccd.document.am.model.Document mockDocument =
uk.gov.hmcts.reform.ccd.document.am.model.Document.builder()
.mimeType(MediaType.IMAGE_PNG_VALUE)
.build();
when(caseDocumentClient.getMetadataForDocument(any(), any(), anyString())).thenReturn(mockDocument);

final var request = post("/document/validateAmendLegalStatement")
.header("authorization", "authToken")
.content(payload)
.contentType(MediaType.APPLICATION_JSON);

final RejectedMimeTypeMatcher contentMatcher = new RejectedMimeTypeMatcher(MediaType.IMAGE_PNG_VALUE);

mockMvc.perform(request)
.andExpect(status().isOk())
.andExpect(content().string(contentMatcher));
}

/*
* There is no distinction between PP and PA at the point this error occurs. We use PP only because it exists.
*/
Expand Down

0 comments on commit deb64c7

Please sign in to comment.