-
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-7427 Internal upload additional evidence doc generation (#695)
* RIA-7427 Internal upload additional evidence doc generation * RIA-7427 Test and checkstyle fixes
- Loading branch information
1 parent
e91fffa
commit 53320c0
Showing
16 changed files
with
574 additions
and
3 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...onalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-ada.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,44 @@ | ||
{ | ||
"description": "RIA-7427 Internal upload addendum evidence letter PDF - ADA", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "AdminOfficer", | ||
"input": { | ||
"eventId": "uploadAddendumEvidenceAdminOfficer", | ||
"state": "decision", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "Yes" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "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-additional-evidence-uploaded-letter.PDF" | ||
}, | ||
"description": "", | ||
"dateUploaded": "{$TODAY}", | ||
"tag": "internalUploadAdditionalEvidenceLetter" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...Test/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-non-ada.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,44 @@ | ||
{ | ||
"description": "RIA-7427 Internal upload addendum evidence letter PDF - ADA", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "AdminOfficer", | ||
"input": { | ||
"eventId": "uploadAddendumEvidenceAdminOfficer", | ||
"state": "decision", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "No" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "No", | ||
"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-additional-evidence-uploaded-letter.PDF" | ||
}, | ||
"description": "", | ||
"dateUploaded": "{$TODAY}", | ||
"tag": "internalUploadAdditionalEvidenceLetter" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...alTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-ada.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,44 @@ | ||
{ | ||
"description": "RIA-7427 Internal upload additional evidence letter PDF - ADA", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "AdminOfficer", | ||
"input": { | ||
"eventId": "uploadAdditionalEvidence", | ||
"state": "caseBuilding", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "Yes" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "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-additional-evidence-uploaded-letter.PDF" | ||
}, | ||
"description": "", | ||
"dateUploaded": "{$TODAY}", | ||
"tag": "internalUploadAdditionalEvidenceLetter" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...st/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-non-ada.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,44 @@ | ||
{ | ||
"description": "RIA-7427 Internal upload additional evidence letter PDF - ADA", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "AdminOfficer", | ||
"input": { | ||
"eventId": "uploadAdditionalEvidence", | ||
"state": "caseBuilding", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "Yes" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"isAcceleratedDetainedAppeal": "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-additional-evidence-uploaded-letter.PDF" | ||
}, | ||
"description": "", | ||
"dateUploaded": "{$TODAY}", | ||
"tag": "internalUploadAdditionalEvidenceLetter" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
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
78 changes: 78 additions & 0 deletions
78
...umentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGenerator.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,78 @@ | ||
package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; | ||
|
||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event.UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event.UPLOAD_ADDITIONAL_EVIDENCE; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAppellantInDetention; | ||
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
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 InternalUploadAdditionalEvidenceGenerator implements PreSubmitCallbackHandler<AsylumCase> { | ||
|
||
private final DocumentCreator<AsylumCase> documentCreator; | ||
private final DocumentHandler documentHandler; | ||
|
||
public InternalUploadAdditionalEvidenceGenerator( | ||
@Qualifier("internalUploadAdditionalEvidenceLetter") DocumentCreator<AsylumCase> documentCreator, | ||
DocumentHandler documentHandler | ||
) { | ||
this.documentCreator = documentCreator; | ||
this.documentHandler = documentHandler; | ||
} | ||
|
||
public boolean canHandle( | ||
PreSubmitCallbackStage callbackStage, | ||
Callback<AsylumCase> callback | ||
) { | ||
Objects.requireNonNull(callbackStage, "callbackStage must not be null"); | ||
Objects.requireNonNull(callback, "callback must not be null"); | ||
|
||
AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); | ||
|
||
Event event = callback.getEvent(); | ||
|
||
return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT | ||
&& List.of(UPLOAD_ADDITIONAL_EVIDENCE, UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER).contains(event) | ||
&& 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 internalUploadAdditionalEvidenceLetter = documentCreator.create(caseDetails); | ||
|
||
documentHandler.addWithMetadataWithoutReplacingExistingDocuments( | ||
asylumCase, | ||
internalUploadAdditionalEvidenceLetter, | ||
NOTIFICATION_ATTACHMENT_DOCUMENTS, | ||
DocumentTag.INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_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
48 changes: 48 additions & 0 deletions
48
...edocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplate.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,48 @@ | ||
package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; | ||
|
||
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.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 InternalUploadAdditionalEvidenceLetterTemplate implements DocumentTemplate<AsylumCase> { | ||
|
||
private final String templateName; | ||
private final CustomerServicesProvider customerServicesProvider; | ||
|
||
public InternalUploadAdditionalEvidenceLetterTemplate( | ||
@Value("${internalUploadAdditionalEvidence.templateName}") String templateName, | ||
CustomerServicesProvider customerServicesProvider) { | ||
this.templateName = templateName; | ||
this.customerServicesProvider = customerServicesProvider; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return templateName; | ||
} | ||
|
||
public Map<String, Object> mapFieldValues( | ||
CaseDetails<AsylumCase> caseDetails | ||
) { | ||
final AsylumCase asylumCase = caseDetails.getCaseData(); | ||
|
||
final Map<String, Object> fieldValues = new HashMap<>(); | ||
|
||
fieldValues.putAll(getAppellantPersonalisation(asylumCase)); | ||
fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); | ||
fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); | ||
fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); | ||
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
Oops, something went wrong.