-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSCSCI-1409 make lapse appeal mid event for validations (#4160)
* make lapse appeal mid event for validations * checkstyle fixes * setting interloc state to review by judge for ibc lapse * checkstyle fix * adding mid event url to lapse appeal * changing nested if * mid event fix
- Loading branch information
Showing
6 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ain/java/uk/gov/hmcts/reform/sscs/ccd/presubmit/dwplapse/DwpLapseCaseMidEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package uk.gov.hmcts.reform.sscs.ccd.presubmit.dwplapse; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
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.InterlocReviewState; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; | ||
import uk.gov.hmcts.reform.sscs.ccd.presubmit.PreSubmitCallbackHandler; | ||
|
||
@Service | ||
@Slf4j | ||
public class DwpLapseCaseMidEventHandler implements PreSubmitCallbackHandler<SscsCaseData> { | ||
|
||
@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.MID_EVENT) | ||
&& callback.getEvent() == EventType.DWP_LAPSE_CASE; | ||
} | ||
|
||
@Override | ||
public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType, Callback<SscsCaseData> callback, | ||
String userAuthorisation) { | ||
if (!canHandle(callbackType, callback)) { | ||
throw new IllegalStateException("Cannot handle callback"); | ||
} | ||
SscsCaseData caseData = callback.getCaseDetails().getCaseData(); | ||
|
||
PreSubmitCallbackResponse<SscsCaseData> sscsCaseDataPreSubmitCallbackResponse = new PreSubmitCallbackResponse<>(caseData); | ||
if (caseData.isIbcCase() && caseData.getInterlocReviewState() != InterlocReviewState.REVIEW_BY_JUDGE) { | ||
sscsCaseDataPreSubmitCallbackResponse.addError("Interlocutory review state must be set to 'Review by Judge'"); | ||
} else if (!caseData.isIbcCase() && caseData.getDwpLT203() == null) { | ||
sscsCaseDataPreSubmitCallbackResponse.addError("Select or fill the required Select document for upload field"); | ||
} | ||
|
||
return sscsCaseDataPreSubmitCallbackResponse; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
...java/uk/gov/hmcts/reform/sscs/ccd/presubmit/dwplapse/DwpLapseCaseMidEventHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package uk.gov.hmcts.reform.sscs.ccd.presubmit.dwplapse; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.openMocks; | ||
import static uk.gov.hmcts.reform.sscs.ccd.callback.CallbackType.ABOUT_TO_SUBMIT; | ||
import static uk.gov.hmcts.reform.sscs.ccd.callback.CallbackType.MID_EVENT; | ||
|
||
import junitparams.JUnitParamsRunner; | ||
import junitparams.Parameters; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import uk.gov.hmcts.reform.sscs.ccd.callback.Callback; | ||
import uk.gov.hmcts.reform.sscs.ccd.callback.PreSubmitCallbackResponse; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.Appeal; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.CaseDetails; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.DocumentLink; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.DwpResponseDocument; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.EventType; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.InterlocReviewState; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.State; | ||
|
||
@RunWith(JUnitParamsRunner.class) | ||
public class DwpLapseCaseMidEventHandlerTest { | ||
|
||
private static final String USER_AUTHORISATION = "Bearer token"; | ||
private DwpLapseCaseMidEventHandler handler; | ||
private SscsCaseData sscsCaseData; | ||
|
||
@Mock | ||
private Callback<SscsCaseData> callback; | ||
|
||
@Mock | ||
private CaseDetails<SscsCaseData> caseDetails; | ||
|
||
@Before | ||
public void setUp() { | ||
openMocks(this); | ||
handler = new DwpLapseCaseMidEventHandler(); | ||
|
||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
|
||
sscsCaseData = SscsCaseData.builder() | ||
.ccdCaseId("1234") | ||
.createdInGapsFrom(State.READY_TO_LIST.getId()) | ||
.appeal(Appeal.builder().build()) | ||
.build(); | ||
|
||
when(callback.getCaseDetails()).thenReturn(caseDetails); | ||
when(caseDetails.getCaseData()).thenReturn(sscsCaseData); | ||
} | ||
|
||
@Test | ||
@Parameters({"APPEAL_RECEIVED", "ACTION_FURTHER_EVIDENCE"}) | ||
public void givenANonHandleDwpLapseEvent_thenReturnFalse(EventType eventType) { | ||
when(callback.getEvent()).thenReturn(eventType); | ||
assertFalse(handler.canHandle(MID_EVENT, callback)); | ||
} | ||
|
||
@Test | ||
public void givenAHandleDwpLapseAboutToSubmitEvent_thenReturnFalse() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
assertFalse(handler.canHandle(ABOUT_TO_SUBMIT, callback)); | ||
} | ||
|
||
@Test | ||
public void givenAHandleDwpLapseEvent_thenReturnTrue() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
assertTrue(handler.canHandle(MID_EVENT, callback)); | ||
} | ||
|
||
@Test | ||
public void givenNullCallback_thenThrowError() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
assertThrows(NullPointerException.class, () -> handler.canHandle(ABOUT_TO_SUBMIT, null)); | ||
assertThrows(NullPointerException.class, () -> handler.canHandle(null, callback)); | ||
} | ||
|
||
@Test | ||
@Parameters({"APPEAL_RECEIVED", "ACTION_FURTHER_EVIDENCE"}) | ||
public void givenANonHandleDwpLapseEvent_thenThrowError(EventType eventType) { | ||
when(callback.getEvent()).thenReturn(eventType); | ||
assertThrows(IllegalStateException.class, () -> handler.handle(MID_EVENT, callback, USER_AUTHORISATION)); | ||
} | ||
|
||
@Test | ||
public void givenAHandleDwpLapseEvent_thenThrowError() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
assertThrows(IllegalStateException.class, () -> handler.handle(ABOUT_TO_SUBMIT, callback, USER_AUTHORISATION)); | ||
} | ||
|
||
@Test | ||
public void passIbaCaseIfInterlocReviewByJudge() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
sscsCaseData.setBenefitCode("093"); | ||
sscsCaseData.setInterlocReviewState(InterlocReviewState.REVIEW_BY_JUDGE); | ||
PreSubmitCallbackResponse<SscsCaseData> response = handler.handle(MID_EVENT, callback, USER_AUTHORISATION); | ||
assertTrue(response.getErrors().isEmpty()); | ||
} | ||
|
||
@Test | ||
@Parameters({"AWAITING_ADMIN_ACTION", "AWAITING_INFORMATION", "NONE", "REVIEW_BY_TCW", "WELSH_TRANSLATION"}) | ||
public void failIbaCaseIfNotInterlocReviewByJudge(InterlocReviewState interlocReviewState) { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
sscsCaseData.setBenefitCode("093"); | ||
sscsCaseData.setInterlocReviewState(interlocReviewState); | ||
PreSubmitCallbackResponse<SscsCaseData> response = handler.handle(MID_EVENT, callback, USER_AUTHORISATION); | ||
assertEquals(1, response.getErrors().size()); | ||
assertTrue(response.getErrors().contains("Interlocutory review state must be set to 'Review by Judge'")); | ||
} | ||
|
||
@Test | ||
public void passNonIbaCaseIfNonNullLt203() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
sscsCaseData.setBenefitCode("001"); | ||
sscsCaseData.setDwpLT203(DwpResponseDocument.builder().documentLink(DocumentLink.builder().documentUrl("lt203Link").build()).build()); | ||
PreSubmitCallbackResponse<SscsCaseData> response = handler.handle(MID_EVENT, callback, USER_AUTHORISATION); | ||
assertTrue(response.getErrors().isEmpty()); | ||
} | ||
|
||
@Test | ||
public void failNonIbaCaseIfNullLt203() { | ||
when(callback.getEvent()).thenReturn(EventType.DWP_LAPSE_CASE); | ||
sscsCaseData.setBenefitCode("001"); | ||
sscsCaseData.setDwpLT203(null); | ||
PreSubmitCallbackResponse<SscsCaseData> response = handler.handle(MID_EVENT, callback, USER_AUTHORISATION); | ||
assertEquals(1, response.getErrors().size()); | ||
assertTrue(response.getErrors().contains("Select or fill the required Select document for upload field")); | ||
} | ||
} |