Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -1,5 +1,5 @@
{
"description": "DIAC-1461 Update Case Mark Detained",
"description": "DIAC-1461 Update Case Mark Detained AiP Digital",

"request": {
"uri": "/asylum/ccdAboutToSubmit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "DIAC-1461 Update Case Mark Detained Other",
"description": "DIAC-1461 Update Case Mark Detained Other AiP Digital",

"request": {
"uri": "/asylum/ccdAboutToSubmit",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"description": "DIAC-1531 Update Case Mark Detained Legally Represented - Manual",

"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "AdminOfficer",
"input": {
"eventId": "markAppealAsDetained",
"state": "appealSubmitted",
"caseData": {
"template": "minimal-appeal-submitted.json",
"replacements": {
"prisonNOMSNumberAo": {
"prison": "123456"
},
"dateCustodialSentenceAo": {
"custodialDate": "2025-01-01"
},
"detentionFacility": "immigrationRemovalCentre",
"appellantAddress": {
"AddressLine1": "123 Main Street",
"AddressLine2": "Flat 1",
"PostTown": "London",
"County": "Greater London",
"PostCode": "E1 6AN"
},
"appellantHasFixedAddress": "Yes",
"contactPreference": "wantsEmail",
"email": "test@test.com",
"mobileNumber": "07444445555",
"detentionRemovalReason": "some reason",
"detentionRemovalDate": "2025-01-02",
"journeyType": null,
"appellantInDetention": "No",
"isAdmin": "Yes",
"appellantsRepresentation": "No"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-appeal-submitted.json",
"replacements": {
"appealType": "protection",
"sendDirectionActionAvailable": "Yes",
"mobileNumber": null,
"prisonNOMSNumber": {
"prison": "123456"
},
"releaseDate": {
"custodialDate": "2025-01-01"
},
"appellantAddress": null,
"appellantHasFixedAddress": null,
"contactPreference": null,
"email": null,
"mobileNumber": null,
"detentionRemovalReason": null,
"detentionRemovalDate": null,
"journeyType": null,
"appellantInDetention": "Yes",
"isAdmin": "Yes",
"appellantsRepresentation": "No",
"appellantLevelFlags": {
"partyName": null,
"roleOnCase": null,
"details": [
{
"id": "$/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-Ff]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/",
"value": {
"name": "Detained individual",
"flagCode": "PF0019",
"status": "Active",
"hearingRelevant": "Yes"
}
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"description": "DIAC-1531 Update Case Mark Detained Legally Represented",

"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "AdminOfficer",
"input": {
"eventId": "markAppealAsDetained",
"state": "appealSubmitted",
"caseData": {
"template": "minimal-appeal-submitted.json",
"replacements": {
"prisonNOMSNumberAo": {
"prison": "123456"
},
"dateCustodialSentenceAo": {
"custodialDate": "2025-01-01"
},
"detentionFacility": "immigrationRemovalCentre",
"appellantAddress": {
"AddressLine1": "123 Main Street",
"AddressLine2": "Flat 1",
"PostTown": "London",
"County": "Greater London",
"PostCode": "E1 6AN"
},
"appellantHasFixedAddress": "Yes",
"contactPreference": "wantsEmail",
"email": "test@test.com",
"mobileNumber": "07444445555",
"detentionRemovalReason": "some reason",
"detentionRemovalDate": "2025-01-02",
"journeyType": null,
"appellantInDetention": "No",
"isAdmin": "No",
"appellantsRepresentation": "No"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-appeal-submitted.json",
"replacements": {
"appealType": "protection",
"sendDirectionActionAvailable": "Yes",
"mobileNumber": null,
"prisonNOMSNumber": {
"prison": "123456"
},
"releaseDate": {
"custodialDate": "2025-01-01"
},
"appellantAddress": null,
"appellantHasFixedAddress": null,
"contactPreference": null,
"email": null,
"mobileNumber": null,
"detentionRemovalReason": null,
"detentionRemovalDate": null,
"journeyType": null,
"appellantInDetention": "Yes",
"isAdmin": "No",
"appellantsRepresentation": "No",
"appellantLevelFlags": {
"partyName": null,
"roleOnCase": null,
"details": [
{
"id": "$/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-Ff]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/",
"value": {
"name": "Detained individual",
"flagCode": "PF0019",
"status": "Active",
"hearingRelevant": "Yes"
}
}
]
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.DetentionFacility.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event.MARK_APPEAL_AS_DETAINED;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.YesOrNo.YES;
import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isAipJourney;

import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
Expand Down Expand Up @@ -63,11 +64,14 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
asylumCase.clear(MOBILE_NUMBER);
asylumCase.clear(DETENTION_REMOVAL_REASON);
asylumCase.clear(DETENTION_REMOVAL_DATE);
asylumCase.clear(JOURNEY_TYPE);

asylumCase.write(APPELLANT_IN_DETENTION, YES);
asylumCase.write(IS_ADMIN, YES);
asylumCase.write(APPELLANTS_REPRESENTATION, YES);

if (isAipJourney(asylumCase)) {
asylumCase.clear(JOURNEY_TYPE);
asylumCase.write(IS_ADMIN, YES);
asylumCase.write(APPELLANTS_REPRESENTATION, YES);
}

return new PreSubmitCallbackResponse<>(asylumCase);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.*;
Expand All @@ -27,6 +28,7 @@
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackResponse;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.field.JourneyType;

@MockitoSettings(strictness = Strictness.LENIENT)
@ExtendWith(MockitoExtension.class)
Expand Down Expand Up @@ -71,13 +73,48 @@ void should_mark_appeal_as_detained_and_update_case_data() {
verify(asylumCase).write(PRISON_NOMS, prisonNomsNumber);
verify(asylumCase).write(DATE_CUSTODIAL_SENTENCE, custodialSentenceDate);
verify(asylumCase).write(APPELLANT_IN_DETENTION, YES);
verify(asylumCase).write(IS_ADMIN, YES);
verify(asylumCase).write(APPELLANTS_REPRESENTATION, YES);
verify(asylumCase).clear(APPELLANT_HAS_FIXED_ADDRESS);
verify(asylumCase).clear(APPELLANT_ADDRESS);
verify(asylumCase).clear(CONTACT_PREFERENCE);
verify(asylumCase).clear(EMAIL);
verify(asylumCase).clear(MOBILE_NUMBER);

// aip only assertions
verify(asylumCase, times(0)).write(IS_ADMIN, YES);
verify(asylumCase, times(0)).write(APPELLANTS_REPRESENTATION, YES);
verify(asylumCase, times(0)).clear(JOURNEY_TYPE);
}

@Test
void should_mark_appeal_as_detained_and_update_case_data_aip() {
when(callback.getCaseDetails()).thenReturn(caseDetails);
when(caseDetails.getCaseData()).thenReturn(asylumCase);
when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_AS_DETAINED);

when(asylumCase.read(PRISON_NOMS_AO, PrisonNomsNumber.class)).thenReturn(Optional.of(prisonNomsNumber));
when(asylumCase.read(DATE_CUSTODIAL_SENTENCE_AO, CustodialSentenceDate.class))
.thenReturn(Optional.of(custodialSentenceDate));
when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of("prison"));
when(asylumCase.read(JOURNEY_TYPE, JourneyType.class)).thenReturn(Optional.of(JourneyType.AIP));

PreSubmitCallbackResponse<AsylumCase> callbackResponse =
markAppealAsDetainedHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback);

assertNotNull(callbackResponse);
assertEquals(asylumCase, callbackResponse.getData());

verify(asylumCase).write(PRISON_NOMS, prisonNomsNumber);
verify(asylumCase).write(DATE_CUSTODIAL_SENTENCE, custodialSentenceDate);
verify(asylumCase).write(APPELLANT_IN_DETENTION, YES);
verify(asylumCase).clear(APPELLANT_HAS_FIXED_ADDRESS);
verify(asylumCase).clear(APPELLANT_ADDRESS);
verify(asylumCase).clear(CONTACT_PREFERENCE);
verify(asylumCase).clear(EMAIL);
verify(asylumCase).clear(MOBILE_NUMBER);

// aip only assertions
verify(asylumCase).write(IS_ADMIN, YES);
verify(asylumCase).write(APPELLANTS_REPRESENTATION, YES);
verify(asylumCase).clear(JOURNEY_TYPE);
}

Expand Down