-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RIA-7701 Added transfer out of ADA letter
- Loading branch information
Showing
13 changed files
with
471 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...tionalTest/resources/scenarios/RIA-7701-internal-detained-transfer-out-of-ada-letter.json
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,48 @@ | ||
{ | ||
"description": "RIA-7701 Internal detained transfer out of ada letter", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "CaseOfficer", | ||
"input": { | ||
"eventId": "transferOutOfAda", | ||
"state": "appealSubmitted", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"transferOutOfAdaReason": "Determined unsuitable following Suitability Assessment", | ||
"transferOutOfAdaMoreDetails": "More transfer out of ADA details", | ||
"isAcceleratedDetainedAppeal": "No", | ||
"appellantInDetention": "Yes" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"transferOutOfAdaReason": "Determined unsuitable following Suitability Assessment", | ||
"transferOutOfAdaMoreDetails": "More transfer out of ADA details", | ||
"isAcceleratedDetainedAppeal": "No", | ||
"appellantInDetention": "Yes", | ||
"notificationAttachmentDocuments": [ | ||
{ | ||
"id": "1", | ||
"value": { | ||
"document": { | ||
"document_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/", | ||
"document_binary_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/binary/", | ||
"document_filename": "PA 12345 2019-Awan-detained-appellant-transferred-out-of-ada.PDF" | ||
}, | ||
"description": "", | ||
"dateUploaded": "{$TODAY}", | ||
"tag": "internalDetainedTransferOutOfAdaLetter" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
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
76 changes: 76 additions & 0 deletions
76
...i/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGenerator.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,76 @@ | ||
package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAppellantInDetention; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; | ||
|
||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.Callback; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackResponse; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.PreSubmitCallbackHandler; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; | ||
|
||
@Component | ||
public class InternalDetainedTransferOutOfAdaDocumentGenerator implements PreSubmitCallbackHandler<AsylumCase> { | ||
|
||
private final DocumentCreator<AsylumCase> internalDetainedTransferOutOfAdaLetterCreator; | ||
private final DocumentHandler documentHandler; | ||
|
||
public InternalDetainedTransferOutOfAdaDocumentGenerator( | ||
@Qualifier("internalDetainedTransferOutOfAdaLetter") DocumentCreator<AsylumCase> internalDetainedTransferOutOfAdaLetterCreator, | ||
DocumentHandler documentHandler | ||
) { | ||
this.internalDetainedTransferOutOfAdaLetterCreator = internalDetainedTransferOutOfAdaLetterCreator; | ||
this.documentHandler = documentHandler; | ||
} | ||
|
||
public boolean canHandle( | ||
PreSubmitCallbackStage callbackStage, | ||
Callback<AsylumCase> callback | ||
) { | ||
requireNonNull(callbackStage, "callbackStage must not be null"); | ||
requireNonNull(callback, "callback must not be null"); | ||
|
||
AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); | ||
|
||
return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT | ||
&& callback.getEvent() == Event.TRANSFER_OUT_OF_ADA | ||
&& isInternalCase(asylumCase) | ||
&& isAppellantInDetention(asylumCase); | ||
} | ||
|
||
public PreSubmitCallbackResponse<AsylumCase> handle( | ||
PreSubmitCallbackStage callbackStage, | ||
Callback<AsylumCase> callback | ||
) { | ||
if (!canHandle(callbackStage, callback)) { | ||
throw new IllegalStateException("Cannot handle callback"); | ||
} | ||
|
||
final CaseDetails<AsylumCase> caseDetails = callback.getCaseDetails(); | ||
final AsylumCase asylumCase = caseDetails.getCaseData(); | ||
|
||
Document internalDetainedTransferOutOfAdaDocument = | ||
internalDetainedTransferOutOfAdaLetterCreator.create(caseDetails); | ||
|
||
documentHandler.addWithMetadata( | ||
asylumCase, | ||
internalDetainedTransferOutOfAdaDocument, | ||
NOTIFICATION_ATTACHMENT_DOCUMENTS, | ||
DocumentTag.INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER | ||
); | ||
|
||
return new PreSubmitCallbackResponse<>(asylumCase); | ||
} | ||
} | ||
|
||
|
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
52 changes: 52 additions & 0 deletions
52
.../iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplate.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,52 @@ | ||
package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; | ||
|
||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.TRANSFER_OUT_OF_ADA_MORE_DETAILS; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.TRANSFER_OUT_OF_ADA_REASON; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; | ||
|
||
import java.time.LocalDate; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; | ||
import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; | ||
|
||
@Component | ||
public class InternalDetainedTransferOutOfAdaTemplate implements DocumentTemplate<AsylumCase> { | ||
|
||
private final String templateName; | ||
private final CustomerServicesProvider customerServicesProvider; | ||
|
||
public InternalDetainedTransferOutOfAdaTemplate( | ||
@Value("${internalDetainedTransferOutOfAdaLetter.templateName}") String templateName, | ||
CustomerServicesProvider customerServicesProvider) { | ||
this.templateName = templateName; | ||
this.customerServicesProvider = customerServicesProvider; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return templateName; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> mapFieldValues( | ||
CaseDetails<AsylumCase> caseDetails | ||
) { | ||
final AsylumCase asylumCase = caseDetails.getCaseData(); | ||
|
||
final Map<String, Object> fieldValues = new HashMap<>(getAppellantPersonalisation(asylumCase)); | ||
fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); | ||
fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); | ||
fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); | ||
fieldValues.put("transferOutOfAdaReason", asylumCase.read(TRANSFER_OUT_OF_ADA_REASON, String.class) | ||
.orElseThrow(() -> new RequiredFieldMissingException("Transfer out of ADA reason is not present"))); | ||
fieldValues.put("transferOutOfAdaMoreDetails", asylumCase.read(TRANSFER_OUT_OF_ADA_MORE_DETAILS, String.class).orElse("")); | ||
return fieldValues; | ||
} | ||
} |
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
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
Oops, something went wrong.