Skip to content

Commit

Permalink
CIV-10336 SDO EA email notification (#3450)
Browse files Browse the repository at this point in the history
* CIV-10336 SDO EA email notification

* CIV-10336 SDO EA email notification

* update tests

---------

Co-authored-by: Gareth Lancaster <[email protected]>
Co-authored-by: Hemanth Potipati <[email protected]>
Co-authored-by: AhsanZX97 <[email protected]>
  • Loading branch information
4 people authored Oct 31, 2023
1 parent 07edf6f commit e67b77c
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ configurations.all {
}

dependencies {
implementation 'com.github.hmcts:civil-commons:1.0.29'
implementation 'com.github.hmcts:civil-commons:1.0.28_10336'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.prd.model.Organisation;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.Optional;
Expand All @@ -17,8 +18,9 @@ public abstract class AbstractCreateSDORespondentLRNotificationSender extends Ab
public AbstractCreateSDORespondentLRNotificationSender(
NotificationService notificationService,
NotificationsProperties notificationsProperties,
OrganisationService organisationService) {
super(notificationService, notificationsProperties);
OrganisationService organisationService,
FeatureToggleService featureToggleService) {
super(notificationService, notificationsProperties, featureToggleService);
this.organisationService = organisationService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.util.Map;

Expand All @@ -20,6 +21,7 @@ public abstract class AbstractCreateSDORespondentNotificationSender implements N

private final NotificationService notificationService;
private final NotificationsProperties notificationsProperties;
private final FeatureToggleService featureToggleService;

protected abstract String getDocReference(CaseData caseData);

Expand All @@ -43,12 +45,14 @@ void notifyRespondentPartySDOTriggered(CaseData caseData) {

private String getSDOTemplate(CaseData caseData) {
if (caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM) {
if (caseData.isRespondentResponseBilingual()) {
if (caseData.isRespondentResponseBilingual()) {
return notificationsProperties.getSdoOrderedSpecBilingual();
}
return notificationsProperties.getSdoOrderedSpec();
}
return featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec();
}
return notificationsProperties.getSdoOrdered();
return featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import uk.gov.hmcts.reform.civil.enums.CaseCategory;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;
import uk.gov.hmcts.reform.civil.prd.model.Organisation;

Expand All @@ -34,6 +35,7 @@ public class CreateSDOApplicantsNotificationHandler extends CallbackHandler impl
private final NotificationService notificationService;
private final NotificationsProperties notificationsProperties;
private final OrganisationService organisationService;
private final FeatureToggleService featureToggleService;

@Override
protected Map<String, Callback> callbacks() {
Expand All @@ -55,11 +57,17 @@ public List<CaseEvent> handledEvents() {
private CallbackResponse notifyApplicantsSolicitorSDOTriggered(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();

String unspecTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedEA() : notificationsProperties.getSdoOrdered();

String specTemplate = featureToggleService.isEarlyAdoptersEnabled()
? notificationsProperties.getSdoOrderedSpecEA() : notificationsProperties.getSdoOrderedSpec();

notificationService.sendMail(
caseData.getApplicantSolicitor1UserDetails().getEmail(),
caseData.getCaseAccessCategory() == CaseCategory.SPEC_CLAIM
? notificationsProperties.getSdoOrderedSpec()
: notificationsProperties.getSdoOrdered(),
? specTemplate
: unspecTemplate,
addProperties(caseData),
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

/**
Expand All @@ -18,8 +19,9 @@ public class CreateSDORespondent1LRNotificationSender extends AbstractCreateSDOR
public CreateSDORespondent1LRNotificationSender(
NotificationService notificationService,
NotificationsProperties notificationsProperties,
OrganisationService organisationService) {
super(notificationService, notificationsProperties, organisationService);
OrganisationService organisationService,
FeatureToggleService featureToggleService) {
super(notificationService, notificationsProperties, organisationService, featureToggleService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

/**
* When an SDO is created it is notified to applicants and defendants.
Expand All @@ -16,8 +17,9 @@ public class CreateSDORespondent1LiPNotificationSender extends AbstractCreateSDO

public CreateSDORespondent1LiPNotificationSender(
NotificationService notificationService,
NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
NotificationsProperties notificationsProperties,
FeatureToggleService featureToggleService) {
super(notificationService, notificationsProperties, featureToggleService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.Optional;
Expand All @@ -24,8 +25,9 @@ public class CreateSDORespondent2LRNotificationSender extends AbstractCreateSDOR
public CreateSDORespondent2LRNotificationSender(
NotificationService notificationService,
NotificationsProperties notificationsProperties,
OrganisationService organisationService) {
super(notificationService, notificationsProperties, organisationService);
OrganisationService organisationService,
FeatureToggleService featureToggleService) {
super(notificationService, notificationsProperties, organisationService, featureToggleService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

/**
* When an SDO is created it is notified to applicants and defendants.
Expand All @@ -16,8 +17,9 @@ public class CreateSDORespondent2LiPNotificationSender extends AbstractCreateSDO

public CreateSDORespondent2LiPNotificationSender(
NotificationService notificationService,
NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
NotificationsProperties notificationsProperties,
FeatureToggleService featureToggleService) {
super(notificationService, notificationsProperties, featureToggleService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,8 @@ public boolean isTransferOnlineCaseEnabled() {
public boolean isCaseProgressionEnabled() {
return featureToggleApi.isFeatureEnabled("cui-case-progression");
}

public boolean isEarlyAdoptersEnabled() {
return featureToggleApi.isFeatureEnabled("early-adopters");
}
}
2 changes: 2 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ notifications:
respondentDefendantResponseForSpec: "94c71894-9590-4995-aae0-edea94fc4594"
sdoOrdered: "90667080-6b20-48f2-b9ea-349fa8ec78e4"
sdoOrderedSpec: "1c1a200c-b3c1-45eb-9768-aeea56857420"
sdoOrderedEA: "837d3f5e-e1f8-4d6b-b053-719392fe556c"
sdoOrderedSpecEA: "7224780e-416c-4c0b-a718-056cd93abe06"
sdoOrderedSpecBilingual: "0ae860e7-80b5-46f8-95b7-8f19d6f974cf"
claimantSolicitorConfirmsNotToProceedSpec: "156b71f5-30ac-4398-aad2-72dfd424c6f2"
claimantSolicitorConfirmsNotToProceedSpecLip: "25988b85-dafc-40be-970f-45fbb7d0f860"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;
import uk.gov.hmcts.reform.civil.prd.model.Organisation;

Expand Down Expand Up @@ -45,6 +46,8 @@ public class CreateSDOApplicantsNotificationHandlerTest extends BaseCallbackHand
private NotificationsProperties notificationsProperties;
@MockBean
private OrganisationService organisationService;
@MockBean
private FeatureToggleService featureToggleService;
@Autowired
private CreateSDOApplicantsNotificationHandler handler;

Expand Down Expand Up @@ -82,6 +85,58 @@ private Map<String, String> getNotificationDataMap(CaseData caseData) {
}
}

@Nested
class AboutToSubmitCallbackEA {

@BeforeEach
void setup() {
when(notificationsProperties.getSdoOrderedEA()).thenReturn("template-id-EA");
when(notificationsProperties.getSdoOrderedSpecEA()).thenReturn("template-id-spec-EA");
when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true);
when(organisationService.findOrganisationById(anyString()))
.thenReturn(Optional.of(Organisation.builder().name("Signer Name").build()));
}

@Test
void shouldNotifyApplicantSolicitor_whenInvoked() {
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build();

handler.handle(params);

verify(notificationService).sendMail(
"[email protected]",
"template-id-EA",
getNotificationDataMap(caseData),
"create-sdo-applicants-notification-000DC001"
);
}

@Test
void shouldNotifyApplicantSolicitorSpec_whenInvoked() {
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified()
.setClaimTypeToSpecClaim().build();
CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).build();

handler.handle(params);

verify(notificationService).sendMail(
"[email protected]",
"template-id-spec-EA",
getNotificationDataMap(caseData),
"create-sdo-applicants-notification-000DC001"
);
}

@NotNull
private Map<String, String> getNotificationDataMap(CaseData caseData) {
return Map.of(
CLAIM_REFERENCE_NUMBER, LEGACY_CASE_REFERENCE,
CLAIM_LEGAL_ORG_NAME_SPEC, "Signer Name"
);
}
}

@Test
void shouldReturnCorrectCamundaActivityId_whenInvoked() {
assertThat(handler.camundaActivityId(CallbackParamsBuilder.builder().request(CallbackRequest.builder().eventId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder;
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder;
import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.Map;
Expand Down Expand Up @@ -54,12 +55,15 @@ public class CreateSDORespondent1NotificationHandlerTest extends BaseCallbackHan
private NotificationsProperties notificationsProperties;
@MockBean
private OrganisationService organisationService;
@MockBean
private FeatureToggleService featureToggleService;
@Autowired
private CreateSDORespondent1NotificationHandler handler;
private static final String DEFENDANT_EMAIL = "[email protected]";
private static final String LEGACY_REFERENCE = "create-sdo-respondent-1-notification-000DC001";
private static final String DEFENDANT_NAME = "respondent";
private static final String TEMPLATE_ID = "template-id";
private static final String TEMPLATE_ID_EA = "template-id-EA";
private static final String ORG_NAME = "Signer Name";

@Nested
Expand All @@ -68,8 +72,10 @@ class AboutToSubmitCallback {
@BeforeEach
void setup() {
when(notificationsProperties.getSdoOrdered()).thenReturn(TEMPLATE_ID);
when(notificationsProperties.getSdoOrderedEA()).thenReturn(TEMPLATE_ID_EA);
when(notificationsProperties.getSdoOrderedSpecBilingual()).thenReturn(TEMPLATE_ID);
when(notificationsProperties.getSdoOrderedSpec()).thenReturn(TEMPLATE_ID);
when(notificationsProperties.getSdoOrderedSpecEA()).thenReturn(TEMPLATE_ID_EA);
when(organisationService.findOrganisationById(anyString()))
.thenReturn(Optional.of(Organisation.builder().name(ORG_NAME).build()));
}
Expand All @@ -95,6 +101,28 @@ void shouldNotifyRespondentSolicitor_whenInvoked() {
);
}

@Test
void shouldNotifyRespondentSolicitor_whenInvokedEA() {
when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true);
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build();
CallbackParams params = CallbackParams.builder()
.caseData(caseData)
.type(ABOUT_TO_SUBMIT)
.request(CallbackRequest.builder()
.eventId(CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_SDO_TRIGGERED.name())
.build())
.build();

handler.handle(params);

verify(notificationService).sendMail(
caseData.getRespondentSolicitor1EmailAddress(),
TEMPLATE_ID_EA,
getNotificationDataMap(caseData),
LEGACY_REFERENCE
);
}

@Test
void shouldNotifyRespondentLiP_whenInvoked() {
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build()
Expand All @@ -120,6 +148,32 @@ void shouldNotifyRespondentLiP_whenInvoked() {
);
}

@Test
void shouldNotifyRespondentLiP_whenInvokedEA() {
when(featureToggleService.isEarlyAdoptersEnabled()).thenReturn(true);
CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build()
.toBuilder()
.respondent1Represented(YesOrNo.NO)
.caseAccessCategory(CaseCategory.SPEC_CLAIM)
.build();
CallbackParams params = CallbackParams.builder()
.caseData(caseData)
.type(ABOUT_TO_SUBMIT)
.request(CallbackRequest.builder()
.eventId(CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_SDO_TRIGGERED.name())
.build())
.build();

handler.handle(params);

verify(notificationService).sendMail(
caseData.getRespondent1().getPartyEmail(),
TEMPLATE_ID_EA,
getNotificationDataLipMap1(caseData),
LEGACY_REFERENCE
);
}

@Test
void shouldNotifyRespondentLiPWithBilingual_whenDefendantResponseIsBilingual() {
Party party = PartyBuilder.builder()
Expand Down
Loading

0 comments on commit e67b77c

Please sign in to comment.