Skip to content

Commit

Permalink
DTSSTCI-865 (#1798)
Browse files Browse the repository at this point in the history
* DTSSTCI-865: Add death of appellant as close case reason

* DTSSTCI-865: Resolve checkstyle

* DTSSTCI-865: Tweak content displayed when death of appellant close case option selected

* DTSSTCI-865: Use static imports for common constants

---------

Co-authored-by: Tom Elliott <tomelliott@Toms-MacBook-Pro.local>
Co-authored-by: jessieharrigan <144362161+jessieharrigan@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 25, 2024
1 parent 1f27f41 commit 0ac0094
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/uk/gov/hmcts/sptribs/ciccase/model/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -161,6 +168,7 @@ public enum State {
CaseManagement,
AwaitingHearing
);

private final String name;
}

Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -117,7 +119,11 @@ private void addCaseClosedTemplateVars(CaseData caseData, Map<String, Object> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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);
}

Expand All @@ -209,7 +214,7 @@ private CaseData getMockCaseData() {
.fullName("fullName").caseNumber("CN1")
.build();
CloseCase closeCase = CloseCase.builder()
.closeCaseReason(CloseReason.Withdrawn)
.closeCaseReason(Withdrawn)
.additionalDetail("additionalDet")
.build();

Expand Down

0 comments on commit 0ac0094

Please sign in to comment.