Skip to content

Commit

Permalink
Implemented prePostHearing field in 'Send to interloc' and 'Send to J…
Browse files Browse the repository at this point in the history
…udge' events (#3516)

* SSCS-12139: implemented prePostHearing field in 'Send to interloc' and 'Send to Judge' events

* common bump
SSCS-12139

* cleanup, sscs-common bump

* tests

* fixed prePosthearing value is not null in about to start handler

* Update build.gradle

* update suppressions
SSCS-12139

* update flags
SSCS-12139

---------

Co-authored-by: Andrei Trushkov <andrei.trushkov@hmcts.net>
Co-authored-by: NickHill111 <47982351+nickhill111@users.noreply.github.com>
Co-authored-by: Nicholas Hill <nicholas.hill@HMCTS.net>
  • Loading branch information
4 people committed Dec 4, 2023
1 parent 70e24c6 commit 528ff6c
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 70 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ dependencies {
implementation group: 'com.github.hmcts', name: 'document-management-client', version: '7.0.0'
implementation group: 'com.github.hmcts', name: 'cmc-pdf-service-client', version: '7.0.1'

implementation group: 'com.github.hmcts', name: 'sscs-common', version: '5.2.2'

implementation group: 'com.github.hmcts', name: 'sscs-common', version: '5.2.3'
implementation group: 'com.github.hmcts', name: 'sscs-pdf-email-common', version: '1.8.10'

implementation group: 'com.azure', name: 'azure-core', version: '1.42.0'
Expand Down
1 change: 1 addition & 0 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<cve>CVE-2023-4586</cve>
<cve>CVE-2023-36052</cve>
<cve>CVE-2023-46604</cve>
<cve>CVE-2023-33202</cve>
</suppress>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ protected SscsCaseData setField(SscsCaseData newSscsCaseData, String newValue, E
}

setInterlocReferralDate(newSscsCaseData, eventType);

clearDirectionDueDate(newSscsCaseData, eventType);

return newSscsCaseData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.sscs.ccd.callback.Callback;
import uk.gov.hmcts.reform.sscs.ccd.callback.CallbackType;
Expand All @@ -20,11 +21,16 @@

@Service
public class DirectionIssuedAboutToStartHandler implements PreSubmitCallbackHandler<SscsCaseData> {
private final boolean isPostHearingsEnabled;

public DirectionIssuedAboutToStartHandler(@Value("${feature.postHearings.enabled}") boolean isPostHearingsEnabled) {
this.isPostHearingsEnabled = isPostHearingsEnabled;
}

@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
requireNonNull(callback, "callback must not be null");
requireNonNull(callbackType, "callbacktype must not be null");
requireNonNull(callbackType, "callbackType must not be null");

return (callbackType.equals(CallbackType.ABOUT_TO_START)
|| callbackType.equals(CallbackType.MID_EVENT))
Expand All @@ -43,6 +49,10 @@ public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType,
setDirectionTypeDropDown(sscsCaseData);
setExtensionNextEventDropdown(callback.getCaseDetails().getState(), sscsCaseData);

if (isPostHearingsEnabled) {
sscsCaseData.setPrePostHearing(null);
}

clearFields(sscsCaseData);
setPartiesToSendLetter(sscsCaseData);
return new PreSubmitCallbackResponse<>(sscsCaseData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ private SscsCaseData updateCaseAfterExtensionRefused(SscsCaseData caseData, Inte
private SscsCaseData updateCaseForDirectionType(CaseDetails<SscsCaseData> caseDetails, SscsCaseData caseData, SscsDocumentTranslationStatus documentTranslationStatus) {

if (DirectionType.PROVIDE_INFORMATION.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {

caseData.setInterlocReviewState(AWAITING_INFORMATION);

} else if (getPreValidStates().contains(caseDetails.getState())
&& DirectionType.APPEAL_TO_PROCEED.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData.setDateSentToDwp(LocalDate.now().toString());
Expand All @@ -161,29 +159,22 @@ private SscsCaseData updateCaseForDirectionType(CaseDetails<SscsCaseData> caseDe
} else if (DirectionType.REFUSE_EXTENSION.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())
&& ExtensionNextEvent.SEND_TO_LISTING.toString().equals(caseData.getExtensionNextEventDl().getValue().getCode())) {
caseData = updateCaseAfterExtensionRefused(caseData, AWAITING_ADMIN_ACTION, State.RESPONSE_RECEIVED);

} else if (DirectionType.REFUSE_EXTENSION.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())
&& ExtensionNextEvent.SEND_TO_VALID_APPEAL.toString().equals(caseData.getExtensionNextEventDl().getValue().getCode())) {
caseData = updateCaseAfterExtensionRefused(caseData, null, State.WITH_DWP);

} else if (DirectionType.GRANT_REINSTATEMENT.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData = updateCaseAfterReinstatementGranted(caseData, documentTranslationStatus);

} else if (DirectionType.REFUSE_REINSTATEMENT.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData = updateCaseAfterReinstatementRefused(caseData, documentTranslationStatus);

} else if (!SscsDocumentTranslationStatus.TRANSLATION_REQUIRED.equals(documentTranslationStatus)
&& DirectionType.GRANT_URGENT_HEARING.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData = updateCaseAfterUrgentHearingGranted(caseData);

} else if (!SscsDocumentTranslationStatus.TRANSLATION_REQUIRED.equals(documentTranslationStatus)
&& DirectionType.REFUSE_URGENT_HEARING.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData = updateCaseAfterUrgentHearingRefused(caseData);

} else if (DirectionType.REFUSE_HEARING_RECORDING_REQUEST.toString().equals(caseData.getDirectionTypeDl().getValue().getCode())) {
caseData.setInterlocReviewState(AWAITING_ADMIN_ACTION);
caseData.setInterlocReferralReason(REJECT_HEARING_RECORDING_REQUEST);

} else {
caseData.setInterlocReviewState(null);
}
Expand All @@ -197,15 +188,12 @@ private int getResponseDueDays(SscsCaseData caseData) {
}

private SscsCaseData updateCaseAfterReinstatementGranted(SscsCaseData caseData, SscsDocumentTranslationStatus documentTranslationStatus) {

if (!SscsDocumentTranslationStatus.TRANSLATION_REQUIRED.equals(documentTranslationStatus)) {
caseData.setReinstatementOutcome(RequestOutcome.GRANTED);
caseData.setDwpState(DwpState.REINSTATEMENT_GRANTED);

updateStateIfInterLockReviewState(caseData);

log.info("Case ID {} reinstatement granted on {}", caseData.getCcdCaseId(), LocalDate.now().toString());

} else {
log.info("Case ID {} reinstatement granted held pending Direction Translation {}", caseData.getCcdCaseId(), LocalDate.now().toString());
}
Expand All @@ -224,7 +212,6 @@ private boolean hasFtaBeenChosenAsOneOfThePartyMembers(SscsCaseData caseData) {
}

private SscsCaseData updateCaseAfterReinstatementRefused(SscsCaseData caseData, SscsDocumentTranslationStatus documentTranslationStatus) {

if (!SscsDocumentTranslationStatus.TRANSLATION_REQUIRED.equals(documentTranslationStatus)) {
caseData.setReinstatementOutcome(RequestOutcome.REFUSED);
caseData.setDwpState(DwpState.REINSTATEMENT_REFUSED);
Expand All @@ -236,15 +223,13 @@ private SscsCaseData updateCaseAfterReinstatementRefused(SscsCaseData caseData,
}

private SscsCaseData updateCaseAfterUrgentHearingGranted(SscsCaseData caseData) {

caseData.setUrgentHearingOutcome(RequestOutcome.GRANTED.getValue());
caseData.setInterlocReviewState(AWAITING_ADMIN_ACTION);
log.info("Case ID {} urgent hearing granted on {}", caseData.getCcdCaseId(), LocalDate.now().toString());
return caseData;
}

private SscsCaseData updateCaseAfterUrgentHearingRefused(SscsCaseData caseData) {

caseData.setUrgentHearingOutcome(RequestOutcome.REFUSED.getValue());
caseData.setUrgentCase("No");
caseData.setInterlocReviewState(NONE);
Expand All @@ -266,7 +251,6 @@ private void updateStateIfInterLockReviewState(SscsCaseData caseData) {
@NotNull
private PreSubmitCallbackResponse<SscsCaseData> validateForPdfAndCreateCallbackResponse(
Callback<SscsCaseData> callback, CaseDetails<SscsCaseData> caseDetails, SscsCaseData caseData, SscsDocumentTranslationStatus documentTranslationStatus) {

final PreSubmitCallbackResponse<SscsCaseData> sscsCaseDataPreSubmitCallbackResponse =
new PreSubmitCallbackResponse<>(caseData);

Expand Down Expand Up @@ -299,7 +283,6 @@ private PreSubmitCallbackResponse<SscsCaseData> buildResponse(Callback<SscsCaseD
PreSubmitCallbackResponse<SscsCaseData> sscsCaseDataPreSubmitCallbackResponse,
DocumentLink url,
SscsDocumentTranslationStatus documentTranslationStatus) {

if (isPostHearingsEnabled) {
clearInterlocReferralReason(caseData);
}
Expand Down Expand Up @@ -344,10 +327,6 @@ private PreSubmitCallbackResponse<SscsCaseData> buildResponse(Callback<SscsCaseD
log.info("Saved the new interloc direction document for case id: " + caseData.getCcdCaseId());
}

if (isPostHearingsEnabled) {
caseData.setPrePostHearing(null);
}

return sscsCaseDataPreSubmitCallbackResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ public class InterlocSendToTcwAboutToSubmitHandler implements PreSubmitCallbackH
@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
requireNonNull(callback, "callback must not be null");
requireNonNull(callbackType, "callbacktype must not be null");
requireNonNull(callbackType, "callbackType must not be null");

return callbackType.equals(CallbackType.ABOUT_TO_SUBMIT)
&& (callback.getEvent() == EventType.INTERLOC_SEND_TO_TCW
);
&& (callback.getEvent() == EventType.INTERLOC_SEND_TO_TCW);
}

@Override
Expand All @@ -38,8 +37,6 @@ public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType,

caseData.setDirectionDueDate(null);

PreSubmitCallbackResponse<SscsCaseData> sscsCaseDataPreSubmitCallbackResponse = new PreSubmitCallbackResponse<>(caseData);

return sscsCaseDataPreSubmitCallbackResponse;
return new PreSubmitCallbackResponse<>(caseData);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package uk.gov.hmcts.reform.sscs.ccd.presubmit.sendtojudge;

import static java.util.Objects.requireNonNull;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
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.callback.PreSubmitCallbackResponse;
import uk.gov.hmcts.reform.sscs.ccd.domain.EventType;
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData;
import uk.gov.hmcts.reform.sscs.ccd.presubmit.PreSubmitCallbackHandler;

@Component
@Slf4j
public class SendToJudgeAboutToStartHandler implements PreSubmitCallbackHandler<SscsCaseData> {
private final boolean postHearingsB;

public SendToJudgeAboutToStartHandler(@Value("${feature.postHearingsB.enabled}") boolean postHearingsB) {
this.postHearingsB = postHearingsB;
}

@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
requireNonNull(callback, "callback must not be null");
requireNonNull(callbackType, "callbackType must not be null");

return callbackType.equals(CallbackType.ABOUT_TO_START)
&& (callback.getEvent() == EventType.TCW_REFER_TO_JUDGE);
}

@Override
public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType, Callback<SscsCaseData> callback, String userAuthorisation) {
if (!canHandle(callbackType, callback)) {
throw new IllegalStateException("Cannot handle callback");
}

SscsCaseData sscsCaseData = callback.getCaseDetails().getCaseData();
if (postHearingsB) {
sscsCaseData.setPrePostHearing(null);
}

return new PreSubmitCallbackResponse<>(sscsCaseData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
public class ValidSendToInterlocAboutToStartHandler implements PreSubmitCallbackHandler<SscsCaseData> {

private final boolean postponementsFeature;
private final boolean postHearingsB;

public ValidSendToInterlocAboutToStartHandler(@Value("${feature.postponements.enabled}") boolean postponementsFeature) {
public ValidSendToInterlocAboutToStartHandler(@Value("${feature.postponements.enabled}") boolean postponementsFeature,
@Value("${feature.postHearingsB.enabled}") boolean postHearingsB) {
this.postponementsFeature = postponementsFeature;
this.postHearingsB = postHearingsB;
}

@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
requireNonNull(callback, "callback must not be null");
requireNonNull(callbackType, "callbacktype must not be null");
requireNonNull(callbackType, "callbackType must not be null");

return callbackType.equals(CallbackType.ABOUT_TO_START)
&& (callback.getEvent() == EventType.VALID_SEND_TO_INTERLOC
Expand All @@ -47,6 +50,10 @@ public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType,
setSelectWhoReviewsCase(sscsCaseData);
setOriginalSenderDropdown(sscsCaseData);

if (postHearingsB) {
sscsCaseData.setPrePostHearing(null);
}

return new PreSubmitCallbackResponse<>(sscsCaseData);
}

Expand All @@ -67,5 +74,4 @@ private void setOriginalSenderDropdown(SscsCaseData sscsCaseData) {

sscsCaseData.setOriginalSender(new DynamicList(listOptions.get(0), listOptions));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ValidSendToInterlocAboutToSubmitHandler(PostponementRequestService postpo
@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
requireNonNull(callback, "callback must not be null");
requireNonNull(callbackType, "callbacktype must not be null");
requireNonNull(callbackType, "callbackType must not be null");

return callbackType.equals(CallbackType.ABOUT_TO_SUBMIT)
&& (callback.getEvent() == EventType.VALID_SEND_TO_INTERLOC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DirectionIssuedAboutToStartHandlerTest {
@Before
public void setUp() {
openMocks(this);
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

sscsCaseData = SscsCaseData.builder().appeal(Appeal.builder().mrnDetails(MrnDetails.builder().dwpIssuingOffice("3").build()).build()).build();

Expand Down Expand Up @@ -141,8 +141,7 @@ public void givenAppealWithTimeExtension_populateDirectionTypeDropdown() {

@Test
public void givenAppealWithReinstatementRequest_populateDirectionTypeDropdown() {

handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

when(callback.getEvent()).thenReturn(EventType.DIRECTION_ISSUED);
when(callback.getCaseDetails().getState()).thenReturn(State.WITH_DWP);
Expand Down Expand Up @@ -238,7 +237,7 @@ public void givenAppealWithNoTimeExtension_populateDirectionTypeDropdown() {

@Test
public void givenAppealWithHearingRecordingRequestOutstanding_populateDirectionTypeDropdownWithRefuseHearingRecordingRequest() {
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

when(callback.getEvent()).thenReturn(EventType.DIRECTION_ISSUED);
when(callback.getCaseDetails().getState()).thenReturn(State.WITH_DWP);
Expand All @@ -258,7 +257,7 @@ public void givenAppealWithHearingRecordingRequestOutstanding_populateDirectionT

@Test
public void givenAppealWithNoHearingRecordingRequestOutstanding_doNotPopulateDirectionTypeDropdownWithRefuseHearingRecordingRequest() {
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

when(callback.getEvent()).thenReturn(EventType.DIRECTION_ISSUED);
when(callback.getCaseDetails().getState()).thenReturn(State.WITH_DWP);
Expand All @@ -277,7 +276,7 @@ public void givenAppealWithNoHearingRecordingRequestOutstanding_doNotPopulateDir

@Test
public void givenAValidCallbackType_thenClearTheConfidentialityFields() {
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);
sscsCaseData.setConfidentialityType(ConfidentialityType.CONFIDENTIAL.getCode());
sscsCaseData.setSendDirectionNoticeToFTA(YES);
sscsCaseData.setSendDirectionNoticeToRepresentative(YES);
Expand All @@ -301,7 +300,7 @@ public void givenAValidCallbackType_thenClearTheConfidentialityFields() {

@Test
public void givenAValidCallbackType_thenVerifyAllPartiesOnTheCase() {
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

Appointee otherPartyAppointee = Appointee.builder()
.id("2")
Expand Down Expand Up @@ -341,7 +340,7 @@ public void givenAValidCallbackType_thenVerifyAllPartiesOnTheCase() {

@Test
public void givenAValidCallbackType_NoAdditionalPartiesForOtherParty() {
handler = new DirectionIssuedAboutToStartHandler();
handler = new DirectionIssuedAboutToStartHandler(false);

CcdValue<OtherParty> otherParty = CcdValue.<OtherParty>builder()
.value(OtherParty.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public void givenDirectionNoticeAlreadyExistsAndThenManuallyUploadANewNotice_the
handler.handle(ABOUT_TO_SUBMIT, callback, USER_AUTHORISATION);

verify(footerService).createFooterAndAddDocToCase(eq(theDocument.getDocumentLink()), any(), eq(DocumentType.DIRECTION_NOTICE), any(), eq(theDocument.getDocumentDateAdded()), eq(null), eq(null));
assertNull(sscsCaseData.getPrePostHearing());
}

public void willSetTheWithDwpStateToDirectionActionRequired() {
Expand Down
Loading

0 comments on commit 528ff6c

Please sign in to comment.