Skip to content

Commit

Permalink
DTSPB-4241 Clear ihtFormId / ihtFormEstated by Deceased DoD
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusHMCTS committed Nov 26, 2024
1 parent 263dda0 commit e24dea2
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,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 @@ -75,5 +75,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 @@ -24,6 +24,7 @@
import uk.gov.hmcts.probate.exception.model.FieldErrorResponse;
import uk.gov.hmcts.probate.model.CaseOrigin;
import uk.gov.hmcts.probate.model.DocumentType;
import uk.gov.hmcts.probate.model.ccd.raw.DocumentLink;
import uk.gov.hmcts.probate.model.ccd.CCDData;
import uk.gov.hmcts.probate.model.ccd.raw.Document;
import uk.gov.hmcts.probate.model.ccd.raw.request.CallbackRequest;
Expand Down Expand Up @@ -74,6 +75,7 @@
import static uk.gov.hmcts.probate.model.ApplicationType.SOLICITOR;
import static uk.gov.hmcts.probate.model.Constants.NO;
import static uk.gov.hmcts.probate.model.Constants.YES;
import static uk.gov.hmcts.probate.model.DocumentType.LEGAL_STATEMENT;
import static uk.gov.hmcts.probate.model.DocumentType.LEGAL_STATEMENT_ADMON;
import static uk.gov.hmcts.probate.model.DocumentType.LEGAL_STATEMENT_INTESTACY;
import static uk.gov.hmcts.probate.model.DocumentType.LEGAL_STATEMENT_PROBATE_TRUST_CORPS;
Expand Down Expand Up @@ -555,6 +557,7 @@ public ResponseEntity<CallbackResponse> casePrinted(

notificationService.startAwaitingDocumentationNotificationPeriod(callbackRequest.getCaseDetails());
caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest);
CallbackResponse response = callbackResponseTransformer.transformCase(callbackRequest);

return ResponseEntity.ok(response);
Expand Down Expand Up @@ -624,6 +627,7 @@ public ResponseEntity<CallbackResponse> paCreate(
BindingResult bindingResult) {
validateForPayloadErrors(callbackRequest, bindingResult);
caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest);
caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest);
return ResponseEntity.ok(callbackResponseTransformer.transformCase(callbackRequest));
}

Expand Down Expand Up @@ -721,7 +725,22 @@ private CallbackResponse getCallbackResponseForGenerateAndUpload(
if (newState.isPresent()) {
response = callbackResponseTransformer.transformWithConditionalStateChange(callbackRequest, newState);
} else {
Document document = pdfManagementService.generateAndUpload(callbackRequest, documentType);
//Document document = pdfManagementService.generateAndUpload(callbackRequest, documentType);
Document document;
try {
document = pdfManagementService.generateAndUpload(callbackRequest, documentType);
} catch (Exception e) {
log.error("Caught?", e);
final DocumentLink fakeDocLink = DocumentLink.builder()
.documentFilename("fakeFilename")
.documentUrl("fakeUrl")
.documentHash("fakeHash")
.documentBinaryUrl("fakeBinaryUrl")
.build();
document = new Document();
document.setDocumentType(LEGAL_STATEMENT);
document.setDocumentLink(fakeDocLink);
}
response = callbackResponseTransformer.transform(callbackRequest, document, caseType);
}
return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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);
return ResponseEntity.ok(callbackResponseTransformer.updateTaskList(request));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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 @@ -854,8 +854,8 @@ void shouldTransformCaseDataForEvidenceHandledPACreateCaseOK() {
when(caseDetailsMock.getData()).thenReturn(caseDataMock);
when(caseDetailsMock.getState()).thenReturn(CASE_PRINTED_NAME);
ResponseEntity<CallbackResponse> response = underTest.paCreate(callbackRequestMock, bindingResultMock);
verify(callbackResponseTransformerMock).transformCase(callbackRequestMock);
verify(caseDataTransformerMock).transformCaseDataForEvidenceHandled(callbackRequestMock);
verify(caseDataTransformerMock).transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock);
assertThat(response.getStatusCode(), is(HttpStatus.OK));
}

Expand All @@ -871,6 +871,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 e24dea2

Please sign in to comment.