diff --git a/src/main/java/uk/gov/hmcts/sptribs/caseworker/event/page/CloseCaseConsentOrder.java b/src/main/java/uk/gov/hmcts/sptribs/caseworker/event/page/CloseCaseConsentOrder.java index e92570881f..a14f716c95 100644 --- a/src/main/java/uk/gov/hmcts/sptribs/caseworker/event/page/CloseCaseConsentOrder.java +++ b/src/main/java/uk/gov/hmcts/sptribs/caseworker/event/page/CloseCaseConsentOrder.java @@ -5,22 +5,11 @@ import uk.gov.hmcts.sptribs.common.ccd.CcdPageConfiguration; import uk.gov.hmcts.sptribs.common.ccd.PageBuilder; -import java.util.HashMap; -import java.util.Map; - public class CloseCaseConsentOrder implements CcdPageConfiguration { @Override public void addTo(PageBuilder pageBuilder) { - Map map = new HashMap<>(); - map.put("closeCaseWithdrawalDetails", "closeCloseCaseReason = \"caseWithdrawn\""); - map.put("closeCaseRejectionDetails", "closeCloseCaseReason = \"caseRejected\""); - map.put("closeCaseStrikeOutDetails", "closeCloseCaseReason = \"caseStrikeOut\""); - map.put("closeCaseConcessionDetails", "closeCloseCaseReason = \"caseConcession\""); - map.put("closeCaseConsentOrder", "closeCloseCaseReason = \"consentOrder\""); - map.put("closeCaseRule27", "closeCloseCaseReason = \"rule27\""); pageBuilder.page("closeCaseConsentOrder") .pageLabel("Consent order details") - .pageShowConditions(map) .complex(CaseData::getCloseCase) .mandatory(CloseCase::getConsentOrderDate) .done(); diff --git a/src/main/java/uk/gov/hmcts/sptribs/caseworker/model/CloseReason.java b/src/main/java/uk/gov/hmcts/sptribs/caseworker/model/CloseReason.java index 88b3e1b08b..42bdcfed35 100644 --- a/src/main/java/uk/gov/hmcts/sptribs/caseworker/model/CloseReason.java +++ b/src/main/java/uk/gov/hmcts/sptribs/caseworker/model/CloseReason.java @@ -26,7 +26,10 @@ public enum CloseReason implements HasLabel { ConsentOrder(State.ConsentOrder, "Consent Order"), @JsonProperty("rule27") - Rule27(State.Rule27, "Rule 27"); + Rule27(State.Rule27, "Rule 27"), + + @JsonProperty("deathOfAppellant") + DeathOfAppellant(State.DeathOfAppellant, "Death of Appellant"); private final State type; private final String label; diff --git a/src/main/java/uk/gov/hmcts/sptribs/ciccase/model/State.java b/src/main/java/uk/gov/hmcts/sptribs/ciccase/model/State.java index 48c1d90667..50001e47e3 100644 --- a/src/main/java/uk/gov/hmcts/sptribs/ciccase/model/State.java +++ b/src/main/java/uk/gov/hmcts/sptribs/ciccase/model/State.java @@ -98,6 +98,13 @@ public enum State { ) ConsentOrder("ConsentOrder"), + @CCD( + label = "Death of Appellant", + hint = "### ${cicCaseFullName}\nCase number: ${hyphenatedCaseRef}", + access = {DefaultStateAccessExcludingCAA.class} + ) + DeathOfAppellant("DeathOfAppellant"), + @CCD( label = "Draft", hint = "### ${cicCaseFullName}\nCase number: ${hyphenatedCaseRef}", @@ -161,6 +168,7 @@ public enum State { CaseManagement, AwaitingHearing ); + private final String name; } diff --git a/src/main/java/uk/gov/hmcts/sptribs/common/CommonConstants.java b/src/main/java/uk/gov/hmcts/sptribs/common/CommonConstants.java index 7a5d248bdc..1331efe474 100644 --- a/src/main/java/uk/gov/hmcts/sptribs/common/CommonConstants.java +++ b/src/main/java/uk/gov/hmcts/sptribs/common/CommonConstants.java @@ -63,6 +63,9 @@ public final class CommonConstants { public static final String BUNDLE_DESCRIPTION_FIELD_LENGTH_ERROR_MSG = "Bundle Description should not contain " + "more than 255 Chars"; + public static final String DEATH_OF_APPELLANT_EMAIL_CONTENT = + "Please refer to the Tribunal’s recent directions for further details"; + public static final String TRIBUNAL_NAME_VALUE = "First-tier Tribunal (CIC)"; public static final String TRIBUNAL_EMAIL_VALUE = "CIC.enquiries@justice.gov.uk"; diff --git a/src/main/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotification.java b/src/main/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotification.java index 9ebe966827..8dfb6b80e0 100644 --- a/src/main/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotification.java +++ b/src/main/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotification.java @@ -17,8 +17,10 @@ import java.util.Map; +import static uk.gov.hmcts.sptribs.caseworker.model.CloseReason.DeathOfAppellant; import static uk.gov.hmcts.sptribs.common.CommonConstants.CLOSURE_INFORMATION; import static uk.gov.hmcts.sptribs.common.CommonConstants.CLOSURE_REASON; +import static uk.gov.hmcts.sptribs.common.CommonConstants.DEATH_OF_APPELLANT_EMAIL_CONTENT; import static uk.gov.hmcts.sptribs.common.CommonConstants.NONE_PROVIDED; @Component @@ -117,7 +119,11 @@ private void addCaseClosedTemplateVars(CaseData caseData, Map te final String additionalDetail = StringUtils.isNotEmpty(closeCase.getAdditionalDetail()) ? closeCase.getAdditionalDetail() : NONE_PROVIDED; - templateVars.put(CLOSURE_REASON, closeCase.getCloseCaseReason()); + if (DeathOfAppellant.equals(closeCase.getCloseCaseReason())) { + templateVars.put(CLOSURE_REASON, DEATH_OF_APPELLANT_EMAIL_CONTENT); + } else { + templateVars.put(CLOSURE_REASON, closeCase.getCloseCaseReason()); + } templateVars.put(CLOSURE_INFORMATION, additionalDetail); } } diff --git a/src/test/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotificationTest.java b/src/test/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotificationTest.java index 7e608b8b80..f70003d583 100644 --- a/src/test/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotificationTest.java +++ b/src/test/java/uk/gov/hmcts/sptribs/common/notification/CaseWithdrawnNotificationTest.java @@ -7,12 +7,10 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.AddressGlobalUK; import uk.gov.hmcts.sptribs.caseworker.model.CloseCase; -import uk.gov.hmcts.sptribs.caseworker.model.CloseReason; import uk.gov.hmcts.sptribs.caseworker.model.ReinstateReason; import uk.gov.hmcts.sptribs.ciccase.model.CaseData; import uk.gov.hmcts.sptribs.ciccase.model.CicCase; import uk.gov.hmcts.sptribs.ciccase.model.ContactPreferenceType; -import uk.gov.hmcts.sptribs.common.CommonConstants; import uk.gov.hmcts.sptribs.notification.NotificationHelper; import uk.gov.hmcts.sptribs.notification.NotificationServiceCIC; import uk.gov.hmcts.sptribs.notification.TemplateName; @@ -26,6 +24,12 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.sptribs.caseworker.model.CloseReason.DeathOfAppellant; +import static uk.gov.hmcts.sptribs.caseworker.model.CloseReason.Withdrawn; +import static uk.gov.hmcts.sptribs.common.CommonConstants.CLOSURE_INFORMATION; +import static uk.gov.hmcts.sptribs.common.CommonConstants.CLOSURE_REASON; +import static uk.gov.hmcts.sptribs.common.CommonConstants.DEATH_OF_APPELLANT_EMAIL_CONTENT; +import static uk.gov.hmcts.sptribs.common.CommonConstants.NONE_PROVIDED; @ExtendWith(MockitoExtension.class) public class CaseWithdrawnNotificationTest { @@ -40,167 +44,168 @@ public class CaseWithdrawnNotificationTest { @Test void shouldNotifySubjectCaseWithdrawnWithEmailWithoutAdditionalDetail() { - //Given final CaseData data = getMockCaseData(); + data.getCloseCase().setCloseCaseReason(DeathOfAppellant); data.getCicCase().setContactPreferenceType(ContactPreferenceType.EMAIL); data.getCicCase().setEmail("testSubject@outlook.com"); data.getCloseCase().setAdditionalDetail(""); - //When when(notificationHelper.buildEmailNotificationRequest(any(), anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getSubjectCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); caseWithdrawnNotification.sendToSubject(data, "CN1"); - //Then verify(notificationService).sendEmail(any(NotificationRequest.class)); verify(notificationHelper).buildEmailNotificationRequest( data.getCicCase().getEmail(), Map.of( - CommonConstants.CLOSURE_INFORMATION, CommonConstants.NONE_PROVIDED, - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, NONE_PROVIDED, + CLOSURE_REASON, DEATH_OF_APPELLANT_EMAIL_CONTENT), + TemplateName.CASE_WITHDRAWN_EMAIL); + } + + @Test + void shouldNotifySubjectWithEmailCaseWithdrawnWithDeathOfAppellantReason() { + final CaseData data = getMockCaseData(); + data.getCicCase().setContactPreferenceType(ContactPreferenceType.EMAIL); + data.getCicCase().setEmail("testSubject@outlook.com"); + data.getCloseCase().setAdditionalDetail(""); + + when(notificationHelper.buildEmailNotificationRequest(any(), anyMap(), any(TemplateName.class))) + .thenReturn(NotificationRequest.builder().build()); + when(notificationHelper.getSubjectCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); + caseWithdrawnNotification.sendToSubject(data, "CN1"); + + verify(notificationService).sendEmail(any(NotificationRequest.class)); + verify(notificationHelper).buildEmailNotificationRequest( + data.getCicCase().getEmail(), + Map.of( + CLOSURE_INFORMATION, NONE_PROVIDED, + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_EMAIL); } @Test void shouldNotifySubjectCaseWithdrawnWithPost() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setContactPreferenceType(ContactPreferenceType.POST); data.getCicCase().setAddress(AddressGlobalUK.builder().build()); - //When when(notificationHelper.buildLetterNotificationRequest(anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getSubjectCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); doNothing().when(notificationHelper).addAddressTemplateVars(any(AddressGlobalUK.class), anyMap()); caseWithdrawnNotification.sendToSubject(data, "CN1"); - //Then verify(notificationService).sendLetter(any(NotificationRequest.class)); verify(notificationHelper).buildLetterNotificationRequest( Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason() + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason() ), TemplateName.CASE_WITHDRAWN_POST); } @Test void shouldNotifyRespondentCaseWithdrawnWithEmail() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setRespondentName("respondentName"); data.getCicCase().setRespondentEmail("testrespondent@outlook.com"); data.getCicCase().setReinstateReason(ReinstateReason.OTHER); - //When when(notificationHelper.buildEmailNotificationRequest(any(), anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getRespondentCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); caseWithdrawnNotification.sendToRespondent(data, "CN1"); - //Then verify(notificationService).sendEmail(any(NotificationRequest.class)); verify(notificationHelper).buildEmailNotificationRequest( data.getCicCase().getRespondentEmail(), Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_EMAIL); } @Test void shouldNotifyRepresentativeCaseWithdrawnWithEmail() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setRepresentativeFullName("repFullName"); data.getCicCase().setRepresentativeContactDetailsPreference(ContactPreferenceType.EMAIL); data.getCicCase().setRepresentativeEmailAddress("testrepr@outlook.com"); - //When when(notificationHelper.buildEmailNotificationRequest(any(), anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getRepresentativeCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); caseWithdrawnNotification.sendToRepresentative(data, "CN1"); - //Then verify(notificationService).sendEmail(any(NotificationRequest.class)); verify(notificationHelper).buildEmailNotificationRequest( data.getCicCase().getRepresentativeEmailAddress(), Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_EMAIL); } @Test void shouldNotifyRepresentativeCaseWithdrawnWithPost() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setRepresentativeFullName("repFullName"); data.getCicCase().setRepresentativeContactDetailsPreference(ContactPreferenceType.POST); data.getCicCase().setRepresentativeAddress(AddressGlobalUK.builder().build()); - //When when(notificationHelper.buildLetterNotificationRequest(anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getRepresentativeCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); doNothing().when(notificationHelper).addAddressTemplateVars(any(AddressGlobalUK.class), anyMap()); caseWithdrawnNotification.sendToRepresentative(data, "CN1"); - //Then verify(notificationService).sendLetter(any(NotificationRequest.class)); verify(notificationHelper).buildLetterNotificationRequest( Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_POST); } @Test void shouldNotifyApplicantCaseWithdrawnWithEmail() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setContactPreferenceType(ContactPreferenceType.EMAIL); data.getCicCase().setApplicantEmailAddress("testApplicant@outlook.com"); - //When when(notificationHelper.buildEmailNotificationRequest(any(), anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getApplicantCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); caseWithdrawnNotification.sendToApplicant(data, "CN1"); - //Then verify(notificationService).sendEmail(any(NotificationRequest.class)); verify(notificationHelper).buildEmailNotificationRequest( data.getCicCase().getApplicantEmailAddress(), Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_EMAIL); } @Test void shouldNotifyApplicantCaseWithdrawnWithPost() { - //Given final CaseData data = getMockCaseData(); data.getCicCase().setContactPreferenceType(ContactPreferenceType.POST); data.getCicCase().setApplicantAddress(AddressGlobalUK.builder().build()); - //When when(notificationHelper.buildLetterNotificationRequest(anyMap(), any(TemplateName.class))) .thenReturn(NotificationRequest.builder().build()); when(notificationHelper.getApplicantCommonVars(any(), any(CicCase.class))).thenReturn(new HashMap<>()); doNothing().when(notificationHelper).addAddressTemplateVars(any(AddressGlobalUK.class), anyMap()); caseWithdrawnNotification.sendToApplicant(data, "CN1"); - //Then verify(notificationService).sendLetter(any(NotificationRequest.class)); verify(notificationHelper).buildLetterNotificationRequest( Map.of( - CommonConstants.CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), - CommonConstants.CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), + CLOSURE_INFORMATION, data.getCloseCase().getAdditionalDetail(), + CLOSURE_REASON, data.getCloseCase().getCloseCaseReason()), TemplateName.CASE_WITHDRAWN_POST); } @@ -209,7 +214,7 @@ private CaseData getMockCaseData() { .fullName("fullName").caseNumber("CN1") .build(); CloseCase closeCase = CloseCase.builder() - .closeCaseReason(CloseReason.Withdrawn) + .closeCaseReason(Withdrawn) .additionalDetail("additionalDet") .build();