Skip to content

Commit ae85f91

Browse files
authored
Merge branch 'master' into DIAC-2126_stf_24weeks_notification
2 parents 6fa2c96 + df1526e commit ae85f91

File tree

10 files changed

+312
-3
lines changed

10 files changed

+312
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,3 @@ If you want to clean up the environment just run:
282282
```shell
283283
npx @hmcts/dev-env@latest --delete
284284
```
285-

src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/entities/AsylumCaseFieldDefinition.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2921,7 +2921,10 @@ public enum AsylumCaseFieldDefinition {
29212921
new TypeReference<YesOrNo>(){}),
29222922

29232923
HAS_BEEN_FTPA_DECIDED("hasBeenFtpaDecided",
2924-
new TypeReference<YesOrNo>(){})
2924+
new TypeReference<YesOrNo>(){}),
2925+
2926+
COMPLETE_CASE_REVIEW_DATE("completeCaseReviewDate",
2927+
new TypeReference<String>(){})
29252928
;
29262929

29272930
private final String value;

src/main/java/uk/gov/hmcts/reform/iacaseapi/domain/entities/ccd/Event.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public enum Event {
168168
FORCE_DECIDED_STATE("forceDecidedState"),
169169
FORCE_FTPA_DECIDED_STATE("forceFtpaDecidedState"),
170170
ROLLBACK_MIGRATION("rollbackMigration"),
171+
COMPLETE_CASE_REVIEW("completeCaseReview"),
171172

172173
@JsonEnumDefaultValue
173174
UNKNOWN("unknown");
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.handlers.postsubmit;
2+
3+
import static java.util.Objects.requireNonNull;
4+
5+
import org.springframework.stereotype.Component;
6+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
7+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
8+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
9+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PostSubmitCallbackResponse;
10+
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PostSubmitCallbackHandler;
11+
12+
@Component
13+
public class CompleteCaseReviewConfirmation implements PostSubmitCallbackHandler<AsylumCase> {
14+
15+
public boolean canHandle(
16+
Callback<AsylumCase> callback
17+
) {
18+
requireNonNull(callback, "callback must not be null");
19+
20+
return callback.getEvent() == Event.COMPLETE_CASE_REVIEW;
21+
}
22+
23+
public PostSubmitCallbackResponse handle(
24+
Callback<AsylumCase> callback
25+
) {
26+
if (!canHandle(callback)) {
27+
throw new IllegalStateException("Cannot handle callback");
28+
}
29+
30+
PostSubmitCallbackResponse postSubmitResponse = new PostSubmitCallbackResponse();
31+
32+
postSubmitResponse.setConfirmationHeader("# You have completed the case review");
33+
postSubmitResponse.setConfirmationBody(
34+
"#### What happens next\n\n"
35+
+ "The case has been validated and will proceed accordingly."
36+
);
37+
38+
return postSubmitResponse;
39+
}
40+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.handlers.presubmit;
2+
3+
import static java.util.Objects.requireNonNull;
4+
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.COMPLETE_CASE_REVIEW_DATE;
5+
6+
import org.springframework.stereotype.Component;
7+
import uk.gov.hmcts.reform.iacaseapi.domain.DateProvider;
8+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
9+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
10+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
11+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackResponse;
12+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage;
13+
import uk.gov.hmcts.reform.iacaseapi.domain.handlers.PreSubmitCallbackHandler;
14+
15+
@Component
16+
public class CompleteCaseReviewHandler implements PreSubmitCallbackHandler<AsylumCase> {
17+
18+
private final DateProvider dateProvider;
19+
20+
public CompleteCaseReviewHandler(DateProvider dateProvider) {
21+
this.dateProvider = requireNonNull(dateProvider, "dateProvider must not be null");
22+
}
23+
24+
public boolean canHandle(
25+
PreSubmitCallbackStage callbackStage,
26+
Callback<AsylumCase> callback
27+
) {
28+
requireNonNull(callbackStage, "callbackStage must not be null");
29+
requireNonNull(callback, "callback must not be null");
30+
31+
return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT
32+
&& callback.getEvent() == Event.COMPLETE_CASE_REVIEW;
33+
}
34+
35+
public PreSubmitCallbackResponse<AsylumCase> handle(
36+
PreSubmitCallbackStage callbackStage,
37+
Callback<AsylumCase> callback
38+
) {
39+
if (!canHandle(callbackStage, callback)) {
40+
throw new IllegalStateException("Cannot handle callback");
41+
}
42+
43+
AsylumCase asylumCase = callback.getCaseDetails().getCaseData();
44+
45+
asylumCase.write(COMPLETE_CASE_REVIEW_DATE, dateProvider.now().toString());
46+
47+
return new PreSubmitCallbackResponse<>(asylumCase);
48+
}
49+
}

src/main/resources/application.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ security:
274274
- "requestCaseEdit"
275275
- "requestHearingRequirements"
276276
- "requestRespondentEvidence"
277+
- "completeCaseReview"
277278
- "uploadRespondentEvidence"
278279
- "requestRespondentReview"
279280
- "addAppealResponse"
@@ -365,6 +366,7 @@ security:
365366
- "requestCaseEdit"
366367
- "requestHearingRequirements"
367368
- "requestRespondentEvidence"
369+
- "completeCaseReview"
368370
- "uploadRespondentEvidence"
369371
- "requestRespondentReview"
370372
- "addAppealResponse"
@@ -453,6 +455,7 @@ security:
453455
- "requestCaseEdit"
454456
- "requestHearingRequirements"
455457
- "requestRespondentEvidence"
458+
- "completeCaseReview"
456459
- "uploadRespondentEvidence"
457460
- "requestRespondentReview"
458461
- "addAppealResponse"

src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/entities/ccd/EventTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,6 @@ void has_correct_values() {
169169

170170
@Test
171171
void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() {
172-
assertEquals(163, Event.values().length);
172+
assertEquals(164, Event.values().length);
173173
}
174174
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.handlers.postsubmit;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
import static org.mockito.Mockito.reset;
9+
import static org.mockito.Mockito.when;
10+
11+
import org.junit.jupiter.api.Test;
12+
import org.junit.jupiter.api.extension.ExtendWith;
13+
import org.mockito.Mock;
14+
import org.mockito.junit.jupiter.MockitoExtension;
15+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
16+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
17+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
18+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PostSubmitCallbackResponse;
19+
20+
@ExtendWith(MockitoExtension.class)
21+
@SuppressWarnings("unchecked")
22+
class CompleteCaseReviewConfirmationTest {
23+
24+
@Mock
25+
private Callback<AsylumCase> callback;
26+
27+
private final CompleteCaseReviewConfirmation completeCaseReviewConfirmation =
28+
new CompleteCaseReviewConfirmation();
29+
30+
@Test
31+
void should_return_confirmation() {
32+
33+
when(callback.getEvent()).thenReturn(Event.COMPLETE_CASE_REVIEW);
34+
35+
PostSubmitCallbackResponse callbackResponse =
36+
completeCaseReviewConfirmation.handle(callback);
37+
38+
assertNotNull(callbackResponse);
39+
assertTrue(callbackResponse.getConfirmationHeader().isPresent());
40+
assertTrue(callbackResponse.getConfirmationBody().isPresent());
41+
42+
assertThat(
43+
callbackResponse.getConfirmationHeader().get())
44+
.contains("You have completed the case review");
45+
46+
assertThat(
47+
callbackResponse.getConfirmationBody().get())
48+
.contains("The case has been validated and will proceed accordingly.");
49+
}
50+
51+
@Test
52+
void handling_should_throw_if_cannot_actually_handle() {
53+
54+
assertThatThrownBy(() -> completeCaseReviewConfirmation.handle(callback))
55+
.hasMessage("Cannot handle callback")
56+
.isExactlyInstanceOf(IllegalStateException.class);
57+
}
58+
59+
@Test
60+
void it_can_handle_callback() {
61+
62+
for (Event event : Event.values()) {
63+
64+
when(callback.getEvent()).thenReturn(event);
65+
66+
boolean canHandle = completeCaseReviewConfirmation.canHandle(callback);
67+
68+
if (event == Event.COMPLETE_CASE_REVIEW) {
69+
assertTrue(canHandle);
70+
} else {
71+
assertFalse(canHandle);
72+
}
73+
74+
reset(callback);
75+
}
76+
}
77+
78+
@Test
79+
void should_not_allow_null_arguments() {
80+
81+
assertThatThrownBy(() -> completeCaseReviewConfirmation.canHandle(null))
82+
.hasMessage("callback must not be null")
83+
.isExactlyInstanceOf(NullPointerException.class);
84+
85+
assertThatThrownBy(() -> completeCaseReviewConfirmation.handle(null))
86+
.hasMessage("callback must not be null")
87+
.isExactlyInstanceOf(NullPointerException.class);
88+
}
89+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package uk.gov.hmcts.reform.iacaseapi.domain.handlers.presubmit;
2+
3+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
import static org.mockito.Mockito.reset;
9+
import static org.mockito.Mockito.verify;
10+
import static org.mockito.Mockito.when;
11+
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.COMPLETE_CASE_REVIEW_DATE;
12+
13+
import java.time.LocalDate;
14+
import org.junit.jupiter.api.BeforeEach;
15+
import org.junit.jupiter.api.Test;
16+
import org.junit.jupiter.api.extension.ExtendWith;
17+
import org.mockito.Mock;
18+
import org.mockito.junit.jupiter.MockitoExtension;
19+
import uk.gov.hmcts.reform.iacaseapi.domain.DateProvider;
20+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
21+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails;
22+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
23+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
24+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackResponse;
25+
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage;
26+
27+
@ExtendWith(MockitoExtension.class)
28+
@SuppressWarnings("unchecked")
29+
class CompleteCaseReviewHandlerTest {
30+
31+
@Mock
32+
private Callback<AsylumCase> callback;
33+
@Mock
34+
private CaseDetails<AsylumCase> caseDetails;
35+
@Mock
36+
private AsylumCase asylumCase;
37+
@Mock
38+
private DateProvider dateProvider;
39+
40+
private CompleteCaseReviewHandler completeCaseReviewHandler;
41+
42+
@BeforeEach
43+
public void setUp() {
44+
completeCaseReviewHandler = new CompleteCaseReviewHandler(dateProvider);
45+
}
46+
47+
@Test
48+
void should_write_complete_case_review_date() {
49+
50+
LocalDate now = LocalDate.of(2026, 3, 3);
51+
52+
when(callback.getEvent()).thenReturn(Event.COMPLETE_CASE_REVIEW);
53+
when(callback.getCaseDetails()).thenReturn(caseDetails);
54+
when(caseDetails.getCaseData()).thenReturn(asylumCase);
55+
when(dateProvider.now()).thenReturn(now);
56+
57+
PreSubmitCallbackResponse<AsylumCase> response =
58+
completeCaseReviewHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback);
59+
60+
assertNotNull(response);
61+
assertEquals(asylumCase, response.getData());
62+
verify(asylumCase).write(COMPLETE_CASE_REVIEW_DATE, "2026-03-03");
63+
}
64+
65+
@Test
66+
void handling_should_throw_if_cannot_actually_handle() {
67+
68+
assertThatThrownBy(
69+
() -> completeCaseReviewHandler.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback))
70+
.hasMessage("Cannot handle callback")
71+
.isExactlyInstanceOf(IllegalStateException.class);
72+
73+
when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION);
74+
assertThatThrownBy(
75+
() -> completeCaseReviewHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback))
76+
.hasMessage("Cannot handle callback")
77+
.isExactlyInstanceOf(IllegalStateException.class);
78+
}
79+
80+
@Test
81+
void it_can_handle_callback() {
82+
83+
for (Event event : Event.values()) {
84+
85+
when(callback.getEvent()).thenReturn(event);
86+
87+
for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) {
88+
89+
boolean canHandle = completeCaseReviewHandler.canHandle(callbackStage, callback);
90+
91+
if (event == Event.COMPLETE_CASE_REVIEW
92+
&& callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT) {
93+
94+
assertTrue(canHandle);
95+
} else {
96+
assertFalse(canHandle);
97+
}
98+
}
99+
100+
reset(callback);
101+
}
102+
}
103+
104+
@Test
105+
void should_not_allow_null_arguments() {
106+
107+
assertThatThrownBy(() -> completeCaseReviewHandler.canHandle(null, callback))
108+
.hasMessage("callbackStage must not be null")
109+
.isExactlyInstanceOf(NullPointerException.class);
110+
111+
assertThatThrownBy(
112+
() -> completeCaseReviewHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null))
113+
.hasMessage("callback must not be null")
114+
.isExactlyInstanceOf(NullPointerException.class);
115+
116+
assertThatThrownBy(() -> completeCaseReviewHandler.handle(null, callback))
117+
.hasMessage("callbackStage must not be null")
118+
.isExactlyInstanceOf(NullPointerException.class);
119+
120+
assertThatThrownBy(() -> completeCaseReviewHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null))
121+
.hasMessage("callback must not be null")
122+
.isExactlyInstanceOf(NullPointerException.class);
123+
}
124+
}

src/test/java/uk/gov/hmcts/reform/iacaseapi/domain/handlers/presubmit/DirectionHandlerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.SEND_DIRECTION_EXPLANATION;
1919
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.SEND_DIRECTION_PARTIES;
2020

21+
2122
import com.google.common.collect.Sets;
2223
import java.util.ArrayList;
2324
import java.util.List;

0 commit comments

Comments
 (0)