From 2e063e3513815194ea3a504a3a624e8d4aef6b24 Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:59:58 +0000 Subject: [PATCH 1/8] CIV-16440 add application to master collection once hwf is made --- ...eralAppBusinessProcessCallbackHandler.java | 7 +- ...plyForHwFDashboardNotificationHandler.java | 29 ++++++- ...AppBusinessProcessCallbackHandlerTest.java | 52 ++++++++++++ ...orHwFDashboardNotificationHandlerTest.java | 81 +++++++++++++++++++ 4 files changed, 165 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandler.java index 6a714f180..2cc7de6ce 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandler.java @@ -157,9 +157,10 @@ private boolean isLipPaymentViaHelpWithFees(CaseData data) { return data.getCcdState().equals(AWAITING_APPLICATION_PAYMENT) && !Objects.isNull(data.getGeneralAppHelpWithFees()) && data.getGeneralAppHelpWithFees().getHelpWithFee() == YesOrNo.YES - && !Objects.isNull(data.getFeePaymentOutcomeDetails()) + && (Objects.nonNull(data.getGeneralAppPBADetails().getPaymentDetails()) + || (!Objects.isNull(data.getFeePaymentOutcomeDetails()) && (data.getFeePaymentOutcomeDetails().getHwfFullRemissionGrantedForGa() == YesOrNo.YES - || (!Objects.isNull(data.getFeePaymentOutcomeDetails().getHwfOutstandingFeePaymentDoneForGa()) - && data.getFeePaymentOutcomeDetails().getHwfOutstandingFeePaymentDoneForGa().contains("Yes"))); + || (!Objects.isNull(data.getFeePaymentOutcomeDetails().getHwfOutstandingFeePaymentDoneForGa()) + && data.getFeePaymentOutcomeDetails().getHwfOutstandingFeePaymentDoneForGa().contains("Yes"))))); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandler.java index a32f3a80e..ceb47cc98 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandler.java @@ -9,22 +9,49 @@ import uk.gov.hmcts.reform.civil.launchdarkly.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; +import uk.gov.hmcts.reform.civil.service.GaForLipService; +import uk.gov.hmcts.reform.civil.service.ParentCaseUpdateHelper; + import java.util.List; +import java.util.Objects; + import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPS_HWF_REQUESTED_APPLICANT; @Service public class ApplyForHwFDashboardNotificationHandler extends DashboardCallbackHandler { private static final List EVENTS = List.of(CaseEvent.NOTIFY_HELP_WITH_FEE); + private GaForLipService gaForLipService; + private ParentCaseUpdateHelper parentCaseUpdateHelper; public ApplyForHwFDashboardNotificationHandler(DashboardApiClient dashboardApiClient, DashboardNotificationsParamsMapper mapper, - FeatureToggleService featureToggleService) { + FeatureToggleService featureToggleService, + GaForLipService gaForLipService, + ParentCaseUpdateHelper parentCaseUpdateHelper) { super(dashboardApiClient, mapper, featureToggleService); + this.gaForLipService = gaForLipService; + this.parentCaseUpdateHelper = parentCaseUpdateHelper; } @Override protected String getScenario(CaseData caseData) { + + if (caseData.getGeneralAppPBADetails().getPaymentDetails() == null + || caseData.getGeneralAppPBADetails().getAdditionalPaymentDetails() == null) { + + /* + * GA for LIP + * When Caseworker should have access to GA to perform HelpWithFee then, + * Add GA into collections + * */ + if (gaForLipService.isGaForLip(caseData) && Objects.nonNull(caseData.getGeneralAppHelpWithFees()) + && caseData.getGeneralAppHelpWithFees().getHelpWithFee().equals(YesOrNo.YES)) { + + parentCaseUpdateHelper.updateMasterCollectionForHwf(caseData); + } + } + return SCENARIO_AAA6_GENERAL_APPS_HWF_REQUESTED_APPLICANT.getScenario(); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index 455a7f981..a776bf0f8 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -245,6 +245,58 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNull() { assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndIsRejected() { + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(NO) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()).paymentDetails( + PaymentDetails.builder().status(PaymentStatus.SUCCESS).build()).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YES).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(2)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(2); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequest() { CaseData updatedCaseDate = CaseData.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java index 971e0e572..6b2329f52 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java @@ -11,15 +11,21 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.client.DashboardApiClient; import uk.gov.hmcts.reform.civil.enums.CaseState; +import uk.gov.hmcts.reform.civil.enums.PaymentStatus; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dq.GeneralApplicationTypes; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.launchdarkly.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.PaymentDetails; +import uk.gov.hmcts.reform.civil.model.citizenui.HelpWithFees; import uk.gov.hmcts.reform.civil.model.genapplication.GAApplicationType; +import uk.gov.hmcts.reform.civil.model.genapplication.GAPbaDetails; import uk.gov.hmcts.reform.civil.sampledata.CallbackParamsBuilder; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; +import uk.gov.hmcts.reform.civil.service.GaForLipService; +import uk.gov.hmcts.reform.civil.service.ParentCaseUpdateHelper; import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams; import java.util.HashMap; @@ -42,6 +48,10 @@ public class ApplyForHwFDashboardNotificationHandlerTest extends BaseCallbackHan private DashboardNotificationsParamsMapper mapper; @Mock private FeatureToggleService featureToggleService; + @Mock + private GaForLipService gaForLipService; + @Mock + private ParentCaseUpdateHelper parentCaseUpdateHelper; @InjectMocks private ApplyForHwFDashboardNotificationHandler handler; @@ -67,10 +77,14 @@ void setup() { @Test void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked() { when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); caseData = caseData.toBuilder() .generalAppType(GAApplicationType.builder().types(List.of(GeneralApplicationTypes.VARY_ORDER)) .build()) + .generalAppPBADetails(GAPbaDetails.builder().build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).build()) .ccdState(CaseState.AWAITING_APPLICATION_PAYMENT) .isGaApplicantLip(YesOrNo.YES) .build(); @@ -93,6 +107,73 @@ void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked() { ); } + @Test + void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked_gaLipIsFalse() { + when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + when(gaForLipService.isGaForLip(any())).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + caseData = caseData.toBuilder() + .generalAppType(GAApplicationType.builder().types(List.of(GeneralApplicationTypes.VARY_ORDER)) + .build()) + .generalAppPBADetails(GAPbaDetails.builder().build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).build()) + .ccdState(CaseState.AWAITING_APPLICATION_PAYMENT) + .isGaApplicantLip(YesOrNo.YES) + .build(); + + HashMap scenarioParams = new HashMap<>(); + + when(mapper.mapCaseDataToParams(any())).thenReturn(scenarioParams); + + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId(NOTIFY_HELP_WITH_FEE.name()) + .build() + ).build(); + + handler.handle(params); + verify(dashboardApiClient).recordScenario( + caseData.getCcdCaseReference().toString(), + SCENARIO_AAA6_GENERAL_APPS_HWF_REQUESTED_APPLICANT.getScenario(), + "BEARER_TOKEN", + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } + + @Test + void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked_for_additional() { + when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + caseData = caseData.toBuilder() + .generalAppType(GAApplicationType.builder().types(List.of(GeneralApplicationTypes.VARY_ORDER)) + .build()) + .generalAppPBADetails(GAPbaDetails.builder().paymentDetails(PaymentDetails.builder().status( + PaymentStatus.SUCCESS).build()).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).build()) + .ccdState(CaseState.APPLICATION_ADD_PAYMENT) + .isGaApplicantLip(YesOrNo.YES) + .build(); + + HashMap scenarioParams = new HashMap<>(); + + when(mapper.mapCaseDataToParams(any())).thenReturn(scenarioParams); + + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId(NOTIFY_HELP_WITH_FEE.name()) + .build() + ).build(); + + handler.handle(params); + verify(dashboardApiClient).recordScenario( + caseData.getCcdCaseReference().toString(), + SCENARIO_AAA6_GENERAL_APPS_HWF_REQUESTED_APPLICANT.getScenario(), + "BEARER_TOKEN", + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } + @Test void shouldRecordApplicantScenario_ApplyForHwFAdditionalApplicationFee_whenInvoked() { when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); From 979e786d5f8517433cec21babfedf717822cca6f Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:19:06 +0000 Subject: [PATCH 2/8] CIV-16440 added more tests --- ...AppBusinessProcessCallbackHandlerTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index a776bf0f8..df4b573bb 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -297,6 +297,61 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndI assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcome() { + List feePayment = new ArrayList<>(); + feePayment.add("yes"); + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(YES) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()).build()) + .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(YES) + .hwfOutstandingFeePaymentDoneForGa(feePayment).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YES).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(3)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(3); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequest() { CaseData updatedCaseDate = CaseData.builder() From 5ad7d66e9e0971834624c1a9747f126422f2de39 Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:37:38 +0000 Subject: [PATCH 3/8] CIV-16440 added new test for sonar --- ...AppBusinessProcessCallbackHandlerTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index df4b573bb..1f0bded78 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -352,6 +352,61 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsNull() { + List feePayment = new ArrayList<>(); + feePayment.add("yes"); + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(YES) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()).build()) + .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(YES) + .build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YES).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(3)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(3); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequest() { CaseData updatedCaseDate = CaseData.builder() From 0cb6f354c0471513fec4098d24dcd9af4f0b585c Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:13:12 +0000 Subject: [PATCH 4/8] CIV-16440 added tests for sonar --- ...AppBusinessProcessCallbackHandlerTest.java | 59 ++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index 1f0bded78..fff7a997f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -368,8 +368,8 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF .ccdCaseReference(1234L) .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()).build()) - .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(YES) - .build()) + .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(NO) + .hwfOutstandingFeePaymentDoneForGa(feePayment).build()) .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YES).build()) .build(); @@ -407,6 +407,61 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsGranted() { + List feePayment = new ArrayList<>(); + feePayment.add("no"); + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(YES) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()).build()) + .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(NO) + .hwfOutstandingFeePaymentDoneForGa(feePayment).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YES).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(2)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(2); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequest() { CaseData updatedCaseDate = CaseData.builder() From 769b25fabc259b42ff44f013922da1d88778ee46 Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:24:05 +0000 Subject: [PATCH 5/8] civ-16440 corrected unit test failure --- .../EndGeneralAppBusinessProcessCallbackHandlerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index fff7a997f..e0b7bdb8f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -394,9 +394,9 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); handler.handle(getCallbackParamsGaForLipCaseData(NO)); - verify(coreCaseDataService, times(3)) + verify(coreCaseDataService, times(2)) .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); - assertThat(caseDataContent.getAllValues()).hasSize(3); + assertThat(caseDataContent.getAllValues()).hasSize(2); Map map = objectMapper .convertValue(caseDataContent.getAllValues().get(0).getData(), From 81d89bb2a712f6e39fbdeb3fee222832d1f60f4b Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:37:50 +0000 Subject: [PATCH 6/8] CIV-16440 added more tests for sonar coverage --- ...AppBusinessProcessCallbackHandlerTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index e0b7bdb8f..737623122 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -352,6 +352,60 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsNullandYes() { + List feePayment = new ArrayList<>(); + feePayment.add("yes"); + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(YES) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()) + .paymentDetails(PaymentDetails.builder().status(PaymentStatus.SUCCESS).build()).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(NO).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(2)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(2); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsNull() { List feePayment = new ArrayList<>(); From 57e120b253a888b83b06ae59bc58a6ecff3f222d Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 18:49:21 +0000 Subject: [PATCH 7/8] added test for sonar --- ...AppBusinessProcessCallbackHandlerTest.java | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java index 737623122..abe159e1e 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/businessprocess/EndGeneralAppBusinessProcessCallbackHandlerTest.java @@ -352,6 +352,62 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF assertThat(gaDetailsMasterCollection).hasSize(1); } + @Test + void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsNullandNo() { + List feePayment = new ArrayList<>(); + feePayment.add("no"); + CaseData updatedCaseDate = CaseData.builder() + .isGaApplicantLip(YES) + .isGaRespondentTwoLip(NO) + .isGaRespondentOneLip(NO) + .parentClaimantIsApplicant(YES) + .isMultiParty(NO) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder().hasAgreed(NO).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(NO).build()) + .ccdState(AWAITING_APPLICATION_PAYMENT) + .ccdCaseReference(1234L) + .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) + .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()) + .paymentDetails(PaymentDetails.builder().status(PaymentStatus.SUCCESS).build()).build()) + .feePaymentOutcomeDetails(FeePaymentOutcomeDetails.builder().hwfFullRemissionGrantedForGa(YES) + .hwfOutstandingFeePaymentDoneForGa(feePayment).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(NO).build()) + .build(); + + GeneralApplicationsDetails judgeCollection = GeneralApplicationsDetails.builder() + .build(); + GeneralApplicationsDetails claimantCollection = GeneralApplicationsDetails.builder() + .caseState("Awaiting Application Payment") + .caseLink(CaseLink.builder() + .caseReference("1234") + .build()) + .build(); + GADetailsRespondentSol respondentOneCollection = GADetailsRespondentSol.builder().build(); + + CaseData parentCaseData = CaseData.builder() + .claimantGaAppDetails(wrapElements(claimantCollection)) + .build(); + + when(coreCaseDataService.caseDataContentFromStartEventResponse(any(), anyMap())).thenCallRealMethod(); + when(gaForLipService.isGaForLip(any())).thenReturn(true); + when(caseDetailsConverter.toCaseData(getCallbackParamsGaForLipCaseData(NO).getRequest().getCaseDetails())) + .thenReturn(updatedCaseDate); + when(coreCaseDataService.startUpdate(any(), any())).thenReturn(getStartEventResponse()); + when(caseDetailsConverter.toCaseData(getStartEventResponse().getCaseDetails())).thenReturn(parentCaseData); + handler.handle(getCallbackParamsGaForLipCaseData(NO)); + verify(coreCaseDataService, times(2)) + .submitUpdate(parentCaseId.capture(), caseDataContent.capture()); + assertThat(caseDataContent.getAllValues()).hasSize(2); + + Map map = objectMapper + .convertValue(caseDataContent.getAllValues().get(0).getData(), + new TypeReference>() {}); + List gaDetailsMasterCollection = objectMapper.convertValue(map + .get("gaDetailsMasterCollection"), + new TypeReference<>(){}); + assertThat(gaDetailsMasterCollection).hasSize(1); + } + @Test void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndFeePaymentOutcomeIsNullandYes() { List feePayment = new ArrayList<>(); @@ -368,7 +424,7 @@ void shouldAddGaToJudgeCollectionPaymentThroughServiceRequestAndHwfIsNotNullAndF .ccdCaseReference(1234L) .generalAppParentCaseLink(GeneralAppParentCaseLink.builder().caseReference("0000").build()) .generalAppPBADetails(GAPbaDetails.builder().fee(Fee.builder().code("PAY").build()) - .paymentDetails(PaymentDetails.builder().status(PaymentStatus.SUCCESS).build()).build()) + .build()) .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(NO).build()) .build(); From 35d638dee4b52127d0ab1f35db00e93229b877f7 Mon Sep 17 00:00:00 2001 From: Deepthi Doppalapudi <107422736+deepthidoppalapudihmcts@users.noreply.github.com> Date: Wed, 29 Jan 2025 20:29:45 +0000 Subject: [PATCH 8/8] added test for sonar coverage --- ...orHwFDashboardNotificationHandlerTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java index 418948530..6efd64c60 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/ApplyForHwFDashboardNotificationHandlerTest.java @@ -150,6 +150,41 @@ void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked_gaLipIsFalse() { ); } + @Test + void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked_gaLipIsTrueAnndWithAdditionalDetails() { + + when(gaForLipService.isGaForLip(any())).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + caseData = caseData.toBuilder() + .generalAppType(GAApplicationType.builder().types(List.of(GeneralApplicationTypes.VARY_ORDER)) + .build()) + .generalAppPBADetails(GAPbaDetails.builder().additionalPaymentDetails(PaymentDetails.builder() + .status(PaymentStatus.SUCCESS) + .build()).build()) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.NO).build()) + .ccdState(CaseState.APPLICATION_ADD_PAYMENT) + .isGaApplicantLip(YesOrNo.YES) + .build(); + + HashMap scenarioParams = new HashMap<>(); + + when(mapper.mapCaseDataToParams(any())).thenReturn(scenarioParams); + + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData).request( + CallbackRequest.builder().eventId(NOTIFY_HELP_WITH_FEE.name()) + .build() + ).build(); + + handler.handle(params); + verify(dashboardApiClient).recordScenario( + caseData.getCcdCaseReference().toString(), + SCENARIO_AAA6_GENERAL_APPS_HWF_REQUESTED_APPLICANT.getScenario(), + "BEARER_TOKEN", + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } + @Test void shouldRecordApplicantScenario_ApplyForHwF_whenInvoked_for_additional() {