From fa9571fce620d4ae0bd4ac9eb0ed9fdac9026f2e Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Fri, 12 Jul 2024 14:35:54 +0100 Subject: [PATCH 01/11] DIAC-497 Reset service request data fields when journey type changes --- .../presubmit/AipToLegalRepJourneyHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java index 3469790a52..2cf8e6666e 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java @@ -4,6 +4,7 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PREV_JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PRE_CLARIFYING_STATE; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.YES; import java.util.List; import java.util.Optional; @@ -12,6 +13,7 @@ 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.ContactPreference; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.DynamicList; import uk.gov.hmcts.reform.iacaseapi.domain.entities.Subscriber; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.State; @@ -20,6 +22,7 @@ import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.JourneyType; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.PaymentStatus; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils; import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PreSubmitCallbackStateHandler; @@ -62,6 +65,11 @@ public PreSubmitCallbackResponse handle(PreSubmitCallbackStage callb if (currentState == State.REASONS_FOR_APPEAL_SUBMITTED) { currentState = State.CASE_UNDER_REVIEW; } + Optional paymentStatusOptional = asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS); + if (paymentStatusOptional.isPresent() && !PaymentStatus.PAID.equals(paymentStatusOptional.get())) { + asylumCase.write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YES); + asylumCase.write(AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YES); + } return new PreSubmitCallbackResponse<>(asylumCase, currentState); } @@ -74,7 +82,7 @@ private void updateAppellantContactDetails(AsylumCase asylumCase) { Subscriber subscriber = subscriptionsOptional.get().stream().findFirst().map(IdValue::getValue).orElse(null); if (subscriber != null) { - ContactPreference contactPreference = subscriber.getWantsEmail() == YesOrNo.YES + ContactPreference contactPreference = subscriber.getWantsEmail() == YES ? ContactPreference.WANTS_EMAIL : ContactPreference.WANTS_SMS; From 6095b700e595bc0b68c45734479adf13fb247a6f Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 07:44:00 +0100 Subject: [PATCH 02/11] Update payment fields and add tests --- .../AipToLegalRepJourneyHandler.java | 30 ++++++++-- .../presubmit/AppealSubmitHandler.java | 2 +- .../AipToLegalRepJourneyHandlerTest.java | 56 +++++++++++++++++++ .../presubmit/AppealSubmitHandlerTest.java | 22 ++++++++ 4 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java index 2cf8e6666e..42371d06b7 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java @@ -4,6 +4,8 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PREV_JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PRE_CLARIFYING_STATE; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_DECISION; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.YES; import java.util.List; @@ -13,7 +15,8 @@ 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.ContactPreference; -import uk.gov.hmcts.reform.iacaseapi.domain.entities.DynamicList; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.Subscriber; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.State; @@ -23,7 +26,6 @@ import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.JourneyType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.PaymentStatus; -import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils; import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PreSubmitCallbackStateHandler; @@ -65,13 +67,33 @@ public PreSubmitCallbackResponse handle(PreSubmitCallbackStage callb if (currentState == State.REASONS_FOR_APPEAL_SUBMITTED) { currentState = State.CASE_UNDER_REVIEW; } + + updatePaymentFields(asylumCase); + + return new PreSubmitCallbackResponse<>(asylumCase, currentState); + } + + private void updatePaymentFields(AsylumCase asylumCase) { Optional paymentStatusOptional = asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS); - if (paymentStatusOptional.isPresent() && !PaymentStatus.PAID.equals(paymentStatusOptional.get())) { + + if (paymentStatusOptional.isPresent() + && !PaymentStatus.PAID.equals(paymentStatusOptional.get()) + && hasNoRemission(asylumCase)) { + asylumCase.write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YES); asylumCase.write(AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YES); } + } - return new PreSubmitCallbackResponse<>(asylumCase, currentState); + private boolean hasNoRemission(AsylumCase asylumCase) { + Optional optRemissionType = asylumCase.read(REMISSION_TYPE, RemissionType.class); + Optional optionalRemissionDecision = + asylumCase.read(REMISSION_DECISION, RemissionDecision.class); + + return optRemissionType.isEmpty() + || optRemissionType.get() == RemissionType.NO_REMISSION + || (optionalRemissionDecision.isPresent() + && optionalRemissionDecision.get() == RemissionDecision.REJECTED); } private void updateAppellantContactDetails(AsylumCase asylumCase) { diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandler.java index c216b2e38d..0bcf168ca0 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandler.java @@ -74,7 +74,7 @@ public PreSubmitCallbackResponse handle( Optional optRemissionType = asylumCase.read(REMISSION_TYPE, RemissionType.class); Optional optRemissionDecision = asylumCase.read(REMISSION_DECISION, RemissionDecision.class); - if (optRemissionType.isPresent() && optRemissionType.get().equals(RemissionType.NO_REMISSION)) { + if (optRemissionType.isEmpty() || optRemissionType.get().equals(RemissionType.NO_REMISSION)) { asylumCase.write(IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YesOrNo.YES); } else { asylumCase.write(IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YesOrNo.NO); diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index a165cb3858..bf836f4f49 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -5,6 +5,8 @@ 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.ArgumentMatchers.any; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -12,6 +14,7 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.CONTACT_PREFERENCE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.CONTACT_PREFERENCE_DESCRIPTION; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.EMAIL; +import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_INTERPRETER_SERVICES_NEEDED; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.MOBILE_NUMBER; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PRE_CLARIFYING_STATE; @@ -21,15 +24,23 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.stream.Stream; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; 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.AsylumCase; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ContactPreference; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.Subscriber; import uk.gov.hmcts.reform.iacaseapi.domain.entities.SubscriberType; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails; @@ -40,6 +51,7 @@ import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.JourneyType; +import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.PaymentStatus; import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo; @MockitoSettings(strictness = Strictness.LENIENT) @@ -192,6 +204,50 @@ void should_update_appellant_contact_details_with_email_preference() { verify(asylumCase, times(1)).clear(SUBSCRIPTIONS); } + @ParameterizedTest + @MethodSource("providePaymentUpdateScenarios") + void should_update_payment_details_when_payment_is_pending_and_remission_rejected( + PaymentStatus paymentStatus, + RemissionType remissionType, + RemissionDecision remissionDecision, + boolean updateServiceRequestFields) { + + when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS)).thenReturn(Optional.of(paymentStatus)); + when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_TYPE)) + .thenReturn(Optional.ofNullable(remissionType)); + when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_DECISION)) + .thenReturn(Optional.ofNullable(remissionDecision)); + + PreSubmitCallbackResponse response = aipToLegalRepJourneyHandler.handle( + PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback, callbackResponse); + + assertNotNull(response); + assertEquals(asylumCase, response.getData()); + + if (updateServiceRequestFields) { + verify(asylumCase, times(1)) + .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); + verify(asylumCase, times(1)).write( + AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YesOrNo.YES); + } else { + verify(asylumCase, never()) + .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); + verify(asylumCase, never()).write( + AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YesOrNo.YES); + } + } + + static Stream providePaymentUpdateScenarios() { + return Stream.of( + Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.NO_REMISSION, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.PARTIALLY_APPROVED, true), + Arguments.of(PaymentStatus.NOT_PAID, null, null, true), + Arguments.of(PaymentStatus.PAID, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, false), + Arguments.of(PaymentStatus.PAID, RemissionType.NO_REMISSION, null, false) + ); + } + @Test void should_update_appellant_contact_details_with_sms_preference() { Subscriber subscriber = new Subscriber( diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java index 7bd6b3b1fb..608616779d 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java @@ -92,6 +92,28 @@ void should_make_service_request_tab_visible_if_no_remission() { assertEquals(YesOrNo.YES, yesOrNoCaptor.getValue()); } + @Test + void should_make_service_request_tab_visible_if_remission_type_does_not_exist() { + + when(callback.getEvent()).thenReturn(SUBMIT_APPEAL); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(PA_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(JOURNEY_TYPE, JourneyType.class)).thenReturn(Optional.empty()); + when(asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.empty()); + + appealSubmitHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + ArgumentCaptor tabVisibleFieldCaptor = ArgumentCaptor.forClass(AsylumCaseFieldDefinition.class); + ArgumentCaptor yesOrNoCaptor = ArgumentCaptor.forClass(YesOrNo.class); + verify(asylumCase, times(1)) + .write(tabVisibleFieldCaptor.capture(), yesOrNoCaptor.capture()); + + assertEquals(IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, tabVisibleFieldCaptor.getValue()); + assertEquals(YesOrNo.YES, yesOrNoCaptor.getValue()); + } + @ParameterizedTest @EnumSource(value = RemissionDecision.class, names = {"PARTIALLY_APPROVED", "APPROVED"}) void should_make_service_request_tab_hidden_if_remission_not_rejected(RemissionDecision remissionDecision) { From fe08ca0731c438b498427231de5677eed67756ba Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 09:53:43 +0100 Subject: [PATCH 03/11] Fix build --- .../handlers/presubmit/AipToLegalRepJourneyHandlerTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index bf836f4f49..880abb754b 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -14,7 +14,6 @@ import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.CONTACT_PREFERENCE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.CONTACT_PREFERENCE_DESCRIPTION; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.EMAIL; -import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_INTERPRETER_SERVICES_NEEDED; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.MOBILE_NUMBER; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PRE_CLARIFYING_STATE; From 7fc6939a9dcca94e97f41d8086aa9bbae5fa7412 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 10:57:27 +0100 Subject: [PATCH 04/11] remove unused imports --- .../handlers/presubmit/AipToLegalRepJourneyHandlerTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index 880abb754b..7c19df62be 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -5,7 +5,6 @@ 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.ArgumentMatchers.any; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; From 71974e39671f81683557da61540aa75a79e87ab2 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 14:08:46 +0100 Subject: [PATCH 05/11] Add missing test scenarios --- .../handlers/presubmit/AipToLegalRepJourneyHandler.java | 2 +- .../presubmit/AipToLegalRepJourneyHandlerTest.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java index 42371d06b7..7bcb2a2630 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java @@ -93,7 +93,7 @@ private boolean hasNoRemission(AsylumCase asylumCase) { return optRemissionType.isEmpty() || optRemissionType.get() == RemissionType.NO_REMISSION || (optionalRemissionDecision.isPresent() - && optionalRemissionDecision.get() == RemissionDecision.REJECTED); + && optionalRemissionDecision.get() != RemissionDecision.APPROVED); } private void updateAppellantContactDetails(AsylumCase asylumCase) { diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index 7c19df62be..ad2d02c5ee 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -211,9 +211,9 @@ void should_update_payment_details_when_payment_is_pending_and_remission_rejecte boolean updateServiceRequestFields) { when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS)).thenReturn(Optional.of(paymentStatus)); - when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_TYPE)) + when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_TYPE, RemissionType.class)) .thenReturn(Optional.ofNullable(remissionType)); - when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_DECISION)) + when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_DECISION, RemissionDecision.class)) .thenReturn(Optional.ofNullable(remissionDecision)); PreSubmitCallbackResponse response = aipToLegalRepJourneyHandler.handle( @@ -240,8 +240,10 @@ static Stream providePaymentUpdateScenarios() { Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.NO_REMISSION, null, true), Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, true), Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.PARTIALLY_APPROVED, true), - Arguments.of(PaymentStatus.NOT_PAID, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.REJECTED, true), Arguments.of(PaymentStatus.PAID, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, false), + Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HELP_WITH_FEES, null, false), Arguments.of(PaymentStatus.PAID, RemissionType.NO_REMISSION, null, false) ); } From da75b978c13ed66eaa43df5c6e69e5c59fd11965 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 15:12:27 +0100 Subject: [PATCH 06/11] disable AM pact test --- .../roleassignment/RoleAssignmentQueryConsumerTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java index 03f3655f77..92390c8a78 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java @@ -22,6 +22,7 @@ import java.util.Map; import org.json.JSONException; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; @@ -111,6 +112,7 @@ public RequestResponsePact generatePactFragmentForQueryRoleAssignments(PactDslWi } @Test + @Disabled @PactTestFor(pactMethod = "generatePactFragmentForQueryRoleAssignments") public void verifyQueryRoleAssignments() { List queryRoleAssignmentResponse = roleAssignmentService From 82f5048376e732ad4e424c582f8ba8672d40dcc0 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 15:14:54 +0100 Subject: [PATCH 07/11] disable AM pact test --- .../handlers/presubmit/AipToLegalRepJourneyHandlerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index ad2d02c5ee..22b2f5c14d 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -208,7 +208,7 @@ void should_update_payment_details_when_payment_is_pending_and_remission_rejecte PaymentStatus paymentStatus, RemissionType remissionType, RemissionDecision remissionDecision, - boolean updateServiceRequestFields) { + boolean updateServiceRequestData) { when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS)).thenReturn(Optional.of(paymentStatus)); when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_TYPE, RemissionType.class)) @@ -222,7 +222,7 @@ void should_update_payment_details_when_payment_is_pending_and_remission_rejecte assertNotNull(response); assertEquals(asylumCase, response.getData()); - if (updateServiceRequestFields) { + if (updateServiceRequestData) { verify(asylumCase, times(1)) .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); verify(asylumCase, times(1)).write( From 3be786bb2e66806489b9d619cd61ae709e79b885 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Tue, 16 Jul 2024 16:21:42 +0100 Subject: [PATCH 08/11] disable AM pact tests --- .../roleassignment/RoleAssignmentQueryConsumerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java index 92390c8a78..401b1966ee 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java @@ -54,6 +54,7 @@ @PactTestFor(providerName = "am_roleAssignment_queryAssignment", port = "8991") @ContextConfiguration(classes = {RoleAssignmentConsumerApplication.class}) @TestPropertySource(locations = {"classpath:application.properties"}) +@Disabled public class RoleAssignmentQueryConsumerTest { @Autowired @@ -112,7 +113,6 @@ public RequestResponsePact generatePactFragmentForQueryRoleAssignments(PactDslWi } @Test - @Disabled @PactTestFor(pactMethod = "generatePactFragmentForQueryRoleAssignments") public void verifyQueryRoleAssignments() { List queryRoleAssignmentResponse = roleAssignmentService From 7e67134833bf8840751892b44418bc19bba23986 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Wed, 17 Jul 2024 08:45:36 +0100 Subject: [PATCH 09/11] Add payment reference check --- .../AipToLegalRepJourneyHandler.java | 11 ++++-- .../AipToLegalRepJourneyHandlerTest.java | 36 +++++++++++++------ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java index 7bcb2a2630..ff4373f6dc 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.iacaseapi.domain.handlers.presubmit; import static java.util.Objects.requireNonNull; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PREV_JOURNEY_TYPE; import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PRE_CLARIFYING_STATE; @@ -74,14 +75,20 @@ public PreSubmitCallbackResponse handle(PreSubmitCallbackStage callb } private void updatePaymentFields(AsylumCase asylumCase) { - Optional paymentStatusOptional = asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS); + Optional paymentStatusOptional = asylumCase.read( + AsylumCaseFieldDefinition.PAYMENT_STATUS, PaymentStatus.class); if (paymentStatusOptional.isPresent() && !PaymentStatus.PAID.equals(paymentStatusOptional.get()) && hasNoRemission(asylumCase)) { - asylumCase.write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YES); asylumCase.write(AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YES); + + Optional paymentReferenceOpt = asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_REFERENCE); + + if (paymentReferenceOpt.isPresent() && isNotEmpty(paymentReferenceOpt.get())) { + asylumCase.write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YES); + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java index 22b2f5c14d..323dbefd43 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandlerTest.java @@ -24,6 +24,7 @@ import java.util.Optional; import java.util.stream.Stream; +import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -206,11 +207,15 @@ void should_update_appellant_contact_details_with_email_preference() { @MethodSource("providePaymentUpdateScenarios") void should_update_payment_details_when_payment_is_pending_and_remission_rejected( PaymentStatus paymentStatus, + String paymentReference, RemissionType remissionType, RemissionDecision remissionDecision, boolean updateServiceRequestData) { - when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS)).thenReturn(Optional.of(paymentStatus)); + when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_STATUS, PaymentStatus.class)) + .thenReturn(Optional.of(paymentStatus)); + when(asylumCase.read(AsylumCaseFieldDefinition.PAYMENT_REFERENCE)) + .thenReturn(Optional.ofNullable(paymentReference)); when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_TYPE, RemissionType.class)) .thenReturn(Optional.ofNullable(remissionType)); when(asylumCase.read(AsylumCaseFieldDefinition.REMISSION_DECISION, RemissionDecision.class)) @@ -223,10 +228,13 @@ void should_update_payment_details_when_payment_is_pending_and_remission_rejecte assertEquals(asylumCase, response.getData()); if (updateServiceRequestData) { - verify(asylumCase, times(1)) - .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); verify(asylumCase, times(1)).write( AsylumCaseFieldDefinition.IS_SERVICE_REQUEST_TAB_VISIBLE_CONSIDERING_REMISSIONS, YesOrNo.YES); + + if (StringUtils.isNotEmpty(paymentReference)) { + verify(asylumCase, times(1)) + .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); + } } else { verify(asylumCase, never()) .write(AsylumCaseFieldDefinition.HAS_SERVICE_REQUEST_ALREADY, YesOrNo.YES); @@ -236,15 +244,21 @@ void should_update_payment_details_when_payment_is_pending_and_remission_rejecte } static Stream providePaymentUpdateScenarios() { + final String reference = "1111-1111-1111-1111"; return Stream.of( - Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.NO_REMISSION, null, true), - Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, true), - Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.PARTIALLY_APPROVED, true), - Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, true), - Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.REJECTED, true), - Arguments.of(PaymentStatus.PAID, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, false), - Arguments.of(PaymentStatus.PAYMENT_PENDING, RemissionType.HELP_WITH_FEES, null, false), - Arguments.of(PaymentStatus.PAID, RemissionType.NO_REMISSION, null, false) + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, RemissionType.NO_REMISSION, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.PARTIALLY_APPROVED, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.REJECTED, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, null, RemissionType.NO_REMISSION, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, null, null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, "", RemissionType.HO_WAIVER_REMISSION, RemissionDecision.PARTIALLY_APPROVED, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, "", null, null, true), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, RemissionType.HO_WAIVER_REMISSION, RemissionDecision.REJECTED, true), + Arguments.of(PaymentStatus.PAID, reference, RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION, RemissionDecision.APPROVED, false), + Arguments.of(PaymentStatus.PAYMENT_PENDING, reference, RemissionType.HELP_WITH_FEES, null, false), + Arguments.of(PaymentStatus.PAID, reference, RemissionType.NO_REMISSION, null, false) ); } From 98caed72e5679192bf2e76f2037d75cff9d8e63a Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Wed, 17 Jul 2024 12:34:15 +0100 Subject: [PATCH 10/11] rename tests --- .../handlers/presubmit/AipToLegalRepJourneyHandler.java | 4 ++-- .../domain/handlers/presubmit/AppealSubmitHandlerTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java index ff4373f6dc..bf22eacc95 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AipToLegalRepJourneyHandler.java @@ -69,12 +69,12 @@ public PreSubmitCallbackResponse handle(PreSubmitCallbackStage callb currentState = State.CASE_UNDER_REVIEW; } - updatePaymentFields(asylumCase); + updatePaymentServiceRequestDetails(asylumCase); return new PreSubmitCallbackResponse<>(asylumCase, currentState); } - private void updatePaymentFields(AsylumCase asylumCase) { + private void updatePaymentServiceRequestDetails(AsylumCase asylumCase) { Optional paymentStatusOptional = asylumCase.read( AsylumCaseFieldDefinition.PAYMENT_STATUS, PaymentStatus.class); diff --git a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java index 608616779d..1cad2defc7 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/AppealSubmitHandlerTest.java @@ -93,7 +93,7 @@ void should_make_service_request_tab_visible_if_no_remission() { } @Test - void should_make_service_request_tab_visible_if_remission_type_does_not_exist() { + void should_make_service_request_tab_visible_when_remission_type_does_not_exist() { when(callback.getEvent()).thenReturn(SUBMIT_APPEAL); when(callback.getCaseDetails()).thenReturn(caseDetails); From 6af6ed35909f096d15a0b35d31622b5fcea69509 Mon Sep 17 00:00:00 2001 From: Aliveni Choppa Date: Fri, 26 Jul 2024 11:58:51 +0100 Subject: [PATCH 11/11] revert changes to AM pact tests --- .../roleassignment/RoleAssignmentQueryConsumerTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java index 7daf674ae2..9a37fb52e7 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/iacaseapi/consumer/roleassignment/RoleAssignmentQueryConsumerTest.java @@ -12,7 +12,6 @@ import org.json.JSONException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; @@ -49,7 +48,6 @@ @PactTestFor(providerName = "am_roleAssignment_queryAssignment", port = "8991") @ContextConfiguration(classes = {RoleAssignmentConsumerApplication.class}) @TestPropertySource(locations = {"classpath:application.properties"}) -@Disabled public class RoleAssignmentQueryConsumerTest { @Autowired