diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/JudicialNotificationService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/JudicialNotificationService.java index 42707b957..dc377b79f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/JudicialNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/JudicialNotificationService.java @@ -278,9 +278,7 @@ private CaseData applicationRequestForInformation(CaseData caseData, String soli } customProps.remove(GA_NOTIFICATION_DEADLINE); - } - - if ((isSendUncloakAdditionalFeeEmailForWithoutNotice(caseData) + } else if ((isSendUncloakAdditionalFeeEmailForWithoutNotice(caseData) || isSendUncloakAdditionalFeeEmailConsentOrder(caseData))) { // Send notification to applicant only if it's without notice application if (solicitorType.equals(APPLICANT) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelper.java b/src/main/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelper.java index 70cb989c8..35e043b5f 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelper.java @@ -75,13 +75,14 @@ public class ParentCaseUpdateHelper { private static final String[] DOCUMENT_TYPES = { "generalOrder", "dismissalOrder", "directionOrder", "hearingNotice", - "gaResp", GA_DRAFT_FORM + "gaResp", GA_DRAFT_FORM, "gaAddl" }; private static final String CLAIMANT_ROLE = "Claimant"; private static final String RESPONDENTSOL_ROLE = "RespondentSol"; private static final String RESPONDENTSOL_TWO_ROLE = "RespondentSolTwo"; private String[] roles = {CLAIMANT_ROLE, RESPONDENTSOL_ROLE, RESPONDENTSOL_TWO_ROLE}; private static final String GA_EVIDENCE = "gaEvidence"; + private static final String GA_ADDL = "gaAddl"; private static final String CIVIL_GA_EVIDENCE = "generalAppEvidence"; private static final String FREE_KEYWORD = "FREE"; @@ -747,6 +748,9 @@ protected void updateCaseDocumentByType(Map updateMap, String ty if (type.equals(GA_EVIDENCE)) { gaCollectionName = CIVIL_GA_EVIDENCE + "Document"; } + if (type.equals(GA_ADDL)) { + gaCollectionName = type + "Doc"; + } String civilCollectionName = type + "Doc" + role; Method gaGetter = ReflectionUtils.findMethod(CaseData.class, diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/JudicialApplicantNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/JudicialApplicantNotificationServiceTest.java index 3283836b7..8abb0d3c8 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/JudicialApplicantNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/JudicialApplicantNotificationServiceTest.java @@ -89,6 +89,8 @@ class JudicialApplicantNotificationServiceTest { private JudicialDecisionHelper judicialDecisionHelper; @MockBean private FeatureToggleService featureToggleService; + @MockBean + private GaForLipService gaForLipService; private static final String APPLICANT = "applicant"; private static final String RESPONDENT = "respondent"; @@ -170,6 +172,7 @@ void sendNotificationApplicantConcurrentWrittenRep() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataForConcurrentWrittenOption(YES, NO)); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseDataForConcurrentWrittenOption(YES, NO), APPLICANT); verify(notificationService, times(1)).sendMail( DUMMY_EMAIL, @@ -184,6 +187,7 @@ void sendNotificationApplicantSequentialWrittenRep() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataForSequentialWrittenOption(YES, NO)); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); + when(gaForLipService.isLipApp(any())).thenReturn(true); CaseData caseData = caseDataForSequentialWrittenOption(YES, NO); judicialNotificationService.sendNotification(caseData.toBuilder().applicantBilingualLanguagePreference(YES) @@ -204,6 +208,7 @@ void sendNotificationInWelshApplicantSequentialWrittenRep() { CaseData claimRespondentResponseLan = CaseData.builder().claimantBilingualLanguagePreference("WELSH") .applicantBilingualLanguagePreference(YES).build(); when(caseDetailsConverter.toCaseData(any())).thenReturn(claimRespondentResponseLan); + when(gaForLipService.isLipApp(any())).thenReturn(true); CaseData caseData = caseDataForSequentialWrittenOption(YES, NO); CaseData updatedCasedata = caseData.toBuilder().applicantBilingualLanguagePreference(YES) .build(); @@ -221,6 +226,7 @@ void notificationUncloakShouldSendForDismissal_ApplicantLIP() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataForJudgeDismissal(NO, NO, NO, YES, NO)); + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseDataForJudgeDismissal(NO, NO, NO, YES, NO), APPLICANT); @@ -237,6 +243,7 @@ void notificationCloakShouldSendForDismissal_ApplicantLIP() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataForJudgeDismissal(NO, NO, YES, YES, NO)); + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseDataForJudgeDismissal(NO, NO, NO, YES, NO), APPLICANT); @@ -258,7 +265,7 @@ void notificationShouldSend_LipRespondent_When_JudicialDirectionOrderRep_unCloak when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseData); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseData, APPLICANT); verify(notificationService, times(1)).sendMail( @@ -273,7 +280,7 @@ void notificationShouldSend_LipRespondent_When_JudicialDirectionOrderRep() { CaseData caseData = caseDataForJudicialDirectionOrderOfApplicationWhenRespondentsArePresentInList(NO, NO, YES, YES, YES, NO); - + when(gaForLipService.isLipApp(any())).thenReturn(true); when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseData); @@ -291,7 +298,7 @@ void notificationShouldSendSendToLipRespondent_IfApplicationUncloakedForApproveO when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataWithSolicitorDataOnlyForApplicationUncloakedJudgeApproveOrEdit( YES, NO, NO)); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification( caseDataWithSolicitorDataOnlyForApplicationUncloakedJudgeApproveOrEdit( YES, NO, NO), APPLICANT); @@ -310,7 +317,7 @@ void notificationShouldSendSendToLipRespondent_IfApplicationForApproveOrEdit() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataWithSolicitorDataOnlyForApplicationUncloakedJudgeApproveOrEdit( YES, NO, YES)); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification( caseDataWithSolicitorDataOnlyForApplicationUncloakedJudgeApproveOrEdit( YES, NO, YES), APPLICANT); @@ -334,6 +341,7 @@ void shouldSendNotification_LipRespondent_UncloakedApplication() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseData); + when(gaForLipService.isLipApp(any())).thenReturn(true); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); judicialNotificationService.sendNotification(caseData, APPLICANT); @@ -358,7 +366,7 @@ void shouldSendNotification_LipRespondent_Application() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseData); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseData, APPLICANT); verify(notificationService, times(1)).sendMail( @@ -369,13 +377,67 @@ void shouldSendNotification_LipRespondent_Application() { ); } + @Test + void shouldSendNotification_LipRespondent_Application_WhenRequestMoreInfo() { + + CaseData caseData + = caseDataForJudicialRequestForInformationOfApplication(YES, YES, YES, + REQUEST_MORE_INFORMATION) + .toBuilder() + .generalAppConsentOrder(NO) + .ccdState(CaseState.APPLICATION_ADD_PAYMENT).generalAppType(GAApplicationType.builder() + .types(applicationTypeVaryOrder()).build()).build(); + + when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) + .thenReturn(caseData); + when(caseDetailsConverter.toCaseData(any())).thenReturn(caseData); + when(gaForLipService.isLipResp(any())).thenReturn(true); + + judicialNotificationService.sendNotification(caseData, RESPONDENT); + + verify(notificationService, times(1)).sendMail( + DUMMY_EMAIL, + + "general-application-apps-judicial-notification-template-lip-id", + notificationPropertiesVaryOrder(), + "general-apps-judicial-notification-make-decision-" + CASE_REFERENCE + ); + } + + @Test + void shouldSendNotification_LipRespondent_Application_WhenRequestMoreInfo_WhenNoLIpInvolved() { + + CaseData caseData + = caseDataForJudicialRequestForInformationOfApplication(YES, YES, YES, + REQUEST_MORE_INFORMATION) + .toBuilder() + .generalAppConsentOrder(NO) + .ccdState(CaseState.APPLICATION_ADD_PAYMENT).generalAppType(GAApplicationType.builder() + .types(applicationTypeVaryOrder()).build()).build(); + + when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) + .thenReturn(caseData); + when(caseDetailsConverter.toCaseData(any())).thenReturn(caseData); + when(gaForLipService.isLipResp(any())).thenReturn(false); + + judicialNotificationService.sendNotification(caseData, RESPONDENT); + + verify(notificationService, times(1)).sendMail( + DUMMY_EMAIL, + + "general-application-apps-judicial-notification-template-id", + notificationPropertiesVaryOrder(), + "general-apps-judicial-notification-make-decision-" + CASE_REFERENCE + ); + } + @Test void notificationShouldSendListForHearing() { when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseDataListForHearing()); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseDataListForHearing(), APPLICANT); verify(notificationService).sendMail( DUMMY_EMAIL, @@ -534,10 +596,17 @@ private CaseData caseDataForJudgeDismissal(YesOrNo orderAgreement, YesOrNo isWit private Map notificationPropertiesSummeryJudgement() { customProp.put(NotificationData.CASE_REFERENCE, CASE_REFERENCE.toString()); - customProp.put(NotificationData.CASE_TITLE, "CL v DEF"); customProp.put(NotificationData.GA_APPLICATION_TYPE, GeneralApplicationTypes.SUMMARY_JUDGEMENT.getDisplayedValue()); - customProp.put(NotificationData.GA_LIP_APPLICANT_NAME, "App"); + + return customProp; + } + + private Map notificationPropertiesVaryOrder() { + + customProp.put(NotificationData.CASE_REFERENCE, CASE_REFERENCE.toString()); + customProp.put(NotificationData.GA_APPLICATION_TYPE, + GeneralApplicationTypes.VARY_ORDER.getDisplayedValue()); return customProp; } @@ -1991,7 +2060,7 @@ void shouldSendAdditionalPaymentNotification_Lip_UncloakedApplication_BeforeAddi when(solicitorEmailValidation.validateSolicitorEmail(any(), any())) .thenReturn(caseData); when(caseDetailsConverter.toCaseData(any())).thenReturn(CaseData.builder().build()); - + when(gaForLipService.isLipApp(any())).thenReturn(true); judicialNotificationService.sendNotification(caseData, APPLICANT); verify(notificationService, times(1)).sendMail( @@ -2096,9 +2165,7 @@ public Map notificationPropertiesToStayTheClaimLip() { return Map.of( NotificationData.CASE_REFERENCE, CASE_REFERENCE.toString(), NotificationData.GA_APPLICATION_TYPE, - GeneralApplicationTypes.STAY_THE_CLAIM.getDisplayedValue(), - NotificationData.GA_LIP_APPLICANT_NAME, "App", - NotificationData.CASE_TITLE, "CL v DEF" + GeneralApplicationTypes.STAY_THE_CLAIM.getDisplayedValue() ); } @@ -2140,4 +2207,10 @@ public List applicationTypeSummeryJudgement() { GeneralApplicationTypes.SUMMARY_JUDGEMENT ); } + + public List applicationTypeVaryOrder() { + return List.of( + GeneralApplicationTypes.VARY_ORDER + ); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelperTest.java index 49ec6f178..801dfb677 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/ParentCaseUpdateHelperTest.java @@ -304,17 +304,14 @@ void updateParentWithGAState_with_n245_after_payment() { @Test void updateParentWithGAState_with_n245_before_payment() { - CaseData gaCase = getGaVaryCaseData("RespondentSolTwo", PENDING_APPLICATION_ISSUED, YES); - CaseData civilCase = getVaryMainCaseData("RespondentSolTwo"); + CaseData gaCase = getGaVaryCaseDataForAddlDoc("RespondentSol", PENDING_APPLICATION_ISSUED, YES); + CaseData civilCase = getVaryMainCaseData("RespondentSol"); when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse(YES, NO)); when(caseDetailsConverter.toCaseData(any())).thenReturn(civilCase); parentCaseUpdateHelper.updateParentWithGAState(gaCase, AWAITING_APPLICATION_PAYMENT.toString()); verify(coreCaseDataService, times(1)) .caseDataContentFromStartEventResponse(any(), mapCaptor.capture()); - assertThat(mapCaptor.getValue().get("gaEvidenceDocRespondentSolTwo")).isNotNull(); - assertThat(mapCaptor.getValue().get("gaEvidenceDocStaff")).isNull(); - assertThat(mapCaptor.getValue().get("gaEvidenceDocRespondentSol")).isNull(); - assertThat(mapCaptor.getValue().get("gaEvidenceDocClaimant")).isNull(); + assertThat(mapCaptor.getValue().get("gaAddlDocRespondentSol")).isNotNull(); } @Test @@ -701,6 +698,61 @@ private CaseData getGaVaryCaseData(String role, CaseState state, YesOrNo isMulti return builder.build(); } + private CaseData getGaVaryCaseDataForAddlDoc(String role, CaseState state, YesOrNo isMultiparty) { + CaseData.CaseDataBuilder builder = CaseData.builder(); + builder.generalAppType(GAApplicationType.builder() + .types(List.of(GeneralApplicationTypes.VARY_PAYMENT_TERMS_OF_JUDGMENT)).build()) + .ccdCaseReference(CaseDataBuilder.CASE_ID) + .generalAppParentCaseLink(GeneralAppParentCaseLink + .builder().caseReference(CaseDataBuilder.CASE_ID.toString()).build()) + .ccdState(state); + CaseDocument pdfDocument = CaseDocument.builder() + .createdBy("John") + .documentName("documentName") + .documentSize(0L) + .createdDatetime(now()) + .documentLink(Document.builder() + .documentUrl("fake-url") + .documentFileName("file-name") + .documentBinaryUrl("binary-url") + .build()) + .build(); + String uid = "f000aa01-0451-4000-b000-000000000000"; + builder.gaAddlDoc(singletonList(Element.builder() + .id(UUID.fromString(uid)) + .value(pdfDocument).build())); + switch (role) { + case "Claimant": + builder.parentClaimantIsApplicant(YES) + .isMultiParty(isMultiparty) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(YES).build()); + break; + case "RespondentSol": + builder.parentClaimantIsApplicant(NO) + .isMultiParty(isMultiparty).generalAppApplnSolicitor( + GASolicitorDetailsGAspec.builder() + .organisationIdentifier("RespondentSol").build()) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(YES).build()); + break; + case "RespondentSolTwo": + builder.parentClaimantIsApplicant(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(YES).build()) + .isMultiParty(isMultiparty).generalAppApplnSolicitor( + GASolicitorDetailsGAspec.builder() + .organisationIdentifier("RespondentSolTwo").build()); + break; + case "RespondentLip": + builder.parentClaimantIsApplicant(NO) + .isGaApplicantLip(YES) + .isMultiParty(isMultiparty) + .generalAppApplnSolicitor(GASolicitorDetailsGAspec.builder().build()); + break; + default: + break; + } + return builder.build(); + } + private CaseData getGaVaryCaseDataForCollection(String role, CaseState state, YesOrNo isMultiparty, YesOrNo hasAgreed, YesOrNo isWithNotice) { CaseData.CaseDataBuilder builder = CaseData.builder();