From 5b0ba65d099f102fbadfedd87341b2614d45dafd Mon Sep 17 00:00:00 2001 From: Ivan Kirsanov Date: Tue, 20 Aug 2024 13:50:45 +0200 Subject: [PATCH 1/3] RIA-9470: Add to checkPaymentConditions new condition to check if lateRemission is also present to check if it is possible to mark appeal is paid --- .../domain/handlers/HandlerUtils.java | 6 + .../presubmit/ManageFeeUpdateMidEvent.java | 7 +- .../RecordRemissionDecisionPreparer.java | 6 +- .../payment/MarkPaymentPaidPreparer.java | 11 +- .../payment/MarkPaymentPaidPreparerTest.java | 122 ++++++++++++++---- 5 files changed, 111 insertions(+), 41 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/HandlerUtils.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/HandlerUtils.java index 62db4036cd..33d4c16892 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/HandlerUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/HandlerUtils.java @@ -28,6 +28,7 @@ import uk.gov.hmcts.reform.iacaseapi.domain.entities.CaseFlagDetail; import uk.gov.hmcts.reform.iacaseapi.domain.entities.DynamicList; import uk.gov.hmcts.reform.iacaseapi.domain.entities.HearingAdjournmentDay; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.StrategicCaseFlag; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.JourneyType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo; @@ -281,4 +282,9 @@ public static boolean isCaseUsingLocationRefData(AsylumCase asylumCase) { .map(yesOrNo -> yesOrNo.equals(YES)) .orElse(false); } + + public static boolean isRemissionExists(Optional remissionType) { + return remissionType.isPresent() + && remissionType.get() != RemissionType.NO_REMISSION; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/ManageFeeUpdateMidEvent.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/ManageFeeUpdateMidEvent.java index 6eea43ca8a..0f26b1f525 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/ManageFeeUpdateMidEvent.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/ManageFeeUpdateMidEvent.java @@ -10,6 +10,7 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.APPROVED; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.PARTIALLY_APPROVED; +import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists; import java.math.BigDecimal; import java.util.Arrays; @@ -219,12 +220,6 @@ private boolean isRemissionApprovedOrPartiallyApproved(Optional remissionType) { - - return remissionType.isPresent() - && remissionType.get() != RemissionType.NO_REMISSION; - } - private boolean completedStagesHasFeeUpdateStatus( Optional> completedStages, String preRequisiteFeeUpdateStatus) { AtomicBoolean preRequisiteFeeUpdateStatusExists = new AtomicBoolean(false); diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/RecordRemissionDecisionPreparer.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/RecordRemissionDecisionPreparer.java index 22a16f9e15..9fa036f6c6 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/RecordRemissionDecisionPreparer.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/RecordRemissionDecisionPreparer.java @@ -5,6 +5,7 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.*; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption.NO_REMISSION; +import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists; import java.util.Arrays; import java.util.Optional; @@ -112,11 +113,6 @@ public PreSubmitCallbackResponse handle( return callbackResponse; } - private boolean isRemissionExists(Optional remissionType) { - - return remissionType.isPresent() && remissionType.get() != RemissionType.NO_REMISSION; - } - private boolean isRemissionExistsAip(Optional remissionOption, Optional helpWithFeesOption) { boolean isDlrmFeeRemission = featureToggler.getValue("dlrm-fee-remission-feature-flag", false); diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparer.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparer.java index b61c7be32a..d218792e21 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparer.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparer.java @@ -6,6 +6,7 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.*; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType.*; +import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists; import java.util.List; import java.util.Optional; @@ -137,12 +138,14 @@ private void checkPaymentConditions(AppealType appealType, AsylumCase asylumCase Optional eaHuPaymentType = asylumCase.read(EA_HU_APPEAL_TYPE_PAYMENT_OPTION, String.class); boolean isEaHuEuAg = List.of(EA, HU, EU, AG).contains(appealType); // old cases - if ((appealType == PA && remissionType.isEmpty() && paPaymentType.isEmpty()) - || (isEaHuEuAg && remissionType.isEmpty() - && eaHuPaymentType.isEmpty())) { + if (!isRemissionExists(remissionType) && !isRemissionExists(lateRemissionType) + && ((appealType == PA && paPaymentType.isEmpty()) || (isEaHuEuAg && eaHuPaymentType.isEmpty())) + ) { callbackResponse.addError(NOT_AVAILABLE_LABEL); } - if (isEaHuEuAg && (remissionType.isEmpty() || remissionType.get() == NO_REMISSION) + if (!isRemissionExists(remissionType) + && !isRemissionExists(lateRemissionType) + && isEaHuEuAg && eaHuPaymentType.isPresent() && eaHuPaymentType.get().equals("payNow") && paymentStatus.isPresent() && paymentStatus.get() == PaymentStatus.PAID) { callbackResponse.addError(NOT_AVAILABLE_LABEL); diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java index c0921f7207..1766e2c93e 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java @@ -2,14 +2,33 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.reset; import static org.powermock.api.mockito.PowerMockito.when; -import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.*; -import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.*; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.AG; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.EA; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.EU; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.HU; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.PA; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.APPEAL_TYPE; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.APPELLANT_IN_DETENTION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.EA_HU_APPEAL_TYPE_PAYMENT_OPTION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.HELP_WITH_FEES_OPTION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_ACCELERATED_DETAINED_APPEAL; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_ADMIN; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.LATE_REMISSION_TYPE; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PAYMENT_STATUS; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PA_APPEAL_TYPE_PAYMENT_OPTION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_DECISION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_OPTION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption.NO_REMISSION; -import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage.*; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType.HO_WAIVER_REMISSION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_START; import java.util.Optional; import java.util.stream.Stream; @@ -26,7 +45,13 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import uk.gov.hmcts.reform.iacaseapi.domain.entities.*; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback; @@ -85,7 +110,7 @@ void should_throw_error_if_payment_status_is_already_paid(AppealType appealType) when(callback.getCaseDetails().getCaseData()).thenReturn(asylumCase); when(asylumCase.read(APPEAL_TYPE, AppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); - when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(HO_WAIVER_REMISSION)); PreSubmitCallbackResponse returnedCallbackResponse = markPaymentPaidPreparer.handle(ABOUT_TO_START, callback); @@ -251,34 +276,34 @@ void handling_should_error_for_remission_decision_not_present_internal_detained_ private static Stream appealTypesWithRemissionTypes() { return Stream.of( - Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(EA, HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(HU, HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(EU, HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(PA, HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(EA, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(HU, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(EU, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(PA, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(AG, HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(AG, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE) ); @@ -333,34 +358,34 @@ void handling_should_error_for_remission_decision_approved_internal_detained_cas private static Stream appealTypesWithRemissionApproved() { return Stream.of( - Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(EA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(HU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(EU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(PA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(EA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(HU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(EU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(PA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(AG, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(AG, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE) ); @@ -419,4 +444,49 @@ void should_not_allow_null_arguments() { .isExactlyInstanceOf(NullPointerException.class); } + @ParameterizedTest + @MethodSource("appealTypesWithRemissionOptions") + void should_pass_checkRemissionConditions_if_remission_or_late_remission_present( + AppealType appealType, + Optional remissionType, + Optional lateRemission) { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(callback.getCaseDetails().getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_TYPE, AppealType.class)).thenReturn(Optional.of(appealType)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(remissionType); + when(asylumCase.read(LATE_REMISSION_TYPE, RemissionType.class)).thenReturn(lateRemission); + when(asylumCase.read(PA_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(EA_HU_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(REMISSION_DECISION, RemissionDecision.class)).thenReturn(Optional.of(RemissionDecision.REJECTED)); + + + PreSubmitCallbackResponse returnedCallbackResponse = + markPaymentPaidPreparer.handle(ABOUT_TO_START, callback); + + assertNotNull(returnedCallbackResponse); + assertThat(returnedCallbackResponse.getErrors()).isEmpty(); + } + + private static Stream appealTypesWithRemissionOptions() { + return Stream.of( + Arguments.of(EA, Optional.of(HO_WAIVER_REMISSION), Optional.empty()), + Arguments.of(EA, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(EA, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(HU, Optional.of(HO_WAIVER_REMISSION), Optional.empty()), + Arguments.of(HU, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(HU, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(EU, Optional.of(HO_WAIVER_REMISSION), Optional.empty()), + Arguments.of(EU, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(EU, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(PA, Optional.of(HO_WAIVER_REMISSION), Optional.empty()), + Arguments.of(PA, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(PA, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(AG, Optional.of(HO_WAIVER_REMISSION), Optional.empty()), + Arguments.of(AG, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)), + Arguments.of(AG, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)) + ); + } + } From 9ff342d4394df2df1ead0039a9aa7e2b79e9ab3a Mon Sep 17 00:00:00 2001 From: Ivan Kirsanov Date: Tue, 20 Aug 2024 14:00:46 +0200 Subject: [PATCH 2/3] RIA-9470: Undo test changes --- .../payment/MarkPaymentPaidPreparerTest.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java index 1766e2c93e..a4d247da45 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java @@ -276,34 +276,34 @@ void handling_should_error_for_remission_decision_not_present_internal_detained_ private static Stream appealTypesWithRemissionTypes() { return Stream.of( - Arguments.of(EA, HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(HU, HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(EU, HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(PA, HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(EA, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(HU, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(EU, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(PA, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE), - Arguments.of(AG, HO_WAIVER_REMISSION, REMISSION_TYPE), + Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, REMISSION_TYPE), - Arguments.of(AG, HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), + Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, LATE_REMISSION_TYPE) ); @@ -358,34 +358,34 @@ void handling_should_error_for_remission_decision_approved_internal_detained_cas private static Stream appealTypesWithRemissionApproved() { return Stream.of( - Arguments.of(EA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(HU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(EU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(PA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(EA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(EA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(HU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(HU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(HU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(EU, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(EU, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(EU, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(PA, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(PA, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(PA, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), - Arguments.of(AG, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), + Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, REMISSION_TYPE), - Arguments.of(AG, HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), + Arguments.of(AG, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.HELP_WITH_FEES, RemissionDecision.APPROVED, LATE_REMISSION_TYPE), Arguments.of(AG, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, LATE_REMISSION_TYPE) ); From 153c4ebb26b85c4a714c43c6e80923f7b5b2f2a1 Mon Sep 17 00:00:00 2001 From: Ivan Kirsanov Date: Tue, 20 Aug 2024 14:01:40 +0200 Subject: [PATCH 3/3] RIA-9470: Undo test changes --- .../handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java index a4d247da45..2bd55d4543 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/payment/MarkPaymentPaidPreparerTest.java @@ -110,7 +110,7 @@ void should_throw_error_if_payment_status_is_already_paid(AppealType appealType) when(callback.getCaseDetails().getCaseData()).thenReturn(asylumCase); when(asylumCase.read(APPEAL_TYPE, AppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); - when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(HO_WAIVER_REMISSION)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); PreSubmitCallbackResponse returnedCallbackResponse = markPaymentPaidPreparer.handle(ABOUT_TO_START, callback);