diff --git a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandler.java b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandler.java index 4f9a8ef5c1..5f64569c73 100644 --- a/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandler.java @@ -5,6 +5,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.sscs.callback.CallbackHandler; import uk.gov.hmcts.reform.sscs.ccd.callback.Callback; @@ -21,21 +22,31 @@ public class UpdateOtherPartyHandler implements CallbackHandler { private final ListingStateProcessingService listingStateProcessingService; + private final boolean cmOtherPartyConfidentialityEnabled; @Autowired - public UpdateOtherPartyHandler(ListingStateProcessingService listingStateProcessingService) { + public UpdateOtherPartyHandler(ListingStateProcessingService listingStateProcessingService, + @Value("${feature.cm-other-party-confidentiality.enabled}") boolean cmOtherPartyConfidentialityEnabled) { this.listingStateProcessingService = listingStateProcessingService; + this.cmOtherPartyConfidentialityEnabled = cmOtherPartyConfidentialityEnabled; } @Override public boolean canHandle(CallbackType callbackType, Callback callback) { + + // TODO When this feature flag is enabled we can delete this handler because its only purpose is to update state for UPDATE_OTHER_PARTY_DATA + if (cmOtherPartyConfidentialityEnabled) { + return false; + } + requireNonNull(callback, "callback must not be null"); return callbackType.equals(CallbackType.SUBMITTED) && callback.getEvent() == EventType.UPDATE_OTHER_PARTY_DATA && callback.getCaseDetails().getCaseData().getAppeal() != null && callback.getCaseDetails().getCaseData().getAppeal().getBenefitType() != null - && StringUtils.equalsIgnoreCase(callback.getCaseDetails().getCaseData().getAppeal().getBenefitType().getCode(), Benefit.CHILD_SUPPORT.getShortName()); + && StringUtils.equalsIgnoreCase(callback.getCaseDetails().getCaseData().getAppeal().getBenefitType().getCode(), + Benefit.CHILD_SUPPORT.getShortName()); } @Override diff --git a/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandlerTest.java index 92b4d7fa80..b4bb428945 100644 --- a/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/sscs/evidenceshare/callback/handlers/UpdateOtherPartyHandlerTest.java @@ -3,6 +3,8 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -19,7 +21,6 @@ import java.util.Collections; import java.util.List; import java.util.function.Consumer; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -33,14 +34,12 @@ import uk.gov.hmcts.reform.sscs.ccd.callback.Callback; import uk.gov.hmcts.reform.sscs.ccd.callback.CallbackType; import uk.gov.hmcts.reform.sscs.ccd.domain.Appeal; -import uk.gov.hmcts.reform.sscs.ccd.domain.Appointee; import uk.gov.hmcts.reform.sscs.ccd.domain.BenefitType; import uk.gov.hmcts.reform.sscs.ccd.domain.CcdValue; import uk.gov.hmcts.reform.sscs.ccd.domain.EventType; import uk.gov.hmcts.reform.sscs.ccd.domain.ExcludeDate; import uk.gov.hmcts.reform.sscs.ccd.domain.HearingOptions; import uk.gov.hmcts.reform.sscs.ccd.domain.OtherParty; -import uk.gov.hmcts.reform.sscs.ccd.domain.Representative; import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseDetails; import uk.gov.hmcts.reform.sscs.ccd.domain.State; @@ -50,38 +49,37 @@ import uk.gov.hmcts.reform.sscs.idam.IdamService; @ExtendWith(MockitoExtension.class) -public class UpdateOtherPartyHandlerTest { +class UpdateOtherPartyHandlerTest { + private UpdateOtherPartyHandler handler; @Mock private UpdateCcdCaseService updateCcdCaseService; @Mock private IdamService idamService; - - UpdateOtherPartyHandler handler; - @Captor private ArgumentCaptor> consumerArgumentCaptor; @BeforeEach - public void setUp() { - handler = new UpdateOtherPartyHandler(new ListingStateProcessingService(updateCcdCaseService, idamService)); + void setUp() { + handler = new UpdateOtherPartyHandler(new ListingStateProcessingService(updateCcdCaseService, idamService), false); } @Test - public void givenAValidSubmittedEvent_thenReturnTrue() { - Assertions.assertTrue(handler.canHandle(SUBMITTED, HandlerHelper.buildTestCallbackForGivenData( - SscsCaseData.builder() - .ccdCaseId("1") - .isFqpmRequired(YES) - .directionDueDate(LocalDate.now().toString()) - .otherParties(List.of(buildOtherParty("2", HearingOptions.builder().build()))) - .appeal(Appeal.builder().benefitType(BenefitType.builder().code("childSupport").build()) - .build()).build(), INTERLOCUTORY_REVIEW_STATE, UPDATE_OTHER_PARTY_DATA))); + void givenAValidSubmittedEvent_thenReturnTrue() { + assertTrue(handler.canHandle(SUBMITTED, HandlerHelper.buildTestCallbackForGivenData( + buildAValidEvent(), INTERLOCUTORY_REVIEW_STATE, UPDATE_OTHER_PARTY_DATA))); + } + + @Test + void givenTheOtherPartyConfidentialityFlagIsEnabled_thenReturnFalse() { + handler = new UpdateOtherPartyHandler(new ListingStateProcessingService(updateCcdCaseService, idamService), true); + assertFalse(handler.canHandle(SUBMITTED, HandlerHelper.buildTestCallbackForGivenData( + buildAValidEvent(), INTERLOCUTORY_REVIEW_STATE, UPDATE_OTHER_PARTY_DATA))); } @ParameterizedTest @MethodSource(value = "generateAllPossibleOtherPartyWithHearingOptions") - public void givenFqpmSetAndDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(HearingOptions hearingOptions) { + void givenFqpmSetAndDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(HearingOptions hearingOptions) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -104,7 +102,7 @@ public void givenFqpmSetAndDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseS @ParameterizedTest @MethodSource(value = "generateAllPossibleOtherPartyWithHearingOptions") - public void givenFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(HearingOptions hearingOptions) { + void givenFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(HearingOptions hearingOptions) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -123,7 +121,7 @@ public void givenFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenCas @ParameterizedTest @CsvSource({"YES", "NO"}) - public void givenFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(String isFqpmRequired) { + void givenFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsReadyToList(String isFqpmRequired) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -144,7 +142,7 @@ public void givenFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_then @ParameterizedTest @CsvSource({"YES", "NO"}) - public void givenFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable(String isFqpmRequired) { + void givenFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable(String isFqpmRequired) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -163,7 +161,7 @@ public void givenFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCa } @Test - public void givenNoFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable() { + void givenNoFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable() { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -181,7 +179,7 @@ public void givenNoFqpmSetAndNoDueDateSetAndNotAllOtherPartyHearingOptionsSet_th } @Test - public void givenNoFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable() { + void givenNoFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable() { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -200,7 +198,8 @@ public void givenNoFqpmSetAndDueDateSetAndNotAllOtherPartyHearingOptionsSet_then @ParameterizedTest @MethodSource(value = "generateAllPossibleOtherPartyWithHearingOptions") - public void givenNoFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable(HearingOptions hearingOptions) { + void givenNoFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenCaseStateIsNotListable( + HearingOptions hearingOptions) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() @@ -222,7 +221,7 @@ public void givenNoFqpmSetAndNoDueDateSetAndAllOtherPartyHearingOptionsSet_thenC "HEARING, 1", "INCOMPLETE_APPLICATION, 1", "INCOMPLETE_APPLICATION_INFORMATION_REQUESTED, 1", "INTERLOCUTORY_REVIEW_STATE, 1", "POST_HEARING, 1", "READY_TO_LIST, 1", "RESPONSE_RECEIVED, 0", "VALID_APPEAL, 1", "WITH_DWP, 0"}) - public void givenAnInitialStateThenTriggerNonListableEventType(State currentState, int wantedNumberOfInvocations) { + void givenAnInitialStateThenTriggerNonListableEventType(State currentState, int wantedNumberOfInvocations) { final Callback callback = HandlerHelper.buildTestCallbackForGivenData( SscsCaseData.builder() .ccdCaseId("1") @@ -234,7 +233,8 @@ public void givenAnInitialStateThenTriggerNonListableEventType(State currentStat handler.handle(CallbackType.SUBMITTED, callback); - verify(updateCcdCaseService, times(wantedNumberOfInvocations)).triggerCaseEventV2(eq(Long.valueOf(callback.getCaseDetails().getCaseData().getCcdCaseId())), + verify(updateCcdCaseService, times(wantedNumberOfInvocations)).triggerCaseEventV2( + eq(Long.valueOf(callback.getCaseDetails().getCaseData().getCcdCaseId())), eq(EventType.NOT_LISTABLE.getCcdType()), anyString(), anyString(), any()); } @@ -273,6 +273,16 @@ private static Object[] generateAllPossibleOtherPartyWithHearingOptions() { }; } + private SscsCaseData buildAValidEvent() { + return SscsCaseData.builder() + .ccdCaseId("1") + .isFqpmRequired(YES) + .directionDueDate(LocalDate.now().toString()) + .otherParties(List.of(buildOtherParty("2", HearingOptions.builder().build()))) + .appeal(Appeal.builder().benefitType(BenefitType.builder().code("childSupport").build()) + .build()).build(); + } + private CcdValue buildOtherParty(String id, HearingOptions hearingOptions) { return CcdValue.builder() .value(OtherParty.builder() @@ -283,14 +293,4 @@ private CcdValue buildOtherParty(String id, HearingOptions hearingOp .build(); } - private CcdValue buildOtherPartyWithAppointeeAndRep(String id, String appointeeId, String repId) { - return CcdValue.builder() - .value(OtherParty.builder() - .id(id) - .isAppointee(YES.getValue()) - .appointee(Appointee.builder().id(appointeeId).build()) - .rep(Representative.builder().id(repId).hasRepresentative(YES.getValue()).build()) - .build()) - .build(); - } }