Skip to content

Commit

Permalink
Merge branch 'master' into DTSPB-4373_Send_Sealed-and-Certified_Email
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusHMCTS committed Dec 12, 2024
2 parents a1b82da + a1d38f4 commit f6e25db
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ void shouldTransformCaseDataForEvidenceHandledPACreateCaseOK() throws Exception
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
verify(caseDataTransformer).transformCaseDataForEvidenceHandled(any(CallbackRequest.class));
verify(caseDataTransformer).transformIhtFormCaseDataByDeceasedDOD(any(CallbackRequest.class));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ void taskListUpdateCasePrintedShouldTransformEvidenceHandled() throws Exception
.andExpect(status().isOk())
.andExpect(content().string(containsString("data")));
verify(caseDataTransformer).transformCaseDataForEvidenceHandled(any());
verify(caseDataTransformer).transformIhtFormCaseDataByDeceasedDOD(any());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,9 @@ public ResponseEntity<CallbackResponse> casePrinted(

notificationService.startAwaitingDocumentationNotificationPeriod(callbackRequest.getCaseDetails());
caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest);
Optional<UserInfo> caseworkerInfo = userInfoService.getCaseworkerInfo();
CallbackResponse response = callbackResponseTransformer.transformCase(callbackRequest, caseworkerInfo);

return ResponseEntity.ok(response);
}

Expand Down Expand Up @@ -611,6 +611,7 @@ public ResponseEntity<CallbackResponse> paCreate(
BindingResult bindingResult) {
validateForPayloadErrors(callbackRequest, bindingResult);
caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest);
Optional<UserInfo> caseworkerInfo = userInfoService.getCaseworkerInfo();
return ResponseEntity.ok(callbackResponseTransformer.transformCase(callbackRequest, caseworkerInfo));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public ResponseEntity<CallbackResponse> update(@RequestBody CallbackRequest requ
@PostMapping(path = "/updateCasePrinted", produces = {APPLICATION_JSON_VALUE})
public ResponseEntity<CallbackResponse> updateCasePrinted(@RequestBody CallbackRequest request) {
caseDataTransformer.transformCaseDataForEvidenceHandled(request);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(request);
Optional<UserInfo> caseworkerInfo = userInfoService.getCaseworkerInfo();
return ResponseEntity.ok(callbackResponseTransformer.updateTaskList(request, caseworkerInfo));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ public void transformCaseDataForDocsReceivedNotificationSent(CallbackRequest cal
attachDocumentsTransformer.updateDocsReceivedNotificationSent(callbackRequest.getCaseDetails().getData());
}

public void transformIhtFormCaseDataByDeceasedDOD(CallbackRequest callbackRequest) {
CaseData caseData = callbackRequest.getCaseDetails().getData();
if (dateOfDeathIsOnOrAfterSwitchDate(caseData.getDeceasedDateOfDeath())) {
resetIhtFormId(caseData);
} else {
resetIhtFormEstate(caseData);
}
}

public void transformFormCaseData(CallbackRequest callbackRequest) {
CaseData caseData = callbackRequest.getCaseDetails().getData();
if (dateOfDeathIsOnOrAfterSwitchDate(caseData.getDeceasedDateOfDeath())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,9 @@ void shouldTransformCaseDataForEvidenceHandledPACreateCaseOK() {
when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock);
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(caseDetailsMock.getState()).thenReturn(CASE_PRINTED_NAME);
ResponseEntity<CallbackResponse> response = underTest.paCreate(callbackRequestMock,
bindingResultMock);
verify(callbackResponseTransformerMock).transformCase(callbackRequestMock, CASEWORKER_USERINFO);
ResponseEntity<CallbackResponse> response = underTest.paCreate(callbackRequestMock, bindingResultMock);
verify(caseDataTransformerMock).transformCaseDataForEvidenceHandled(callbackRequestMock);
verify(caseDataTransformerMock).transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock);
assertThat(response.getStatusCode(), is(HttpStatus.OK));
}

Expand All @@ -892,6 +891,7 @@ void shouldTransformCaseDataForEvidenceHandledCasePrinted() {
bindingResultMock);

verify(caseDataTransformerMock).transformCaseDataForEvidenceHandled(callbackRequestMock);
verify(caseDataTransformerMock).transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock);
assertThat(response.getStatusCode(), is(HttpStatus.OK));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void shouldNotTransformEvidenceHandledForNotCasePrinted() {
verify(evidenceHandledTransformer, times(0)).updateEvidenceHandled(caseDataMock);
}


@Test
void shouldTransformEvidenceHandledForManualCreateByCWCasePrinted() {
when(caseDetailsMock.getState()).thenReturn(CASE_PRINTED_NAME);
Expand Down Expand Up @@ -295,4 +296,32 @@ void shouldTransformCaseDataForPaperForm() {
caseDataTransformer.transformCaseDataForPaperForm(callbackRequestMock);
assertThat(caseDataMock.getChannelChoice(), is("PaperForm"));
}

@Test
void shouldTransformIhtFormIdNullForDiedAfter() {
caseDataMock = CaseData.builder().applicationType(ApplicationType.PERSONAL)
.ihtFormEstate("IHT400")
.ihtFormId("IHT205").build();

when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock);
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(exceptedEstateDateOfDeathChecker.isOnOrAfterSwitchDate((LocalDate) any())).thenReturn(true);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock);
assertThat(caseDataMock.getIhtFormId(), CoreMatchers.is(nullValue()));
}

@Test
void shouldTransformIhtFormEstateNullForDiedBefore() {
caseDataMock = CaseData.builder().applicationType(ApplicationType.PERSONAL)
.ihtFormEstate("IHT400")
.ihtFormId("IHT205").build();


when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock);
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(exceptedEstateDateOfDeathChecker.isOnOrAfterSwitchDate((LocalDate) any())).thenReturn(false);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock);
assertThat(caseDataMock.getIhtFormEstate(), CoreMatchers.is(nullValue()));
}

}

0 comments on commit f6e25db

Please sign in to comment.