From a1d38f4142ac25e2873483bf015da9f8f6a681c1 Mon Sep 17 00:00:00 2001 From: Marcus Ho <99657446+MarcusHMCTS@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:15:04 +0000 Subject: [PATCH] DTSPB-4241 Clear ihtFormId / ihtFormEstated by Deceased DoD (#2896) * DTSPB-4241 Clear ihtFormId / ihtFormEstated by Deceased DoD * DTSPB-4241 fix typo * DTSPB-4241 remove unused import * Update typo BusinessValidationController.java * DTSPB-4241 fix sonar issue --- .../BusinessValidationControllerIT.java | 1 + .../controller/TaskListControllerIT.java | 1 + .../BusinessValidationController.java | 3 +- .../controller/TaskListController.java | 1 + .../transformer/CaseDataTransformer.java | 9 ++++++ .../BusinessValidationUnitTest.java | 6 ++-- .../transformer/CaseDataTransformerTest.java | 29 +++++++++++++++++++ 7 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/integrationTest/java/uk/gov/hmcts/probate/controller/BusinessValidationControllerIT.java b/src/integrationTest/java/uk/gov/hmcts/probate/controller/BusinessValidationControllerIT.java index fce98ceda8..cda6ea4e0e 100644 --- a/src/integrationTest/java/uk/gov/hmcts/probate/controller/BusinessValidationControllerIT.java +++ b/src/integrationTest/java/uk/gov/hmcts/probate/controller/BusinessValidationControllerIT.java @@ -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 diff --git a/src/integrationTest/java/uk/gov/hmcts/probate/controller/TaskListControllerIT.java b/src/integrationTest/java/uk/gov/hmcts/probate/controller/TaskListControllerIT.java index 350a934236..ebefb0e69c 100644 --- a/src/integrationTest/java/uk/gov/hmcts/probate/controller/TaskListControllerIT.java +++ b/src/integrationTest/java/uk/gov/hmcts/probate/controller/TaskListControllerIT.java @@ -94,5 +94,6 @@ void taskListUpdateCasePrintedShouldTransformEvidenceHandled() throws Exception .andExpect(status().isOk()) .andExpect(content().string(containsString("data"))); verify(caseDataTransformer).transformCaseDataForEvidenceHandled(any()); + verify(caseDataTransformer).transformIhtFormCaseDataByDeceasedDOD(any()); } } diff --git a/src/main/java/uk/gov/hmcts/probate/controller/BusinessValidationController.java b/src/main/java/uk/gov/hmcts/probate/controller/BusinessValidationController.java index 0198a3874c..c691e866b0 100644 --- a/src/main/java/uk/gov/hmcts/probate/controller/BusinessValidationController.java +++ b/src/main/java/uk/gov/hmcts/probate/controller/BusinessValidationController.java @@ -540,9 +540,9 @@ public ResponseEntity casePrinted( notificationService.startAwaitingDocumentationNotificationPeriod(callbackRequest.getCaseDetails()); caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest); + caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest); Optional caseworkerInfo = userInfoService.getCaseworkerInfo(); CallbackResponse response = callbackResponseTransformer.transformCase(callbackRequest, caseworkerInfo); - return ResponseEntity.ok(response); } @@ -611,6 +611,7 @@ public ResponseEntity paCreate( BindingResult bindingResult) { validateForPayloadErrors(callbackRequest, bindingResult); caseDataTransformer.transformCaseDataForEvidenceHandled(callbackRequest); + caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(callbackRequest); Optional caseworkerInfo = userInfoService.getCaseworkerInfo(); return ResponseEntity.ok(callbackResponseTransformer.transformCase(callbackRequest, caseworkerInfo)); } diff --git a/src/main/java/uk/gov/hmcts/probate/controller/TaskListController.java b/src/main/java/uk/gov/hmcts/probate/controller/TaskListController.java index 059a091386..da0826f5c2 100644 --- a/src/main/java/uk/gov/hmcts/probate/controller/TaskListController.java +++ b/src/main/java/uk/gov/hmcts/probate/controller/TaskListController.java @@ -37,6 +37,7 @@ public ResponseEntity update(@RequestBody CallbackRequest requ @PostMapping(path = "/updateCasePrinted", produces = {APPLICATION_JSON_VALUE}) public ResponseEntity updateCasePrinted(@RequestBody CallbackRequest request) { caseDataTransformer.transformCaseDataForEvidenceHandled(request); + caseDataTransformer.transformIhtFormCaseDataByDeceasedDOD(request); Optional caseworkerInfo = userInfoService.getCaseworkerInfo(); return ResponseEntity.ok(callbackResponseTransformer.updateTaskList(request, caseworkerInfo)); } diff --git a/src/main/java/uk/gov/hmcts/probate/transformer/CaseDataTransformer.java b/src/main/java/uk/gov/hmcts/probate/transformer/CaseDataTransformer.java index 1a0c68f6f2..f10b1926de 100644 --- a/src/main/java/uk/gov/hmcts/probate/transformer/CaseDataTransformer.java +++ b/src/main/java/uk/gov/hmcts/probate/transformer/CaseDataTransformer.java @@ -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())) { diff --git a/src/test/java/uk/gov/hmcts/probate/controller/BusinessValidationUnitTest.java b/src/test/java/uk/gov/hmcts/probate/controller/BusinessValidationUnitTest.java index 95d280e9bc..1a1855562d 100644 --- a/src/test/java/uk/gov/hmcts/probate/controller/BusinessValidationUnitTest.java +++ b/src/test/java/uk/gov/hmcts/probate/controller/BusinessValidationUnitTest.java @@ -873,10 +873,9 @@ void shouldTransformCaseDataForEvidenceHandledPACreateCaseOK() { when(callbackRequestMock.getCaseDetails()).thenReturn(caseDetailsMock); when(caseDetailsMock.getData()).thenReturn(caseDataMock); when(caseDetailsMock.getState()).thenReturn(CASE_PRINTED_NAME); - ResponseEntity response = underTest.paCreate(callbackRequestMock, - bindingResultMock); - verify(callbackResponseTransformerMock).transformCase(callbackRequestMock, CASEWORKER_USERINFO); + ResponseEntity response = underTest.paCreate(callbackRequestMock, bindingResultMock); verify(caseDataTransformerMock).transformCaseDataForEvidenceHandled(callbackRequestMock); + verify(caseDataTransformerMock).transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock); assertThat(response.getStatusCode(), is(HttpStatus.OK)); } @@ -892,6 +891,7 @@ void shouldTransformCaseDataForEvidenceHandledCasePrinted() { bindingResultMock); verify(caseDataTransformerMock).transformCaseDataForEvidenceHandled(callbackRequestMock); + verify(caseDataTransformerMock).transformIhtFormCaseDataByDeceasedDOD(callbackRequestMock); assertThat(response.getStatusCode(), is(HttpStatus.OK)); } diff --git a/src/test/java/uk/gov/hmcts/probate/transformer/CaseDataTransformerTest.java b/src/test/java/uk/gov/hmcts/probate/transformer/CaseDataTransformerTest.java index a13f49ad13..e32ddf4576 100644 --- a/src/test/java/uk/gov/hmcts/probate/transformer/CaseDataTransformerTest.java +++ b/src/test/java/uk/gov/hmcts/probate/transformer/CaseDataTransformerTest.java @@ -120,6 +120,7 @@ void shouldNotTransformEvidenceHandledForNotCasePrinted() { verify(evidenceHandledTransformer, times(0)).updateEvidenceHandled(caseDataMock); } + @Test void shouldTransformEvidenceHandledForManualCreateByCWCasePrinted() { when(caseDetailsMock.getState()).thenReturn(CASE_PRINTED_NAME); @@ -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())); + } + }