Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSCSCI-1616 #4349

Merged
merged 21 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9072eb5
add logic to handle added outcomes
hashimalisolirius Jan 30, 2025
39bbd00
move boolean check for new hearing outcomes
hashimalisolirius Jan 30, 2025
0ef8b92
midevent for amend hearing
hashimalisolirius Jan 30, 2025
bbed646
test for amend hearing midevent
hashimalisolirius Jan 30, 2025
224f356
update midevent check
hashimalisolirius Jan 30, 2025
8dbd7d4
remove logging
hashimalisolirius Jan 30, 2025
7c04987
Merge branch 'master' into amend-demo
hashimalisolirius Jan 30, 2025
1d81960
update message
hashimalisolirius Jan 31, 2025
4cced0f
Merge branch 'master' into amend-demo
hashimalisolirius Jan 31, 2025
10be2bb
Merge branch 'master' into amend-demo
hashimalisolirius Jan 31, 2025
c79ba22
Merge branch 'master' into amend-demo
hashimalisolirius Jan 31, 2025
0862797
Merge branch 'master' into amend-demo
hashimalisolirius Feb 3, 2025
a8cfa1b
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 4, 2025
45d0dc1
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 4, 2025
c55c028
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 4, 2025
26f8318
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 4, 2025
84b914f
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 5, 2025
0b97109
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 5, 2025
234374c
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 5, 2025
425cd23
Merge branch 'master' into amend-demo
ArunabhaChowdhury Feb 6, 2025
1cb22b8
Merge branch 'master' into amend-demo
hashimalisolirius Feb 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"DisplayOrder": 361,
"PreConditionState(s)": "*",
"CallBackURLAboutToStartEvent": "${CCD_DEF_TRIBUNALS_API_URL}/ccdAboutToStart",
"CallBackURLMidEvent": "${CCD_DEF_TRIBUNALS_API_URL}/ccdMidEvent",
"CallBackURLAboutToSubmitEvent": "${CCD_DEF_TRIBUNALS_API_URL}/ccdAboutToSubmit",
"PostConditionState": "*",
"SecurityClassification": "Public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"CaseFieldID": "hearingOutcomes",
"CaseTypeID": "Benefit",
"DisplayContext": "COMPLEX",
"CallBackURLMidEvent": "${CCD_DEF_TRIBUNALS_API_URL}/ccdMidEvent",
"PageDisplayOrder": 1,
"PageFieldDisplayOrder": 1,
"PageID": "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ public PreSubmitCallbackResponse<SscsCaseData> handle(CallbackType callbackType,
}

SscsCaseData sscsCaseData = callback.getCaseDetails().getCaseData();
PreSubmitCallbackResponse<SscsCaseData> preSubmitCallbackResponse = new PreSubmitCallbackResponse<>(sscsCaseData);

if (sscsCaseData.getHearingOutcomes().isEmpty()) {
sscsCaseData.setHearingOutcomes(null);
}

return new PreSubmitCallbackResponse<>(sscsCaseData);
return preSubmitCallbackResponse;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package uk.gov.hmcts.reform.sscs.ccd.presubmit.amendhearingoutcome;

import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@Component
public class AmendHearingOutcomeMidEventHandler implements PreSubmitCallbackHandler<SscsCaseData> {
@Override
public boolean canHandle(CallbackType callbackType, Callback<SscsCaseData> callback) {
return callbackType.equals(CallbackType.MID_EVENT)
&& callback.getEvent().equals(EventType.AMEND_HEARING_OUTCOME);

}

@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();
PreSubmitCallbackResponse<SscsCaseData> preSubmitCallbackResponse = new PreSubmitCallbackResponse<>(sscsCaseData);
boolean hasNewOutcomeBeenAdded = sscsCaseData.getHearingOutcomes().stream()
.anyMatch(hearingOutcome -> hearingOutcome.getValue().getCompletedHearingId() == null);
if (hasNewOutcomeBeenAdded) {
preSubmitCallbackResponse.addError("You cannot create a new hearing outcome in Amend Hearing Outcome, select ‘Add New hearing outcome’ event to add another outcome.");
}

return preSubmitCallbackResponse;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package uk.gov.hmcts.reform.sscs.ccd.presubmit.amendhearingoutcome;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;

import java.time.LocalDateTime;
import java.util.List;
import junitparams.JUnitParamsRunner;
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.CallbackType;
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.EventType;
import uk.gov.hmcts.reform.sscs.ccd.domain.HearingOutcome;
import uk.gov.hmcts.reform.sscs.ccd.domain.HearingOutcomeDetails;
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData;
import uk.gov.hmcts.reform.sscs.reference.data.model.HearingChannel;


@RunWith(JUnitParamsRunner.class)
public class AmendHearingOutcomeMidEventHandlerTest {

private AmendHearingOutcomeMidEventHandler handler;

@Mock
private Callback<SscsCaseData> callback;

@Mock
private CaseDetails<SscsCaseData> caseDetails;

private SscsCaseData sscsCaseData;

@Before
public void setUp() {
openMocks(this);
handler = new AmendHearingOutcomeMidEventHandler();

when(callback.getEvent()).thenReturn(EventType.AMEND_HEARING_OUTCOME);
when(callback.getCaseDetails()).thenReturn(caseDetails);
sscsCaseData = SscsCaseData.builder().ccdCaseId("ccdDd").appeal(Appeal.builder().build()).build();
when(caseDetails.getCaseData()).thenReturn(sscsCaseData);
}

@Test
public void givenAValidAboutToSubmitEvent_thenReturnTrue() {
assertThat(handler.canHandle(CallbackType.MID_EVENT, callback)).isTrue();
}

@Test
public void givenAnInvalidAboutToSubmitEvent_thenReturnTrue() {
when(callback.getEvent()).thenReturn(EventType.APPEAL_RECEIVED);
assertThat(handler.canHandle(CallbackType.MID_EVENT, callback)).isFalse();
}

@Test
public void givenAHearingWasAdded_ThenReturnError() {
sscsCaseData.setHearingOutcomes(List.of(
HearingOutcome.builder().value(HearingOutcomeDetails.builder().completedHearingId(null).build()).build(),
HearingOutcome.builder().value(
HearingOutcomeDetails.builder()
.hearingOutcomeId("17")
.hearingChannelId(HearingChannel.FACE_TO_FACE)
.hearingStartDateTime(LocalDateTime.now().minusHours(1))
.hearingEndDateTime(LocalDateTime.now())
.completedHearingId("123").build()).build()
));
var response = handler.handle(CallbackType.MID_EVENT, callback, "userAuthorisation");
assertThat(response.getErrors()).contains("You cannot create a new hearing outcome in Amend Hearing Outcome, select ‘Add New hearing outcome’ event to add another outcome.");
}

@Test
public void givenNoHearingAdded_ThenReturnResponse() {
sscsCaseData.setHearingOutcomes(List.of(
HearingOutcome.builder().value(
HearingOutcomeDetails.builder()
.hearingOutcomeId("17")
.hearingChannelId(HearingChannel.FACE_TO_FACE)
.hearingStartDateTime(LocalDateTime.now().minusHours(1))
.hearingEndDateTime(LocalDateTime.now())
.completedHearingId("123").build()).build()
));
var response = handler.handle(CallbackType.MID_EVENT, callback, "userAuthorisation");
assertThat(response.getErrors()).isEmpty();
}

}
Loading