From 0a18e3b63381c01b49326fa25c51d53dded5bf78 Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Thu, 19 Sep 2024 16:41:18 +0100 Subject: [PATCH 1/8] added code changes and unit tests. --- .../reform/civil/callback/CaseEvent.java | 4 +- ...ionWhenFinalOrderMadeApplicantHandler.java | 35 ++++++ ...onWhenFinalOrderMadeRespondentHandler.java | 44 ++++++++ ...hboardNotificationForApplicantHandler.java | 16 ++- ...boardNotificationForRespondentHandler.java | 13 +-- .../DashboardScenarios.java | 4 +- .../hmcts/reform/civil/model/CaseData.java | 10 ++ ...henFinalOrderMadeApplicantHandlerTest.java | 86 ++++++++++++++ ...enFinalOrderMadeRespondentHandlerTest.java | 105 ++++++++++++++++++ ...dNotificationForRespondentHandlerTest.java | 8 +- .../civil/sampledata/CaseDataBuilder.java | 34 ++++++ 11 files changed, 333 insertions(+), 26 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler.java create mode 100644 src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler.java create mode 100644 src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandlerTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandlerTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java index 976dfa26a..4c5b78b4c 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/callback/CaseEvent.java @@ -100,7 +100,9 @@ public enum CaseEvent { CREATE_DASHBOARD_NOTIFICATION_FOR_GA_APPLICANT(CAMUNDA), UPDATE_GA_DASHBOARD_NOTIFICATION(CAMUNDA), CREATE_APPLICANT_DASHBOARD_NOTIFICATION_FOR_MAKE_DECISION(CAMUNDA), - CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_FOR_MAKE_DECISION(CAMUNDA); + CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_FOR_MAKE_DECISION(CAMUNDA), + CREATE_APPLICANT_DASHBOARD_NOTIFICATION_ORDER_MADE(CAMUNDA), + CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE(CAMUNDA); private final UserType userType; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler.java new file mode 100644 index 000000000..c94f6095a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler.java @@ -0,0 +1,35 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications; + +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.callback.DashboardCallbackHandler; +import uk.gov.hmcts.reform.civil.client.DashboardApiClient; +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 java.util.List; + +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT; + +@Service +public class CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler extends DashboardCallbackHandler { + + private static final List EVENTS = List.of(CaseEvent.CREATE_APPLICANT_DASHBOARD_NOTIFICATION_ORDER_MADE); + + public CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler(DashboardApiClient dashboardApiClient, + DashboardNotificationsParamsMapper mapper, + FeatureToggleService featureToggleService) { + super(dashboardApiClient, mapper, featureToggleService); + } + + @Override + public List handledEvents() { + return EVENTS; + } + + @Override + public String getScenario(CaseData caseData) { + return SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT.getScenario(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler.java new file mode 100644 index 000000000..065ee7601 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler.java @@ -0,0 +1,44 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications; + +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.callback.DashboardCallbackHandler; +import uk.gov.hmcts.reform.civil.client.DashboardApiClient; +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 java.util.List; + +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT; + +@Service +public class CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler extends DashboardCallbackHandler { + + private static final List EVENTS = List.of(CaseEvent.CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE); + + public CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler(DashboardApiClient dashboardApiClient, + DashboardNotificationsParamsMapper mapper, + FeatureToggleService featureToggleService) { + super(dashboardApiClient, mapper, featureToggleService); + } + + @Override + public List handledEvents() { + return EVENTS; + } + + @Override + public String getScenario(CaseData caseData) { + if (isWithNoticeOrConsent(caseData)) { + return SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT.getScenario(); + } + return ""; + } + + private boolean isWithNoticeOrConsent(CaseData caseData) { + return YES.equals(caseData.getGeneralAppInformOtherParty().getIsWithNotice()) + || caseData.getGeneralAppConsentOrder() == YES; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForApplicantHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForApplicantHandler.java index 01faca944..e8f440d55 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForApplicantHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForApplicantHandler.java @@ -7,15 +7,14 @@ import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.enums.dq.GAJudgeDecisionOption; import uk.gov.hmcts.reform.civil.enums.dq.GAJudgeRequestMoreInfoOption; -import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.launchdarkly.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; -import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; import java.util.List; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_APPLICANT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_REQUEST_MORE_INFO_APPLICANT; @Service @@ -23,17 +22,11 @@ public class CreateMakeDecisionDashboardNotificationForApplicantHandler extends private static final List EVENTS = List.of(CaseEvent.CREATE_APPLICANT_DASHBOARD_NOTIFICATION_FOR_MAKE_DECISION); - private final CoreCaseDataService coreCaseDataService; - private final CaseDetailsConverter caseDetailsConverter; - public CreateMakeDecisionDashboardNotificationForApplicantHandler(DashboardApiClient dashboardApiClient, DashboardNotificationsParamsMapper mapper, - CoreCaseDataService coreCaseDataService, - CaseDetailsConverter caseDetailsConverter, FeatureToggleService featureToggleService) { super(dashboardApiClient, mapper, featureToggleService); - this.coreCaseDataService = coreCaseDataService; - this.caseDetailsConverter = caseDetailsConverter; + } @Override @@ -49,7 +42,11 @@ protected String getScenario(CaseData caseData) { return SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_APPLICANT.getScenario(); + } else if (caseData.judgeHasMadeAnOrder() + && caseData.getCcdState().equals(CaseState.APPLICATION_SUBMITTED_AWAITING_JUDICIAL_DECISION)) { + return SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT.getScenario(); } + return ""; } @@ -57,4 +54,5 @@ protected String getScenario(CaseData caseData) { public List handledEvents() { return EVENTS; } + } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandler.java index b58a34d78..ca42ac10b 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandler.java @@ -8,10 +8,8 @@ import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dq.GAJudgeDecisionOption; import uk.gov.hmcts.reform.civil.enums.dq.GAJudgeRequestMoreInfoOption; -import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.launchdarkly.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; -import uk.gov.hmcts.reform.civil.service.CoreCaseDataService; import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; import java.util.List; @@ -20,6 +18,7 @@ import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_RESPONDENT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_JUDGE_UNCLOAK_RESPONDENT; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT; import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_REQUEST_MORE_INFO_RESPONDENT; @Service @@ -27,17 +26,10 @@ public class CreateMakeDecisionDashboardNotificationForRespondentHandler extends private static final List EVENTS = List.of(CaseEvent.CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_FOR_MAKE_DECISION); - private final CoreCaseDataService coreCaseDataService; - private final CaseDetailsConverter caseDetailsConverter; - public CreateMakeDecisionDashboardNotificationForRespondentHandler(DashboardApiClient dashboardApiClient, DashboardNotificationsParamsMapper mapper, - CoreCaseDataService coreCaseDataService, - CaseDetailsConverter caseDetailsConverter, FeatureToggleService featureToggleService) { super(dashboardApiClient, mapper, featureToggleService); - this.coreCaseDataService = coreCaseDataService; - this.caseDetailsConverter = caseDetailsConverter; } @Override @@ -63,6 +55,9 @@ protected String getScenario(CaseData caseData) { && caseData.getGaHearingNoticeDetail() != null) { return SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_RESPONDENT.getScenario(); + } else if (caseData.judgeHasMadeAnOrder() + && caseData.getCcdState().equals(CaseState.APPLICATION_SUBMITTED_AWAITING_JUDICIAL_DECISION)) { + return SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT.getScenario(); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java index f29e5b1d1..2af0f1d04 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/DashboardScenarios.java @@ -22,7 +22,9 @@ public enum DashboardScenarios { SCENARIO_AAA6_GENERAL_APPLICATION_SUBMITTED_APPLICANT("Scenario.AAA6.GeneralApps.ApplicationSubmitted.Applicant"), SCENARIO_AAA6_GENERAL_APPLICATION_REQUEST_MORE_INFO_RESPONDENT("Scenario.AAA6.GeneralApps.MoreInfoRequired.Respondent"), SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_APPLICANT("Scenario.AAA6.GeneralApps.HearingScheduled.Applicant"), - SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_RESPONDENT("Scenario.AAA6.GeneralApps.HearingScheduled.Respondent"); + SCENARIO_AAA6_GENERAL_APPLICATION_HEARING_SCHEDULED_RESPONDENT("Scenario.AAA6.GeneralApps.HearingScheduled.Respondent"), + SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT("Scenario.AAA6.GeneralApps.OrderMade.Applicant"), + SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT("Scenario.AAA6.GeneralApps.OrderMade.Respondent"); private final String scenario; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java index dbb7b7781..7899feabf 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java @@ -18,6 +18,7 @@ import uk.gov.hmcts.reform.civil.enums.dq.FinalOrderSelection; import uk.gov.hmcts.reform.civil.enums.dq.FinalOrderShowToggle; import uk.gov.hmcts.reform.civil.enums.dq.GAByCourtsInitiativeGAspec; +import uk.gov.hmcts.reform.civil.enums.dq.GAJudgeDecisionOption; import uk.gov.hmcts.reform.civil.enums.dq.OrderMadeOnTypes; import uk.gov.hmcts.reform.civil.enums.dq.OrderOnCourts; import uk.gov.hmcts.reform.civil.model.citizenui.HelpWithFees; @@ -74,6 +75,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import static uk.gov.hmcts.reform.civil.enums.BusinessProcessStatus.FINISHED; @@ -365,4 +367,12 @@ public boolean isUrgent() { .filter(urgency -> urgency == YES) .isPresent(); } + + @JsonIgnore + public boolean judgeHasMadeAnOrder() { + return (Objects.nonNull(this.getJudicialDecision()) + && this.getJudicialDecision().getDecision().equals(GAJudgeDecisionOption.MAKE_AN_ORDER) + || this.getJudicialDecision().getDecision().equals(GAJudgeDecisionOption.FREE_FORM_ORDER) + || this.getJudicialDecision().getDecision().equals(GAJudgeDecisionOption.LIST_FOR_A_HEARING)); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandlerTest.java new file mode 100644 index 000000000..2e7ec2060 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeApplicantHandlerTest.java @@ -0,0 +1,86 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.client.DashboardApiClient; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +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.sampledata.CallbackParamsBuilder; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; +import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams; + +import java.util.HashMap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_APPLICANT_DASHBOARD_NOTIFICATION_ORDER_MADE; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT; + +@ExtendWith(MockitoExtension.class) +class CreateDashboardNotificationWhenFinalOrderMadeApplicantHandlerTest extends BaseCallbackHandlerTest { + + @Mock + private DashboardApiClient dashboardApiClient; + @Mock + private DashboardNotificationsParamsMapper mapper; + @Mock + private FeatureToggleService featureToggleService; + @InjectMocks + private CreateDashboardNotificationWhenFinalOrderMadeApplicantHandler handler; + + @Test + void handleEventsReturnsTheExpectedCallbackEvent() { + assertThat(handler.handledEvents()).contains(CREATE_APPLICANT_DASHBOARD_NOTIFICATION_ORDER_MADE); + } + + @Test + void shouldReturnCorrectCamundaActivityId_whenInvoked() { + assertThat(handler.camundaActivityId()) + .isEqualTo("default"); + } + + @Nested + class AboutToSubmitCallback { + @BeforeEach + void setup() { + when(featureToggleService.isDashboardServiceEnabled()).thenReturn(true); + } + + @Test + void shouldRecordApplicationSubmittedScenario_whenInvoked() { + when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + caseData = caseData.toBuilder().parentCaseReference(caseData.getCcdCaseReference().toString()) + .isGaApplicantLip(YesOrNo.YES) + .parentClaimantIsApplicant(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(CREATE_APPLICANT_DASHBOARD_NOTIFICATION_ORDER_MADE.name()) + .build() + ).build(); + handler.handle(params); + verify(dashboardApiClient).recordScenario( + caseData.getCcdCaseReference().toString(), + SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_APPLICANT.getScenario(), + "BEARER_TOKEN", + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandlerTest.java new file mode 100644 index 000000000..6631fe001 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateDashboardNotificationWhenFinalOrderMadeRespondentHandlerTest.java @@ -0,0 +1,105 @@ +package uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; +import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.client.DashboardApiClient; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +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.sampledata.CallbackParamsBuilder; +import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; +import uk.gov.hmcts.reform.civil.service.DashboardNotificationsParamsMapper; +import uk.gov.hmcts.reform.dashboard.data.ScenarioRequestParams; + +import java.util.HashMap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE; +import static uk.gov.hmcts.reform.civil.handler.callback.camunda.dashboardnotifications.DashboardScenarios.SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT; + +@ExtendWith(MockitoExtension.class) +class CreateDashboardNotificationWhenFinalOrderMadeRespondentHandlerTest extends BaseCallbackHandlerTest { + + @Mock + private DashboardApiClient dashboardApiClient; + @Mock + private DashboardNotificationsParamsMapper mapper; + @Mock + private FeatureToggleService featureToggleService; + @InjectMocks + private CreateDashboardNotificationWhenFinalOrderMadeRespondentHandler handler; + + @Test + void handleEventsReturnsTheExpectedCallbackEvent() { + assertThat(handler.handledEvents()).contains(CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE); + } + + @Test + void shouldReturnCorrectCamundaActivityId_whenInvoked() { + assertThat(handler.camundaActivityId()) + .isEqualTo("default"); + } + + @Nested + class AboutToSubmitCallback { + @BeforeEach + void setup() { + when(featureToggleService.isDashboardServiceEnabled()).thenReturn(true); + } + + @Test + void shouldRecordApplicationSubmittedScenario_whenInvoked() { + when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + caseData = caseData.toBuilder().parentCaseReference(caseData.getCcdCaseReference().toString()) + .isGaApplicantLip(YesOrNo.YES) + .parentClaimantIsApplicant(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(CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE.name()) + .build() + ).build(); + handler.handle(params); + verify(dashboardApiClient).recordScenario( + caseData.getCcdCaseReference().toString(), + SCENARIO_AAA6_GENERAL_APPLICATION_ORDER_MADE_RESPONDENT.getScenario(), + "BEARER_TOKEN", + ScenarioRequestParams.builder().params(scenarioParams).build() + ); + } + + @Test + void shouldNotRecordApplicationSubmittedScenario_whenInvoked() { + when(featureToggleService.isGaForLipsEnabled()).thenReturn(true); + CaseData caseData = CaseDataBuilder.builder().withoutNoticeCaseData(); + caseData = caseData.toBuilder().parentCaseReference(caseData.getCcdCaseReference().toString()) + .isGaApplicantLip(YesOrNo.YES) + .parentClaimantIsApplicant(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(CREATE_RESPONDENT_DASHBOARD_NOTIFICATION_ORDER_MADE.name()) + .build() + ).build(); + handler.handle(params); + verifyNoInteractions(dashboardApiClient); + } + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandlerTest.java index 2b04a2b1a..96994677d 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/dashboardnotifications/CreateMakeDecisionDashboardNotificationForRespondentHandlerTest.java @@ -84,7 +84,6 @@ void shouldRecordMoreInfoRequiredRespondentScenarioWhenInvoked() { .judicialDecisionRequestMoreInfo(GAJudicialRequestMoreInfo.builder().deadlineForMoreInfoSubmission( LocalDateTime.now().plusDays(5)).build()) .ccdState(CaseState.APPLICATION_SUBMITTED_AWAITING_JUDICIAL_DECISION) - .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(YesOrNo.YES).build()) .build(); HashMap scenarioParams = new HashMap<>(); @@ -108,7 +107,7 @@ void shouldRecordMoreInfoRequiredRespondentScenarioWhenInvoked() { @Test void shouldNotRecordMoreInfoRequiredRespondentScenarioWhenAppIsWithoutNoticeInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withoutNoticeCaseData(); caseData = caseData.toBuilder() .parentCaseReference(caseData.getCcdCaseReference().toString()) .isGaApplicantLip(YesOrNo.YES) @@ -116,7 +115,6 @@ void shouldNotRecordMoreInfoRequiredRespondentScenarioWhenAppIsWithoutNoticeInvo .judicialDecisionRequestMoreInfo(GAJudicialRequestMoreInfo.builder().requestMoreInfoOption( GAJudgeRequestMoreInfoOption.REQUEST_MORE_INFORMATION).deadlineForMoreInfoSubmission( LocalDateTime.now().plusDays(5)).build()) - .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(YesOrNo.NO).build()) .build(); HashMap scenarioParams = new HashMap<>(); @@ -143,7 +141,6 @@ void shouldNotRecordMoreInfoRequiredRespondentScenarioWhenGALipsToggleIsDisableI .judicialDecisionRequestMoreInfo(GAJudicialRequestMoreInfo.builder().requestMoreInfoOption( GAJudgeRequestMoreInfoOption.REQUEST_MORE_INFORMATION).deadlineForMoreInfoSubmission( LocalDateTime.now().plusDays(5)).build()) - .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(YesOrNo.YES).build()) .build(); when(featureToggleService.isDashboardServiceEnabled()).thenReturn(true); when(featureToggleService.isGaForLipsEnabled()).thenReturn(false); @@ -159,14 +156,13 @@ void shouldNotRecordMoreInfoRequiredRespondentScenarioWhenGALipsToggleIsDisableI @Test void shouldRecordApplicationUncloakedRespondentScenarioWhenAppIsWithoutNoticeInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withNoticeCaseData(); + CaseData caseData = CaseDataBuilder.builder().atStateClaimDraft().withoutNoticeCaseData(); caseData = caseData.toBuilder() .parentCaseReference(caseData.getCcdCaseReference().toString()) .isGaApplicantLip(YesOrNo.YES) .parentClaimantIsApplicant(YesOrNo.YES) .applicationIsUncloakedOnce(YesOrNo.YES) .makeAppVisibleToRespondents(gaMakeApplicationAvailableCheck) - .generalAppInformOtherParty(GAInformOtherParty.builder().isWithNotice(YesOrNo.NO).build()) .build(); HashMap scenarioParams = new HashMap<>(); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java index 4e36cd56d..7e1fec51f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java @@ -501,6 +501,40 @@ public CaseData withNoticeCaseData() { .build(); } + public CaseData withoutNoticeCaseData() { + uk.gov.hmcts.reform.ccd.model.Organisation orgId = uk.gov.hmcts.reform.ccd.model.Organisation.builder() + .organisationID("OrgId").build(); + + return build().toBuilder() + .ccdCaseReference(1644495739087775L) + .ccdCaseReference(1644495739087775L) + .legacyCaseReference("000DC001") + .businessProcess(BusinessProcess.builder().status(BusinessProcessStatus.READY).build()) + .generalAppInformOtherParty(GAInformOtherParty.builder() + .isWithNotice(NO).build()) + .generalAppRespondentAgreement(GARespondentOrderAgreement.builder() + .hasAgreed(NO).build()) + .generalAppPBADetails( + GAPbaDetails.builder() + .paymentSuccessfulDate(LocalDateTime.of(LocalDate.of(2020, 01, 01), + LocalTime.of(12, 00, 00))) + .paymentDetails(PaymentDetails.builder() + .status(PaymentStatus.SUCCESS) + .reference("RC-1658-4258-2679-9795") + .customerReference(CUSTOMER_REFERENCE) + .build()) + .fee( + Fee.builder() + .code("FE203") + .calculatedAmountInPence(BigDecimal.valueOf(27500)) + .version("1") + .build()) + .serviceReqReference(CUSTOMER_REFERENCE).build()) + .applicant1OrganisationPolicy(OrganisationPolicy.builder().organisation(orgId).build()) + .generalAppApplnSolicitor(GASolicitorDetailsGAspec.builder().organisationIdentifier("OrgId").build()) + .build(); + } + public CaseData buildPaymentSuccessfulCaseData() { uk.gov.hmcts.reform.ccd.model.Organisation orgId = uk.gov.hmcts.reform.ccd.model.Organisation.builder() .organisationID("OrgId").build(); From b0f9414fd61c0355b9a05354438a8ae665d2fd5d Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Mon, 18 Nov 2024 16:48:22 +0000 Subject: [PATCH 2/8] added a fix. --- .../applicationdraft/GeneralApplicationDraftGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/applicationdraft/GeneralApplicationDraftGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/applicationdraft/GeneralApplicationDraftGenerator.java index c8840e6b8..54694a2be 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/applicationdraft/GeneralApplicationDraftGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/applicationdraft/GeneralApplicationDraftGenerator.java @@ -100,8 +100,8 @@ public GADraftForm getTemplateData(CaseData caseData) { .getHearingDetailsEmailID()) .unavailableTrialRequiredYesOrNo(caseData.getGeneralAppHearingDetails() .getUnavailableTrialRequiredYesOrNo()) - .unavailableTrialDateTo(getAppUnavailabilityDate(caseData, YesOrNo.YES)) - .unavailableTrialDateFrom(getAppUnavailabilityDate(caseData, YesOrNo.NO)) + .unavailableTrialDateTo(getAppUnavailabilityDate(caseData, YesOrNo.NO)) + .unavailableTrialDateFrom(getAppUnavailabilityDate(caseData, YesOrNo.YES)) .vulnerabilityQuestionsYesOrNo(caseData.getGeneralAppHearingDetails().getVulnerabilityQuestionsYesOrNo()) .supportRequirement(getGaSupportRequirement(caseData)) .supportRequirementSignLanguage(caseData.getGeneralAppHearingDetails().getSupportRequirementSignLanguage()) From ca889f8ec752240842e1b24be437d6d32840797f Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Wed, 22 Jan 2025 10:47:31 +0000 Subject: [PATCH 3/8] added a fix. --- .../callback/user/FeePaymentOutcomeHWFCallBackHandler.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java index c2ff9bbd7..629d0457a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java @@ -154,7 +154,8 @@ private CallbackResponse submitFeePaymentOutcome(CallbackParams callbackParams) .fee(caseData.getGeneralAppPBADetails().getFee()) .hwfReferenceNumber(caseData .getGeneralAppHelpWithFees() - .getHelpWithFeesReferenceNumber()).build()) + .getHelpWithFeesReferenceNumber()) + .outstandingFeeInPounds(BigDecimal.ZERO).build()) .businessProcess(BusinessProcess.ready(caseEvent)).build(); } else if (processedCaseData.isHWFTypeAdditional()) { caseData = processedCaseData.toBuilder() @@ -162,7 +163,8 @@ private CallbackResponse submitFeePaymentOutcome(CallbackParams callbackParams) .fee(caseData.getGeneralAppPBADetails().getFee()) .hwfReferenceNumber(caseData .getGeneralAppHelpWithFees() - .getHelpWithFeesReferenceNumber()).build()) + .getHelpWithFeesReferenceNumber()) + .outstandingFeeInPounds(BigDecimal.ZERO).build()) .businessProcess(BusinessProcess.ready(UPDATE_GA_ADD_HWF)) .build(); log.info("Start business process UPDATE_GA_ADD_HWF for caseId: {}", callbackParams.getCaseData().getCcdCaseReference()); From b9f8446dbef317ef8ec3df323fd87cb1f85589e7 Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Wed, 22 Jan 2025 17:07:57 +0000 Subject: [PATCH 4/8] fixed the filed name and bug. --- .../FeePaymentOutcomeHWFCallBackHandler.java | 12 +++++----- .../user/FullRemissionHWFCallbackHandler.java | 11 +++++----- .../genapplication/HelpWithFeesDetails.java | 2 +- .../DashboardNotificationsParamsMapper.java | 6 +++-- .../civil/service/HwfNotificationService.java | 12 ++++++---- .../reform/civil/utils/HwFFeeTypeService.java | 4 ++-- ...ePaymentOutcomeHWFCallBackHandlerTest.java | 4 ++-- ...ashboardNotificationsParamsMapperTest.java | 8 +++---- .../service/HwfNotificationServiceTest.java | 22 +++++++++---------- 9 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java index 629d0457a..5304034b0 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java @@ -107,13 +107,13 @@ private CallbackResponse validateSelectedRemissionType(CallbackParams callbackPa if ((caseData.isHWFTypeApplication() && caseData.getFeePaymentOutcomeDetails().getHwfFullRemissionGrantedForGa() == YesOrNo.YES && Objects.nonNull(caseData.getGaHwfDetails()) - && Objects.nonNull(caseData.getGaHwfDetails().getOutstandingFeeInPounds()) - && !Objects.equals(caseData.getGaHwfDetails().getOutstandingFeeInPounds(), BigDecimal.ZERO)) + && Objects.nonNull(caseData.getGaHwfDetails().getOutstandingFee()) + && !Objects.equals(caseData.getGaHwfDetails().getOutstandingFee(), BigDecimal.ZERO)) || (caseData.isHWFTypeAdditional() && caseData.getFeePaymentOutcomeDetails().getHwfFullRemissionGrantedForAdditionalFee() == YesOrNo.YES && Objects.nonNull(caseData.getAdditionalHwfDetails()) - && Objects.nonNull(caseData.getAdditionalHwfDetails().getOutstandingFeeInPounds()) - && !Objects.equals(caseData.getAdditionalHwfDetails().getOutstandingFeeInPounds(), BigDecimal.ZERO))) { + && Objects.nonNull(caseData.getAdditionalHwfDetails().getOutstandingFee()) + && !Objects.equals(caseData.getAdditionalHwfDetails().getOutstandingFee(), BigDecimal.ZERO))) { errors.add(WRONG_REMISSION_TYPE_SELECTED); } return AboutToStartOrSubmitCallbackResponse.builder() @@ -155,7 +155,7 @@ private CallbackResponse submitFeePaymentOutcome(CallbackParams callbackParams) .hwfReferenceNumber(caseData .getGeneralAppHelpWithFees() .getHelpWithFeesReferenceNumber()) - .outstandingFeeInPounds(BigDecimal.ZERO).build()) + .outstandingFee(BigDecimal.ZERO).build()) .businessProcess(BusinessProcess.ready(caseEvent)).build(); } else if (processedCaseData.isHWFTypeAdditional()) { caseData = processedCaseData.toBuilder() @@ -164,7 +164,7 @@ private CallbackResponse submitFeePaymentOutcome(CallbackParams callbackParams) .hwfReferenceNumber(caseData .getGeneralAppHelpWithFees() .getHelpWithFeesReferenceNumber()) - .outstandingFeeInPounds(BigDecimal.ZERO).build()) + .outstandingFee(BigDecimal.ZERO).build()) .businessProcess(BusinessProcess.ready(UPDATE_GA_ADD_HWF)) .build(); log.info("Start business process UPDATE_GA_ADD_HWF for caseId: {}", callbackParams.getCaseData().getCcdCaseReference()); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FullRemissionHWFCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FullRemissionHWFCallbackHandler.java index cddfd1785..757e1c832 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FullRemissionHWFCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FullRemissionHWFCallbackHandler.java @@ -61,14 +61,14 @@ private CallbackResponse fullRemissionHWF(CallbackParams callbackParams) { .ifPresentOrElse( gaHwfDetails -> updatedData.gaHwfDetails( gaHwfDetails.toBuilder().remissionAmount(feeAmount) - .outstandingFeeInPounds(BigDecimal.ZERO) + .outstandingFee(BigDecimal.ZERO) .hwfFeeType(FeeType.APPLICATION) .hwfCaseEvent(FULL_REMISSION_HWF_GA) .build() ), () -> updatedData.gaHwfDetails( HelpWithFeesDetails.builder().remissionAmount(feeAmount) - .outstandingFeeInPounds(BigDecimal.ZERO) + .outstandingFee(BigDecimal.ZERO) .hwfFeeType(FeeType.APPLICATION) .hwfCaseEvent(FULL_REMISSION_HWF_GA) .build() @@ -79,15 +79,16 @@ private CallbackResponse fullRemissionHWF(CallbackParams callbackParams) { log.info("HWF fee type is additional for caseId: {}", callbackParams.getCaseData().getCcdCaseReference()); Optional.ofNullable(caseData.getAdditionalHwfDetails()) .ifPresentOrElse( - hearingHwfDetails -> updatedData.additionalHwfDetails( - HelpWithFeesDetails.builder().remissionAmount(feeAmount) - .outstandingFeeInPounds(BigDecimal.ZERO) + additionalHwfDetails -> updatedData.additionalHwfDetails( + additionalHwfDetails.toBuilder().remissionAmount(feeAmount) + .outstandingFee(BigDecimal.ZERO) .hwfCaseEvent(FULL_REMISSION_HWF_GA) .hwfFeeType(FeeType.ADDITIONAL) .build() ), () -> updatedData.additionalHwfDetails( HelpWithFeesDetails.builder().remissionAmount(feeAmount) + .outstandingFee(BigDecimal.ZERO) .hwfCaseEvent(FULL_REMISSION_HWF_GA) .hwfFeeType(FeeType.ADDITIONAL) .build() diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/genapplication/HelpWithFeesDetails.java b/src/main/java/uk/gov/hmcts/reform/civil/model/genapplication/HelpWithFeesDetails.java index 579ff90fb..8382d3e40 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/genapplication/HelpWithFeesDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/genapplication/HelpWithFeesDetails.java @@ -22,7 +22,7 @@ public class HelpWithFeesDetails { @JsonFormat(shape = JsonFormat.Shape.STRING) private BigDecimal remissionAmount; @JsonFormat(shape = JsonFormat.Shape.STRING) - private BigDecimal outstandingFeeInPounds; + private BigDecimal outstandingFee; private String noRemissionDetails; private NoRemissionDetailsSummary noRemissionDetailsSummary; private String hwfReferenceNumber; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapper.java b/src/main/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapper.java index d47107c7d..dc62b58f8 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapper.java @@ -59,14 +59,16 @@ public HashMap mapCaseDataToParams(CaseData caseData) { if (caseData.getGaHwfDetails() != null && (caseData.getHwfFeeType() != null && FeeType.APPLICATION == caseData.getHwfFeeType())) { if (caseData.getGaHwfDetails().getHwfCaseEvent().equals(CaseEvent.PARTIAL_REMISSION_HWF_GA)) { params.put("remissionAmount", "£" + MonetaryConversions.penniesToPounds(caseData.getGaHwfDetails().getRemissionAmount())); - params.put("outstandingFeeInPounds", "£" + caseData.getGaHwfDetails().getOutstandingFeeInPounds()); + params.put("outstandingFeeInPounds", "£" + MonetaryConversions + .penniesToPounds(caseData.getGaHwfDetails().getOutstandingFee())); } } else if (caseData.getAdditionalHwfDetails() != null && (caseData.getHwfFeeType() != null && FeeType.ADDITIONAL == caseData.getHwfFeeType())) { if (caseData.getAdditionalHwfDetails().getHwfCaseEvent().equals(CaseEvent.PARTIAL_REMISSION_HWF_GA)) { params.put("remissionAmount", "£" + MonetaryConversions.penniesToPounds(caseData.getAdditionalHwfDetails() .getRemissionAmount())); - params.put("outstandingFeeInPounds", "£" + caseData.getAdditionalHwfDetails().getOutstandingFeeInPounds()); + params.put("outstandingFeeInPounds", "£" + MonetaryConversions + .penniesToPounds(caseData.getAdditionalHwfDetails().getOutstandingFee())); } } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/HwfNotificationService.java b/src/main/java/uk/gov/hmcts/reform/civil/service/HwfNotificationService.java index f40f8d4c1..0ab9f0f82 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/HwfNotificationService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/HwfNotificationService.java @@ -97,11 +97,13 @@ private Map getPartialRemissionProperties(CaseData caseData) { if (caseData.isHWFTypeApplication()) { remission = MonetaryConversions .penniesToPounds(HwFFeeTypeService.getGaRemissionAmount(caseData)); - outstanding = caseData.getGaHwfDetails().getOutstandingFeeInPounds(); + outstanding = MonetaryConversions + .penniesToPounds(caseData.getGaHwfDetails().getOutstandingFee()); } else { remission = MonetaryConversions .penniesToPounds(HwFFeeTypeService.getAdditionalRemissionAmount(caseData)); - outstanding = caseData.getAdditionalHwfDetails().getOutstandingFeeInPounds(); + outstanding = MonetaryConversions + .penniesToPounds(caseData.getAdditionalHwfDetails().getOutstandingFee()); } return Map.of( PART_AMOUNT, remission.toString(), @@ -125,10 +127,12 @@ private Map getNoRemissionProperties(CaseData caseData) { BigDecimal outstanding; if (caseData.isHWFTypeApplication()) { remission = caseData.getGaHwfDetails().getNoRemissionDetailsSummary().getLabel(); - outstanding = caseData.getGaHwfDetails().getOutstandingFeeInPounds(); + outstanding = MonetaryConversions + .penniesToPounds(caseData.getGaHwfDetails().getOutstandingFee()); } else { remission = caseData.getAdditionalHwfDetails().getNoRemissionDetailsSummary().getLabel(); - outstanding = caseData.getAdditionalHwfDetails().getOutstandingFeeInPounds(); + outstanding = MonetaryConversions + .penniesToPounds(caseData.getAdditionalHwfDetails().getOutstandingFee()); } return Map.of( FEE_AMOUNT, outstanding.toString(), diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/HwFFeeTypeService.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/HwFFeeTypeService.java index 197f17452..a25342400 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/HwFFeeTypeService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/HwFFeeTypeService.java @@ -87,7 +87,7 @@ public static CaseData updateOutstandingFee(CaseData caseData, String caseEventI updatedData.gaHwfDetails( caseData.getGaHwfDetails().toBuilder() .remissionAmount(gaRemissionAmount) - .outstandingFeeInPounds(MonetaryConversions.penniesToPounds(outstandingFeeAmount)) + .outstandingFee(outstandingFeeAmount) .build() ); } else if (caseData.isHWFTypeAdditional() && BigDecimal.ZERO.compareTo(feeAmount) != 0) { @@ -95,7 +95,7 @@ public static CaseData updateOutstandingFee(CaseData caseData, String caseEventI updatedData.additionalHwfDetails( caseData.getAdditionalHwfDetails().toBuilder() .remissionAmount(hearingRemissionAmount) - .outstandingFeeInPounds(MonetaryConversions.penniesToPounds(outstandingFeeAmount)) + .outstandingFee(outstandingFeeAmount) .build() ); } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java index dffdf5eaa..c184aec16 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java @@ -170,7 +170,7 @@ void shouldValidationFeePaymentOutcomeGa_withInvalidOutstandingFee() { .hwfFullRemissionGrantedForGa(YesOrNo.YES).build()) .hwfFeeType(FeeType.APPLICATION) .gaHwfDetails(HelpWithFeesDetails.builder() - .outstandingFeeInPounds(BigDecimal.valueOf(100.00)) + .outstandingFee(BigDecimal.valueOf(100.00)) .build()) .build(); //When @@ -189,7 +189,7 @@ void shouldValidationFeePaymentOutcomeAdditional_withInvalidOutstandingFee() { .hwfFullRemissionGrantedForAdditionalFee(YesOrNo.YES).build()) .hwfFeeType(FeeType.ADDITIONAL) .additionalHwfDetails(HelpWithFeesDetails.builder() - .outstandingFeeInPounds(BigDecimal.valueOf(100.00)) + .outstandingFee(BigDecimal.valueOf(100.00)) .build()) .build(); //When diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java index 360c5a801..15a7fe0ca 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java @@ -180,7 +180,7 @@ void shouldMapParametersWhenHwfApplicationFeeIsRequestedAndMoreInfoRequired() { .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).helpWithFeesReferenceNumber("HWF-A1B-23C").build()) .gaHwfDetails(HelpWithFeesDetails.builder().hwfCaseEvent(CaseEvent.MORE_INFORMATION_HWF_GA) .remissionAmount(BigDecimal.valueOf(7500)) - .outstandingFeeInPounds(new BigDecimal(200.00)).build()) + .outstandingFee(new BigDecimal(200.00)).build()) .build(); Map result = mapper.mapCaseDataToParams(caseData); @@ -202,7 +202,7 @@ void shouldMapParametersWhenHwfAdditionalApplicationFeeIsRequestedAndMoreInfoReq .additionalHwfDetails(HelpWithFeesDetails.builder() .hwfCaseEvent(CaseEvent.MORE_INFORMATION_HWF_GA) .remissionAmount(BigDecimal.valueOf(7500)) - .outstandingFeeInPounds(new BigDecimal(200.00)).build()) + .outstandingFee(new BigDecimal(200.00)).build()) .build(); Map result = mapper.mapCaseDataToParams(caseData); @@ -223,7 +223,7 @@ void shouldMapParametersWhenHwfApplicationFeeIsRequestedAndIsPartAdmitted_PartRe .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).helpWithFeesReferenceNumber("HWF-A1B-23C").build()) .gaHwfDetails(HelpWithFeesDetails.builder().hwfCaseEvent(CaseEvent.PARTIAL_REMISSION_HWF_GA) .remissionAmount(BigDecimal.valueOf(7500)) - .outstandingFeeInPounds(new BigDecimal(200.00)).build()) + .outstandingFee(new BigDecimal(200.00)).build()) .build(); Map result = mapper.mapCaseDataToParams(caseData); @@ -246,7 +246,7 @@ void shouldMapParametersWhenHwfAdditionalApplicationFeeIsRequestedAndIsPartAdmit .generalAppHelpWithFees(HelpWithFees.builder().helpWithFee(YesOrNo.YES).helpWithFeesReferenceNumber("HWF-A1B-23C").build()) .additionalHwfDetails(HelpWithFeesDetails.builder() .hwfCaseEvent(CaseEvent.PARTIAL_REMISSION_HWF_GA).remissionAmount(BigDecimal.valueOf(7500)) - .outstandingFeeInPounds(new BigDecimal(200.00)).build()) + .outstandingFee(new BigDecimal(200.00)).build()) .build(); Map result = mapper.mapCaseDataToParams(caseData); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java index d391ddb22..14dedeac8 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java @@ -562,7 +562,7 @@ void shouldNotifyApplicant_HwfOutcome_PartialRemission_Ga() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(PARTIAL_REMISSION_HWF_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder().gaHwfDetails(hwfeeDetails) @@ -588,7 +588,7 @@ void shouldNotifyApplicant_HwfOutcome_PartialRemission_Ga_Bilingual() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(PARTIAL_REMISSION_HWF_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder() @@ -614,7 +614,7 @@ void shouldNotifyApplicant_HwfOutcome_PartialRemission_Additional() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(PARTIAL_REMISSION_HWF_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = ADDITIONAL_CASE_DATA.toBuilder().additionalHwfDetails(hwfeeDetails) @@ -640,7 +640,7 @@ void shouldNotifyApplicant_HwfOutcome_PartialRemission_Additional_Bilingual_Def( HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(PARTIAL_REMISSION_HWF_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = ADDITIONAL_CASE_DATA.toBuilder() @@ -668,7 +668,7 @@ void shouldNotifyApplicant_HwfNoRemission_ClaimIssued() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(NO_REMISSION_HWF_GA) .noRemissionDetailsSummary(NoRemissionDetailsSummary.INCORRECT_EVIDENCE) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder().gaHwfDetails(hwfeeDetails) .parentCaseReference(GA_REFERENCE).build(); @@ -692,7 +692,7 @@ void shouldNotifyApplicant_HwfNoRemission_ClaimIssued_Bilingual() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(NO_REMISSION_HWF_GA) .noRemissionDetailsSummary(NoRemissionDetailsSummary.INCORRECT_EVIDENCE) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder() .parentCaseReference(GA_REFERENCE).applicantBilingualLanguagePreference(YesOrNo.YES) @@ -716,7 +716,7 @@ void shouldNotifyApplicant_HwfNoRemission_AdditionalFee() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(NO_REMISSION_HWF_GA) .noRemissionDetailsSummary(NoRemissionDetailsSummary.INCORRECT_EVIDENCE) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = ADDITIONAL_CASE_DATA.toBuilder().additionalHwfDetails(hwfeeDetails) .parentCaseReference(GA_REFERENCE).build(); @@ -740,7 +740,7 @@ void shouldNotifyApplicant_HwfNoRemission_AdditionalFee_Bilingual_Def() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(NO_REMISSION_HWF_GA) .noRemissionDetailsSummary(NoRemissionDetailsSummary.INCORRECT_EVIDENCE) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = ADDITIONAL_CASE_DATA.toBuilder() .parentCaseReference(GA_REFERENCE) @@ -816,7 +816,7 @@ void shouldNotifyApplicant_HwfOutcome_PaymentOut_Ga() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(FEE_PAYMENT_OUTCOME_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder().gaHwfDetails(hwfeeDetails) @@ -842,7 +842,7 @@ void shouldNotifyApplicant_HwfOutcome_PaymentOut_Ga_inWelsh() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(FEE_PAYMENT_OUTCOME_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = GA_CASE_DATA.toBuilder().gaHwfDetails(hwfeeDetails) @@ -870,7 +870,7 @@ void shouldNotifyApplicant_HwfOutcome_PaymentOut_Additional() { HelpWithFeesDetails hwfeeDetails = HelpWithFeesDetails.builder() .hwfCaseEvent(FEE_PAYMENT_OUTCOME_GA) .remissionAmount(new BigDecimal(REMISSION_AMOUNT)) - .outstandingFeeInPounds(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) + .outstandingFee(new BigDecimal(OUTSTANDING_AMOUNT_IN_POUNDS)) .build(); CaseData caseData = ADDITIONAL_CASE_DATA.toBuilder().additionalHwfDetails(hwfeeDetails) From 0bd61d09c65948d89f929639657444f63281a693 Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Wed, 22 Jan 2025 17:18:10 +0000 Subject: [PATCH 5/8] fixed test. --- .../civil/service/DashboardNotificationsParamsMapperTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java index 15a7fe0ca..82e12a3e8 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/DashboardNotificationsParamsMapperTest.java @@ -231,7 +231,7 @@ void shouldMapParametersWhenHwfApplicationFeeIsRequestedAndIsPartAdmitted_PartRe assertThat(result).extracting("applicationFeeTypeEn").isEqualTo("application"); assertThat(result).extracting("applicationFeeTypeCy").isEqualTo("cais"); assertThat(result).extracting("remissionAmount").isEqualTo("£75.00"); - assertThat(result).extracting("outstandingFeeInPounds").isEqualTo("£200"); + assertThat(result).extracting("outstandingFeeInPounds").isEqualTo("£2.00"); } @Test @@ -254,7 +254,7 @@ void shouldMapParametersWhenHwfAdditionalApplicationFeeIsRequestedAndIsPartAdmit assertThat(result).extracting("applicationFeeTypeEn").isEqualTo("additional application"); assertThat(result).extracting("applicationFeeTypeCy").isEqualTo("ffi ychwanegol i wneud cais"); assertThat(result).extracting("remissionAmount").isEqualTo("£75.00"); - assertThat(result).extracting("outstandingFeeInPounds").isEqualTo("£200"); + assertThat(result).extracting("outstandingFeeInPounds").isEqualTo("£2.00"); } @Test From 2546b48eed3e4c43194289894aa54cb1d7706bf2 Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Wed, 22 Jan 2025 17:41:19 +0000 Subject: [PATCH 6/8] fixed test. --- .../reform/civil/service/HwfNotificationServiceTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java index 14dedeac8..d3e04e83a 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/service/HwfNotificationServiceTest.java @@ -767,7 +767,7 @@ private Map getNotificationDataMapNoRemissionApplication() { TYPE_OF_FEE, FeeType.APPLICATION.getLabel(), TYPE_OF_FEE_WELSH, FeeType.APPLICATION.getLabelInWelsh(), HWF_REFERENCE_NUMBER, HWF_REFERENCE, - FEE_AMOUNT, OUTSTANDING_AMOUNT_IN_POUNDS, + FEE_AMOUNT, "5.00", NO_REMISSION_REASONS, NoRemissionDetailsSummary.INCORRECT_EVIDENCE.getLabel(), NO_REMISSION_REASONS_WELSH, NoRemissionDetailsSummary.INCORRECT_EVIDENCE.getLabelWelsh() ); @@ -780,7 +780,7 @@ private Map getNotificationDataMapNoRemissionAdditional() { TYPE_OF_FEE, FeeType.ADDITIONAL.getLabel(), TYPE_OF_FEE_WELSH, FeeType.ADDITIONAL.getLabelInWelsh(), HWF_REFERENCE_NUMBER, HWF_REFERENCE, - FEE_AMOUNT, OUTSTANDING_AMOUNT_IN_POUNDS, + FEE_AMOUNT, "5.00", NO_REMISSION_REASONS, NoRemissionDetailsSummary.INCORRECT_EVIDENCE.getLabel(), NO_REMISSION_REASONS_WELSH, NoRemissionDetailsSummary.INCORRECT_EVIDENCE.getLabelWelsh() ); @@ -794,7 +794,7 @@ private Map getNotificationDataMapPartialRemissionGa() { TYPE_OF_FEE_WELSH, FeeType.APPLICATION.getLabelInWelsh(), HWF_REFERENCE_NUMBER, HWF_REFERENCE, PART_AMOUNT, "1000.00", - REMAINING_AMOUNT, OUTSTANDING_AMOUNT_IN_POUNDS + REMAINING_AMOUNT, "5.00" ); } @@ -806,7 +806,7 @@ private Map getNotificationDataMapPartialRemissionAdditional() { TYPE_OF_FEE_WELSH, FeeType.ADDITIONAL.getLabelInWelsh(), HWF_REFERENCE_NUMBER, HWF_REFERENCE, PART_AMOUNT, "1000.00", - REMAINING_AMOUNT, OUTSTANDING_AMOUNT_IN_POUNDS + REMAINING_AMOUNT, "5.00" ); } From 5c003ffed4e0026acc0451762473871265f208c3 Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Thu, 23 Jan 2025 13:00:16 +0000 Subject: [PATCH 7/8] refactored setData method. --- .../FeePaymentOutcomeHWFCallBackHandler.java | 29 +++---------------- ...ePaymentOutcomeHWFCallBackHandlerTest.java | 6 +++- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java index 5304034b0..2ea7eeae8 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java @@ -68,31 +68,10 @@ private CallbackResponse setData(CallbackParams callbackParams) { CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); FeePaymentOutcomeDetails.FeePaymentOutcomeDetailsBuilder feeDetailBuilder = FeePaymentOutcomeDetails.builder(); feeDetailBuilder.hwfNumberAvailable(YesOrNo.NO); - if (caseData.getCcdState().equals(CaseState.APPLICATION_ADD_PAYMENT)) { - caseDataBuilder.hwfFeeType(FeeType.ADDITIONAL); - if (Objects.isNull(caseData.getAdditionalHwfDetails())) { - caseDataBuilder.additionalHwfDetails(HelpWithFeesDetails.builder() - .hwfFeeType(FeeType.ADDITIONAL).build()); - } - if (Objects.nonNull(caseData.getGaAdditionalHelpWithFees()) - && Objects.nonNull(caseData.getGaAdditionalHelpWithFees().getHelpWithFeesReferenceNumber())) { - feeDetailBuilder.hwfNumberAvailable(YesOrNo.YES) - .hwfNumberForFeePaymentOutcome(caseData.getGaAdditionalHelpWithFees() - .getHelpWithFeesReferenceNumber()); - } - } else { - caseDataBuilder.hwfFeeType(FeeType.APPLICATION); - if (Objects.isNull(caseData.getGaHwfDetails())) { - caseDataBuilder.gaHwfDetails(HelpWithFeesDetails.builder() - .hwfFeeType(FeeType.APPLICATION).build()); - - } - if (Objects.nonNull(caseData.getGeneralAppHelpWithFees()) - && Objects.nonNull(caseData.getGeneralAppHelpWithFees().getHelpWithFeesReferenceNumber())) { - feeDetailBuilder.hwfNumberAvailable(YesOrNo.YES) - .hwfNumberForFeePaymentOutcome(caseData.getGeneralAppHelpWithFees() - .getHelpWithFeesReferenceNumber()); - } + if (Objects.nonNull(caseData.getGeneralAppHelpWithFees()) + && Objects.nonNull(caseData.getGeneralAppHelpWithFees().getHelpWithFeesReferenceNumber())) { + feeDetailBuilder.hwfNumberAvailable(YesOrNo.YES) + .hwfNumberForFeePaymentOutcome(caseData.getGeneralAppHelpWithFees().getHelpWithFeesReferenceNumber()); } caseDataBuilder.feePaymentOutcomeDetails(feeDetailBuilder.build()); return AboutToStartOrSubmitCallbackResponse.builder() diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java index c184aec16..52b4a789b 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandlerTest.java @@ -83,6 +83,7 @@ void updateFeeType_shouldSetAdditionalFeeTypeWithEmptyRef_whenCaseStateIsApplica CaseData caseData = CaseData.builder() .ccdState(CaseState.APPLICATION_ADD_PAYMENT) .generalAppHelpWithFees(HelpWithFees.builder().build()) + .hwfFeeType(FeeType.ADDITIONAL) .generalAppPBADetails(GAPbaDetails.builder().fee( Fee.builder() .calculatedAmountInPence(BigDecimal.valueOf(180)) @@ -103,7 +104,8 @@ void updateFeeType_shouldSetAdditionalFeeTypeWithRef_whenCaseStateIsApplicationA // Arrange CaseData caseData = CaseData.builder() .ccdState(CaseState.APPLICATION_ADD_PAYMENT) - .gaAdditionalHelpWithFees(HelpWithFees.builder().helpWithFeesReferenceNumber("123").build()) + .hwfFeeType(FeeType.ADDITIONAL) + .generalAppHelpWithFees(HelpWithFees.builder().helpWithFeesReferenceNumber("123").build()) .build(); // Act @@ -121,6 +123,7 @@ void updateFeeType_shouldSetApplicationFeeTypeWithEmptyRef_whenCaseStateIsNotApp // Arrange CaseData caseData = CaseData.builder() .ccdState(CaseState.AWAITING_RESPONDENT_RESPONSE) + .hwfFeeType(FeeType.APPLICATION) .generalAppHelpWithFees(HelpWithFees.builder().build()) .generalAppPBADetails(GAPbaDetails.builder().fee( Fee.builder() @@ -143,6 +146,7 @@ void updateFeeType_shouldSetApplicationFeeTypeWithRef_whenCaseStateIsNotApplicat // Arrange CaseData caseData = CaseData.builder() .ccdState(CaseState.AWAITING_RESPONDENT_RESPONSE) + .hwfFeeType(FeeType.APPLICATION) .generalAppHelpWithFees(HelpWithFees.builder().helpWithFeesReferenceNumber("123").build()) .build(); From 1f0bc37402889413c6e054cde859145956fe3ccc Mon Sep 17 00:00:00 2001 From: neeta-hmcts Date: Thu, 23 Jan 2025 13:06:04 +0000 Subject: [PATCH 8/8] removed unused import. --- .../callback/user/FeePaymentOutcomeHWFCallBackHandler.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java index 2ea7eeae8..4c89f3c1d 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/FeePaymentOutcomeHWFCallBackHandler.java @@ -13,15 +13,12 @@ import uk.gov.hmcts.reform.civil.callback.Callback; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; -import uk.gov.hmcts.reform.civil.enums.CaseState; -import uk.gov.hmcts.reform.civil.enums.FeeType; import uk.gov.hmcts.reform.civil.enums.YesOrNo; import uk.gov.hmcts.reform.civil.enums.dq.GeneralApplicationTypes; import uk.gov.hmcts.reform.civil.launchdarkly.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.genapplication.FeePaymentOutcomeDetails; -import uk.gov.hmcts.reform.civil.model.genapplication.HelpWithFeesDetails; import uk.gov.hmcts.reform.civil.service.HwfNotificationService; import uk.gov.hmcts.reform.civil.service.PaymentRequestUpdateCallbackService; import uk.gov.hmcts.reform.civil.utils.HwFFeeTypeService;