diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index c7ca183c6..112c14ee6 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -44,7 +44,16 @@ def secrets = [ secret('customer-services-email', 'IA_CUSTOMER_SERVICES_EMAIL'), secret('gov-call-charges-url', 'IA_BAIL_GOV_CALL_CHARGES_URL'), - secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS') + secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS'), + + secret('system-username', 'IA_SYSTEM_USERNAME'), + secret('system-password', 'IA_SYSTEM_PASSWORD'), + + secret('test-homeoffice-lart-username', 'TEST_HOMEOFFICE_LART_USERNAME'), + secret('test-homeoffice-lart-password', 'TEST_HOMEOFFICE_LART_PASSWORD'), + + secret('test-homeoffice-pou-username', 'TEST_HOMEOFFICE_POU_USERNAME'), + secret('test-homeoffice-pou-password', 'TEST_HOMEOFFICE_POU_PASSWORD') ] ] diff --git a/Jenkinsfile_nightly b/Jenkinsfile_nightly index 01fe4a2b2..221312386 100644 --- a/Jenkinsfile_nightly +++ b/Jenkinsfile_nightly @@ -26,37 +26,46 @@ def product = "ia" def component = "case-documents-api" def secrets = [ - 'ia-${env}': [ - - secret('test-caseofficer-username', 'TEST_CASEOFFICER_USERNAME'), - secret('test-caseofficer-password', 'TEST_CASEOFFICER_PASSWORD'), - secret('test-law-firm-a-username', 'TEST_LAW_FIRM_A_USERNAME'), - secret('test-law-firm-a-password', 'TEST_LAW_FIRM_A_PASSWORD'), - secret('test-citizen-username', 'TEST_CITIZEN_USERNAME'), - secret('test-citizen-password', 'TEST_CITIZEN_PASSWORD'), - secret('test-adminofficer-username', 'TEST_ADMINOFFICER_USERNAME'), - secret('test-adminofficer-password', 'TEST_ADMINOFFICER_PASSWORD'), - - secret('test-judge-x-username', 'TEST_JUDGE_X_USERNAME'), - secret('test-judge-x-password', 'TEST_JUDGE_X_PASSWORD'), - secret('system-username', 'SYSTEM_USERNAME'), - secret('system-password', 'SYSTEM_PASSWORD'), - - secret('idam-client-id', 'IA_IDAM_CLIENT_ID'), - secret('idam-secret', 'IA_IDAM_SECRET'), - secret('s2s-secret', 'IA_S2S_SECRET'), - secret('s2s-microservice', 'IA_S2S_MICROSERVICE'), - secret('launch-darkly-sdk-key', 'LAUNCH_DARKLY_SDK_KEY'), - secret('ia-config-validator-secret', 'IA_CONFIG_VALIDATOR_SECRET'), - - secret('app-insights-connection-string', 'app-insights-connection-string'), - - secret('customer-services-telephone', 'IA_CUSTOMER_SERVICES_TELEPHONE'), - secret('customer-services-email', 'IA_CUSTOMER_SERVICES_EMAIL'), - secret('gov-call-charges-url', 'IA_BAIL_GOV_CALL_CHARGES_URL'), - - secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS') - ] + 'ia-${env}': [ + + secret('test-caseofficer-username', 'TEST_CASEOFFICER_USERNAME'), + secret('test-caseofficer-password', 'TEST_CASEOFFICER_PASSWORD'), + secret('test-law-firm-a-username', 'TEST_LAW_FIRM_A_USERNAME'), + secret('test-law-firm-a-password', 'TEST_LAW_FIRM_A_PASSWORD'), + secret('test-citizen-username', 'TEST_CITIZEN_USERNAME'), + secret('test-citizen-password', 'TEST_CITIZEN_PASSWORD'), + secret('test-adminofficer-username', 'TEST_ADMINOFFICER_USERNAME'), + secret('test-adminofficer-password', 'TEST_ADMINOFFICER_PASSWORD'), + + secret('test-judge-x-username', 'TEST_JUDGE_X_USERNAME'), + secret('test-judge-x-password', 'TEST_JUDGE_X_PASSWORD'), + secret('system-username', 'SYSTEM_USERNAME'), + secret('system-password', 'SYSTEM_PASSWORD'), + + secret('idam-client-id', 'IA_IDAM_CLIENT_ID'), + secret('idam-secret', 'IA_IDAM_SECRET'), + secret('s2s-secret', 'IA_S2S_SECRET'), + secret('s2s-microservice', 'IA_S2S_MICROSERVICE'), + secret('launch-darkly-sdk-key', 'LAUNCH_DARKLY_SDK_KEY'), + secret('ia-config-validator-secret', 'IA_CONFIG_VALIDATOR_SECRET'), + + secret('app-insights-connection-string', 'app-insights-connection-string'), + + secret('customer-services-telephone', 'IA_CUSTOMER_SERVICES_TELEPHONE'), + secret('customer-services-email', 'IA_CUSTOMER_SERVICES_EMAIL'), + secret('gov-call-charges-url', 'IA_BAIL_GOV_CALL_CHARGES_URL'), + + secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS'), + + secret('system-username', 'IA_SYSTEM_USERNAME'), + secret('system-password', 'IA_SYSTEM_PASSWORD'), + + secret('test-homeoffice-lart-username', 'TEST_HOMEOFFICE_LART_USERNAME'), + secret('test-homeoffice-lart-password', 'TEST_HOMEOFFICE_LART_PASSWORD'), + + secret('test-homeoffice-pou-username', 'TEST_HOMEOFFICE_POU_USERNAME'), + secret('test-homeoffice-pou-password', 'TEST_HOMEOFFICE_POU_PASSWORD') + ] ] static LinkedHashMap secret(String secretName, String envVar) { @@ -191,6 +200,40 @@ withNightlyPipeline(type, product, component) { steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*' } + before('fullFunctionalTest') { + try { + builder.gradle('smoke') + builder.gradle('test') + builder.gradle('integration') + } finally { + publishHTML target: [ + allowMissing : true, + alwaysLinkToLastBuild: true, + keepAll : true, + reportDir : "build/reports/tests/test", + reportFiles : "index.html", + reportName : "Unit Test Report" + ] + publishHTML target: [ + allowMissing : true, + alwaysLinkToLastBuild: true, + keepAll : true, + reportDir : "build/reports/tests/smoke", + reportFiles : "index.html", + reportName : "Smoke Test Report" + ] + publishHTML target: [ + allowMissing : true, + alwaysLinkToLastBuild: true, + keepAll : true, + reportDir : "build/reports/tests/integration", + reportFiles : "index.html", + reportName : "Integration Test Report" + ] + junit '**/test-results/**/*.xml' + } + } + afterAlways('mutationTest') { publishHTML([ allowMissing : true, diff --git a/Jenkinsfile_parameterized b/Jenkinsfile_parameterized index 4afd5d159..e0c833ee1 100644 --- a/Jenkinsfile_parameterized +++ b/Jenkinsfile_parameterized @@ -42,6 +42,12 @@ def secrets = [ secret('gov-call-charges-url', 'IA_BAIL_GOV_CALL_CHARGES_URL'), secret('generic-docker-pact-broker-password', 'GENERIC_DOCKER_PACT_BROKER_YAML_PASS') + + secret('test-homeoffice-lart-username', 'TEST_HOMEOFFICE_LART_USERNAME'), + secret('test-homeoffice-lart-password', 'TEST_HOMEOFFICE_LART_PASSWORD'), + + secret('test-homeoffice-pou-username', 'TEST_HOMEOFFICE_POU_USERNAME'), + secret('test-homeoffice-pou-password', 'TEST_HOMEOFFICE_POU_PASSWORD') ] ] diff --git a/build.gradle b/build.gradle index 9d7ff686b..0a400affd 100644 --- a/build.gradle +++ b/build.gradle @@ -143,7 +143,7 @@ idea { configurations { integrationTestCompile.extendsFrom testImplementation integrationTestRuntime.extendsFrom testRuntime - functionalTestCompile.extendsFrom testImplementation + functionalTestImplementation.extendsFrom testImplementation contractTestImplementation.extendsFrom testImplementation functionalTestRuntime.extendsFrom testRuntime } @@ -174,12 +174,16 @@ task integration(type: Test, description: 'Runs the integration tests.', group: task functional(type: Test, description: 'Runs the functional tests.', group: 'Verification') { systemProperty "scenario", System.getProperty('scenario') + systemProperty "file.encoding", "UTF-8" testClassesDirs = sourceSets.functionalTest.output.classesDirs classpath = sourceSets.functionalTest.runtimeClasspath finalizedBy aggregate testLogging { showStackTraces = true + showStandardStreams = true + showCauses = true + showExceptions = true } } @@ -352,6 +356,7 @@ dependencies { implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14' + implementation group: 'com.github.hmcts', name: 'ccd-case-document-am-client', version: '1.7.3' implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.87' implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-websocket', version: '9.0.87' diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml index 225f209b1..c7ca335df 100644 --- a/config/owasp/suppressions.xml +++ b/config/owasp/suppressions.xml @@ -6,7 +6,7 @@ using HttpInvokerServiceExport and org.springframework.remoting. As we don't use those constructs, we are not affected by it. The suppression will be a long-term one. An expiry to the suppression is kept to allow re-evaluating whether - we're still unaffected by it. + we are still unaffected by it. ]]> CVE-2016-1000027 diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/CcdScenarioRunnerTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/CcdScenarioRunnerTest.java index 697ea0c55..f6cf6883c 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/CcdScenarioRunnerTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/CcdScenarioRunnerTest.java @@ -11,11 +11,7 @@ import io.restassured.http.Headers; import java.io.IOException; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @@ -88,8 +84,8 @@ public void scenarios_should_behave_as_specified() throws IOException { } assertFalse( - "Verifiers are configured", - verifiers.isEmpty() + "Verifiers are configured", + verifiers.isEmpty() ); String scenarioPattern = System.getProperty("scenario"); @@ -99,20 +95,18 @@ public void scenarios_should_behave_as_specified() throws IOException { scenarioPattern = "*" + scenarioPattern + "*.json"; } - Map scenarioSources = - StringResourceLoader - .load("/scenarios/" + scenarioPattern); - - //Adding Bail functional tests - scenarioSources.putAll(StringResourceLoader - .load("/scenarios/bail/" + scenarioPattern)); + Collection scenarioSources = new ArrayList<>(); + scenarioSources.addAll(StringResourceLoader.load("/scenarios/" + scenarioPattern).values()); + scenarioSources.addAll(StringResourceLoader.load("/scenarios/bail/" + scenarioPattern).values()); System.out.println((char) 27 + "[36m" + "-------------------------------------------------------------------"); System.out.println((char) 27 + "[33m" + "RUNNING " + scenarioSources.size() + " SCENARIOS"); System.out.println((char) 27 + "[36m" + "-------------------------------------------------------------------"); - for (String scenarioSource : scenarioSources.values()) { - final int maxRetries = 3; + List runScenarios = new ArrayList<>(); + int maxRetries = 3; + for (String scenarioSource : scenarioSources) { + for (int i = 0; i < maxRetries; i++) { String description = ""; @@ -191,6 +185,7 @@ public void scenarios_should_behave_as_specified() throws IOException { actualResponse ) ); + runScenarios.add(description); break; } catch (Error | RetryableException e) { System.out.println("Scenario failed with error " + e.getMessage()); @@ -202,6 +197,10 @@ public void scenarios_should_behave_as_specified() throws IOException { } } + System.out.println((char) 27 + "[36m" + "-------------------------------------------------------------------"); + List scenariosThatHaveRun = runScenarios.stream().distinct().toList(); + System.out.println((char) 27 + "[" + scenariosThatHaveRun.size() + " SCENARIOS HAVE RUN]"); + System.out.println(String.join(";\n", scenariosThatHaveRun)); System.out.println((char) 27 + "[36m" + "-------------------------------------------------------------------"); if (!haveAllPassed) { throw new AssertionError("Not all scenarios passed.\nFailed scenarios are:\n" + failedScenarios.stream().map(Object::toString).collect(Collectors.joining(";\n"))); @@ -367,6 +366,7 @@ private Headers getAuthorizationHeaders(Map scenario) { return authorizationHeadersProvider .getHomeOfficeLartAuthorization(); + } if ("HomeOfficePOU".equalsIgnoreCase(credentials)) { diff --git a/src/functionalTest/resources/scenarios/RIA-3132-ftpa-reheard-send-decisions-and-reasons.json b/src/functionalTest/resources/scenarios/RIA-3132-ftpa-reheard-send-decisions-and-reasons.json index 1319c6a77..704d80d5f 100644 --- a/src/functionalTest/resources/scenarios/RIA-3132-ftpa-reheard-send-decisions-and-reasons.json +++ b/src/functionalTest/resources/scenarios/RIA-3132-ftpa-reheard-send-decisions-and-reasons.json @@ -1,5 +1,6 @@ { "description": "RIA-3132 Send decision and reasons - FTPA reheard", + "disabled": "true", "request": { "uri": "/asylum/ccdAboutToSubmit", "credentials": "CaseOfficer", diff --git a/src/functionalTest/resources/scenarios/RIA-3683-reheard-hearing-notice-document-iac-birmingham.json b/src/functionalTest/resources/scenarios/RIA-3683-reheard-hearing-notice-document-iac-birmingham.json index 2b778c543..a8a76ddc8 100644 --- a/src/functionalTest/resources/scenarios/RIA-3683-reheard-hearing-notice-document-iac-birmingham.json +++ b/src/functionalTest/resources/scenarios/RIA-3683-reheard-hearing-notice-document-iac-birmingham.json @@ -1,5 +1,6 @@ { "description": "RIA-3683 Create reheard hearing notice PDF (IAC Birmingham) - FTPA reheard case", + "disabled": "true", "request": { "uri": "/asylum/ccdAboutToSubmit", "credentials": "AdminOfficer", diff --git a/src/functionalTest/resources/scenarios/RIA-587-RIA-2804-hearing-requirements-request-document.json b/src/functionalTest/resources/scenarios/RIA-587-RIA-2804-hearing-requirements-request-document.json index c7633b737..e484c304f 100644 --- a/src/functionalTest/resources/scenarios/RIA-587-RIA-2804-hearing-requirements-request-document.json +++ b/src/functionalTest/resources/scenarios/RIA-587-RIA-2804-hearing-requirements-request-document.json @@ -36,7 +36,6 @@ "physicalOrMentalHealthIssuesDescription": "Physical or mental health issues description", "pastExperiences": "Yes", "pastExperiencesDescription": "Past experiences", - "isOutOfCountryEnabled": "Yes", "remoteVideoCall": "Yes", "remoteVideoCallDescription": "Remote video call description", "multimediaEvidence": "Yes", @@ -99,7 +98,6 @@ "physicalOrMentalHealthIssuesDescription": "Physical or mental health issues description", "pastExperiences": "Yes", "pastExperiencesDescription": "Past experiences", - "isOutOfCountryEnabled": "Yes", "remoteVideoCall": "Yes", "remoteVideoCallDescription": "Remote video call description", "multimediaEvidence": "Yes", diff --git a/src/functionalTest/resources/scenarios/RIA-6605-ada-suitability-document.json b/src/functionalTest/resources/scenarios/RIA-6605-ada-suitability-document.json new file mode 100644 index 000000000..43bdf0c12 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-6605-ada-suitability-document.json @@ -0,0 +1,43 @@ +{ + "description": "RIA-6605 ADA suitability document - Created", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "adaSuitabilityReview", + "state": "respondentReview", + "caseData": { + "template": "minimal-appeal-started.json", + "replacements": { + "suitabilityReviewJudge": "Judge x", + "suitabilityReviewDecision": "suitable", + "suitabilityReviewReason": "Reason1" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-started.json", + "replacements": { + "tribunalDocuments": [ + { + "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": "DRAFT-Awan-ADA-suitability-decision.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "adaSuitability" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-6612-customise-hearing-bundle-with-ada-suitability-preparer.json b/src/functionalTest/resources/scenarios/RIA-6612-customise-hearing-bundle-with-ada-suitability-preparer.json new file mode 100644 index 000000000..2389fae5f --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-6612-customise-hearing-bundle-with-ada-suitability-preparer.json @@ -0,0 +1,279 @@ +{ + "description": "RIA-6612-customise-hearing-ready-bundle-preparer-with Tribunal Document (Ada Suitabilty)", + "enabled": "{$featureFlag.isEmStitchingEnabled}", + "request": { + "uri": "/asylum/ccdAboutToStart", + "credentials": "CaseOfficer", + "input": { + "eventId": "customiseHearingBundle", + "state": "preHearing", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "suitabilityReviewDecision": "suitable", + "hearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "hearingNotice" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "caseSummary" + } + } + ], + "legalRepresentativeDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "caseSummary" + } + }, + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "caseArgument" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "appealSubmission" + } + } + ], + "additionalEvidenceDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "additionalEvidence" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "additionalEvidence" + } + } + ], + "respondentDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "respondentEvidence" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "respondentEvidence" + } + } + ], + "tribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "adaSuitability" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "customHearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + } + ], + "customLegalRepDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + } + ], + "customAdditionalEvidenceDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + } + ], + "customRespondentDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + } + ], + "customTribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-6612-generate-hearing-bundle-with-tribunal-documents-stitching-enabled.json b/src/functionalTest/resources/scenarios/RIA-6612-generate-hearing-bundle-with-tribunal-documents-stitching-enabled.json new file mode 100644 index 000000000..e86625f5c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-6612-generate-hearing-bundle-with-tribunal-documents-stitching-enabled.json @@ -0,0 +1,231 @@ +{ + "description": "RIA-6612 Generate hearing bundle with Tribunal Document (Ada Suitabilty) - stitching enabled", + "enabled": "{$featureFlag.isEmStitchingEnabled}", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "generateHearingBundle", + "state": "preHearing", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "suitabilityReviewDecision": "suitable", + "hearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "hearingNotice" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "caseSummary" + } + } + ], + "legalRepresentativeDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "caseArgument" + } + }, + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeDecisionLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "appealSubmission" + } + } + ], + "respondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "tribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "adaSuitability" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "hearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "hearingNotice" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "caseSummary" + } + } + ], + "legalRepresentativeDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "caseArgument" + } + }, + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeDecisionLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "appealSubmission" + } + } + ], + "respondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "tribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "adaSuitability" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-6612-generate-upper-tribunal-bundle-with-tribunal-documents-stitching-enabled.json b/src/functionalTest/resources/scenarios/RIA-6612-generate-upper-tribunal-bundle-with-tribunal-documents-stitching-enabled.json new file mode 100644 index 000000000..425544797 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-6612-generate-upper-tribunal-bundle-with-tribunal-documents-stitching-enabled.json @@ -0,0 +1,684 @@ +{ + "description": "RIA-6612 Generate Upper Tribunal bundle with Tribunal Document (Ada Suitabilty) - stitching enabled (Admin Officer)", + "enabled": "{$featureFlag.isEmStitchingEnabled}", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "generateUpperTribunalBundle", + "state": "ftpaDecided", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "suitabilityReviewDecision": "suitable", + "appAdditionalEvidenceDocs": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "additionalEvidence" + } + } + ], + "respAdditionalEvidenceDocs": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "additionalEvidence" + } + } + ], + "ftpaAppellantDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "ftpaAppellant" + } + } + ], + "ftpaRespondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "ftpaRespondent" + } + } + ], + "finalDecisionAndReasonsDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "decisionAndReasonsCoverLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "finalDecisionAndReasonsPdf" + } + } + ], + "hearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "hearingNotice" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "caseSummary" + } + } + ], + "legalRepresentativeDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "caseArgument" + } + }, + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeDecisionLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "appealSubmission" + } + } + ], + "respondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "addendumEvidenceDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "addendumEvidence" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "addendumEvidence" + } + } + ], + "tribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "adaSuitability" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "appAdditionalEvidenceDocs": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "additionalEvidence" + } + } + ], + "respAdditionalEvidenceDocs": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "additionalEvidence" + } + } + ], + "ftpaAppellantDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "ftpaAppellant" + } + } + ], + "ftpaRespondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "ftpaRespondent" + } + } + ], + "finalDecisionAndReasonsDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "decisionAndReasonsCoverLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "finalDecisionAndReasonsPdf" + } + } + ], + "hearingDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "hearingNotice" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "caseSummary" + } + } + ], + "legalRepresentativeDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "caseArgument" + } + }, + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeDecisionLetter" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "appealSubmission" + } + } + ], + "respondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "addendumEvidenceDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-7}", + "tag": "addendumEvidence" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY-14}", + "tag": "addendumEvidence" + } + } + ], + "tribunalDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "adaSuitability" + } + } + ], + "caseBundles": [ + { + "value": { + "id": "$/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/", + "title": "IAC Upper Tribunal Bundle", + "eligibleForStitching": "no", + "eligibleForCloning": "no", + "documents": [ + ], + "folders": [ + { + "value": { + "name": "FTPA Appellant documents", + "documents": [ + { + "value": { + "name": "doc1.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 0 + } + }, + { + "value": { + "name": "FTPA Respondent documents", + "documents": [ + { + "value": { + "name": "doc1.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 1 + } + }, + { + "value": { + "name": "Decisions and reasons documents", + "documents": [ + { + "value": { + "name": "doc2.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc2.pdf", + "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/" + } + } + }, + { + "value": { + "name": "doc1.pdf", + "sortIndex": 1, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 2 + } + }, + { + "value": { + "name": "Hearing documents", + "documents": [ + { + "value": { + "name": "doc2.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc2.pdf", + "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/" + } + } + }, + { + "value": { + "name": "doc1.pdf", + "sortIndex": 1, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 3 + } + }, + { + "value": { + "name": "Appellant documents", + "documents": [ + { + "value": { + "name": "doc3.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc3.pdf", + "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/" + } + } + }, + { + "value": { + "name": "doc2.pdf", + "sortIndex": 1, + "sourceDocument": { + "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_filename": "doc2.pdf", + "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/" + } + } + }, + { + "value": { + "name": "doc1.pdf", + "sortIndex": 2, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 4 + } + }, + { + "value": { + "name": "Respondent documents", + "documents": [ + { + "value": { + "name": "doc1.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 5 + } + }, + { + "value": { + "name": "Evidence supplied after the hearing bundle documents", + "documents": [ + { + "value": { + "name": "doc2.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc2.pdf", + "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/" + } + } + }, + { + "value": { + "name": "doc1.pdf", + "sortIndex": 1, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 6 + } + }, + { + "value": { + "name": "Tribunal documents", + "documents": [ + { + "value": { + "name": "doc1.pdf", + "sortIndex": 0, + "sourceDocument": { + "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_filename": "doc1.pdf", + "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/" + } + } + } + ], + "sortIndex": 7 + } + } + ] + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7158-request-case-building-internal-legal-officer.json b/src/functionalTest/resources/scenarios/RIA-7158-request-case-building-internal-legal-officer.json new file mode 100644 index 000000000..dd0d840a0 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7158-request-case-building-internal-legal-officer.json @@ -0,0 +1,73 @@ +{ + "description": "RIA-7158 Internal ADA case Legal Officer requests case building - verify document generated", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestCaseBuilding", + "state": "awaitingRespondentEvidence", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestCaseBuilding", + "dateDue": "{$TODAY+13}", + "parties": "legalRepresentative", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\n\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\n\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\n\n- a concise summary of the appellant’s case\n- a schedule of issues\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\n\n# Next steps\n\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\n\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "directions": [ + { + "id": "1", + "value": { + "tag": "requestCaseBuilding", + "dateDue": "{$TODAY+13}", + "parties": "legalRepresentative", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\n\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\n\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\n\n- a concise summary of the appellant’s case\n- a schedule of issues\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\n\n# Next steps\n\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\n\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "previousDates": [] + } + } + ], + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "requestCaseBuilding", + "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_filename": "PA 12345 2019-Awan-ADA appellant letter-appeal reasons.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7172-ho-review-evidence-letter-document.json b/src/functionalTest/resources/scenarios/RIA-7172-ho-review-evidence-letter-document.json new file mode 100644 index 000000000..707e0ec31 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7172-ho-review-evidence-letter-document.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7172 HO Review Evidence Letter PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestRespondentReview", + "state": "caseUnderReview", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "respondentReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ], + "notificationAttachmentDocuments":[] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "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 11111 2019-Gonzlez-HO-Review-Evidence-Letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "requestRespondentReview" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7174-internal-ada-suitability-suitable-document.json b/src/functionalTest/resources/scenarios/RIA-7174-internal-ada-suitability-suitable-document.json new file mode 100644 index 000000000..917041b84 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7174-internal-ada-suitability-suitable-document.json @@ -0,0 +1,73 @@ +{ + "description": "RIA-7174 ada suitability review - suitable - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "adaSuitabilityReview", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "suitabilityReviewJudge": "Judge x", + "suitabilityReviewDecision": "suitable", + "suitabilityReviewReason": "Reason1", + "directions": [ + { + "id": "1", + "value": { + "tag": "respondentReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + }, + { + "id": "2", + "value": { + "tag": "requestCaseBuilding", + "parties": "legalRepresentative", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f26", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\\n\\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\\n\\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\\n\\n- a concise summary of the appellant’s case\\n- a schedule of issues\\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\\n\\n# Next steps\\n\\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\\n\\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "dateDue": "{$TODAY+15}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAdaSuitability", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-suitability-decision-suitable.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7175-internal-ada-suitability-unsuitable-document.json b/src/functionalTest/resources/scenarios/RIA-7175-internal-ada-suitability-unsuitable-document.json new file mode 100644 index 000000000..ab99ac54d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7175-internal-ada-suitability-unsuitable-document.json @@ -0,0 +1,73 @@ +{ + "description": "RIA-7175 ADA suitability review - Unsuitable - document generation", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "adaSuitabilityReview", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "suitabilityReviewJudge": "Judge x", + "suitabilityReviewDecision": "unsuitable", + "suitabilityReviewReason": "Reason1", + "directions": [ + { + "id": "1", + "value": { + "tag": "respondentReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + }, + { + "id": "2", + "value": { + "tag": "requestCaseBuilding", + "parties": "legalRepresentative", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f26", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\\n\\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\\n\\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\\n\\n- a concise summary of the appellant’s case\\n- a schedule of issues\\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\\n\\n# Next steps\\n\\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\\n\\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "dateDue": "{$TODAY+15}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAdaSuitability", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-suitability-decision-unsuitable.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7198-upload-appeal-response-decision-maintained-letter-document.json b/src/functionalTest/resources/scenarios/RIA-7198-upload-appeal-response-decision-maintained-letter-document.json new file mode 100644 index 000000000..0ac08b5e1 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7198-upload-appeal-response-decision-maintained-letter-document.json @@ -0,0 +1,76 @@ +{ + "description": "RIA-7198 HO Uploads Appeal Response Letter PDF - Decision maintained", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficeLart", + "input": { + "eventId": "uploadHomeOfficeAppealResponse", + "state": "respondentReview", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "listCaseHearingDate": "2023-07-08T09:00:00.000", + "appealSubmissionDate": "2023-06-29", + "appealReviewOutcome": "decisionMaintained", + "directions": [ + { + "id": "1", + "value": { + "tag": "respondentReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + }, + { + "id": "2", + "value": { + "tag": "requestCaseBuilding", + "parties": "legalRepresentative", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f26", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\\n\\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\\n\\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\\n\\n- a concise summary of the appellant’s case\\n- a schedule of issues\\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\\n\\n# Next steps\\n\\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\\n\\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "dateDue": "{$TODAY+15}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ], + "notificationAttachmentDocuments":[] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "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 11111 2019-Gonzlez-HO-Response-Letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "uploadTheAppealResponse" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7200-internal-ada-hearing-bundle-ready-letter-generation.json b/src/functionalTest/resources/scenarios/RIA-7200-internal-ada-hearing-bundle-ready-letter-generation.json new file mode 100644 index 000000000..bc7b4b2b1 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7200-internal-ada-hearing-bundle-ready-letter-generation.json @@ -0,0 +1,52 @@ +{ + "description": "RIA-7200 - Internal ADA hearing bundle ready letter generation", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "caseOfficer", + "input": { + "id": 7200, + "eventId": "asyncStitchingComplete", + "state": "preHearing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "listCaseHearingDate": "2023-07-10T20:23:35", + "listCaseHearingCentre": "birmingham", + "caseBundles": [{ + "id": "1", + "value": { + "stitchStatus": "DONE" + } + }] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "hearingBundleReadyLetter", + "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_filename": "PA 12345 2019-Awan-ADA appellant hearing bundle.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7212-internal-ada-send-decision-and-reasons-allowed-document.json b/src/functionalTest/resources/scenarios/RIA-7212-internal-ada-send-decision-and-reasons-allowed-document.json new file mode 100644 index 000000000..67aa3dcc6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7212-internal-ada-send-decision-and-reasons-allowed-document.json @@ -0,0 +1,64 @@ +{ + "description": "RIA-7212 Internal ADA send decision and reasons - allowed - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDecisionAndReasons", + "state": "decision", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "isDecisionAllowed": "allowed", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "draftDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "decisionAndReasons", + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetDecisionAndReasonsLetter", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-appeal-decided-allowed.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7213-internal-ada-send-decision-and-reasons-dismissed-document.json b/src/functionalTest/resources/scenarios/RIA-7213-internal-ada-send-decision-and-reasons-dismissed-document.json new file mode 100644 index 000000000..f2a42958c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7213-internal-ada-send-decision-and-reasons-dismissed-document.json @@ -0,0 +1,92 @@ +{ + "description": "RIA-7213 Internal ADA send decision and reasons - dismissed - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDecisionAndReasons", + "state": "decision", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestCaseBuilding", + "dateDue": "{$TODAY+13}", + "parties": "legalRepresentative", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\n\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\n\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\n\n- a concise summary of the appellant’s case\n- a schedule of issues\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\n\n# Next steps\n\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\n\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "requestCaseBuilding", + "previousDates": [] + } + }, + { + "id": "2", + "value": { + "tag": "respondentReview", + "dateDue": "{$TODAY+13}", + "parties": "legalRepresentative", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a888", + "explanation": "You must now build your case to enable the respondent to conduct a thorough review of their decision.\n\nYou have until the date indicated below to upload your Appeal Skeleton Argument and evidence.\n\nYour Appeal Skeleton Argument must be set out in three distinct parts to include:\n\n- a concise summary of the appellant’s case\n- a schedule of issues\n- why those issues should be resolved in the appellant’s favour, by reference to the evidence you have (or plan to have) and any legal authorities you rely upon\n\n# Next steps\n\nOnce you've uploaded your Appeal Skeleton Argument and evidence, you should submit your case. The Legal Officer will review everything you've added.\n\nIf your case looks ready, the Tribunal will send it to the respondent to review.", + "directionType": "respondentReview", + "previousDates": [] + } + } + ], + "isDecisionAllowed": "dismissed", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "draftDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "decisionAndReasons", + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetDecisionAndReasonsLetter", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-appeal-decided-dismissed.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7215-internal-detained-non-ada-send-decision-and-reasons-allowed-document.json b/src/functionalTest/resources/scenarios/RIA-7215-internal-detained-non-ada-send-decision-and-reasons-allowed-document.json new file mode 100644 index 000000000..f737b45c4 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7215-internal-detained-non-ada-send-decision-and-reasons-allowed-document.json @@ -0,0 +1,64 @@ +{ + "description": "RIA-7215 Internal detained non-ADA send decision and reasons - allowed - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDecisionAndReasons", + "state": "decision", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "isDecisionAllowed": "allowed", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "draftDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "decisionAndReasons", + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetDecisionAndReasonsLetter", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-appeal-decided-allowed.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7216-internal-detained-non-ada-send-decision-and-reasons-dismissed-document.json b/src/functionalTest/resources/scenarios/RIA-7216-internal-detained-non-ada-send-decision-and-reasons-dismissed-document.json new file mode 100644 index 000000000..104d8c258 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7216-internal-detained-non-ada-send-decision-and-reasons-dismissed-document.json @@ -0,0 +1,64 @@ +{ + "description": "RIA-7216 Internal detained non-ADA send decision and reasons - dismissed - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDecisionAndReasons", + "state": "decision", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "isDecisionAllowed": "dismissed", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "draftDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "decisionAndReasons", + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetDecisionAndReasonsLetter", + "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_filename": "PA 12345 2019-Awan-ADA-Appellant-letter-appeal-decided-dismissed.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7279-internal-ada-home-office-amend-appeal-response-letter.json b/src/functionalTest/resources/scenarios/RIA-7279-internal-ada-home-office-amend-appeal-response-letter.json new file mode 100644 index 000000000..265547bf7 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7279-internal-ada-home-office-amend-appeal-response-letter.json @@ -0,0 +1,73 @@ +{ + "description": "RIA-7279 internal ADA LO requests HO to amend appeal response", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7279, + "eventId": "requestResponseAmend", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseAmend", + "dateDue": "{$TODAY+13}", + "parties": "respondent", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "Some explanation", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseAmend", + "dateDue": "{$TODAY+13}", + "parties": "respondent", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "Some explanation", + "previousDates": [] + } + } + ], + "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-home-office-amend-appeal-response.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "amendHomeOfficeAppealResponse" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7279-internal-detained-home-office-amend-appeal-response-letter.json b/src/functionalTest/resources/scenarios/RIA-7279-internal-detained-home-office-amend-appeal-response-letter.json new file mode 100644 index 000000000..3ba79d6e0 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7279-internal-detained-home-office-amend-appeal-response-letter.json @@ -0,0 +1,71 @@ +{ + "description": "RIA-7279 internal detained non-ada LO requests HO to amend appeal response", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7279, + "eventId": "requestResponseAmend", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseAmend", + "dateDue": "{$TODAY+13}", + "parties": "respondent", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "Some explanation", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseAmend", + "dateDue": "{$TODAY+13}", + "parties": "respondent", + "dateSent": "{$TODAY}", + "uniqueId": "e2353950-0bef-4a97-8d1b-eb2f7d00a260", + "explanation": "Some explanation", + "previousDates": [] + } + } + ], + "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-home-office-amend-appeal-response.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "amendHomeOfficeAppealResponse" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-ada-iac-newcastle.json b/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-ada-iac-newcastle.json new file mode 100644 index 000000000..f2c90376e --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-ada-iac-newcastle.json @@ -0,0 +1,58 @@ +{ + "description": "RIA-7281 Internal detained non-ADA edit case listing hearing notice PDF (IAC Glasgow) - previously (IAC Manchester)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "editCaseListing", + "state": "prepareForHearing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "glasgow", + "listCaseHearingLength": "60", + "listCaseHearingDate": "2023-10-20T12:30:00", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "manchester", + "listCaseHearingLength": "120", + "listCaseHearingDate": "2023-09-15T11:15:00" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "glasgow", + "listCaseHearingLength": "60", + "listCaseHearingDate": "2023-10-20T12:30:00", + "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-edit-case-listing-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDetainedEditCaseListingLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-non-ada-iac-glasgow.json b/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-non-ada-iac-glasgow.json new file mode 100644 index 000000000..b1f543489 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7281-edit-case-listing-internal-detained-non-ada-iac-glasgow.json @@ -0,0 +1,58 @@ +{ + "description": "RIA-7281 Internal detained ADA edit case listing hearing notice PDF (IAC Newcastle) - previously (IAC Nottingham)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "editCaseListing", + "state": "prepareForHearing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "newcastle", + "listCaseHearingLength": "30", + "listCaseHearingDate": "2023-09-22T13:30:00", + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "nottingham", + "listCaseHearingLength": "150", + "listCaseHearingDate": "2023-08-10T10:15:00" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "newcastle", + "listCaseHearingLength": "30", + "listCaseHearingDate": "2023-09-22T13:30:00", + "isAcceleratedDetainedAppeal": "Yes", + "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-edit-case-listing-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDetainedEditCaseListingLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-ada.json b/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-ada.json new file mode 100644 index 000000000..9e6369c95 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-ada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7324 Internal detained ADA adjourn hearing without date", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "adjournHearingWithoutDate", + "state": "listing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "nottingham", + "adjournHearingWithoutDateReasons": "Sample reasons", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "nottingham", + "listCaseHearingDate": "2018-12-31T12:34:56" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "nottingham", + "adjournHearingWithoutDateReasons": "Sample reasons", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "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-internal-detained-adjourn-hearing-without-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalAdjournHearingWithoutDate" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-non-ada.json new file mode 100644 index 000000000..1c06b1b62 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7324-adjourn-hearing-without-date-internal-detained-non-ada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7324 Internal detained non ADA adjourn hearing without date", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "adjournHearingWithoutDate", + "state": "listing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "nottingham", + "adjournHearingWithoutDateReasons": "Sample reasons", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "nottingham", + "listCaseHearingDate": "2018-12-31T12:34:56" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "nottingham", + "adjournHearingWithoutDateReasons": "Sample reasons", + "isAdmin": "Yes", + "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-internal-detained-adjourn-hearing-without-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalAdjournHearingWithoutDate" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7326-internal-ada-apply-for-ftpa-appellant-letter.json b/src/functionalTest/resources/scenarios/RIA-7326-internal-ada-apply-for-ftpa-appellant-letter.json new file mode 100644 index 000000000..50a3d6a21 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7326-internal-ada-apply-for-ftpa-appellant-letter.json @@ -0,0 +1,44 @@ +{ + "description": "RIA-7326 internal ADA apply for ftpa (appellant) letter generation", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "id": 7326, + "eventId": "applyForFTPAAppellant", + "state": "decided", + "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", + "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-apply-for-ftpa-appellant-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalFtpaSubmittedAppellantLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7326-internal-detained-apply-for-ftpa-appellant-letter.json b/src/functionalTest/resources/scenarios/RIA-7326-internal-detained-apply-for-ftpa-appellant-letter.json new file mode 100644 index 000000000..ce9553a71 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7326-internal-detained-apply-for-ftpa-appellant-letter.json @@ -0,0 +1,43 @@ +{ + "description": "RIA-7326 internal detained (non-ada) apply for ftpa (appellant) letter generation", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "id": 7326, + "eventId": "applyForFTPAAppellant", + "state": "decided", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-apply-for-ftpa-appellant-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalFtpaSubmittedAppellantLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-ada-letter.json new file mode 100644 index 000000000..57212aace --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-ada-letter.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7328 Internal detained apply for FTPA respondent as Ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficePOU", + "input": { + "id": 7328, + "eventId": "applyForFTPARespondent", + "state": "decided", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalApplyForFtpaRespondent", + "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_filename": "PA 11111 2019-Gonzlez-apply-for-ftpa-respondent-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-non-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-non-ada-letter.json new file mode 100644 index 000000000..1d753ef1c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7328-internal-detained-case-apply-for-ftpa-respondent-non-ada-letter.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7328 Internal detained apply for FTPA respondent as non-Ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficePOU", + "input": { + "id": 7328, + "eventId": "applyForFTPARespondent", + "state": "decided", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "No" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "isAcceleratedDetainedAppeal": "No", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalApplyForFtpaRespondent", + "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_filename": "PA 11111 2019-Gonzlez-apply-for-ftpa-respondent-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-ada.json b/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-ada.json new file mode 100644 index 000000000..6be269c8a --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7330 Internal appellant ftpa decided - granted letter - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7330, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-non-ada.json new file mode 100644 index 000000000..6e980704b --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7330-internal-appellant-ftpa-decided-granted-document-non-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7330 Internal appellant ftpa decided - granted letter - non-ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7330, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-ada.json b/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-ada.json new file mode 100644 index 000000000..fb9fa8df5 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7331 Internal appellant ftpa decided - partially granted letter - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7331, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-partially-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-non-ada.json new file mode 100644 index 000000000..749788a63 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted-non-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7331 Internal appellant ftpa decided - partially granted letter - non-ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7331, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-partially-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-ada.json b/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-ada.json new file mode 100644 index 000000000..abc70e9fe --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7332 Internal appellant ftpa decided - refused letter - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7332, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "ftpaAppellantRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-refused-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-non-ada.json new file mode 100644 index 000000000..aabb7ced9 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7332-internal-appellant-ftpa-decided-refused-document-non-ada.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7332 Internal appellant ftpa decided - refused letter - non-ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7332, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "appellant" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "ftpaAppellantRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "appellant", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppellantFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-refused-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7360-internal-ho-ftpa-decided-granted-document.json b/src/functionalTest/resources/scenarios/RIA-7360-internal-ho-ftpa-decided-granted-document.json new file mode 100644 index 000000000..2f5a19603 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7360-internal-ho-ftpa-decided-granted-document.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7360 Internal HO ftpa decided - granted letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7360, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "respondent" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "granted", + "ftpaApplicantType": "respondent", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalHoFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7361-internal-ho-ftpa-decided-partially-granted-document.json b/src/functionalTest/resources/scenarios/RIA-7361-internal-ho-ftpa-decided-partially-granted-document.json new file mode 100644 index 000000000..aa295f208 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7361-internal-ho-ftpa-decided-partially-granted-document.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7361 Internal HO ftpa decided - partially granted letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7361, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "respondent" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "partiallyGranted", + "ftpaApplicantType": "respondent", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalHoFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-partially-granted-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7362-internal-ho-ftpa-decided-refused-document.json b/src/functionalTest/resources/scenarios/RIA-7362-internal-ho-ftpa-decided-refused-document.json new file mode 100644 index 000000000..f007d1375 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7362-internal-ho-ftpa-decided-refused-document.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7362 Internal HO ftpa decided - refused letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7362, + "eventId": "residentJudgeFtpaDecision", + "state": "ftpaSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "respondent" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "ftpaRespondentRjDecisionOutcomeType": "refused", + "ftpaApplicantType": "respondent", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalHoFtpaDecidedLetter", + "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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-refused-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-adjourn-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-adjourn-decision-granted-letter.json new file mode 100644 index 000000000..b2e9a7cc2 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-adjourn-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7364 internal ADA application decided letter (Adjourn - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73641, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-expedite-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-expedite-decision-granted-letter.json new file mode 100644 index 000000000..bccbd2522 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-expedite-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7364 internal ADA application decided letter (Expedite - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73642, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-judge-review-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-judge-review-decision-granted-letter.json new file mode 100644 index 000000000..d3d37eed0 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-judge-review-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7364 internal ADA application decided letter (Judges review - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73643, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json new file mode 100644 index 000000000..7981c756c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7364 internal ADA application decided letter (Transfer out of ada- Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73644, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-adjourn-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-adjourn-decision-granted-letter.json new file mode 100644 index 000000000..6b841ba83 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-adjourn-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7364 internal detained (non-ada) application decided letter (Adjourn - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73645, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-expedite-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-expedite-decision-granted-letter.json new file mode 100644 index 000000000..83f87553a --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-expedite-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7364 internal detained (non-ada) application decided letter (Expedite - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73646, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-judge-review-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-judge-review-decision-granted-letter.json new file mode 100644 index 000000000..3f58d29f6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-judge-review-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7364 internal detained (non-ada) application decided letter (Judges review - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73647, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json new file mode 100644 index 000000000..109ca2170 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7364-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7364 internal detained (non-ada) application decided letter (Transfer out of ada - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73648, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-adjourn-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-adjourn-decision-refused-letter.json new file mode 100644 index 000000000..23d90f8b1 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-adjourn-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7365 internal ADA application decided letter (Adjourn - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73651, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-expedite-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-expedite-decision-refused-letter.json new file mode 100644 index 000000000..0018c6f1f --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-expedite-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7365 internal ADA application decided letter (Expedite - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73652, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-judge-review-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-judge-review-decision-refused-letter.json new file mode 100644 index 000000000..4783ae7d9 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-judge-review-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7365 internal ADA application decided letter (Judges review - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73653, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json new file mode 100644 index 000000000..f0f175fe4 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-ada-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7365 internal ADA application decided letter (Transfer out of ada- Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73654, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-adjourn-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-adjourn-decision-refused-letter.json new file mode 100644 index 000000000..8585d47ab --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-adjourn-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7365 internal detained (non-ada) application decided letter (Adjourn - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73655, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-expedite-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-expedite-decision-refused-letter.json new file mode 100644 index 000000000..aaa7afca8 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-expedite-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7365 internal detained (non-ada) application decided letter (Expedite - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73656, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-judge-review-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-judge-review-decision-refused-letter.json new file mode 100644 index 000000000..c9cd7ea05 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-judge-review-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7365 internal detained (non-ada) application decided letter (Judges review - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73657, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json new file mode 100644 index 000000000..ef8b6f5fa --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7365-internal-detained-decide-an-appellant-application-transfer-out-of-ada-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7365 internal detained (non-ada) application decided letter (Transfer out of ada - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73658, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-adjourn-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-adjourn-decision-granted-letter.json new file mode 100644 index 000000000..f64a2c4bc --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-adjourn-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7367 internal ADA application decided letter (Adjourn - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73671, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-expedite-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-expedite-decision-granted-letter.json new file mode 100644 index 000000000..1525e0366 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-expedite-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7367 internal ADA application decided letter (Expedite - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73672, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-judge-review-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-judge-review-decision-granted-letter.json new file mode 100644 index 000000000..71698bb37 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-judge-review-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7367 internal ADA application decided letter (Judges review - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73673, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json new file mode 100644 index 000000000..5aabfaa5a --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7367 internal ADA application decided letter (Transfer out of ada- Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73674, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-adjourn-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-adjourn-decision-granted-letter.json new file mode 100644 index 000000000..1a30a8138 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-adjourn-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7367 internal detained (non-ada) application decided letter (Adjourn - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73675, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-expedite-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-expedite-decision-granted-letter.json new file mode 100644 index 000000000..2a4f055b3 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-expedite-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7367 internal detained (non-ada) application decided letter (Expedite - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73676, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-judge-review-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-judge-review-decision-granted-letter.json new file mode 100644 index 000000000..97faa4f32 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-judge-review-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7367 internal detained (non-ada) application decided letter (Judges review - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73677, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json new file mode 100644 index 000000000..b63232591 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7367-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7367 internal detained (non-ada) application decided letter (Transfer out of ada - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 73678, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-adjourn-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-adjourn-decision-refused-letter.json new file mode 100644 index 000000000..924669084 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-adjourn-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7368 internal ADA application decided letter (Adjourn - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73681, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-expedite-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-expedite-decision-refused-letter.json new file mode 100644 index 000000000..b0e5caecd --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-expedite-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7368 internal ADA application decided letter (Expedite - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73682, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-judge-review-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-judge-review-decision-refused-letter.json new file mode 100644 index 000000000..03c42bf0d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-judge-review-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7368 internal ADA application decided letter (Judges review - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73683, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json new file mode 100644 index 000000000..490efca32 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-ada-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7368 internal ADA application decided letter (Transfer out of ada- Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73684, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-adjourn-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-adjourn-decision-refused-letter.json new file mode 100644 index 000000000..d4d9b8088 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-adjourn-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7368 internal detained (non-ada) application decided letter (Adjourn - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73685, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Adjourn", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-expedite-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-expedite-decision-refused-letter.json new file mode 100644 index 000000000..34aa332aa --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-expedite-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7368 internal detained (non-ada) application decided letter (Expedite - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73686, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Expedite", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-judge-review-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-judge-review-decision-refused-letter.json new file mode 100644 index 000000000..61a72cabb --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-judge-review-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7368 internal detained (non-ada) application decided letter (Judges review - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73687, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Judge's review of Legal Officer decision", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json new file mode 100644 index 000000000..1021357e6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7368-internal-detained-decide-a-respondent-application-transfer-out-of-ada-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7368 internal detained (non-ada) application decided letter (Transfer out of ada - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 73688, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Transfer out of accelerated detained appeals process", + "details":"", + "evidence":[], + "applicant":"Respondent", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-respondent-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideHomeOfficeApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-addendum-evidence.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-addendum-evidence.json new file mode 100644 index 000000000..e59c52f4c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-addendum-evidence.json @@ -0,0 +1,76 @@ +{ + "description": "RIA-7370 - Internal upload home office upload addendum evidence letter generation - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficeLart", + "input": { + "eventId": "uploadAddendumEvidenceHomeOffice", + "state": "decided", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_HO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeUploadAdditionalAddendumEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-additional-evidence.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-additional-evidence.json new file mode 100644 index 000000000..9271008d6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-home-office-upload-additional-evidence.json @@ -0,0 +1,76 @@ +{ + "description": "RIA-7370 - Internal upload home office upload additional evidence letter generation - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficeLart", + "input": { + "eventId": "uploadAdditionalEvidenceHomeOffice", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_HO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeUploadAdditionalAddendumEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-legal-officer-upload-addendum-evidence-supplied-by-ho.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-legal-officer-upload-addendum-evidence-supplied-by-ho.json new file mode 100644 index 000000000..e1935bd00 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-ada-legal-officer-upload-addendum-evidence-supplied-by-ho.json @@ -0,0 +1,78 @@ +{ + "description": "RIA-7370 - Internal upload Legal Officer upload addendum evidence letter generation - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "uploadAddendumEvidence", + "state": "decided", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313/binary" + }, + "suppliedBy": "The respondent", + "uploadedBy": "TCW", + "description": "k", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313/binary" + }, + "suppliedBy": "The respondent", + "uploadedBy": "TCW", + "description": "k", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_LO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "legalOfficerUploadAdditionalEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-addendum-evidence.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-addendum-evidence.json new file mode 100644 index 000000000..a1918dcd4 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-addendum-evidence.json @@ -0,0 +1,76 @@ +{ + "description": "RIA-7370 - Internal upload home office upload addendum evidence letter generation - Detained non-ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficeLart", + "input": { + "eventId": "uploadAddendumEvidenceHomeOffice", + "state": "decided", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_HO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeUploadAdditionalAddendumEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-additional-evidence.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-additional-evidence.json new file mode 100644 index 000000000..73876031b --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-home-office-upload-additional-evidence.json @@ -0,0 +1,76 @@ +{ + "description": "RIA-7370 - Internal upload home office upload additional evidence letter generation - Detained non-ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "HomeOfficeLart", + "input": { + "eventId": "uploadAdditionalEvidenceHomeOffice", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/653180d2-b004-4b7a-8293-69a39d5b8a79/binary" + }, + "suppliedBy": "The respondent", + "description": "HO addendum 1", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_HO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "homeOfficeUploadAdditionalAddendumEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-legal-officer-upload-addendum-evidence-supplied-by-ho.json b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-legal-officer-upload-addendum-evidence-supplied-by-ho.json new file mode 100644 index 000000000..566a2a41b --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7370-internal-detained-legal-officer-upload-addendum-evidence-supplied-by-ho.json @@ -0,0 +1,78 @@ +{ + "description": "RIA-7370 - Internal upload Legal Officer upload addendum evidence letter generation - Detained non-ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "uploadAddendumEvidence", + "state": "decided", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313/binary" + }, + "suppliedBy": "The respondent", + "uploadedBy": "TCW", + "description": "k", + "dateUploaded": "2023-09-26" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "addendumEvidenceDocuments": [ + { + "id": "1", + "value": { + "tag": "addendumEvidence", + "document": { + "document_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313", + "document_filename": "fake-doc.pdf", + "document_binary_url": "http://dm-store:8080/documents/bcc86de8-daca-4c16-b610-28bad91ba313/binary" + }, + "suppliedBy": "The respondent", + "uploadedBy": "TCW", + "description": "k", + "dateUploaded": "2023-09-26" + } + } + ], + "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-appellant letter_LO-evidence.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "legalOfficerUploadAdditionalEvidenceLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7372-internal-end-ada-appeal-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7372-internal-end-ada-appeal-notice-document.json new file mode 100644 index 000000000..c42b276d0 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7372-internal-end-ada-appeal-notice-document.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7372 end appeal for Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "endAppeal", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "endAppealDate": "2022-08-01", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-end-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "endAppeal" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7372-internal-end-non-ada-appeal-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7372-internal-end-non-ada-appeal-notice-document.json new file mode 100644 index 000000000..2aa9e0d56 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7372-internal-end-non-ada-appeal-notice-document.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7372 end appeal for non Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "endAppeal", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "endAppealDate": "2022-08-01", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "No" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-end-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "endAppeal" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-admin-mark-as-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-admin-mark-as-ada-letter.json new file mode 100644 index 000000000..089244fe8 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-admin-mark-as-ada-letter.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7374 Internal detained mark appeal as Ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "id": 7374, + "eventId": "markAppealAsAda", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "reasonAppealMarkedAsAda": "Some explanation" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "reasonAppealMarkedAsAda": "Some explanation", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetMarkAsAdaLetter", + "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_filename": "PA 11111 2019-Gonzlez-detained-appellant-mark-as-ada-notice.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-case-officer-mark-as-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-case-officer-mark-as-ada-letter.json new file mode 100644 index 000000000..7f8caea2b --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7374-internal-detained-case-officer-mark-as-ada-letter.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7374 Internal detained mark appeal as Ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7374, + "eventId": "markAppealAsAda", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "reasonAppealMarkedAsAda": "Some explanation" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "reasonAppealMarkedAsAda": "Some explanation", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetMarkAsAdaLetter", + "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_filename": "PA 11111 2019-Gonzlez-detained-appellant-mark-as-ada-notice.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-ada-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-ada-notice-document.json new file mode 100644 index 000000000..0be1af73c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-ada-notice-document.json @@ -0,0 +1,101 @@ +{ + "description": "RIA-7376 maintain case link appeal for Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "createCaseLink", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "Yes", + "caseLinks": [ + { + "id": "1", + "value": { + "CaseType": "Asylum", + "CaseReference": "1", + "CreatedDateTime": "2023-09-22T15:54:09.839", + "ReasonForLink": [ + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80b", + "value": { + "Reason": "CLRC015" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80q", + "value": { + "Reason": "CLRC014" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80w", + "value": { + "Reason": "CLRC013" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80e", + "value": { + "Reason": "CLRC012" + } + } + ] + } + }, + { + "id": "2", + "value": { + "CaseType": "Asylum", + "CaseReference": "2", + "CreatedDateTime": "2023-09-21T15:54:09.839", + "ReasonForLink": [ + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80b", + "value": { + "Reason": "CLRC015" + } + } + ] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-maintain-case-link-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "maintainCaseLinkAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-non-ada-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-non-ada-notice-document.json new file mode 100644 index 000000000..0e1d5ba93 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7376-internal-link-case-non-ada-notice-document.json @@ -0,0 +1,101 @@ +{ + "description": "RIA-7376 maintain case link appeal for Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "createCaseLink", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "No", + "caseLinks": [ + { + "id": "1", + "value": { + "CaseType": "Asylum", + "CaseReference": "1", + "CreatedDateTime": "2023-09-22T15:54:09.839", + "ReasonForLink": [ + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80b", + "value": { + "Reason": "CLRC015" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80q", + "value": { + "Reason": "CLRC014" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80w", + "value": { + "Reason": "CLRC013" + } + }, + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80e", + "value": { + "Reason": "CLRC012" + } + } + ] + } + }, + { + "id": "2", + "value": { + "CaseType": "Asylum", + "CaseReference": "2", + "CreatedDateTime": "2023-09-21T15:54:09.839", + "ReasonForLink": [ + { + "id": "f0768aed-7e52-43cf-b35c-5cd45781e80b", + "value": { + "Reason": "CLRC015" + } + } + ] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-maintain-case-link-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "maintainCaseLinkAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7378-internal-ada-maintain-case-unlink-appeal-document.json b/src/functionalTest/resources/scenarios/RIA-7378-internal-ada-maintain-case-unlink-appeal-document.json new file mode 100644 index 000000000..4313732ab --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7378-internal-ada-maintain-case-unlink-appeal-document.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7378 maintain case unlink appeal for Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "maintainCaseLinks", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "endAppealDate": "2022-08-01", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-maintain-case-unlink-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "maintainCaseUnlinkAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7378-internal-non-ada-maintain-case-unlink-appeal-document.json b/src/functionalTest/resources/scenarios/RIA-7378-internal-non-ada-maintain-case-unlink-appeal-document.json new file mode 100644 index 000000000..9cf7af224 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7378-internal-non-ada-maintain-case-unlink-appeal-document.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7378 maintain case unlink appeal for non-Ada notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "maintainCaseLinks", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "endAppealDate": "2022-08-01", + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "No" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-maintain-case-unlink-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "maintainCaseUnlinkAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-ada-appeal-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-ada-appeal-notice-document.json new file mode 100644 index 000000000..83da3d2a9 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-ada-appeal-notice-document.json @@ -0,0 +1,49 @@ +{ + "description": "RIA-7418 edit appeal for ADA letter document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "editAppealAfterSubmit", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-edit-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalEditAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-non-ada-appeal-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-non-ada-appeal-notice-document.json new file mode 100644 index 000000000..3d2f842d7 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7418-internal-edit-non-ada-appeal-notice-document.json @@ -0,0 +1,49 @@ +{ + "description": "RIA-7418 edit appeal for non Ada letter document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "editAppealAfterSubmit", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "tribunalDocuments": [], + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "isAcceleratedDetainedAppeal": "No" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "appealSubmissionDate": "{$TODAY}", + "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 11111 2019-Gonzlez-detained-appellant-edit-appeal-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalEditAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-ada.json b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-ada.json new file mode 100644 index 000000000..32a21b57b --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-ada.json @@ -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" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-non-ada.json new file mode 100644 index 000000000..96e04b862 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-addendum-evidence-document-non-ada.json @@ -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" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-ada.json b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-ada.json new file mode 100644 index 000000000..be3381a48 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-ada.json @@ -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" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-non-ada.json new file mode 100644 index 000000000..be3381a48 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7427-internal-upload-additional-evidence-document-non-ada.json @@ -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" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-ada.json b/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-ada.json new file mode 100644 index 000000000..daa042b3e --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-ada.json @@ -0,0 +1,53 @@ +{ + "description": "RIA-7429 Internal reinstate appeal document - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7429, + "eventId": "reinstateAppeal", + "state": "ended", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "stateBeforeEndAppeal": "appealSubmitted", + "reinstateAppealDate": "{$TODAY}", + "reinstateAppealReason": "Withdraw", + "reinstatedDecisionMaker": "Judge", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "stateBeforeEndAppeal": "appealSubmitted", + "reinstateAppealDate": "{$TODAY}", + "reinstateAppealReason": "Withdraw", + "reinstatedDecisionMaker": "Judge", + "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-internal-detained-reinstate-appeal-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalReinstateAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-non-ada.json b/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-non-ada.json new file mode 100644 index 000000000..18e3c9d96 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7429-internal-reinstate-appeal-document-non-ada.json @@ -0,0 +1,53 @@ +{ + "description": "RIA-7429 Internal reinstate appeal document - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7429, + "eventId": "reinstateAppeal", + "state": "ended", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "stateBeforeEndAppeal": "appealSubmitted", + "reinstateAppealDate": "{$TODAY}", + "reinstateAppealReason": "Withdraw", + "reinstatedDecisionMaker": "Judge", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "stateBeforeEndAppeal": "appealSubmitted", + "reinstateAppealDate": "{$TODAY}", + "reinstateAppealReason": "Withdraw", + "reinstatedDecisionMaker": "Judge", + "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-internal-detained-reinstate-appeal-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalReinstateAppealLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained-ada.json b/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained-ada.json new file mode 100644 index 000000000..44c4b7720 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained-ada.json @@ -0,0 +1,52 @@ +{ + "description": "RIA-7433 Internal detained ADA change hearing centre PDF (IAC Newcastle) - previously (IAC Nottingham)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeHearingCentre", + "state": "prepareForHearing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "newcastle", + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "nottingham" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "newcastle", + "isAcceleratedDetainedAppeal": "Yes", + "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-appellant-change-hearing-centre-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalChangeHearingCentreLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained.json b/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained.json new file mode 100644 index 000000000..973aa44b3 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7433-change-hearing-centre-internal-detained.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7433 Internal detained non-ADA change hearing centre PDF (IAC Newcastle) - previously (IAC Nottingham)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeHearingCentre", + "state": "prepareForHearing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "newcastle", + "appellantInDetention": "Yes" + } + }, + "caseDataBefore": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "nottingham" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "hearingCentre": "newcastle", + "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-appellant-change-hearing-centre-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalChangeHearingCentreLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7435_appellant_respondent_non_standard_direction_letter_ada.json b/src/functionalTest/resources/scenarios/RIA-7435_appellant_respondent_non_standard_direction_letter_ada.json new file mode 100644 index 000000000..3fca49e84 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7435_appellant_respondent_non_standard_direction_letter_ada.json @@ -0,0 +1,71 @@ +{ + "description": "RIA-7435 Internal (Ada) non standard direction to appellant & respondent letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDirection", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "explanation": "some explanation", + "parties": "appellantAndRespondent", + "dateDue": "{$TODAY+14}", + "dateSent": "{$TODAY}", + "tag": "" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "2", + "value": { + "tag": "internalNonStandardDirectionToRespondentLetter", + "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_filename": "PA 12345 2019-Awan-home-office-non-standard-direction-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + }, + { + "id": "1", + "value": { + "tag": "internalNonStandardDirectionToAppellantLetter", + "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_filename": "PA 12345 2019-Awan-non-standard-direction-to-appellant-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_ada.json b/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_ada.json new file mode 100644 index 000000000..5131ac5d3 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_ada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7435 Internal (Ada) non standard direction to respondent letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDirection", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "explanation": "some explanation", + "parties": "respondent", + "dateDue": "{$TODAY+14}", + "dateSent": "{$TODAY}", + "tag": "" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalNonStandardDirectionToRespondentLetter", + "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_filename": "PA 12345 2019-Awan-home-office-non-standard-direction-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_nonada.json b/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_nonada.json new file mode 100644 index 000000000..2216fcb2d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7435_home_office_non_standard_direction_letter_nonada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7435 Internal (Non-ada) non standard direction to respondent letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDirection", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "directions": [ + { + "id": "1", + "value": { + "explanation": "some explanation", + "parties": "respondent", + "dateDue": "{$TODAY+14}", + "dateSent": "{$TODAY}", + "tag": "" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalNonStandardDirectionToRespondentLetter", + "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_filename": "PA 12345 2019-Awan-home-office-non-standard-direction-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-Nonada.json b/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-Nonada.json new file mode 100644 index 000000000..a1aed2837 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-Nonada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7437 Internal (Non-ada) non standard direction to appellant letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDirection", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "directions": [ + { + "id": "1", + "value": { + "explanation": "Review the built case", + "parties": "appellant", + "dateDue": "{$TODAY+14}", + "dateSent": "{$TODAY}", + "tag": "" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalNonStandardDirectionToAppellantLetter", + "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_filename": "PA 12345 2019-Awan-non-standard-direction-to-appellant-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-ada.json b/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-ada.json new file mode 100644 index 000000000..eaf5a7ac1 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7437_Internal_Non_Standard_Direction_Letter-ada.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7437 Internal (ada) non standard direction to appellant letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "sendDirection", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "directions": [ + { + "id": "1", + "value": { + "explanation": "Review the built case", + "parties": "appellant", + "dateDue": "{$TODAY+14}", + "dateSent": "{$TODAY}", + "tag": "" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAdmin": "Yes", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalNonStandardDirectionToAppellantLetter", + "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_filename": "PA 12345 2019-Awan-non-standard-direction-to-appellant-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-ada-internal.json b/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-ada-internal.json new file mode 100644 index 000000000..10a6887d2 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-ada-internal.json @@ -0,0 +1,111 @@ +{ + "description": "RIA-7439 - letter generation on change ho direction due date - internal ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeDirectionDueDate", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "respondent", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "respondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "directionList": "Direction 2", + "directionEditDateDue": "2023-12-31", + "directionEditParties" : "respondent", + "directionEditExplanation": "Do the second thing" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "respondent", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "respondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "editableDirections": null, + "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-internal-ho-change-direction-due-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalHoChangeDirectionDueDateLetter" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-non-ada-internal.json b/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-non-ada-internal.json new file mode 100644 index 000000000..b43ef8ea8 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7439-ho-change-direction-due-date-letter-generation-non-ada-internal.json @@ -0,0 +1,111 @@ +{ + "description": "RIA-7439 - letter generation on change ho direction due date - internal non-Ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeDirectionDueDate", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "respondent", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "respondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "directionList": "Direction 2", + "directionEditDateDue": "2023-12-31", + "directionEditParties" : "respondent", + "directionEditExplanation": "Do the second thing" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "respondent", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "respondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "editableDirections": null, + "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-internal-ho-change-direction-due-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalHoChangeDirectionDueDateLetter" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-ada-internal.json b/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-ada-internal.json new file mode 100644 index 000000000..44ea6ec43 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-ada-internal.json @@ -0,0 +1,111 @@ +{ + "description": "RIA-7471 - letter generation on change direction due date - internal ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeDirectionDueDate", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "appellant", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "appellantAndRespondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "directionList": "Direction 2", + "directionEditDateDue": "2023-12-31", + "directionEditParties" : "appellantAndRespondent", + "directionEditExplanation": "Do the second thing" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "Yes", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "appellant", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "appellantAndRespondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "editableDirections": null, + "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-appellant-change-direction-due-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalChangeDirectionDueDateLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-non-ada-internal.json b/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-non-ada-internal.json new file mode 100644 index 000000000..b42ba12b5 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7471-change-direction-due-date-letter-generation-non-ada-internal.json @@ -0,0 +1,109 @@ +{ + "description": "RIA-7471 - letter generation on change direction due date - internal non-ada", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "changeDirectionDueDate", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "appellant", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "appellantAndRespondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "directionList": "Direction 2", + "directionEditDateDue": "2023-12-31", + "directionEditParties" : "appellant", + "directionEditExplanation": "Do the second thing" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "directions": [ + { + "id": "2", + "value": { + "explanation": "Do the second thing", + "parties": "appellant", + "dateDue": "2023-10-15", + "dateSent": "2023-09-25", + "tag": "", + "previousDates": [ + { + "id": "1", + "value": { + "dateDue": "2023-01-05", + "dateSent": "2023-01-01" + } + } + ] + } + }, + { + "id": "1", + "value": { + "explanation": "Do the first thing", + "parties": "appellantAndRespondent", + "dateDue": "2018-12-31", + "dateSent": "2018-12-25", + "tag": "" + } + } + ], + "editableDirections": null, + "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-appellant-change-direction-due-date-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalChangeDirectionDueDateLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7552-internal-detained-non-ada-appeal-can-proceed.json b/src/functionalTest/resources/scenarios/RIA-7552-internal-detained-non-ada-appeal-can-proceed.json new file mode 100644 index 000000000..295380be6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7552-internal-detained-non-ada-appeal-can-proceed.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7552 Internal detained non-ADA appeal can proceed - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "recordOutOfTimeDecision", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY-2}", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC3_DOC_URL}", + "document_binary_url": "{$FIXTURE_DOC3_DOC_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_DOC_FILENAME}" + } + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "recordOutOfTimeDecisionDocument", + "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_filename": "PA 12345 2019-Awan-appeal-form.PDF", + "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/" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7554-internal-detained-non-ada-request-respondent-evidence.json b/src/functionalTest/resources/scenarios/RIA-7554-internal-detained-non-ada-request-respondent-evidence.json new file mode 100644 index 000000000..8ca6103c4 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7554-internal-detained-non-ada-request-respondent-evidence.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7554 Internal detained non-ADA request respondent evidence - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestRespondentEvidence", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY-2}", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "respondentEvidence", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ], + "notificationAttachmentDocuments":[] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "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-detained-appellant-request-respondent-evidence-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalRequestRespondentEvidenceLetter" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7556-internal-detained-review-home-office-response-decision-maintained.json b/src/functionalTest/resources/scenarios/RIA-7556-internal-detained-review-home-office-response-decision-maintained.json new file mode 100644 index 000000000..414bb9338 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7556-internal-detained-review-home-office-response-decision-maintained.json @@ -0,0 +1,64 @@ +{ + "description": "RIA-7556 Internal detained non-ADA request HO response review - decision maintained", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestResponseReview", + "state": "respondentReview", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY-2}", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "appealReviewOutcome": "decisionMaintained", + "isAdmin": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "appealReviewOutcome": "decisionMaintained", + "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 11111 2019-Gonzlez-Detained appellant letter_HO response when decision maintained.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDetainedRequestHomeOfficeResponseReview" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7557-internal-detained-review-home-office-response-decision-withdrawn.json b/src/functionalTest/resources/scenarios/RIA-7557-internal-detained-review-home-office-response-decision-withdrawn.json new file mode 100644 index 000000000..b37537a0d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7557-internal-detained-review-home-office-response-decision-withdrawn.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7557 Internal detained non-ADA request HO response review - decision withdrawn", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestResponseReview", + "state": "respondentReview", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "appealReviewOutcome": "decisionWithdrawn", + "isAdmin": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestRespondentReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "appealReviewOutcome": "decisionWithdrawn", + "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 11111 2019-Gonzlez-Detained appellant letter_HO response when decision withdrawn.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDetainedRequestHomeOfficeResponseReview" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7559-internal-detained-non-ada-list-case-letter.json b/src/functionalTest/resources/scenarios/RIA-7559-internal-detained-non-ada-list-case-letter.json new file mode 100644 index 000000000..285ad2b60 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7559-internal-detained-non-ada-list-case-letter.json @@ -0,0 +1,48 @@ +{ + "description": "RIA-7559 Internal detained non-ADA list case letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "listCase", + "state": "listing", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "manchester", + "listCaseHearingDate": "2023-08-14T14:30:00", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "manchester", + "listCaseHearingDate": "2023-08-14T14:30:00", + "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-list-case-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalListCaseLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7561-internal-detained-request-hearing-requirements.json b/src/functionalTest/resources/scenarios/RIA-7561-internal-detained-request-hearing-requirements.json new file mode 100644 index 000000000..dd8a49d7d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7561-internal-detained-request-hearing-requirements.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7561 Internal detained non-ADA request hearing requirements - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "requestHearingRequirementsFeature", + "state": "respondentReview", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY-2}", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "directions": [ + { + "id": "1", + "value": { + "tag": "requestResponseReview", + "parties": "respondent", + "uniqueId": "eba53f77-a98e-47ed-af30-f0f4d3372f01", + "explanation": "You have until the date indicated below to review the appellant's argument and evidence. You must explain whether the appellant makes a valid case for overturning the original decision.\n\nYou must respond to the Tribunal and tell them:\n\n- whether you oppose all or parts of the appellant's case\n- what your grounds are for opposing the case\n- which of the issues are agreed or not agreed\n- whether there are any further issues you wish to raise\n- whether you are prepared to withdraw to grant\n- whether the appeal can be resolved without a hearing\n\nNext steps\n\nIf you do not respond in time the Tribunal will decide how the case should proceed.", + "directionType": "requestResponseReview", + "dateDue": "{$TODAY+13}", + "dateSent": "{$TODAY}", + "previousDates": [] + } + } + ], + "notificationAttachmentDocuments":[] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "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-detained-appellant-request-hearing-requirements-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalRequestHearingRequirementsLetter" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7580-internal-detained-non-ada-submit-appeal-appeal-fee-due-letter-generation.json b/src/functionalTest/resources/scenarios/RIA-7580-internal-detained-non-ada-submit-appeal-appeal-fee-due-letter-generation.json new file mode 100644 index 000000000..71fbc4f9d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7580-internal-detained-non-ada-submit-appeal-appeal-fee-due-letter-generation.json @@ -0,0 +1,56 @@ +{ + "description": "RIA-7580 - Internal detained non-ADA appeal fee payment letter no remission", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "id": 7580, + "eventId": "submitAppeal", + "state": "pendingPayment", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "feeAmountGbp": "14000", + "ccdReferenceNumberForDisplay": "1234 5678 1234 5678", + "appellantInDetention": "Yes", + "remissionType": "noRemission", + "appealType": "refusalOfHumanRights", + "appealSubmissionDate": "{$TODAY}" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "feeAmountGbp": "14000", + "ccdReferenceNumberForDisplay": "1234 5678 1234 5678", + "appellantInDetention": "Yes", + "remissionType": "noRemission", + "appealType": "refusalOfHumanRights", + "appealSubmissionDate": "{$TODAY}", + "notificationAttachmentDocuments": [ + { + "id": "2", + "value": { + "tag": "internalAppealFeeDueLetter", + "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_filename": "PA 12345 2019-Awan-internal-detained-appeal-fee-is-due-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-no-remission.json b/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-no-remission.json new file mode 100644 index 000000000..870d4e7f7 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-no-remission.json @@ -0,0 +1,55 @@ +{ + "description": "RIA-7581 Internal detained non-ADA mark appeal paid - No Remission - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "markAppealPaid", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealType": "refusalOfEu", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "paymentStatus": "Paid", + "feeAmountGbp": "14000", + "paidAmount": "14000", + "remissionType": "noRemission" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealType": "refusalOfEu", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "paymentStatus": "Paid", + "feeAmountGbp": "14000", + "paidAmount": "14000", + "remissionType": "noRemission", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetMarkAsPaidLetter", + "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_filename": "PA 12345 2019-Awan-detained-appellant-mark-appeal-paid-notice.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-with-remission.json b/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-with-remission.json new file mode 100644 index 000000000..aaf90160a --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7581-internal-detained-non-ada-mark-as-paid-document-with-remission.json @@ -0,0 +1,57 @@ +{ + "description": "RIA-7581 Internal detained non-ADA mark appeal paid - No Remission - document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "markAppealPaid", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealType": "refusalOfEu", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "paymentStatus": "Paid", + "feeAmountGbp": "14000", + "paidAmount": "4000", + "amountRemitted": "10000", + "remissionType": "hoWaiverRemission" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealType": "refusalOfEu", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "paymentStatus": "Paid", + "feeAmountGbp": "14000", + "paidAmount": "4000", + "amountRemitted": "10000", + "remissionType": "hoWaiverRemission", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalDetMarkAsPaidLetter", + "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_filename": "PA 12345 2019-Awan-detained-appellant-mark-appeal-paid-notice.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7582-internal-end-appeal-automatically-notice-document.json b/src/functionalTest/resources/scenarios/RIA-7582-internal-end-appeal-automatically-notice-document.json new file mode 100644 index 000000000..903c1a8ab --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7582-internal-end-appeal-automatically-notice-document.json @@ -0,0 +1,50 @@ +{ + "description": "RIA-7582 internal end appeal automatically notice document PDF", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "System", + "input": { + "eventId": "endAppealAutomatically", + "state": "*", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY-2}", + "isAcceleratedDetainedAppeal": "No", + "appellantInDetention": "Yes", + "tribunalDocuments": [], + "isAdmin": "Yes", + "remissionType": "noRemission" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isAdmin": "Yes", + "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 11111 2019-Gonzlez-detained-appellant-end-appeal-automaticaly-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalEndAppealAutomatically" + } + } + ] + } + } + } +} + diff --git a/src/functionalTest/resources/scenarios/RIA-7618-internal-detained-non-ada-remission-decision-appeal-fee-due-letter.json b/src/functionalTest/resources/scenarios/RIA-7618-internal-detained-non-ada-remission-decision-appeal-fee-due-letter.json new file mode 100644 index 000000000..3e61c19e9 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7618-internal-detained-non-ada-remission-decision-appeal-fee-due-letter.json @@ -0,0 +1,59 @@ +{ + "description": "RIA-7618 - Internal detained non-ADA Remission Decision appeal fee due", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "id": 7618, + "eventId": "recordRemissionDecision", + "state": "pendingPayment", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "feeAmountGbp": "14000", + "ccdReferenceNumberForDisplay": "1234 5678 1234 5678", + "appellantInDetention": "Yes", + "remissionType": "hoWaiverRemission", + "remissionDecision": "rejected", + "amountRemitted": 0, + "appealType": "refusalOfHumanRights", + "appealSubmissionDate": "{$TODAY}" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "isAcceleratedDetainedAppeal": "No", + "feeAmountGbp": "14000", + "ccdReferenceNumberForDisplay": "1234 5678 1234 5678", + "appellantInDetention": "Yes", + "remissionType": "hoWaiverRemission", + "remissionDecision": "rejected", + "appealType": "refusalOfHumanRights", + "appealSubmissionDate": "{$TODAY}", + "notificationAttachmentDocuments": [ + { + "id": "1", + "value": { + "tag": "internalAppealFeeDueLetter", + "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_filename": "PA 12345 2019-Awan-internal-detained-appeal-fee-is-due-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/src/functionalTest/resources/scenarios/RIA-7701-internal-detained-transfer-out-of-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7701-internal-detained-transfer-out-of-ada-letter.json new file mode 100644 index 000000000..214899e98 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7701-internal-detained-transfer-out-of-ada-letter.json @@ -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" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-granted-letter.json new file mode 100644 index 000000000..7d671f27d --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-granted-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7844 internal ADA application decided letter (Reinstate - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7844, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Reinstate an ended appeal", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-refused-letter.json new file mode 100644 index 000000000..9534c17fd --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7844-internal-ada-decide-an-application-reinstate-decision-refused-letter.json @@ -0,0 +1,63 @@ +{ + "description": "RIA-7844 internal ADA application decided letter (Reinstate - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7844, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Reinstate an ended appeal", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-granted-letter.json b/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-granted-letter.json new file mode 100644 index 000000000..ecd2ab106 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-granted-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7844 internal detained (non-ada) application decided letter (Reinstate - Granted)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7844, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Reinstate an ended appeal", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Granted", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-granted.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-refused-letter.json b/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-refused-letter.json new file mode 100644 index 000000000..7ae0c5fe4 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7844-internal-detained-decide-an-application-reinstate-decision-refused-letter.json @@ -0,0 +1,62 @@ +{ + "description": "RIA-7844 internal detained (non-ada) application decided letter (Reinstate - Refused)", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "id": 7844, + "eventId": "decideAnApplication", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appellantInDetention": "Yes", + "decideAnApplicationId": "1", + "makeAnApplications": [ + { + "id": "1", + "value": { + "type":"Reinstate an ended appeal", + "details":"", + "evidence":[], + "applicant":"Admin Officer", + "date":"{$TODAY}", + "decision":"Refused", + "state":"appealSubmitted", + "applicantRole":"caseworker-ia-admofficer", + "decisionReason":"No Reason given", + "decisionDate":"{$TODAY}", + "decisionMaker": "Admin Officer" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "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-appellant-letter-application-refused.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "internalDecideAnAppellantApplicationLetter" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-ada-letter.json new file mode 100644 index 000000000..b9cdcb883 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-ada-letter.json @@ -0,0 +1,46 @@ +{ + "description": "RIA-7911 Internal hearing adjustments updated letter - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7911, + "eventId": "updateHearingAdjustments", + "state": "awaitingRespondentEvidence", + "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": { + "tag": "internalHearingAdjustmentsUpdatedLetter", + "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_filename": "PA 12345 2019-Awan-hearing-adjustments-updated-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-non-ada-letter.json b/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-non-ada-letter.json new file mode 100644 index 000000000..9211891da --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-7911-internal-hearing-requirements-updated-non-ada-letter.json @@ -0,0 +1,46 @@ +{ + "description": "RIA-7911 Internal hearing adjustments updated letter - ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "id": 7911, + "eventId": "updateHearingAdjustments", + "state": "awaitingRespondentEvidence", + "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": { + "tag": "internalHearingAdjustmentsUpdatedLetter", + "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_filename": "PA 12345 2019-Awan-hearing-adjustments-updated-letter.PDF", + "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/" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8023-internal-appeal-summary-document-and-det-letter-detained-non-ada.json b/src/functionalTest/resources/scenarios/RIA-8023-internal-appeal-summary-document-and-det-letter-detained-non-ada.json new file mode 100644 index 000000000..b221945f6 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8023-internal-appeal-summary-document-and-det-letter-detained-non-ada.json @@ -0,0 +1,44 @@ +{ + "description": "RIA-8023 Internal appeal summary for Submit Appeal - Detained Non-ADA", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "submitAppeal", + "state": "appealSubmitted", + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "appealSubmissionDate": "{$TODAY}", + "appellantInDetention": "Yes", + "isAcceleratedDetainedAppeal": "No", + "legalRepresentativeDocuments": [] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-internal-appeal-submitted.json", + "replacements": { + "legalRepresentativeDocuments": [ + { + "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-appeal-form.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "appealSubmission" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8256-ftpa-reheard-decisions-and-reasons-complex-collection.json b/src/functionalTest/resources/scenarios/RIA-8256-ftpa-reheard-decisions-and-reasons-complex-collection.json new file mode 100644 index 000000000..150f7b7a1 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8256-ftpa-reheard-decisions-and-reasons-complex-collection.json @@ -0,0 +1,96 @@ +{ + "description": "RIA-8256 Send decision and reasons - FTPA reheard", + "disabled": "true", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "sendDecisionAndReasons", + "state": "decision", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "isReheardAppealEnabled": "Yes", + "caseFlagSetAsideReheardExists": "Yes", + "appellantFamilyName": "Doe", + "appealReferenceNumber": "PA/11111/2019", + "legalRepReferenceNumber": "some-legal-rep-reference", + "isDecisionAllowed": "allowed", + "finalDecisionAndReasonsDocument": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "draftDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "decisionAndReasons", + "document": { + "document_url": "{$FIXTURE_DOC3_DOC_URL}", + "document_binary_url": "{$FIXTURE_DOC3_DOC_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_DOC_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ], + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}" + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantFamilyName": "Doe", + "isReheardAppealEnabled": "Yes", + "caseFlagSetAsideReheardExists": "Yes", + "reheardDecisionReasonsCollection": [ + { + "id": "1", + "value": { + "reheardHearingDocs": [ + { + "id": "2", + "value": { + "tag": "finalDecisionAndReasonsPdf", + "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 11111 2019-Doe-Decision-and-reasons-FINAL.pdf" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "suppliedBy": "" + } + }, + { + "id": "1", + "value": { + "tag": "decisionAndReasonsCoverLetter", + "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 11111 2019-Doe-Decision-and-reasons-Cover-letter.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "suppliedBy": "" + } + } + ] + } + } + ], + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}" + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8291-generate-hearing-bundle-remitted.json b/src/functionalTest/resources/scenarios/RIA-8291-generate-hearing-bundle-remitted.json new file mode 100644 index 000000000..19208d303 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8291-generate-hearing-bundle-remitted.json @@ -0,0 +1,307 @@ +{ + "description": "RIA-3130-generate-hearing-generic-bundle", + "enabled": "{$featureFlag.isEmStitchingEnabled}", + "launchDarklyKey": "dlrm-remitted-feature-flag:true", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "CaseOfficer", + "input": { + "eventId": "generateHearingBundle", + "state": "preHearing", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "listCaseHearingCentre": "taylorHouse", + "ariaListingReference": "LP/12345/2019", + "legalRepReferenceNumber": "REF54321", + "caseFlagSetAsideReheardExists": "Yes", + "addendumEvidenceDocuments": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The respondent" + } + }, + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The appellant" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The appellant" + } + } + ], + "additionalEvidenceDocuments": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "respondentDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "additionalEvidence" + } + } + ], + "reheardDecisionReasonsCollection": [ + { + "id": "1", + "value": { + "reheardHearingDocs": [ + { + "id": "1", + "value": { + "tag": "finalDecisionAndReasonsPdf", + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + }, + { + "id": "1", + "value": { + "tag": "decisionAndReasonsCoverLetter", + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "suppliedBy": "", + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + ], + "remittalDocuments": [ + { + "id": "1", + "value": { + "decisionDocument": { + "tag": "remittalDecision", + "document": { + "document_url": "http://document-store/BBB", + "document_filename": "UI-2023-000001-Decision-to-remit.pdf", + "document_binary_url": "http://document-store/BBB/binary" + }, + "description": "", + "dateUploaded": "{$TODAY}" + }, + "otherRemittalDocs": [ + { + "id": "11", + "value": { + "tag": "remittalDecision", + "document": { + "document_url": "http://document-store/BBB", + "document_filename": "otherRemittalDoc.pdf", + "document_binary_url": "http://document-store/BBB/binary" + }, + "description": "test", + "dateUploaded": "{$TODAY}" + } + } + ] + } + } + ], + "reheardHearingDocumentsCollection": [ + { + "id": "1", + "value": { + "reheardHearingDocs": [ + { + "id": "2", + "value": { + "document": { + "document_url": "http://document-store/AAA", + "document_binary_url": "http://document-store/AAA/binary", + "document_filename": "case-summary.pdf" + }, + "description": "Case summary", + "dateUploaded": "{$TODAY}", + "tag": "caseSummary" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "http://document-store/BBB", + "document_binary_url": "http://document-store/BBB/binary", + "document_filename": "PA 11111 2019-Awan-hearing-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "reheardHearingNotice", + "suppliedBy": "" + } + } + ] + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantAddendumEvidenceDocs": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The appellant" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The appellant" + } + } + ], + "respondentAddendumEvidenceDocs": [ + { + "id": "3", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC3_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC3_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC3_PDF_FILENAME}" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "addendumEvidence", + "suppliedBy": "The respondent" + } + } + ], + "appAdditionalEvidenceDocs": [ + { + "id": "2", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + }, + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC2_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC2_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC2_PDF_FILENAME}" + }, + "description": "" + } + } + ], + "respAdditionalEvidenceDocs": [ + { + "id": "1", + "value": { + "document": { + "document_url": "{$FIXTURE_DOC1_PDF_URL}", + "document_binary_url": "{$FIXTURE_DOC1_PDF_URL_BINARY}", + "document_filename": "{$FIXTURE_DOC1_PDF_FILENAME}" + }, + "description": "" + } + } + ] + + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter-aip.json b/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter-aip.json new file mode 100644 index 000000000..8876b17b3 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter-aip.json @@ -0,0 +1,68 @@ +{ + "description": "RIA-8721 AIP Update tribunal decision - AMENDED cover letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "updateTribunalDecision", + "state": "decided", + "caseData": { + "template": "minimal-aip-appeal-submitted.json", + "replacements": { + "updateTribunalDecisionList": "underRule31", + "updatedAppealDecision": "Allowed", + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "correctedDecisionAndReasons": [ + { + "id": "1", + "value": { + "updatedDecisionDate": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-aip-appeal-submitted.json", + "replacements": { + "finalDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "updatedDecisionAndReasonsCoverLetter", + "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 2018-Awan-Decision-and-reasons-Cover-letter-AMENDED.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ], + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "correctedDecisionAndReasons": [ + { + "id": "1", + "value": { + "updatedDecisionDate": "{$TODAY}", + "coverLetterDocument": { + "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 2018-Awan-Decision-and-reasons-Cover-letter-AMENDED.PDF" + }, + "dateCoverLetterDocumentUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter.json b/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter.json new file mode 100644 index 000000000..bf550878c --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8721-update-tribunal-decision-cover-letter.json @@ -0,0 +1,74 @@ +{ + "description": "RIA-8721 Update tribunal decision - AMENDED cover letter", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "Judge", + "input": { + "eventId": "updateTribunalDecision", + "state": "decided", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "updateTribunalDecisionList": "underRule31", + "appealReferenceNumber": "PA/11111/2019", + "legalRepReferenceNumber": "some-legal-rep-reference", + "updatedAppealDecision": "Dismissed", + "appellantGivenNames": "John", + "appellantFamilyName": "Doe", + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "correctedDecisionAndReasons": [ + { + "id": "1", + "value": { + "updatedDecisionDate": "{$TODAY}" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantGivenNames": "John", + "appellantFamilyName": "Doe", + "finalDecisionAndReasonsDocuments": [ + { + "id": "1", + "value": { + "tag": "updatedDecisionAndReasonsCoverLetter", + "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 11111 2019-Doe-Decision-and-reasons-Cover-letter-AMENDED.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}" + } + } + ], + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "correctedDecisionAndReasons": [ + { + "id": "1", + "value": { + "updatedDecisionDate": "{$TODAY}", + "coverLetterDocument": { + "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 11111 2019-Doe-Decision-and-reasons-Cover-letter-AMENDED.PDF" + }, + "dateCoverLetterDocumentUploaded": "{$TODAY}" + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/scenarios/RIA-8772-reheard-listing-hearing-noticed-remitted.json b/src/functionalTest/resources/scenarios/RIA-8772-reheard-listing-hearing-noticed-remitted.json new file mode 100644 index 000000000..7f76cb2d2 --- /dev/null +++ b/src/functionalTest/resources/scenarios/RIA-8772-reheard-listing-hearing-noticed-remitted.json @@ -0,0 +1,92 @@ +{ + "description": "RIA-8772 Create reheard hearing notice PDF (IAC Birmingham) - Remitted reheard hearing documents complex collection", + "disabled": "true", + "request": { + "uri": "/asylum/ccdAboutToSubmit", + "credentials": "AdminOfficer", + "input": { + "eventId": "listCase", + "state": "listing", + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantFamilyName": "Doe", + "isReheardAppealEnabled": "Yes", + "caseFlagSetAsideReheardExists": "Yes", + "listCaseHearingCentre": "birmingham", + "listCaseHearingLength": "60", + "listCaseHearingDate": "2018-12-31T12:34:56", + "listCaseRequirementsVulnerabilities": "something around Vulnerabilities", + "listCaseRequirementsMultimedia": "something around Multimedia", + "listCaseRequirementsSingleSexCourt": "something around SingleSexCourt", + "listCaseRequirementsInCameraCourt": "something around InCameraCourt", + "listCaseRequirementsOther": "something around Other", + "ariaListingReference": "AA/12345/1234", + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "hearingDocuments": [ + { + "id": "1", + "value": { + "document": { + "document_url": "old-hearing-notice", + "document_binary_url": "old-hearing-notice", + "document_filename": "old-hearing-notice" + }, + "description": "OLD HEARING NOTICE", + "dateUploaded": "2019-01-01", + "tag": "hearingNotice" + } + } + ] + } + } + } + }, + "expectation": { + "status": 200, + "errors": [], + "caseData": { + "template": "minimal-appeal-submitted.json", + "replacements": { + "appellantFamilyName": "Doe", + "isReheardAppealEnabled": "Yes", + "caseFlagSetAsideReheardExists": "Yes", + "listCaseHearingCentre": "birmingham", + "listCaseHearingLength": "60", + "listCaseHearingDate": "2018-12-31T12:34:56", + "listCaseRequirementsVulnerabilities": "something around Vulnerabilities", + "listCaseRequirementsMultimedia": "something around Multimedia", + "listCaseRequirementsSingleSexCourt": "something around SingleSexCourt", + "listCaseRequirementsInCameraCourt": "something around InCameraCourt", + "listCaseRequirementsOther": "something around Other", + "ariaListingReference": "AA/12345/1234", + "customerServicesTelephone": "{$customerServices.telephoneNumber}", + "customerServicesEmail": "{$customerServices.emailAddress}", + "reheardHearingDocumentsCollection": [ + { + "id": "1", + "value": { + "reheardHearingDocs": [ + { + "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 11111 2019-Doe-hearing-notice.PDF" + }, + "description": "", + "dateUploaded": "{$TODAY}", + "tag": "reheardHearingNotice", + "suppliedBy": "" + } + } + ] + } + } + ] + } + } + } +} diff --git a/src/functionalTest/resources/templates/minimal-appeal-submitted.json b/src/functionalTest/resources/templates/minimal-appeal-submitted.json index d8eec4b24..fa1c95de9 100644 --- a/src/functionalTest/resources/templates/minimal-appeal-submitted.json +++ b/src/functionalTest/resources/templates/minimal-appeal-submitted.json @@ -29,4 +29,4 @@ "legalRepresentativeName": "A Test Legal Rep", "legalRepresentativeEmailAddress": "{$TEST_LAW_FIRM_A_USERNAME}", "sendDirectionActionAvailable": "Yes" -} \ No newline at end of file +} diff --git a/src/functionalTest/resources/templates/minimal-internal-appeal-submitted.json b/src/functionalTest/resources/templates/minimal-internal-appeal-submitted.json new file mode 100644 index 000000000..6e0ca1a30 --- /dev/null +++ b/src/functionalTest/resources/templates/minimal-internal-appeal-submitted.json @@ -0,0 +1,29 @@ +{ + "homeOfficeReferenceNumber": "A1234567", + "isAdmin": "Yes", + "homeOfficeDecisionDate": "{$TODAY}", + "appellantTitle": "Mr", + "appellantGivenNames": "Talha", + "appellantFamilyName": "Awan", + "appellantDateOfBirth": "{$TODAY-7300}", + "appellantNationalities": [ + { + "id": "1", + "value": { + "Iceland": "IS" + } + } + ], + "appellantHasFixedAddress": "No", + "appealType": "protection", + "appealGroundsProtection": { + "values": [ + "refugeeConvention" + ] + }, + "hasNewMatters": "No", + "hasOtherAppeals": "No", + "appealReferenceNumber": "PA/12345/2019", + "sendDirectionActionAvailable": "Yes", + "hearingCentre": "taylorHouse" +} diff --git a/src/integrationTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/component/GenerateDecisionAndReasonsTestWiremock.java b/src/integrationTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/component/GenerateDecisionAndReasonsTestWiremock.java index 8eb4d813f..c2f294ff5 100644 --- a/src/integrationTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/component/GenerateDecisionAndReasonsTestWiremock.java +++ b/src/integrationTest/java/uk/gov/hmcts/reform/iacasedocumentsapi/component/GenerateDecisionAndReasonsTestWiremock.java @@ -16,6 +16,7 @@ import org.springframework.security.test.context.support.WithMockUser; import uk.gov.hmcts.reform.iacasedocumentsapi.component.testutils.*; import uk.gov.hmcts.reform.iacasedocumentsapi.component.testutils.fixtures.PreSubmitCallbackResponseForTest; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealType; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; @@ -64,6 +65,7 @@ void generates_decision_and_reasons() { .with(APPELLANT_REPRESENTATIVE, "ted") .with(RESPONDENT_REPRESENTATIVE, "bill") .with(LIST_CASE_HEARING_CENTRE, "taylorHouse") + .with(APPEAL_TYPE, AppealType.HU.getValue()) ))); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AdaSuitabilityReviewDecision.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AdaSuitabilityReviewDecision.java new file mode 100644 index 000000000..dc13442f9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AdaSuitabilityReviewDecision.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AdaSuitabilityReviewDecision { + + SUITABLE("suitable"), + UNSUITABLE("unsuitable"); + + @JsonValue + private final String value; + + AdaSuitabilityReviewDecision(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealReviewOutcome.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealReviewOutcome.java new file mode 100644 index 000000000..d69c17e58 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealReviewOutcome.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum AppealReviewOutcome { + + DECISION_MAINTAINED("decisionMaintained"), + DECISION_WITHDRAWN("decisionWithdrawn"); + + @JsonValue + private final String value; + + AppealReviewOutcome(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealType.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealType.java new file mode 100644 index 000000000..18aaf2b53 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealType.java @@ -0,0 +1,49 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static java.util.Arrays.stream; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Optional; + +public enum AppealType { + + RP("revocationOfProtection", "Revocation of a protection status"), + PA("protection", "Refusal of protection claim"), + EA("refusalOfEu", "Refusal of application under the EEA regulations"), + HU("refusalOfHumanRights", "Refusal of a human rights claim"), + DC("deprivation", "Deprivation of citizenship"), + EU("euSettlementScheme", "EU Settlement Scheme"), + AG("ageAssessment", "Age assessment appeal"); + + + @JsonValue + private String value; + + private String description; + + AppealType(String value, String description) { + this.value = value; + this.description = description; + } + + public static Optional from( + String value + ) { + return stream(values()) + .filter(v -> v.getValue().equals(value)) + .findFirst(); + } + + public String getValue() { + return value; + } + + public String getDescription() { + return description; + } + + @Override + public String toString() { + return value + ": " + description; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCase.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCase.java index 3bc79d407..9c80e3de8 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCase.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCase.java @@ -1,9 +1,14 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Optional; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseData; public class AsylumCase extends HashMap implements CaseData { @@ -12,6 +17,13 @@ public class AsylumCase extends HashMap implements CaseData { public AsylumCase() { objectMapper.registerModule(new Jdk8Module()); + + JavaTimeModule javaTimeModule = new JavaTimeModule(); + + javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ISO_DATE_TIME)); + + objectMapper.registerModule(javaTimeModule); + objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); } /* diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCaseDefinition.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCaseDefinition.java index 69601e8f9..38c623f39 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCaseDefinition.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AsylumCaseDefinition.java @@ -1,10 +1,11 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; -import com.fasterxml.jackson.core.type.TypeReference; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.type.TypeReference; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.OutOfCountryDecisionType; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking.CaseLink; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.Bundle; public enum AsylumCaseDefinition { @@ -97,7 +98,7 @@ public enum AsylumCaseDefinition { "appellantAddress", new TypeReference(){}), APPEAL_TYPE( - "appealType", new TypeReference(){}), + "appealType", new TypeReference(){}), REASONS_FOR_APPEAL_DECISION( "reasonsForAppealDecision", new TypeReference(){}), @@ -114,6 +115,11 @@ public enum AsylumCaseDefinition { APPEAL_SUBMISSION_DATE( "appealSubmissionDate", new TypeReference(){}), + REMOVAL_ORDER_OPTIONS( + "removalOrderOptions", new TypeReference(){}), + + REMOVAL_ORDER_DATE( + "removalOrderDate", new TypeReference(){}), NEW_MATTERS( "newMatters", new TypeReference(){}), @@ -486,8 +492,6 @@ public enum AsylumCaseDefinition { DATES_TO_AVOID_YES_NO( "datesToAvoidYesNo", new TypeReference(){}), - IS_OUT_OF_COUNTRY_ENABLED( - "isOutOfCountryEnabled", new TypeReference(){}), REMOTE_VIDEO_CALL( "remoteVideoCall", new TypeReference(){}), @@ -590,6 +594,9 @@ public enum AsylumCaseDefinition { APP_ADDITIONAL_EVIDENCE_DOCS( "appAdditionalEvidenceDocs", new TypeReference>>(){}), + CUSTOM_TRIBUNAL_DOCUMENTS( + "customTribunalDocuments", new TypeReference>>(){}), + RESP_ADDITIONAL_EVIDENCE_DOCS( "respAdditionalEvidenceDocs", new TypeReference>>(){}), @@ -615,10 +622,150 @@ public enum AsylumCaseDefinition { "isIntegrated", new TypeReference(){}), CLARIFYING_QUESTIONS_ANSWERS("clarifyingQuestionsAnswers", - new TypeReference>>() {}) + new TypeReference>>() {}), + + UPDATED_APPEAL_DECISION( + "updatedAppealDecision", new TypeReference(){}), + + APPELLANT_IN_DETENTION( + "appellantInDetention", new TypeReference() {} + ), + DETENTION_FACILITY( + "detentionFacility", new TypeReference(){}), + + IRC_NAME( + "ircName", new TypeReference(){}), + + PRISON_NAME( + "prisonName", new TypeReference(){}), + + HAS_PENDING_BAIL_APPLICATIONS( + "hasPendingBailApplications", new TypeReference() {}), + + BAIL_APPLICATION_NUMBER( + "bailApplicationNumber", new TypeReference(){}), + + IS_ACCELERATED_DETAINED_APPEAL( + "isAcceleratedDetainedAppeal", new TypeReference(){}), + + SUITABILITY_REVIEW_DECISION( + "suitabilityReviewDecision", new TypeReference(){}), + + SUITABILITY_REVIEW_REASON( + "suitabilityReviewReason", new TypeReference(){}), + + SUITABILITY_REVIEW_JUDGE( + "suitabilityReviewJudge", new TypeReference(){}), + + IS_ADMIN( + "isAdmin", new TypeReference() {}), + + HAS_OTHER_APPEALS( + "hasOtherAppeals", new TypeReference() {}), + + // Case data section to hold generated documents,so they can be attached to email notifications + NOTIFICATION_ATTACHMENT_DOCUMENTS( + "notificationAttachmentDocuments", new TypeReference>>(){}), + + RECORDED_OUT_OF_TIME_DECISION( + "recordedOutOfTimeDecision", new TypeReference(){}), + + APPEAL_REVIEW_OUTCOME( + "appealReviewOutcome", new TypeReference(){}), + + REMISSION_TYPE( + "remissionType", new TypeReference(){}), + + REMISSION_REJECTED_DATE_PLUS_14DAYS( + "remissionRejectedDatePlus14days", new TypeReference(){}), + + CCD_REFERENCE_NUMBER_FOR_DISPLAY( + "ccdReferenceNumberForDisplay", new TypeReference(){}), + + FEE_AMOUNT_GBP( + "feeAmountGbp", new TypeReference(){}), + + UPDATE_TRIBUNAL_DECISION_LIST( + "updateTribunalDecisionList", new TypeReference(){}), + + CORRECTED_DECISION_AND_REASONS( + "correctedDecisionAndReasons", new TypeReference>>() {}), + + AMOUNT_REMITTED( + "amountRemitted", new TypeReference(){}), + + REHEARD_HEARING_DOCUMENTS_COLLECTION( + "reheardHearingDocumentsCollection", new TypeReference>>(){}), + + REHEARD_DECISION_REASONS_COLLECTION( + "reheardDecisionReasonsCollection", new TypeReference>>(){}), + + REMITTAL_DOCUMENTS( + "remittalDocuments", new TypeReference>>(){}), + + LATEST_DECISION_AND_REASONS_DOCUMENTS( + "latestDecisionAndReasonsDocuments", new TypeReference>>(){}), + + LATEST_REMITTAL_DOCUMENTS( + "latestRemittalDocuments", new TypeReference>>(){}), + + LATEST_REHEARD_HEARING_DOCUMENTS( + "latestReheardHearingDocuments", new TypeReference>>(){}), + + PAID_AMOUNT( + "paidAmount", new TypeReference(){}), + + REMISSION_DECISION( + "remissionDecision", new TypeReference(){}), + + REASON_APPEAL_MARKED_AS_ADA( + "reasonAppealMarkedAsAda", new TypeReference(){}), + + MAKE_AN_APPLICATIONS( + "makeAnApplications", new TypeReference>>(){}), + + DECIDE_AN_APPLICATION_ID( + "decideAnApplicationId", new TypeReference(){}), + + TRANSFER_OUT_OF_ADA_REASON( + "transferOutOfAdaReason", new TypeReference(){}), + + TRANSFER_OUT_OF_ADA_MORE_DETAILS( + "transferOutOfAdaMoreDetails", new TypeReference(){}), + + FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE( + "ftpaAppellantRjDecisionOutcomeType", new TypeReference(){}), + + FTPA_APPLICANT_TYPE( + "ftpaApplicantType", new TypeReference(){}), + DIRECTION_EDIT_DATE_DUE( + "directionEditDateDue", new TypeReference(){}), + + DIRECTION_EDIT_EXPLANATION( + "directionEditExplanation", new TypeReference(){}), + DIRECTION_EDIT_PARTIES( + "directionEditParties", new TypeReference(){}), + + SEND_DIRECTION_PARTIES( + "sendDirectionParties", new TypeReference(){}), + + FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE( + "ftpaRespondentRjDecisionOutcomeType", new TypeReference(){}), + + CASE_LINKS( + "caseLinks", new TypeReference>>(){}), + + REINSTATE_APPEAL_DATE( + "reinstateAppealDate", new TypeReference(){}), + + REINSTATE_APPEAL_REASON( + "reinstateAppealReason", new TypeReference(){}), - ; + REINSTATED_DECISION_MAKER( + "reinstatedDecisionMaker", new TypeReference(){}), + ADJOURN_HEARING_WITHOUT_DATE_REASONS( + "adjournHearingWithoutDateReasons", new TypeReference() {}); private final String value; private final TypeReference typeReference; diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/BailCaseFieldDefinition.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/BailCaseFieldDefinition.java index 7d1119dab..f412098d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/BailCaseFieldDefinition.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/BailCaseFieldDefinition.java @@ -6,6 +6,13 @@ import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.bail.BailInterpreterLanguageRefData; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.*; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients.model.refdata.CourtVenue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.bail.BailInterpreterLanguageRefData; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.AddressUk; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.InterpreterLanguage; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.NationalityFieldValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; public enum BailCaseFieldDefinition { SENT_BY_CHECKLIST( @@ -339,6 +346,7 @@ public enum BailCaseFieldDefinition { "fcs4InterpreterSpokenLanguage", new TypeReference() {}), FCS4_INTERPRETER_SIGN_LANGUAGE( "fcs4InterpreterSignLanguage", new TypeReference() {}), + LISTING_EVENT("listingEvent", new TypeReference(){}), LISTING_LOCATION("listingLocation", new TypeReference(){}), LISTING_HEARING_DATE("listingHearingDate", new TypeReference(){}), diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasons.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasons.java new file mode 100644 index 000000000..8a3a1d5e3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasons.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; + +@Getter +@Setter +@Builder +@AllArgsConstructor +public class DecisionAndReasons { + + private String updatedDecisionDate; + private String dateCoverLetterDocumentUploaded; + private Document coverLetterDocument; + private String dateDocumentAndReasonsDocumentUploaded; + private Document documentAndReasonsDocument; + private String summariseChanges; + + private DecisionAndReasons() { + // noop -- for deserializer + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTag.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTag.java index 0d273bcba..d6efe9300 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTag.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTag.java @@ -18,6 +18,7 @@ public enum DirectionTag { REQUEST_REASONS_FOR_APPEAL("requestReasonsForAppeal"), REQUEST_CLARIFYING_QUESTIONS("requestClarifyingQuestions"), REQUEST_CMA_REQUIREMENTS("requestCmaRequirements"), + ADA_LIST_CASE("adaListCase"), @JsonEnumDefaultValue NONE(""); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTag.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTag.java index 1088e273f..5e663c270 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTag.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTag.java @@ -10,17 +10,24 @@ public enum DocumentTag { RESPONDENT_EVIDENCE("respondentEvidence", CaseType.ASYLUM), APPEAL_RESPONSE("appealResponse", CaseType.ASYLUM), APPEAL_SUBMISSION("appealSubmission", CaseType.ASYLUM), + INTERNAL_APPEAL_SUBMISSION("internalAppealSubmission", CaseType.ASYLUM), ADDITIONAL_EVIDENCE("additionalEvidence", CaseType.ASYLUM), HEARING_REQUIREMENTS("hearingRequirements", CaseType.ASYLUM), HEARING_NOTICE("hearingNotice", CaseType.ASYLUM), REHEARD_HEARING_NOTICE("reheardHearingNotice", CaseType.ASYLUM), + ADA_SUITABILITY("adaSuitability", CaseType.ASYLUM), + INTERNAL_ADA_SUITABILITY("internalAdaSuitability", CaseType.ASYLUM), CASE_SUMMARY("caseSummary", CaseType.ASYLUM), HEARING_BUNDLE("hearingBundle", CaseType.ASYLUM), ADDENDUM_EVIDENCE("addendumEvidence", CaseType.ASYLUM), DECISION_AND_REASONS_DRAFT("decisionAndReasons", CaseType.ASYLUM), REHEARD_DECISION_AND_REASONS_DRAFT("reheardDecisionAndReasons", CaseType.ASYLUM), DECISION_AND_REASONS_COVER_LETTER("decisionAndReasonsCoverLetter", CaseType.ASYLUM), + UPDATED_DECISION_AND_REASONS_COVER_LETTER("updatedDecisionAndReasonsCoverLetter", CaseType.ASYLUM), + INTERNAL_DET_DECISION_AND_REASONS_LETTER("internalDetDecisionAndReasonsLetter", CaseType.ASYLUM), FINAL_DECISION_AND_REASONS_PDF("finalDecisionAndReasonsPdf", CaseType.ASYLUM), + UPDATED_FINAL_DECISION_AND_REASONS_PDF("updatedFinalDecisionAndReasonsPdf", CaseType.ASYLUM), + FINAL_DECISION_AND_REASONS_DOCUMENT("finalDecisionAndReasonsDocument", CaseType.ASYLUM), APPEAL_SKELETON_BUNDLE("submitCaseBundle", CaseType.ASYLUM), END_APPEAL("endAppeal", CaseType.ASYLUM), END_APPEAL_AUTOMATICALLY("endAppealAutomatically", CaseType.ASYLUM), @@ -35,6 +42,46 @@ public enum DocumentTag { APPEAL_REASONS("appealReasons", CaseType.ASYLUM), CLARIFYING_QUESTIONS("clarifyingQuestions", CaseType.ASYLUM), NOTICE_OF_ADJOURNED_HEARING("noticeOfAdjournedHearing", CaseType.ASYLUM), + APPEAL_FORM("appealForm", CaseType.ASYLUM), + NOTICE_OF_DECISION_UT_TRANSFER("noticeOfDecisionUtTransfer", CaseType.ASYLUM), + REQUEST_CASE_BUILDING("requestCaseBuilding", CaseType.ASYLUM), + REQUEST_RESPONDENT_REVIEW("requestRespondentReview", CaseType.ASYLUM), + UPLOAD_THE_APPEAL_RESPONSE("uploadTheAppealResponse", CaseType.ASYLUM), + HEARING_BUNDLE_READY_LETTER("hearingBundleReadyLetter", CaseType.ASYLUM), + INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER("internalRequestRespondentEvidenceLetter", CaseType.ASYLUM), + INTERNAL_END_APPEAL_AUTOMATICALLY("internalEndAppealAutomatically", CaseType.ASYLUM), + INTERNAL_APPEAL_FEE_DUE_LETTER("internalAppealFeeDueLetter", CaseType.ASYLUM), + INTERNAL_DET_MARK_AS_PAID_LETTER("internalDetMarkAsPaidLetter", CaseType.ASYLUM), + INTERNAL_LIST_CASE_LETTER("internalListCaseLetter", CaseType.ASYLUM), + INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER("internalRequestHearingRequirementsLetter", CaseType.ASYLUM), + INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW("internalDetainedRequestHomeOfficeResponseReview", CaseType.ASYLUM), + INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER("internalDetainedEditCaseListingLetter", CaseType.ASYLUM), + INTERNAL_DET_MARK_AS_ADA_LETTER("internalDetMarkAsAdaLetter", CaseType.ASYLUM), + INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER("internalDecideAnAppellantApplicationLetter", CaseType.ASYLUM), + INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER("internalDecideHomeOfficeApplicationLetter", CaseType.ASYLUM), + INTERNAL_APPLY_FOR_FTPA_RESPONDENT("internalApplyForFtpaRespondent", CaseType.ASYLUM), + INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER("internalDetainedTransferOutOfAdaLetter", CaseType.ASYLUM), + INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER("internalFtpaSubmittedAppellantLetter", CaseType.ASYLUM), + INTERNAL_APPELLANT_FTPA_DECIDED_LETTER("internalAppellantFtpaDecidedLetter", CaseType.ASYLUM), + INTERNAL_HO_FTPA_DECIDED_LETTER("internalHoFtpaDecidedLetter", CaseType.ASYLUM), + INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER("internalHearingAdjustmentsUpdatedLetter", CaseType.ASYLUM), + MAINTAIN_CASE_UNLINK_APPEAL_LETTER("maintainCaseUnlinkAppealLetter", CaseType.ASYLUM), + MAINTAIN_CASE_LINK_APPEAL_LETTER("maintainCaseLinkAppealLetter", CaseType.ASYLUM), + INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER("internalUploadAdditionalEvidenceLetter", CaseType.ASYLUM), + INTERNAL_CHANGE_HEARING_CENTRE_LETTER("internalChangeHearingCentreLetter", CaseType.ASYLUM), + HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER("homeOfficeUploadAdditionalAddendumEvidenceLetter", CaseType.ASYLUM), + LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER("legalOfficerUploadAdditionalEvidenceLetter", CaseType.ASYLUM), + AMEND_HOME_OFFICE_APPEAL_RESPONSE("amendHomeOfficeAppealResponse", CaseType.ASYLUM), + INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER("internalNonStandardDirectionToAppellantLetter", CaseType.ASYLUM), + INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER("internalChangeDirectionDueDateLetter", CaseType.ASYLUM), + INTERNAL_EDIT_APPEAL_LETTER("internalEditAppealLetter", CaseType.ASYLUM), + INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER("internalNonStandardDirectionToRespondentLetter", CaseType.ASYLUM), + INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER("internalHoChangeDirectionDueDateLetter", CaseType.ASYLUM), + INTERNAL_REINSTATE_APPEAL_LETTER("internalReinstateAppealLetter", CaseType.ASYLUM), + INTERNAL_ADJOURN_HEARING_WITHOUT_DATE("internalAdjournHearingWithoutDate", CaseType.ASYLUM), + UPPER_TRIBUNAL_TRANSFER_ORDER_DOCUMENT("upperTribunalTransferOrderDocument", CaseType.ASYLUM), + IAUT_2_FORM("iAUT2Form", CaseType.ASYLUM), + REMITTAL_DECISION("remittalDecision", CaseType.ASYLUM), BAIL_SUBMISSION("bailSubmission", CaseType.BAIL), BAIL_EVIDENCE("uploadTheBailEvidenceDocs", CaseType.BAIL), BAIL_DECISION_UNSIGNED("bailDecisionUnsigned", CaseType.BAIL), diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadata.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadata.java index a56866d9b..c60822a16 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadata.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadata.java @@ -5,44 +5,59 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.HasDocument; @EqualsAndHashCode @ToString -public class DocumentWithMetadata { +public class DocumentWithMetadata implements HasDocument { private Document document; private String description; private String dateUploaded; private DocumentTag tag; private String suppliedBy; + private String uploadedBy; private DocumentWithMetadata() { // noop -- for deserializer } public DocumentWithMetadata( - Document document, - String description, - String dateUploaded, - DocumentTag tag + Document document, + String description, + String dateUploaded, + DocumentTag tag ) { this(document, description, dateUploaded, tag, null); } public DocumentWithMetadata( - Document document, - String description, - String dateUploaded, - DocumentTag tag, - String suppliedBy + Document document, + String description, + String dateUploaded, + DocumentTag tag, + String suppliedBy + ) { + this(document, description, dateUploaded, tag, suppliedBy, null); + } + + public DocumentWithMetadata( + Document document, + String description, + String dateUploaded, + DocumentTag tag, + String suppliedBy, + String uploadedBy ) { this.document = document; this.description = description; this.dateUploaded = dateUploaded; this.tag = tag; this.suppliedBy = suppliedBy; + this.uploadedBy = uploadedBy; } + @Override public Document getDocument() { requireNonNull(document); return document; @@ -65,4 +80,8 @@ public DocumentTag getTag() { public String getSuppliedBy() { return suppliedBy; } + + public String getUploadedBy() { + return uploadedBy; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/FtpaDecisionOutcomeType.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/FtpaDecisionOutcomeType.java new file mode 100644 index 000000000..9d94eb7e0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/FtpaDecisionOutcomeType.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum FtpaDecisionOutcomeType { + + FTPA_GRANTED("granted"), + FTPA_PARTIALLY_GRANTED("partiallyGranted"), + FTPA_REFUSED("refused"), + FTPA_NOT_ADMITTED("notAdmitted"), + FTPA_REHEARD35("reheardRule35"), + FTPA_REHEARD32("reheardRule32"), + FTPA_REMADE32("remadeRule32"); + + @JsonValue + private final String value; + + FtpaDecisionOutcomeType(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppeals.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppeals.java new file mode 100644 index 000000000..6d4dcffc9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppeals.java @@ -0,0 +1,37 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; +import java.util.Optional; + +public enum HasOtherAppeals { + + YES("Yes"), + YES_WITHOUT_APPEAL_NUMBER("YesWithoutAppealNumber"), + NO("No"), + NOT_SURE("NotSure"); + + @JsonValue + private String value; + + HasOtherAppeals(String value) { + this.value = value; + } + + public static Optional from( + String value + ) { + return Arrays.stream(values()) + .filter(v -> v.getValue().equals(value)) + .findFirst(); + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HearingCentre.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HearingCentre.java index 9fb660cda..b20ea9a40 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HearingCentre.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HearingCentre.java @@ -22,6 +22,7 @@ public enum HearingCentre { TAYLOR_HOUSE("taylorHouse"), BELFAST("belfast"), HARMONDSWORTH("harmondsworth"), + HENDON("hendon"), YARLS_WOOD("yarlsWood"), BRADFORD_KEIGHLEY("bradfordKeighley"), @@ -31,6 +32,7 @@ public enum HearingCentre { NTH_TYNE_MAGS("nthTyneMags"), LEEDS_MAGS("leedsMags"), ALLOA_SHERRIF("alloaSherrif"), + REMOTE_HEARING("remoteHearing"), DECISION_WITHOUT_HEARING("decisionWithoutHearing"); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageCategory.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageCategory.java index 9314917d7..4d371dcb5 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageCategory.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageCategory.java @@ -1,22 +1,23 @@ -package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; - -public enum InterpreterLanguageCategory { - - SPOKEN_LANGUAGE_INTERPRETER("spokenLanguageInterpreter"), - SIGN_LANGUAGE_INTERPRETER("signLanguageInterpreter"); - - private final String value; - - InterpreterLanguageCategory(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return getValue(); - } -} \ No newline at end of file + +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +public enum InterpreterLanguageCategory { + + SPOKEN_LANGUAGE_INTERPRETER("spokenLanguageInterpreter"), + SIGN_LANGUAGE_INTERPRETER("signLanguageInterpreter"); + + private final String value; + + InterpreterLanguageCategory(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return getValue(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageRefData.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageRefData.java index 094117a7f..c12f70088 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageRefData.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/InterpreterLanguageRefData.java @@ -1,12 +1,12 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import java.util.List; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.List; - @Getter @Setter @NoArgsConstructor @@ -17,4 +17,5 @@ public class InterpreterLanguageRefData { private List languageManualEntry; private String languageManualEntryDescription; + } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplication.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplication.java new file mode 100644 index 000000000..bba311e18 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplication.java @@ -0,0 +1,130 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static java.util.Objects.requireNonNull; + +import java.util.List; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +@EqualsAndHashCode +@ToString +public class MakeAnApplication { + + private String type; + private String details; + private List> evidence; + private String applicant; + private String date; + private String decision; + private String state; + private String applicantRole; + private String decisionReason; + private String decisionDate; + private String decisionMaker; + + public MakeAnApplication() { + + } + + public MakeAnApplication( + String applicant, + String type, + String details, + List> evidence, + String date, + String decision, + String state, + String applicantRole) { + requireNonNull(applicant); + requireNonNull(type); + requireNonNull(details); + requireNonNull(evidence); + requireNonNull(date); + requireNonNull(decision); + requireNonNull(state); + requireNonNull(applicantRole); + + this.applicant = applicant; + this.type = type; + this.details = details; + this.evidence = evidence; + this.date = date; + this.decision = decision; + this.state = state; + this.applicantRole = applicantRole; + } + + public String getType() { + requireNonNull(type); + return type; + } + + public String getDetails() { + requireNonNull(details); + return details; + } + + public List> getEvidence() { + requireNonNull(evidence); + return evidence; + } + + public String getApplicant() { + requireNonNull(applicant); + return applicant; + } + + public String getDate() { + requireNonNull(date); + return date; + } + + public String getDecision() { + requireNonNull(decision); + return decision; + } + + public String getState() { + requireNonNull(state); + return state; + } + + public String getApplicantRole() { + requireNonNull(applicantRole); + return applicantRole; + } + + public void setDecision(String decision) { + requireNonNull(decision); + this.decision = decision; + } + + public void setDecisionReason(String decisionReason) { + requireNonNull(decisionReason); + this.decisionReason = decisionReason; + } + + public void setDecisionDate(String decisionDate) { + requireNonNull(decisionDate); + this.decisionDate = decisionDate; + } + + public void setDecisionMaker(String decisionMaker) { + requireNonNull(decisionMaker); + this.decisionMaker = decisionMaker; + } + + public String getDecisionReason() { + return decisionReason; + } + + public String getDecisionDate() { + return decisionDate; + } + + public String getDecisionMaker() { + return decisionMaker; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypes.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypes.java new file mode 100644 index 000000000..5a58c2957 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypes.java @@ -0,0 +1,49 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static java.util.Arrays.stream; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Optional; + +public enum MakeAnApplicationTypes { + + ADJOURN("Adjourn"), + EXPEDITE("Expedite"), + JUDGE_REVIEW("Judge's review of application decision"), + JUDGE_REVIEW_LO("Judge's review of Legal Officer decision"), + LINK_OR_UNLINK("Link/unlink appeals"), + TIME_EXTENSION("Time extension"), + TRANSFER("Transfer"), + WITHDRAW("Withdraw"), + UPDATE_HEARING_REQUIREMENTS("Update hearing requirements"), + UPDATE_APPEAL_DETAILS("Update appeal details"), + REINSTATE("Reinstate an ended appeal"), + TRANSFER_OUT_OF_ACCELERATED_DETAINED_APPEALS_PROCESS("Transfer out of accelerated detained appeals process"), + OTHER("Other"); + + MakeAnApplicationTypes(String value) { + this.value = value; + } + + @JsonValue + private final String value; + + public static Optional from( + String value + ) { + return stream(values()) + .filter(v -> v.getValue().equals(value)) + .findFirst(); + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return value; + } +} + + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocuments.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocuments.java new file mode 100644 index 000000000..9c1b00f61 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocuments.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import lombok.Getter; +import lombok.Setter; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +import java.util.List; + +import static java.util.Objects.requireNonNull; + +@Getter +@Setter +public class ReheardHearingDocuments { + + private List> reheardHearingDocs; + + private ReheardHearingDocuments() { + // noop -- for deserializer + } + + public ReheardHearingDocuments(List> reheardHearingDocs) { + requireNonNull(reheardHearingDocs); + this.reheardHearingDocs = reheardHearingDocs; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecision.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecision.java new file mode 100644 index 000000000..fbabd3c9b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecision.java @@ -0,0 +1,22 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum RemissionDecision { + + APPROVED("approved"), + PARTIALLY_APPROVED("partiallyApproved"), + REJECTED("rejected"); + + @JsonValue + private final String id; + + RemissionDecision(String id) { + this.id = id; + } + + @Override + public String toString() { + return id; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionType.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionType.java new file mode 100644 index 000000000..f691e9b76 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionType.java @@ -0,0 +1,22 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum RemissionType { + NO_REMISSION("noRemission"), + HO_WAIVER_REMISSION("hoWaiverRemission"), + HELP_WITH_FEES("helpWithFees"), + EXCEPTIONAL_CIRCUMSTANCES_REMISSION("exceptionalCircumstancesRemission"); + + @JsonValue + private final String id; + + RemissionType(String id) { + this.id = id; + } + + @Override + public String toString() { + return id; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemittalDocument.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemittalDocument.java new file mode 100644 index 000000000..1d00f73a5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemittalDocument.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +import java.util.List; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +// Complex object in CCD to represent the collection of the +// Remittal Decision Document & Other remittal documents. +public class RemittalDocument { + + private DocumentWithMetadata decisionDocument; + private List> otherRemittalDocs; +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/UpdateTribunalRules.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/UpdateTribunalRules.java new file mode 100644 index 000000000..cc1d20427 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/UpdateTribunalRules.java @@ -0,0 +1,22 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum UpdateTribunalRules { + + UNDER_RULE_31("underRule31"), + UNDER_RULE_32("underRule32"); + + @JsonValue + private final String value; + + UpdateTribunalRules(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/Value.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/Value.java index 300aa0efc..6be97e674 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/Value.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/Value.java @@ -26,4 +26,6 @@ public String getCode() { public String getLabel() { return label; } + } + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/Event.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/Event.java index 03f2b8fbe..56c3096f7 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/Event.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/Event.java @@ -19,15 +19,17 @@ public enum Event { ADD_APPEAL_RESPONSE("addAppealResponse", CaseType.ASYLUM), REQUEST_HEARING_REQUIREMENTS("requestHearingRequirements", CaseType.ASYLUM), DRAFT_HEARING_REQUIREMENTS("draftHearingRequirements", CaseType.ASYLUM), - UPDATE_HEARING_REQUIREMENTS("updateHearingRequirements", CaseType.ASYLUM), CHANGE_DIRECTION_DUE_DATE("changeDirectionDueDate", CaseType.ASYLUM), UPLOAD_ADDITIONAL_EVIDENCE("uploadAdditionalEvidence", CaseType.ASYLUM), LIST_CASE("listCase", CaseType.ASYLUM), CREATE_CASE_SUMMARY("createCaseSummary", CaseType.ASYLUM), REVERT_STATE_TO_AWAITING_RESPONDENT_EVIDENCE("revertStateToAwaitingRespondentEvidence", CaseType.ASYLUM), GENERATE_HEARING_BUNDLE("generateHearingBundle", CaseType.ASYLUM), + ASYNC_STITCHING_COMPLETE("asyncStitchingComplete", CaseType.ASYLUM), + REQUEST_HEARING_REQUIREMENTS_FEATURE("requestHearingRequirementsFeature", CaseType.ASYLUM), CUSTOMISE_HEARING_BUNDLE("customiseHearingBundle", CaseType.ASYLUM), GENERATE_DECISION_AND_REASONS("generateDecisionAndReasons", CaseType.ASYLUM), + ADA_SUITABILITY_REVIEW("adaSuitabilityReview", CaseType.ASYLUM), SEND_DECISION_AND_REASONS("sendDecisionAndReasons", CaseType.ASYLUM), EDIT_CASE_LISTING("editCaseListing", CaseType.ASYLUM), END_APPEAL("endAppeal", CaseType.ASYLUM), @@ -39,7 +41,32 @@ public enum Event { GENERATE_UPPER_TRIBUNAL_BUNDLE("generateUpperTribunalBundle", CaseType.ASYLUM), SUBMIT_REASONS_FOR_APPEAL("submitReasonsForAppeal", CaseType.ASYLUM), SUBMIT_CLARIFYING_QUESTION_ANSWERS("submitClarifyingQuestionAnswers", CaseType.ASYLUM), + RECORD_ADJOURNMENT_DETAILS("recordAdjournmentDetails", CaseType.ASYLUM), + + UPDATE_TRIBUNAL_DECISION("updateTribunalDecision", CaseType.ASYLUM), + REQUEST_CASE_BUILDING("requestCaseBuilding", CaseType.ASYLUM), + UPLOAD_HOME_OFFICE_APPEAL_RESPONSE("uploadHomeOfficeAppealResponse", CaseType.ASYLUM), + RECORD_OUT_OF_TIME_DECISION("recordOutOfTimeDecision", CaseType.ASYLUM), + MARK_APPEAL_PAID("markAppealPaid", CaseType.ASYLUM), + RECORD_REMISSION_DECISION("recordRemissionDecision", CaseType.ASYLUM), + REQUEST_RESPONSE_REVIEW("requestResponseReview", CaseType.ASYLUM), + MARK_APPEAL_AS_ADA("markAppealAsAda", CaseType.ASYLUM), + APPLY_FOR_FTPA_RESPONDENT("applyForFTPARespondent", CaseType.ASYLUM), + APPLY_FOR_FTPA_APPELLANT("applyForFTPAAppellant", CaseType.ASYLUM), + DECIDE_AN_APPLICATION("decideAnApplication", CaseType.ASYLUM), + TRANSFER_OUT_OF_ADA("transferOutOfAda", CaseType.ASYLUM), + RESIDENT_JUDGE_FTPA_DECISION("residentJudgeFtpaDecision", CaseType.ASYLUM), + MAINTAIN_CASE_LINKS("maintainCaseLinks", CaseType.ASYLUM), + UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER("uploadAddendumEvidenceAdminOfficer", CaseType.ASYLUM), + CHANGE_HEARING_CENTRE("changeHearingCentre", CaseType.ASYLUM), + CREATE_CASE_LINK("createCaseLink", CaseType.ASYLUM), + REQUEST_RESPONSE_AMEND("requestResponseAmend", CaseType.ASYLUM), + UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE("uploadAdditionalEvidenceHomeOffice", CaseType.ASYLUM), + UPLOAD_ADDENDUM_EVIDENCE_HOME_OFFICE("uploadAddendumEvidenceHomeOffice", CaseType.ASYLUM), + UPLOAD_ADDENDUM_EVIDENCE("uploadAddendumEvidence", CaseType.ASYLUM), + REINSTATE_APPEAL("reinstateAppeal", CaseType.ASYLUM), + SUBMIT_APPLICATION("submitApplication", CaseType.BAIL), RECORD_THE_DECISION("recordTheDecision", CaseType.BAIL), END_APPLICATION("endApplication", CaseType.BAIL), @@ -47,6 +74,10 @@ public enum Event { EDIT_BAIL_APPLICATION_AFTER_SUBMIT("editBailApplicationAfterSubmit", CaseType.BAIL), UPLOAD_SIGNED_DECISION_NOTICE("uploadSignedDecisionNotice", CaseType.BAIL), CASE_LISTING("caseListing", CaseType.BAIL), + + UPDATE_HEARING_REQUIREMENTS("updateHearingRequirements", CaseType.ASYLUM), + UPDATE_HEARING_ADJUSTMENTS("updateHearingAdjustments", CaseType.ASYLUM), + @JsonEnumDefaultValue UNKNOWN("unknown", CaseType.UNKNOWN); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/State.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/State.java index e1c32eca5..730919ab3 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/State.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/State.java @@ -6,6 +6,7 @@ public enum State { APPEAL_STARTED("appealStarted"), + APPEAL_STARTED_BY_ADMIN("appealStartedByAdmin"), APPEAL_SUBMITTED("appealSubmitted"), APPEAL_SUBMITTED_OUT_OF_TIME("appealSubmittedOutOfTime"), AWAITING_RESPONDENT_EVIDENCE("awaitingRespondentEvidence"), @@ -23,6 +24,13 @@ public enum State { ENDED("ended"), AWAITING_CMA_REQUIREMENTS("awaitingCmaRequirements"), CMA_ADJUSTMENTS_AGREED("cmaAdjustmentsAgreed"), + FTPA_DECIDED("ftpaDecided"), + PENDING_PAYMENT("pendingPayment"), + ADJOURNED("adjourned"), + FTPA_SUBMITTED("ftpaSubmitted"), + + + @JsonEnumDefaultValue UNKNOWN("unknown"); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatus.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatus.java new file mode 100644 index 000000000..735aa9758 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatus.java @@ -0,0 +1,22 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field; + +import com.fasterxml.jackson.annotation.JsonValue; + +public enum BailApplicationStatus { + YES("Yes"), + NO("No"), + YES_WITHOUT_BAIL_APPLICATION_NUMBER("YesWithoutBailApplicationNumber"), + NOT_SURE("NotSure"); + + @JsonValue + private final String id; + + BailApplicationStatus(String id) { + this.id = id; + } + + @Override + public String toString() { + return id; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/HasDocument.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/HasDocument.java new file mode 100644 index 000000000..853bbf0c1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/HasDocument.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field; + +public interface HasDocument { + Document getDocument(); +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/CaseLink.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/CaseLink.java new file mode 100644 index 000000000..1565077bb --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/CaseLink.java @@ -0,0 +1,27 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking; + +import java.time.LocalDateTime; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +@ToString +public class CaseLink { + @JsonProperty("CaseReference") + String caseReference; + @JsonProperty("CaseType") + String caseType; + @JsonProperty("CreatedDateTime") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS") + LocalDateTime createdDateTime; + @JsonProperty("ReasonForLink") + List> reasonsForLink; +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/ReasonForLink.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/ReasonForLink.java new file mode 100644 index 000000000..c058601c2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/caselinking/ReasonForLink.java @@ -0,0 +1,16 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.*; + +@Getter +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +@ToString +public class ReasonForLink { + @JsonProperty("Reason") + String reason; +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdaSuitabilityDocumentGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdaSuitabilityDocumentGenerator.java new file mode 100644 index 000000000..64d7cee3c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdaSuitabilityDocumentGenerator.java @@ -0,0 +1,67 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +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 AdaSuitabilityDocumentGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator adaSuitabilityDocumentGenerator; + private final DocumentHandler documentHandler; + + public AdaSuitabilityDocumentGenerator( + @Qualifier("adaSuitability") DocumentCreator appealSubmissionDocumentCreator, + DocumentHandler documentHandler + ) { + this.adaSuitabilityDocumentGenerator = appealSubmissionDocumentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + return callback.getEvent() == Event.ADA_SUITABILITY_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT; + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document adaSuitabilityDocument = adaSuitabilityDocumentGenerator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + adaSuitabilityDocument, + TRIBUNAL_DOCUMENTS, + DocumentTag.ADA_SUITABILITY + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandler.java index 4a329f50c..e19668599 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandler.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; +import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; @@ -13,6 +14,8 @@ import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ReheardHearingDocuments; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemittalDocument; 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; @@ -20,6 +23,8 @@ import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.PreSubmitCallbackHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentsAppender; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients.EmBundleRequestExecutor; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.Bundle; @@ -33,15 +38,20 @@ public class AdvancedBundlingCallbackHandler implements PreSubmitCallbackHandler private final EmBundleRequestExecutor emBundleRequestExecutor; private final String emBundlerUrl; private final String emBundlerStitchUri; + private final DocumentsAppender documentsAppender; + private final FeatureToggler featureToggler; public AdvancedBundlingCallbackHandler( - @Value("${emBundler.url}") String emBundlerUrl, - @Value("${emBundler.stitch.async.uri}") String emBundlerStitchUri, - EmBundleRequestExecutor emBundleRequestExecutor) { + @Value("${emBundler.url}") String emBundlerUrl, + @Value("${emBundler.stitch.async.uri}") String emBundlerStitchUri, + EmBundleRequestExecutor emBundleRequestExecutor, + DocumentsAppender documentsAppender, + FeatureToggler featureToggler) { this.emBundlerUrl = emBundlerUrl; this.emBundlerStitchUri = emBundlerStitchUri; this.emBundleRequestExecutor = emBundleRequestExecutor; - + this.documentsAppender = documentsAppender; + this.featureToggler = featureToggler; } public boolean canHandle( @@ -72,19 +82,29 @@ public PreSubmitCallbackResponse handle( asylumCase.clear(AsylumCaseDefinition.CASE_BUNDLES); Optional maybeCaseFlagSetAsideReheardExists = asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS,YesOrNo.class); + boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent(); + + boolean isRemittedFeature = featureToggler.getValue("dlrm-remitted-feature-flag", false); if (maybeCaseFlagSetAsideReheardExists.isPresent() && maybeCaseFlagSetAsideReheardExists.get() == YesOrNo.YES) { - asylumCase.write(APPELLANT_ADDENDUM_EVIDENCE_DOCS,getIdValues(asylumCase,ADDENDUM_EVIDENCE_DOCUMENTS, SUPPLIED_BY_APPELLANT, DocumentTag.ADDENDUM_EVIDENCE)); asylumCase.write(RESPONDENT_ADDENDUM_EVIDENCE_DOCS,getIdValues(asylumCase,ADDENDUM_EVIDENCE_DOCUMENTS, SUPPLIED_BY_RESPONDENT,DocumentTag.ADDENDUM_EVIDENCE)); asylumCase.write(APP_ADDITIONAL_EVIDENCE_DOCS,getIdValues(asylumCase, ADDITIONAL_EVIDENCE_DOCUMENTS, SUPPLIED_BY_APPELLANT,DocumentTag.ADDITIONAL_EVIDENCE)); asylumCase.write(RESP_ADDITIONAL_EVIDENCE_DOCS,getIdValues(asylumCase, RESPONDENT_DOCUMENTS, SUPPLIED_BY_RESPONDENT,DocumentTag.ADDITIONAL_EVIDENCE)); - asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-reheard-hearing-bundle-config.yaml"); + if (isRemittedFeature) { + mapRemittedData(asylumCase); + asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-remitted-reheard-hearing-bundle-config.yaml"); + } else { + asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-reheard-hearing-bundle-config.yaml"); + } + } else { - asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-hearing-bundle-config.yaml"); + asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + isOrWasAda ? "iac-hearing-bundle-inc-tribunal-config.yaml" : "iac-hearing-bundle-config.yaml"); + } asylumCase.write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, getBundlePrefix(asylumCase)); @@ -108,6 +128,12 @@ public PreSubmitCallbackResponse handle( responseData.write(AsylumCaseDefinition.STITCHING_STATUS, stitchStatus); + if (isRemittedFeature) { + //Clearing temporary fields + responseData.clear(LATEST_DECISION_AND_REASONS_DOCUMENTS); + responseData.clear(LATEST_REMITTAL_DOCUMENTS); + responseData.clear(LATEST_REHEARD_HEARING_DOCUMENTS); + } return new PreSubmitCallbackResponse<>(responseData); } @@ -148,4 +174,56 @@ private List> getIdValues( .collect(Collectors.toList()); } } + + private void mapRemittedData(AsylumCase asylumCase) { + asylumCase.write(LATEST_DECISION_AND_REASONS_DOCUMENTS, fetchLatestDecisionDocuments(asylumCase)); + asylumCase.write(LATEST_REMITTAL_DOCUMENTS, fetchLatestRemittalDocuments(asylumCase)); + asylumCase.write(LATEST_REHEARD_HEARING_DOCUMENTS, fetchLatestReheardDocuments(asylumCase)); + } + + private List> fetchLatestDecisionDocuments(AsylumCase asylumCase) { + Optional>> maybeExistingReheardDocuments = + asylumCase.read(REHEARD_DECISION_REASONS_COLLECTION); + List> allReheardDecisionDocuments = maybeExistingReheardDocuments + .orElse(emptyList()); + + if (allReheardDecisionDocuments.isEmpty()) { + Optional>> maybeFinalDecisionAndReasonsDocuments = + asylumCase.read(FINAL_DECISION_AND_REASONS_DOCUMENTS); + return maybeFinalDecisionAndReasonsDocuments.orElse(emptyList()); + } else { + return allReheardDecisionDocuments.get(0).getValue().getReheardHearingDocs(); + } + } + + private List> fetchLatestRemittalDocuments(AsylumCase asylumCase) { + Optional>> maybeExistingRemittalDocuments = + asylumCase.read(REMITTAL_DOCUMENTS); + List> allRemittalDocuments = maybeExistingRemittalDocuments + .orElse(emptyList()); + + if (!allRemittalDocuments.isEmpty()) { + RemittalDocument remittalDocument = allRemittalDocuments.get(0).getValue(); + + List> allDocuments = + documentsAppender.append( + remittalDocument.getOtherRemittalDocs(), + Collections.singletonList(remittalDocument.getDecisionDocument()) + ); + return allDocuments; + } + return emptyList(); + } + + private List> fetchLatestReheardDocuments(AsylumCase asylumCase) { + Optional>> maybeExistingReheardDocuments = + asylumCase.read(REHEARD_HEARING_DOCUMENTS_COLLECTION); + List> allReheardHearingDocuments = maybeExistingReheardDocuments + .orElse(emptyList()); + + if (!allReheardHearingDocuments.isEmpty()) { + return allReheardHearingDocuments.get(0).getValue().getReheardHearingDocs(); + } + return emptyList(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreator.java index 5c5556901..34cbe6971 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreator.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreator.java @@ -1,9 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; import static java.util.Objects.requireNonNull; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REPRESENTATIVE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.PA_APPEAL_TYPE_PAYMENT_OPTION; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.PaymentStatus.FAILED; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; import java.util.Arrays; import org.springframework.beans.factory.annotation.Qualifier; @@ -26,13 +26,16 @@ public class AppealSubmissionCreator implements PreSubmitCallbackHandler { private final DocumentCreator appealSubmissionDocumentCreator; + private final DocumentCreator internalAppealSubmissionDocumentCreator; private final DocumentHandler documentHandler; public AppealSubmissionCreator( @Qualifier("appealSubmission") DocumentCreator appealSubmissionDocumentCreator, + @Qualifier("internalAppealSubmission") DocumentCreator internalAppealSubmissionDocumentCreator, DocumentHandler documentHandler ) { this.appealSubmissionDocumentCreator = appealSubmissionDocumentCreator; + this.internalAppealSubmissionDocumentCreator = internalAppealSubmissionDocumentCreator; this.documentHandler = documentHandler; } @@ -80,16 +83,35 @@ public PreSubmitCallbackResponse handle( final CaseDetails caseDetails = callback.getCaseDetails(); final AsylumCase asylumCase = caseDetails.getCaseData(); - Document appealSubmission = appealSubmissionDocumentCreator.create(caseDetails); + Document appealSubmission; + DocumentTag documentTag; + AsylumCaseDefinition documentField; + + appealSubmission = appealSubmissionDocumentCreator.create(caseDetails); + documentTag = DocumentTag.APPEAL_SUBMISSION; + documentField = LEGAL_REPRESENTATIVE_DOCUMENTS; documentHandler.addWithMetadata( asylumCase, appealSubmission, - LEGAL_REPRESENTATIVE_DOCUMENTS, - DocumentTag.APPEAL_SUBMISSION + documentField, + documentTag ); + if (callback.getEvent().equals(Event.SUBMIT_APPEAL) && isInternalCase(asylumCase) && isAppellantInDetention(asylumCase) && !isAcceleratedDetainedAppeal(asylumCase)) { + appealSubmission = internalAppealSubmissionDocumentCreator.create(caseDetails); + documentTag = DocumentTag.INTERNAL_APPEAL_SUBMISSION; + documentField = NOTIFICATION_ATTACHMENT_DOCUMENTS; + + documentHandler.addWithMetadata( + asylumCase, + appealSubmission, + documentField, + documentTag + ); + } return new PreSubmitCallbackResponse<>(asylumCase); } + } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandler.java index 528f458e0..88eb44b37 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandler.java @@ -94,13 +94,15 @@ public PreSubmitCallbackResponse handle( boolean isReheardCase = asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YesOrNo.YES)).orElse(false) && featureToggler.getValue("reheard-feature", false); + boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent(); if (isReheardCase) { //populate these collections to avoid error on the Stitching api initializeNewCollections(asylumCase); asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-reheard-hearing-bundle-config.yaml"); } else { - asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-hearing-bundle-config.yaml"); + asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + isOrWasAda ? "iac-hearing-bundle-inc-tribunal-config.yaml" : "iac-hearing-bundle-config.yaml"); } asylumCase.write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, getBundlePrefix(asylumCase)); @@ -114,7 +116,7 @@ public PreSubmitCallbackResponse handle( throw new IllegalStateException("Cannot make a deep copy of the case"); } - prepareDocuments(getMappingFields(isReheardCase),asylumCaseCopy); + prepareDocuments(getMappingFields(isReheardCase, isOrWasAda),asylumCaseCopy); if (isReheardCase) { prepareDocuments(getMappingFieldsForAdditionalEvidenceDocuments(),asylumCaseCopy); } @@ -257,7 +259,8 @@ private void restoreCollections( AsylumCase asylumCaseBefore, boolean isReheardCase ) { - getFieldDefinitions(isReheardCase).forEach(field -> { + boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent(); + getFieldDefinitions(isReheardCase, isOrWasAda).forEach(field -> { Optional>> currentIdValues = asylumCase.read(field); Optional>> beforeIdValues = asylumCaseBefore.read(field); @@ -301,43 +304,52 @@ boolean contains( return found; } - private List getFieldDefinitions(boolean isReheardCase) { + private List getFieldDefinitions(boolean isReheardCase, boolean isOrWasAda) { + List fieldDefnList; if (isReheardCase) { - return Arrays.asList( + fieldDefnList = new ArrayList<>(Arrays.asList( REHEARD_HEARING_DOCUMENTS, ADDITIONAL_EVIDENCE_DOCUMENTS, RESPONDENT_DOCUMENTS, FTPA_APPELLANT_DOCUMENTS, FTPA_RESPONDENT_DOCUMENTS, FINAL_DECISION_AND_REASONS_DOCUMENTS - ); + )); } else { - return Arrays.asList( - HEARING_DOCUMENTS, - LEGAL_REPRESENTATIVE_DOCUMENTS, - ADDITIONAL_EVIDENCE_DOCUMENTS, - RESPONDENT_DOCUMENTS); + fieldDefnList = new ArrayList<>(Arrays.asList( + HEARING_DOCUMENTS, + LEGAL_REPRESENTATIVE_DOCUMENTS, + ADDITIONAL_EVIDENCE_DOCUMENTS, + RESPONDENT_DOCUMENTS + )); + if (isOrWasAda) { + fieldDefnList.add(TRIBUNAL_DOCUMENTS); + } } - + return fieldDefnList; } - private Map getMappingFields(boolean isReheardCase) { - + private Map getMappingFields(boolean isReheardCase, boolean isOrWasAda) { + Map fieldMap; if (isReheardCase) { - return Map.of(CUSTOM_APP_ADDITIONAL_EVIDENCE_DOCS, APP_ADDITIONAL_EVIDENCE_DOCS, + fieldMap = new HashMap<>(Map.of(CUSTOM_APP_ADDITIONAL_EVIDENCE_DOCS, APP_ADDITIONAL_EVIDENCE_DOCS, CUSTOM_RESP_ADDITIONAL_EVIDENCE_DOCS, RESP_ADDITIONAL_EVIDENCE_DOCS, CUSTOM_FTPA_APPELLANT_DOCS, FTPA_APPELLANT_DOCUMENTS, CUSTOM_FTPA_RESPONDENT_DOCS, FTPA_RESPONDENT_DOCUMENTS, CUSTOM_FINAL_DECISION_AND_REASONS_DOCS, FINAL_DECISION_AND_REASONS_DOCUMENTS, CUSTOM_REHEARD_HEARING_DOCS, REHEARD_HEARING_DOCUMENTS, CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS, APPELLANT_ADDENDUM_EVIDENCE_DOCS, - CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS, RESPONDENT_ADDENDUM_EVIDENCE_DOCS); + CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS, RESPONDENT_ADDENDUM_EVIDENCE_DOCS)); } else { - return Map.of(CUSTOM_HEARING_DOCUMENTS, HEARING_DOCUMENTS, + fieldMap = new HashMap<>(Map.of(CUSTOM_HEARING_DOCUMENTS, HEARING_DOCUMENTS, CUSTOM_LEGAL_REP_DOCUMENTS, LEGAL_REPRESENTATIVE_DOCUMENTS, CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS, ADDITIONAL_EVIDENCE_DOCUMENTS, - CUSTOM_RESPONDENT_DOCUMENTS, RESPONDENT_DOCUMENTS); + CUSTOM_RESPONDENT_DOCUMENTS, RESPONDENT_DOCUMENTS)); + if (isOrWasAda) { + fieldMap.put(CUSTOM_TRIBUNAL_DOCUMENTS, TRIBUNAL_DOCUMENTS); + } } + return fieldMap; } private Map getMappingFieldsForAdditionalEvidenceDocuments() { diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparer.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparer.java index 6a3b3d32c..61d9634ab 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparer.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparer.java @@ -4,10 +4,7 @@ import static java.util.Objects.requireNonNull; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event; @@ -63,8 +60,8 @@ public PreSubmitCallbackResponse handle(PreSubmitCallbackStage callb } public void prepareCustomDocuments(AsylumCase asylumCase, boolean isCaseReheard) { - - getMappingFields(isCaseReheard).forEach((sourceField,targetField) -> + boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent(); + getMappingFields(isCaseReheard, isOrWasAda).forEach((sourceField,targetField) -> populateCustomCollections(asylumCase, sourceField, targetField) ); @@ -105,6 +102,10 @@ void populateCustomCollections(AsylumCase asylumCase, AsylumCaseDefinition sourc if ("The respondent".equals(documentWithMetadata.getValue().getSuppliedBy())) { customDocuments = documentWithDescriptionAppender.append(newDocumentWithDescription, customDocuments); } + } else if (targetField == CUSTOM_TRIBUNAL_DOCUMENTS) { + if (documentWithMetadata.getValue().getTag() == DocumentTag.ADA_SUITABILITY) { + customDocuments = documentWithDescriptionAppender.append(newDocumentWithDescription, customDocuments); + } } else { customDocuments = documentWithDescriptionAppender.append(newDocumentWithDescription, customDocuments); } @@ -112,27 +113,33 @@ void populateCustomCollections(AsylumCase asylumCase, AsylumCaseDefinition sourc asylumCase.clear(targetField); asylumCase.write(targetField, customDocuments); - } - private Map getMappingFields(boolean isReheardCase) { + } + private Map getMappingFields(boolean isReheardCase, boolean isOrWasAda) { + Map fieldMapping; if (isReheardCase) { - return Map.of( + fieldMapping = new HashMap<>(Map.of( APP_ADDITIONAL_EVIDENCE_DOCS, CUSTOM_APP_ADDITIONAL_EVIDENCE_DOCS, RESP_ADDITIONAL_EVIDENCE_DOCS, CUSTOM_RESP_ADDITIONAL_EVIDENCE_DOCS, FTPA_APPELLANT_DOCUMENTS, CUSTOM_FTPA_APPELLANT_DOCS, FTPA_RESPONDENT_DOCUMENTS, CUSTOM_FTPA_RESPONDENT_DOCS, FINAL_DECISION_AND_REASONS_DOCUMENTS, CUSTOM_FINAL_DECISION_AND_REASONS_DOCS, REHEARD_HEARING_DOCUMENTS, CUSTOM_REHEARD_HEARING_DOCS, - ADDENDUM_EVIDENCE_DOCUMENTS, CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS); + ADDENDUM_EVIDENCE_DOCUMENTS, CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS)); } else { - return Map.of( + fieldMapping = new HashMap<>(Map.of( HEARING_DOCUMENTS, CUSTOM_HEARING_DOCUMENTS, LEGAL_REPRESENTATIVE_DOCUMENTS, CUSTOM_LEGAL_REP_DOCUMENTS, ADDITIONAL_EVIDENCE_DOCUMENTS, CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS, - RESPONDENT_DOCUMENTS, CUSTOM_RESPONDENT_DOCUMENTS); + RESPONDENT_DOCUMENTS, CUSTOM_RESPONDENT_DOCUMENTS)); + if (isOrWasAda) { + //With Tribunal Documents + fieldMapping.put(TRIBUNAL_DOCUMENTS, CUSTOM_TRIBUNAL_DOCUMENTS); + } } + return fieldMapping; } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreator.java index 8e9d602ed..f2cc6688c 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreator.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreator.java @@ -1,42 +1,64 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.NO; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.YES; +import java.util.Collections; +import java.util.List; import java.util.Optional; 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.AsylumCaseDefinition; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; 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.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.PreSubmitCallbackHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.Appender; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentReceiver; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentsAppender; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler; @Component public class HearingNoticeCreator implements PreSubmitCallbackHandler { private final DocumentCreator hearingNoticeDocumentCreator; private final DocumentCreator remoteHearingNoticeDocumentCreator; + private final DocumentCreator adaHearingNoticeDocumentCreator; private final DocumentHandler documentHandler; + private final FeatureToggler featureToggler; + private final DocumentReceiver documentReceiver; + private final DocumentsAppender documentsAppender; + private final Appender reheardHearingAppender; public HearingNoticeCreator( - @Qualifier("hearingNotice") DocumentCreator hearingNoticeDocumentCreator, - @Qualifier("remoteHearingNotice") DocumentCreator remoteHearingNoticeDocumentCreator, - DocumentHandler documentHandler + @Qualifier("hearingNotice") DocumentCreator hearingNoticeDocumentCreator, + @Qualifier("remoteHearingNotice") DocumentCreator remoteHearingNoticeDocumentCreator, + @Qualifier("adaHearingNotice") DocumentCreator adaHearingNoticeDocumentCreator, + DocumentHandler documentHandler, + FeatureToggler featureToggler, + DocumentReceiver documentReceiver, + DocumentsAppender documentsAppender, + Appender reheardHearingAppender ) { this.hearingNoticeDocumentCreator = hearingNoticeDocumentCreator; this.remoteHearingNoticeDocumentCreator = remoteHearingNoticeDocumentCreator; + this.adaHearingNoticeDocumentCreator = adaHearingNoticeDocumentCreator; this.documentHandler = documentHandler; + this.featureToggler = featureToggler; + this.documentReceiver = documentReceiver; + this.documentsAppender = documentsAppender; + this.reheardHearingAppender = reheardHearingAppender; } public boolean canHandle( @@ -68,17 +90,23 @@ public PreSubmitCallbackResponse handle( if (listCaseHearingCentre.equals(HearingCentre.REMOTE_HEARING)) { hearingNotice = remoteHearingNoticeDocumentCreator.create(caseDetails); } else { - hearingNotice = hearingNoticeDocumentCreator.create(caseDetails); + boolean isAda = asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class).orElse(NO) == YES; + hearingNotice = isAda ? adaHearingNoticeDocumentCreator.create(caseDetails) : hearingNoticeDocumentCreator.create(caseDetails); } - if ((asylumCase.read(AsylumCaseDefinition.IS_REHEARD_APPEAL_ENABLED, YesOrNo.class).equals(Optional.of(YesOrNo.YES)) - && (asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YesOrNo.YES)).orElse(false)))) { - documentHandler.addWithMetadataWithoutReplacingExistingDocuments( - asylumCase, - hearingNotice, - REHEARD_HEARING_DOCUMENTS, - DocumentTag.REHEARD_HEARING_NOTICE - ); + if ((asylumCase.read(AsylumCaseDefinition.IS_REHEARD_APPEAL_ENABLED, YesOrNo.class).equals(Optional.of(YES)) + && (asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YES)).orElse(false)))) { + + if (featureToggler.getValue("dlrm-remitted-feature-flag", false)) { + appendReheardHearingDocuments(asylumCase, hearingNotice); + } else { + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + hearingNotice, + REHEARD_HEARING_DOCUMENTS, + DocumentTag.REHEARD_HEARING_NOTICE + ); + } } else { documentHandler.addWithMetadataWithoutReplacingExistingDocuments( asylumCase, @@ -90,4 +118,27 @@ public PreSubmitCallbackResponse handle( return new PreSubmitCallbackResponse<>(asylumCase); } + + private void appendReheardHearingDocuments(AsylumCase asylumCase, Document hearingNotice) { + DocumentWithMetadata documentWithMetadata = + documentReceiver.receive( + hearingNotice, + "", + DocumentTag.REHEARD_HEARING_NOTICE + ); + + List> allDocuments = + documentsAppender.append( + Collections.emptyList(), + Collections.singletonList(documentWithMetadata) + ); + + ReheardHearingDocuments newReheardDocuments = new ReheardHearingDocuments(allDocuments); + + Optional>> maybeExistingReheardDocuments = + asylumCase.read(REHEARD_HEARING_DOCUMENTS_COLLECTION); + List> allReheardDocuments = + reheardHearingAppender.append(newReheardDocuments, maybeExistingReheardDocuments.orElse(emptyList())); + asylumCase.write(REHEARD_HEARING_DOCUMENTS_COLLECTION, allReheardDocuments); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreator.java index 3019f684b..3639cfb49 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreator.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreator.java @@ -3,6 +3,8 @@ import static java.util.Arrays.asList; import static java.util.Objects.requireNonNull; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.NO; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.YES; import java.util.Optional; import org.springframework.beans.factory.annotation.Qualifier; @@ -29,6 +31,7 @@ public class HearingNoticeEditedCreator implements PreSubmitCallbackHandler hearingNoticeUpdatedRequirementsDocumentCreator; private final DocumentCreator hearingNoticeUpdatedDetailsDocumentCreator; private final DocumentCreator remoteHearingNoticeUpdatedDetailsDocumentCreator; + private final DocumentCreator adaHearingNoticeUpdatedDetailsDocumentCreator; private final DocumentHandler documentHandler; private final HearingDetailsFinder hearingDetailsFinder; @@ -36,12 +39,14 @@ public HearingNoticeEditedCreator( @Qualifier("hearingNoticeUpdatedRequirements") DocumentCreator hearingNoticeUpdatedRequirementsDocumentCreator, @Qualifier("hearingNoticeUpdatedDetails") DocumentCreator hearingNoticeUpdatedDetailsDocumentCreator, @Qualifier("remoteHearingNoticeUpdatedDetails") DocumentCreator remoteHearingNoticeUpdatedDetailsDocumentCreator, + @Qualifier("adaHearingNoticeUpdatedDetails") DocumentCreator adaHearingNoticeUpdatedDetailsDocumentCreator, DocumentHandler documentHandler, HearingDetailsFinder hearingDetailsFinder ) { this.hearingNoticeUpdatedRequirementsDocumentCreator = hearingNoticeUpdatedRequirementsDocumentCreator; this.hearingNoticeUpdatedDetailsDocumentCreator = hearingNoticeUpdatedDetailsDocumentCreator; this.remoteHearingNoticeUpdatedDetailsDocumentCreator = remoteHearingNoticeUpdatedDetailsDocumentCreator; + this.adaHearingNoticeUpdatedDetailsDocumentCreator = adaHearingNoticeUpdatedDetailsDocumentCreator; this.documentHandler = documentHandler; this.hearingDetailsFinder = hearingDetailsFinder; } @@ -80,12 +85,22 @@ public PreSubmitCallbackResponse handle( final String oldHearingDate = hearingDetailsFinder.getHearingDateTime(caseDetailsBefore.get().getCaseData()); + boolean isAda = asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class).orElse(NO) == YES; + if (asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class).equals(Optional.of(HearingCentre.REMOTE_HEARING))) { generateDocument(caseDetails, asylumCase, caseDetailsBefore, remoteHearingNoticeUpdatedDetailsDocumentCreator); } else if (hearingCentreNameBefore.equals(listCaseHearingCentre) && oldHearingDate.equals(hearingDate)) { - generateDocument(caseDetails, asylumCase, caseDetailsBefore, hearingNoticeUpdatedRequirementsDocumentCreator); + if (isAda) { + generateDocument(caseDetails, asylumCase, caseDetailsBefore, adaHearingNoticeUpdatedDetailsDocumentCreator); + } else { + generateDocument(caseDetails, asylumCase, caseDetailsBefore, hearingNoticeUpdatedRequirementsDocumentCreator); + } } else { - generateDocument(caseDetails, asylumCase, caseDetailsBefore, hearingNoticeUpdatedDetailsDocumentCreator); + if (isAda) { + generateDocument(caseDetails, asylumCase, caseDetailsBefore, adaHearingNoticeUpdatedDetailsDocumentCreator); + } else { + generateDocument(caseDetails, asylumCase, caseDetailsBefore, hearingNoticeUpdatedDetailsDocumentCreator); + } } } else { throw new IllegalStateException("previous case data is not present"); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGenerator.java new file mode 100644 index 000000000..4e8904d36 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGenerator.java @@ -0,0 +1,80 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; +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 InternalAdaSuitabilityReviewSuitableLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAdaSuitabilityReviewSuitableLetterGenerator; + private final DocumentHandler documentHandler; + + public InternalAdaSuitabilityReviewSuitableLetterGenerator( + @Qualifier("internalAdaSuitabilitySuitable") DocumentCreator internalAdaSuitabilityReviewSuitableLetterGenerator, + DocumentHandler documentHandler + ) { + this.internalAdaSuitabilityReviewSuitableLetterGenerator = internalAdaSuitabilityReviewSuitableLetterGenerator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.ADA_SUITABILITY_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalAdaSuitabilitySuitableLetterDocument = internalAdaSuitabilityReviewSuitableLetterGenerator.create(caseDetails); + + final AdaSuitabilityReviewDecision suitabilityDecision = + asylumCase.read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class) + .orElseThrow(() -> new RequiredFieldMissingException("ADA suitability decision is missing.")); + + if (suitabilityDecision.equals(AdaSuitabilityReviewDecision.SUITABLE)) { + documentHandler.addWithMetadata( + asylumCase, + internalAdaSuitabilitySuitableLetterDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_ADA_SUITABILITY + ); + } + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGenerator.java new file mode 100644 index 000000000..d1b423ef1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGenerator.java @@ -0,0 +1,81 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +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 InternalAdaSuitabilityReviewUnsuitableLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAdaSuitabilityReviewUnsuitableLetterGenerator; + private final DocumentHandler documentHandler; + + public InternalAdaSuitabilityReviewUnsuitableLetterGenerator( + @Qualifier("internalAdaSuitabilityUnsuitable") DocumentCreator internalAdaSuitabilityReviewUnsuitableLetterGenerator, + DocumentHandler documentHandler + ) { + this.internalAdaSuitabilityReviewUnsuitableLetterGenerator = internalAdaSuitabilityReviewUnsuitableLetterGenerator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.ADA_SUITABILITY_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalAdaSuitabilityUnsuitableLetterDocument = internalAdaSuitabilityReviewUnsuitableLetterGenerator.create(caseDetails); + + final AdaSuitabilityReviewDecision suitabilityDecision = + asylumCase.read(AsylumCaseDefinition.SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class) + .orElseThrow(() -> new RequiredFieldMissingException("ADA suitability decision is missing.")); + + if (suitabilityDecision.equals(AdaSuitabilityReviewDecision.UNSUITABLE)) { + documentHandler.addWithMetadata( + asylumCase, + internalAdaSuitabilityUnsuitableLetterDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_ADA_SUITABILITY + ); + } + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGenerator.java new file mode 100644 index 000000000..28ae54956 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGenerator.java @@ -0,0 +1,98 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealDecision; +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.handlers.PreSubmitCallbackHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@Component +public class InternalDetainedDecisionsAndReasonsLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAdaDecisionsAndReasonsLetterAllowedCreator; + private final DocumentCreator internalAdaDecisionsAndReasonsLetterDismissedCreator; + private final DocumentCreator internalDetainedDecisionsAndReasonsLetterDismissedCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedDecisionsAndReasonsLetterGenerator( + @Qualifier("internalDetainedDecisionsAndReasonsAllowed") DocumentCreator internalAdaDecisionsAndReasonsLetterAllowedCreator, + @Qualifier("internalAdaDecisionsAndReasonsDismissed") DocumentCreator internalAdaDecisionsAndReasonsLetterDismissedCreator, + @Qualifier("internalDetainedDecisionsAndReasonsDismissed") DocumentCreator internalDetainedDecisionsAndReasonsLetterDismissedCreator, + DocumentHandler documentHandler + ) { + this.internalAdaDecisionsAndReasonsLetterAllowedCreator = internalAdaDecisionsAndReasonsLetterAllowedCreator; + this.internalAdaDecisionsAndReasonsLetterDismissedCreator = internalAdaDecisionsAndReasonsLetterDismissedCreator; + this.internalDetainedDecisionsAndReasonsLetterDismissedCreator = internalDetainedDecisionsAndReasonsLetterDismissedCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.SEND_DECISION_AND_REASONS + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + + final AppealDecision appealDecision = + asylumCase.read(IS_DECISION_ALLOWED, AppealDecision.class) + .orElseThrow(() -> new RequiredFieldMissingException("Appeal decision is missing.")); + + if (appealDecision.equals(AppealDecision.ALLOWED)) { + documentHandler.addWithMetadata( + asylumCase, + internalAdaDecisionsAndReasonsLetterAllowedCreator.create(caseDetails), + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER + ); + } else if (appealDecision.equals(AppealDecision.DISMISSED) && isAcceleratedDetainedAppeal(asylumCase)) { + documentHandler.addWithMetadata( + asylumCase, + internalAdaDecisionsAndReasonsLetterDismissedCreator.create(caseDetails), + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER + ); + } else if (appealDecision.equals(AppealDecision.DISMISSED) && !isAcceleratedDetainedAppeal(asylumCase)) { + documentHandler.addWithMetadata( + asylumCase, + internalDetainedDecisionsAndReasonsLetterDismissedCreator.create(caseDetails), + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER + ); + } + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGenerator.java new file mode 100644 index 000000000..2ba2e9953 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGenerator.java @@ -0,0 +1,72 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils; + +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.isAcceleratedDetainedAppeal; + +@Component +public class InternalDetainedRequestHearingRequirementsLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetainedRequestHearingRequirementLetterCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedRequestHearingRequirementsLetterGenerator( + @Qualifier("internalDetainedRequestHearingRequirements") DocumentCreator internalDetainedRequestHearingRequirementLetterCreator, + DocumentHandler documentHandler + ) { + this.internalDetainedRequestHearingRequirementLetterCreator = internalDetainedRequestHearingRequirementLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.REQUEST_HEARING_REQUIREMENTS_FEATURE + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && AsylumCaseUtils.isInternalCase(asylumCase) + && AsylumCaseUtils.isAppellantInDetention(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetainedRequestRespondentEvidenceLetter = internalDetainedRequestHearingRequirementLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + internalDetainedRequestRespondentEvidenceLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER + ); + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGenerator.java new file mode 100644 index 000000000..403a91622 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGenerator.java @@ -0,0 +1,73 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +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.isAcceleratedDetainedAppeal; + +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils; + +@Component +public class InternalDetainedRequestRespondentEvidenceGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetainedRequestRespondentEvidenceCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedRequestRespondentEvidenceGenerator( + @Qualifier("internalDetainedRequestRespondentEvidence") DocumentCreator internalDetainedRequestRespondentEvidenceCreator, + DocumentHandler documentHandler + ) { + this.internalDetainedRequestRespondentEvidenceCreator = internalDetainedRequestRespondentEvidenceCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.REQUEST_RESPONDENT_EVIDENCE + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && AsylumCaseUtils.isInternalCase(asylumCase) + && AsylumCaseUtils.isAppellantInDetention(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetainedRequestRespondentEvidenceLetter = internalDetainedRequestRespondentEvidenceCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + internalDetainedRequestRespondentEvidenceLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGenerator.java new file mode 100644 index 000000000..585341af3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGenerator.java @@ -0,0 +1,75 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +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 InternalHoChangeDirectionDueDateLetterGenerator implements PreSubmitCallbackHandler { + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalHoChangeDirectionDueDateLetterGenerator( + @Qualifier("internalHoChangeDueDateLetter") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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 + && Event.CHANGE_DIRECTION_DUE_DATE == event + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && isDirectionPartyRespondent(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalChangeDirectionDueDateLetter = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalChangeDirectionDueDateLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreator.java new file mode 100644 index 000000000..9622fcaf3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreator.java @@ -0,0 +1,109 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static java.util.Collections.emptyList; +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.UpdateTribunalRules.UNDER_RULE_31; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.JourneyType.AIP; + +import java.util.List; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DecisionAndReasons; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.UpdateTribunalRules; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.JourneyType; +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 UpdateTribunalDecisionCreator implements PreSubmitCallbackHandler { + private final DocumentCreator updatedDecisionAndReasonsCoverLetterDocumentCreator; + private final DocumentCreator aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator; + private final DocumentHandler documentHandler; + private final DateProvider dateProvider; + + + public UpdateTribunalDecisionCreator( + @Qualifier("updatedDecisionAndReasonsCoverLetter") DocumentCreator updatedDecisionAndReasonsCoverLetterDocumentCreator, + @Qualifier("aipUpdatedDecisionAndReasonsCoverLetter") DocumentCreator aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator, + DocumentHandler documentHandler, + DateProvider dateProvider + ) { + this.updatedDecisionAndReasonsCoverLetterDocumentCreator = updatedDecisionAndReasonsCoverLetterDocumentCreator; + this.aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator = aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator; + this.documentHandler = documentHandler; + this.dateProvider = dateProvider; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isDecisionRule31(callback.getCaseDetails().getCaseData()) + && callback.getEvent() == Event.UPDATE_TRIBUNAL_DECISION; + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + Document coverLetter = getCoverLetterCreatorInstance(asylumCase).create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + coverLetter, + FINAL_DECISION_AND_REASONS_DOCUMENTS, + DocumentTag.UPDATED_DECISION_AND_REASONS_COVER_LETTER + ); + + Optional>> maybeExistingDecisionAndReasons = + asylumCase.read(CORRECTED_DECISION_AND_REASONS); + + List> existingDecisionAndReasons = maybeExistingDecisionAndReasons.orElse(emptyList()); + + DecisionAndReasons decisionAndReasons = existingDecisionAndReasons.stream() + .findFirst() + .orElseThrow(() -> new IllegalStateException("updatedDecisionAndReasons is not present in correctedDecisionAndReasons list")) + .getValue(); + + decisionAndReasons.setCoverLetterDocument(coverLetter); + decisionAndReasons.setDateCoverLetterDocumentUploaded(dateProvider.now().toString()); + asylumCase.write(CORRECTED_DECISION_AND_REASONS, existingDecisionAndReasons); + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private boolean isDecisionRule31(AsylumCase asylumCase) { + return asylumCase.read(UPDATE_TRIBUNAL_DECISION_LIST, UpdateTribunalRules.class) + .map(type -> type.equals(UNDER_RULE_31)).orElse(false); + } + + private DocumentCreator getCoverLetterCreatorInstance(AsylumCase asylumCase) { + boolean isAipJourney = asylumCase.read(JOURNEY_TYPE, JourneyType.class) + .map(type -> type == AIP).orElse(false); + + return isAipJourney ? aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator : + updatedDecisionAndReasonsCoverLetterDocumentCreator; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandler.java index c4c411f83..ab05e9a89 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandler.java @@ -60,10 +60,13 @@ public PreSubmitCallbackResponse handle( .getCaseDetails() .getCaseData(); + boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent(); asylumCase.clear(HMCTS); asylumCase.write(AsylumCaseDefinition.HMCTS, "[userImage:hmcts.png]"); asylumCase.clear(AsylumCaseDefinition.CASE_BUNDLES); - asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-upper-tribunal-bundle-config.yaml"); + asylumCase.write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + isOrWasAda ? "iac-upper-tribunal-bundle-inc-tribunal-config.yaml" : "iac-upper-tribunal-bundle-config.yaml"); + asylumCase.write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, getBundlePrefix(asylumCase)); final PreSubmitCallbackResponse response = diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreator.java new file mode 100644 index 000000000..d582a00e9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreator.java @@ -0,0 +1,78 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +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 ChangeHearingCentreLetterCreator implements PreSubmitCallbackHandler { + + private final DocumentCreator changeHearingCentreDocumentCreator; + private final DocumentHandler documentHandler; + + public ChangeHearingCentreLetterCreator( + @Qualifier("internalChangeHearingCentreLetter") DocumentCreator changeHearingCentreDocumentCreator, + DocumentHandler documentHandler + ) { + this.changeHearingCentreDocumentCreator = changeHearingCentreDocumentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + final AsylumCase asylumCase = + callback + .getCaseDetails() + .getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && callback.getEvent() == Event.CHANGE_HEARING_CENTRE; + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final CaseDetails caseDetailsBefore = callback.getCaseDetailsBefore() + .orElseThrow(() -> new IllegalStateException("previous case data is not present")); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document letter = changeHearingCentreDocumentCreator.create(caseDetails, caseDetailsBefore); + documentHandler.addWithMetadata( + asylumCase, + letter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_HEARING_CENTRE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/HoReviewEvidenceLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/HoReviewEvidenceLetterGenerator.java new file mode 100644 index 000000000..e3a77f5f9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/HoReviewEvidenceLetterGenerator.java @@ -0,0 +1,69 @@ +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.*; + +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils; + +@Component +public class HoReviewEvidenceLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator hoReviewEvidenceLetterCreator; + private final DocumentHandler documentHandler; + + public HoReviewEvidenceLetterGenerator( + @Qualifier("hoReviewEvidenceLetter") DocumentCreator hoReviewEvidenceLetterCreator, + DocumentHandler documentHandler + ) { + this.hoReviewEvidenceLetterCreator = hoReviewEvidenceLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + return callback.getEvent() == Event.REQUEST_RESPONDENT_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && AsylumCaseUtils.isInternalCase(callback.getCaseDetails().getCaseData()) + && AsylumCaseUtils.isAppellantInDetention(callback.getCaseDetails().getCaseData()); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document hoReviewEvidenceLetter = hoReviewEvidenceLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + hoReviewEvidenceLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.REQUEST_RESPONDENT_REVIEW + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGenerator.java new file mode 100644 index 000000000..aba58a89c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGenerator.java @@ -0,0 +1,70 @@ +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.*; + +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.handlers.PreSubmitCallbackHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@Component +public class InternalAppealCanProceedLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAppealCanProceedLetterCreator; + private final DocumentHandler documentHandler; + + public InternalAppealCanProceedLetterGenerator( + @Qualifier("internalAppealCanProceedLetter") DocumentCreator internalAppealCanProceedLetterCreator, + DocumentHandler documentHandler + ) { + this.internalAppealCanProceedLetterCreator = internalAppealCanProceedLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.RECORD_OUT_OF_TIME_DECISION + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + documentHandler.addWithMetadata( + asylumCase, + internalAppealCanProceedLetterCreator.create(caseDetails), + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.RECORD_OUT_OF_TIME_DECISION_DOCUMENT); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGenerator.java new file mode 100644 index 000000000..bdd1f74e2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGenerator.java @@ -0,0 +1,73 @@ +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 InternalApplyForFtpaAppellantLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalApplyForFtpaAppellantLetter; + private final DocumentHandler documentHandler; + + public InternalApplyForFtpaAppellantLetterGenerator( + @Qualifier("internalApplyForFtpaAppellantLetter") DocumentCreator internalApplyForFtpaAppellantLetter, + DocumentHandler documentHandler + ) { + this.internalApplyForFtpaAppellantLetter = internalApplyForFtpaAppellantLetter; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.APPLY_FOR_FTPA_APPELLANT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document documentForUpload = internalApplyForFtpaAppellantLetter.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + documentForUpload, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalChangeDirectionDueDateLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalChangeDirectionDueDateLetterGenerator.java new file mode 100644 index 000000000..e90556493 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalChangeDirectionDueDateLetterGenerator.java @@ -0,0 +1,84 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.DIRECTION_EDIT_PARTIES; +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 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.Parties; +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 InternalChangeDirectionDueDateLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalChangeDirectionDueDateLetterGenerator( + @Qualifier("internalChangeDueDateLetter") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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 + && Event.CHANGE_DIRECTION_DUE_DATE == event + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && isDirectionPartyAppellantOrAppellantRespondent(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalChangeDirectionDueDateLetter = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalChangeDirectionDueDateLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private boolean isDirectionPartyAppellantOrAppellantRespondent(AsylumCase asylumCase) { + return asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class) + .map(Parties -> Parties.equals(Parties.APPELLANT) || Parties.equals(Parties.APPELLANT_AND_RESPONDENT)) + .orElse(false); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandler.java new file mode 100644 index 000000000..11bcde30c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandler.java @@ -0,0 +1,118 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import java.util.Optional; +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.MakeAnApplication; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@Component +public class InternalDecideAnApplicationLetterHandler implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDecideAnAppellantApplicationDecisionGrantedLetter; + private final DocumentCreator internalDecideAnAppellantApplicationDecisionRefusedLetter; + private final DocumentCreator internalDecideHomeOfficeApplicationDecisionGrantedLetter; + private final DocumentCreator internalDecideHomeOfficeApplicationDecisionRefusedLetter; + private final DocumentHandler documentHandler; + private final MakeAnApplicationService makeAnApplicationService; + private final String decisionGranted = "Granted"; + private final String decisionRefused = "Refused"; + private final String applicationApplicantNameWhenAppellant = "Admin Officer"; + + public InternalDecideAnApplicationLetterHandler( + @Qualifier("internalDecideAnAppellantApplicationDecisionGrantedLetter") DocumentCreator internalDecideAnAppellantApplicationDecisionGrantedLetter, + @Qualifier("internalDecideAnAppellantApplicationDecisionRefusedLetter") DocumentCreator internalDecideAnAppellantApplicationDecisionRefusedLetter, + @Qualifier("internalDecideHomeOfficeApplicationDecisionGrantedLetter") DocumentCreator internalDecideHomeOfficeApplicationDecisionGrantedLetter, + @Qualifier("internalDecideHomeOfficeApplicationDecisionRefusedLetter") DocumentCreator internalDecideHomeOfficeApplicationDecisionRefusedLetter, + DocumentHandler documentHandler, + MakeAnApplicationService makeAnApplicationService + ) { + this.internalDecideAnAppellantApplicationDecisionGrantedLetter = internalDecideAnAppellantApplicationDecisionGrantedLetter; + this.internalDecideAnAppellantApplicationDecisionRefusedLetter = internalDecideAnAppellantApplicationDecisionRefusedLetter; + this.internalDecideHomeOfficeApplicationDecisionGrantedLetter = internalDecideHomeOfficeApplicationDecisionGrantedLetter; + this.internalDecideHomeOfficeApplicationDecisionRefusedLetter = internalDecideHomeOfficeApplicationDecisionRefusedLetter; + this.documentHandler = documentHandler; + this.makeAnApplicationService = makeAnApplicationService; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.DECIDE_AN_APPLICATION + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Optional optionalMakeAnApplication = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + if (!optionalMakeAnApplication.isPresent()) { + throw new IllegalStateException("Application not found"); + } + + boolean isAppellantApplication = optionalMakeAnApplication.get().getApplicant().equals(applicationApplicantNameWhenAppellant); + + boolean applicationGranted = optionalMakeAnApplication.get().getDecision().equals(decisionGranted); + boolean applicationRefused = optionalMakeAnApplication.get().getDecision().equals(decisionRefused); + + Document documentForUpload; + DocumentTag documentTagForUpload = DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER; + if (applicationGranted) { + if (isAppellantApplication) { + documentForUpload = internalDecideAnAppellantApplicationDecisionGrantedLetter.create(caseDetails); + } else { + documentTagForUpload = DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER; + documentForUpload = internalDecideHomeOfficeApplicationDecisionGrantedLetter.create(caseDetails); + } + } else if (applicationRefused) { + if (isAppellantApplication) { + documentForUpload = internalDecideAnAppellantApplicationDecisionRefusedLetter.create(caseDetails); + } else { + documentTagForUpload = DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER; + documentForUpload = internalDecideHomeOfficeApplicationDecisionRefusedLetter.create(caseDetails); + } + } else { + return new PreSubmitCallbackResponse<>(asylumCase); + } + + documentHandler.addWithMetadata( + asylumCase, + documentForUpload, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + documentTagForUpload + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandler.java new file mode 100644 index 000000000..24a1e616a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandler.java @@ -0,0 +1,94 @@ +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 java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +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.AsylumCaseDefinition; +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.State; +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.entities.ccd.field.IdValue; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.Bundle; + +@Component +public class InternalDetHearingBundleReadyHandler implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetHearingBundleReadyGenerator; + private final DocumentHandler documentHandler; + + public InternalDetHearingBundleReadyHandler( + @Qualifier("internalDetHearingBundle") DocumentCreator internalDetHearingBundleReadyGenerator, + DocumentHandler documentHandler + ) { + this.internalDetHearingBundleReadyGenerator = internalDetHearingBundleReadyGenerator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.ASYNC_STITCHING_COMPLETE + && callback.getCaseDetails().getState() != State.FTPA_DECIDED + && "DONE".equalsIgnoreCase(getStitchStatus(callback)) + && isInternalCase(callback.getCaseDetails().getCaseData()) + && isAppellantInDetention(callback.getCaseDetails().getCaseData()); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetGenerateHearingBundleDocument = internalDetHearingBundleReadyGenerator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + internalDetGenerateHearingBundleDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.HEARING_BUNDLE_READY_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private String getStitchStatus(Callback callback) { + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + Optional>> maybeCaseBundles = asylumCase.read(AsylumCaseDefinition.CASE_BUNDLES); + + final List caseBundles = maybeCaseBundles.isPresent() ? maybeCaseBundles.get() + .stream() + .map(IdValue::getValue) + .collect(Collectors.toList()) : Collections.emptyList(); + + return caseBundles.isEmpty() ? "" : caseBundles.get(0).getStitchStatus().orElse(""); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGenerator.java new file mode 100644 index 000000000..0001a53c6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGenerator.java @@ -0,0 +1,93 @@ +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.AsylumAppealType.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_TYPE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import java.util.Optional; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +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.State; +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.entities.ccd.field.PaymentStatus; +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 InternalDetMarkAsPaidLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetMarkAsPaidLetterLetterCreator; + private final DocumentHandler documentHandler; + + public InternalDetMarkAsPaidLetterGenerator( + @Qualifier("internalDetMarkAsPaidLetter") DocumentCreator internalDetMarkAsPaidLetterLetterCreator, + DocumentHandler documentHandler + ) { + this.internalDetMarkAsPaidLetterLetterCreator = internalDetMarkAsPaidLetterLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + State currentState = callback.getCaseDetails().getState(); + + boolean isCorrectAppealTypePA = asylumCase + .read(APPEAL_TYPE, AsylumAppealType.class) + .map(type -> type == PA).orElse(false); + + boolean isCorrectAppealTypeAndStateEaHuEu = + isEaHuEuAppeal(asylumCase) && (currentState == State.APPEAL_SUBMITTED); + + Optional paymentStatus = asylumCase + .read(AsylumCaseDefinition.PAYMENT_STATUS, PaymentStatus.class); + + return callback.getEvent() == Event.MARK_APPEAL_PAID + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && (isCorrectAppealTypePA || isCorrectAppealTypeAndStateEaHuEu) + && paymentStatus.isPresent() + && paymentStatus.get().equals(PaymentStatus.PAID) + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetMarkAsPaidLetter = internalDetMarkAsPaidLetterLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + internalDetMarkAsPaidLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_MARK_AS_PAID_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGenerator.java new file mode 100644 index 000000000..7b9623ab9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGenerator.java @@ -0,0 +1,80 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +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; + +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; + +@Component +public class InternalDetainedAdjournHearingWithoutDateLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator adjournHearingWithoutDateDocumentCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedAdjournHearingWithoutDateLetterGenerator( + @Qualifier("internalAdjournHearingWithoutDateLetter") DocumentCreator adjournHearingWithoutDateDocumentCreator, + DocumentHandler documentHandler + ) { + this.adjournHearingWithoutDateDocumentCreator = adjournHearingWithoutDateDocumentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + final AsylumCase asylumCase = + callback + .getCaseDetails() + .getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && callback.getEvent() == Event.ADJOURN_HEARING_WITHOUT_DATE; + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final CaseDetails caseDetailsBefore = callback.getCaseDetailsBefore() + .orElseThrow(() -> new IllegalStateException("previous case data is not present")); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document letter = adjournHearingWithoutDateDocumentCreator.create(caseDetails, caseDetailsBefore); + + documentHandler.addWithMetadata( + asylumCase, + letter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_ADJOURN_HEARING_WITHOUT_DATE + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAppealFeeDueLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAppealFeeDueLetterGenerator.java new file mode 100644 index 000000000..e88c79dac --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAppealFeeDueLetterGenerator.java @@ -0,0 +1,98 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionDecision.PARTIALLY_APPROVED; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionDecision.REJECTED; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isEaHuEuAppeal; + +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.RemissionDecision; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionType; +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.State; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils; + + +@Component +public class InternalDetainedAppealFeeDueLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetainedAppealFeeDueCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedAppealFeeDueLetterGenerator( + @Qualifier("internalDetainedAppealFeeDue") DocumentCreator internalDetainedAppealFeeDueCreator, + DocumentHandler documentHandler + ) { + this.internalDetainedAppealFeeDueCreator = internalDetainedAppealFeeDueCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + boolean isNoRemission = asylumCase.read(REMISSION_TYPE, RemissionType.class) + .map(remission -> remission == RemissionType.NO_REMISSION).orElse(false); + + boolean isRemissionPartiallyApprovedOrRejected = asylumCase.read(REMISSION_DECISION, RemissionDecision.class) + .map(decision -> PARTIALLY_APPROVED == decision || REJECTED == decision) + .orElse(false); + + boolean isSubmitAppealNoRemissionScenario = + callback.getEvent() == Event.SUBMIT_APPEAL + && isNoRemission; + + boolean isRecordRemissionDecisionPartiallyApprovedRejectedScenario = + callback.getEvent() == Event.RECORD_REMISSION_DECISION + && isRemissionPartiallyApprovedOrRejected; + + return (isSubmitAppealNoRemissionScenario || isRecordRemissionDecisionPartiallyApprovedRejectedScenario) + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getCaseDetails().getState().equals(State.PENDING_PAYMENT) + && AsylumCaseUtils.isInternalCase(asylumCase) + && AsylumCaseUtils.isAppellantInDetention(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase) + && isEaHuEuAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetainedAppealFeeDueLetter = internalDetainedAppealFeeDueCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + internalDetainedAppealFeeDueLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPEAL_FEE_DUE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGenerator.java new file mode 100644 index 000000000..39ba783ec --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGenerator.java @@ -0,0 +1,74 @@ +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.utils.AsylumCaseUtils.isAppellantInDetention; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; + +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 InternalDetainedApplyForFtpaRespondentLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedApplyForFtpaRespondentLetterGenerator( + @Qualifier("internalApplyForFtpaRespondent") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.APPLY_FOR_FTPA_RESPONDENT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalMarkAsAdaNotice = documentCreator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + internalMarkAsAdaNotice, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPLY_FOR_FTPA_RESPONDENT + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGenerator.java new file mode 100644 index 000000000..73a7c40fb --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGenerator.java @@ -0,0 +1,77 @@ +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.*; + +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 InternalDetainedEditCaseListingDocumentGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetainedEditCaseListingLetterCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedEditCaseListingDocumentGenerator( + @Qualifier("internalDetEditCaseListingLetter") DocumentCreator internalDetainedEditCaseListingLetterCreator, + DocumentHandler documentHandler + ) { + this.internalDetainedEditCaseListingLetterCreator = internalDetainedEditCaseListingLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.EDIT_CASE_LISTING + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final CaseDetails caseDetailsBefore = callback.getCaseDetailsBefore() + .orElseThrow(() -> new IllegalStateException("previous case data is not present")); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalEditCaseListingDocument = + internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore); + + documentHandler.addWithMetadata( + asylumCase, + internalEditCaseListingDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} + + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGenerator.java new file mode 100644 index 000000000..f5a2b7a00 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGenerator.java @@ -0,0 +1,74 @@ +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.utils.AsylumCaseUtils.*; + +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 InternalDetainedListCaseLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedListCaseLetterGenerator( + @Qualifier("internalDetainedListCase") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.LIST_CASE + && isInternalCase(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalDetainedListCaseLetter = documentCreator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + internalDetainedListCaseLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_LIST_CASE_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGenerator.java new file mode 100644 index 000000000..ecd9a4228 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGenerator.java @@ -0,0 +1,71 @@ +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.utils.AsylumCaseUtils.*; + +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 InternalDetainedMarkAsAdaLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedMarkAsAdaLetterGenerator( + @Qualifier("internalMarkAsAdaNotice") DocumentCreator documentCreator, + DocumentHandler documentHandler) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.MARK_APPEAL_AS_ADA + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalMarkAsAdaNotice = documentCreator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + internalMarkAsAdaNotice, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_MARK_AS_ADA_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.java new file mode 100644 index 000000000..5a1cdfa51 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.java @@ -0,0 +1,79 @@ +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.APPEAL_REVIEW_OUTCOME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealReviewOutcome; +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 InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalReviewHomeOfficeResponseLetterCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator( + @Qualifier("internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetter") DocumentCreator internalReviewHomeOfficeResponseLetterCreator, + DocumentHandler documentHandler + ) { + this.internalReviewHomeOfficeResponseLetterCreator = internalReviewHomeOfficeResponseLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.REQUEST_RESPONSE_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase) + && isAppellantInDetention(asylumCase) + && getAppealReviewOutcome(asylumCase).equals(AppealReviewOutcome.DECISION_MAINTAINED); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document uploadTheAppealResponseLetter = internalReviewHomeOfficeResponseLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + uploadTheAppealResponseLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private AppealReviewOutcome getAppealReviewOutcome(AsylumCase asylumCase) { + return asylumCase.read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class) + .orElseThrow(() -> new IllegalStateException("Appeal review outcome is not present")); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.java new file mode 100644 index 000000000..6bba5d6ee --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.java @@ -0,0 +1,78 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealReviewOutcome; +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 InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter; + private final DocumentHandler documentHandler; + + public InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator( + @Qualifier("internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter") DocumentCreator internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter, + DocumentHandler documentHandler + ) { + this.internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.REQUEST_RESPONSE_REVIEW + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase) + && isAppellantInDetention(asylumCase) + && getAppealReviewOutcome(asylumCase).equals(AppealReviewOutcome.DECISION_WITHDRAWN); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document uploadTheAppealResponseLetter = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + uploadTheAppealResponseLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private AppealReviewOutcome getAppealReviewOutcome(AsylumCase asylumCase) { + return asylumCase.read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class) + .orElseThrow(() -> new IllegalStateException("Appeal review outcome is not present")); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGenerator.java new file mode 100644 index 000000000..8eb2f9acd --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGenerator.java @@ -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 { + + private final DocumentCreator internalDetainedTransferOutOfAdaLetterCreator; + private final DocumentHandler documentHandler; + + public InternalDetainedTransferOutOfAdaDocumentGenerator( + @Qualifier("internalDetainedTransferOutOfAdaLetter") DocumentCreator internalDetainedTransferOutOfAdaLetterCreator, + DocumentHandler documentHandler + ) { + this.internalDetainedTransferOutOfAdaLetterCreator = internalDetainedTransferOutOfAdaLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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 handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails 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); + } +} + + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGenerator.java new file mode 100644 index 000000000..1f85fc080 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGenerator.java @@ -0,0 +1,74 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +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; + +import java.util.Objects; + +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; + +@Component +public class InternalEditAppealGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalEditAppealGenerator( + @Qualifier("internalEditAppealNotice") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.EDIT_APPEAL_AFTER_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalEditAppealNotice = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalEditAppealNotice, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_EDIT_APPEAL_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGenerator.java new file mode 100644 index 000000000..97868ce2c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGenerator.java @@ -0,0 +1,74 @@ +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.utils.AsylumCaseUtils.*; + +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 InternalEndAppealAutomaticallyGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalEndAppealAutomaticallyGenerator( + @Qualifier("internalEndAppealAutomaticallyNotice") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.END_APPEAL_AUTOMATICALLY + && isInternalCase(asylumCase) + && !isAcceleratedDetainedAppeal(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalEndAppealAutomaticallyNotice = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalEndAppealAutomaticallyNotice, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_END_APPEAL_AUTOMATICALLY + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGenerator.java new file mode 100644 index 000000000..1facf08a7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGenerator.java @@ -0,0 +1,73 @@ +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.utils.AsylumCaseUtils.isAppellantInDetention; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; + +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 InternalEndAppealGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalEndAppealGenerator( + @Qualifier("internalEndAppealNotice") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.END_APPEAL + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalEndAppealNotice = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalEndAppealNotice, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.END_APPEAL + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGenerator.java new file mode 100644 index 000000000..158e61a00 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGenerator.java @@ -0,0 +1,125 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.FtpaDecisionOutcomeType.*; +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.Optional; +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.FtpaDecisionOutcomeType; +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 InternalFtpaDecidedLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAppellantFtpaDecidedGrantedLetter; + private final DocumentCreator internalAppellantFtpaDecidedPartiallyGrantedLetter; + private final DocumentCreator internalAppellantFtpaDecidedRefusedLetter; + private final DocumentCreator internalHoFtpaDecidedGrantedLetter; + private final DocumentCreator internalHoFtpaDecidedPartiallyGrantedLetter; + private final DocumentCreator internalHoFtpaDecidedRefusedLetter; + private final DocumentHandler documentHandler; + private final String ftpaApplicantAppellant = "appellant"; + + public InternalFtpaDecidedLetterGenerator( + @Qualifier("internalAppellantFtpaDecidedGrantedLetter") DocumentCreator internalAppellantFtpaDecidedGrantedLetter, + @Qualifier("internalAppellantFtpaDecidedPartiallyGrantedLetter") DocumentCreator internalAppellantFtpaDecidedPartiallyGrantedLetter, + @Qualifier("internalAppellantFtpaDecidedRefusedLetter") DocumentCreator internalAppellantFtpaDecidedRefusedLetter, + @Qualifier("internalHoFtpaDecidedGrantedLetter") DocumentCreator internalHoFtpaDecidedGrantedLetter, + @Qualifier("internalHoFtpaDecidedPartiallyGrantedLetter") DocumentCreator internalHoFtpaDecidedPartiallyGrantedLetter, + @Qualifier("internalHoFtpaDecidedRefusedLetter") DocumentCreator internalHoFtpaDecidedRefusedLetter, + DocumentHandler documentHandler + ) { + this.internalAppellantFtpaDecidedGrantedLetter = internalAppellantFtpaDecidedGrantedLetter; + this.internalAppellantFtpaDecidedPartiallyGrantedLetter = internalAppellantFtpaDecidedPartiallyGrantedLetter; + this.internalAppellantFtpaDecidedRefusedLetter = internalAppellantFtpaDecidedRefusedLetter; + this.internalHoFtpaDecidedGrantedLetter = internalHoFtpaDecidedGrantedLetter; + this.internalHoFtpaDecidedPartiallyGrantedLetter = internalHoFtpaDecidedPartiallyGrantedLetter; + this.internalHoFtpaDecidedRefusedLetter = internalHoFtpaDecidedRefusedLetter; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.RESIDENT_JUDGE_FTPA_DECISION + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Optional ftpaAppellantDecisionOutcomeType = asylumCase + .read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class); + + Optional ftpaRespondentDecisionOutcomeType = asylumCase + .read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class); + + Optional ftpaApplicantType = asylumCase.read(FTPA_APPLICANT_TYPE, String.class); + + Document documentForUpload; + DocumentTag documentTag; + + if (ftpaApplicantType.equals(Optional.of(ftpaApplicantAppellant))) { + if (ftpaAppellantDecisionOutcomeType.equals(Optional.of(FTPA_GRANTED))) { + documentForUpload = internalAppellantFtpaDecidedGrantedLetter.create(caseDetails); + } else if (ftpaAppellantDecisionOutcomeType.equals(Optional.of(FTPA_PARTIALLY_GRANTED))) { + documentForUpload = internalAppellantFtpaDecidedPartiallyGrantedLetter.create(caseDetails); + } else if (ftpaAppellantDecisionOutcomeType.equals(Optional.of(FTPA_REFUSED))) { + documentForUpload = internalAppellantFtpaDecidedRefusedLetter.create(caseDetails); + } else { + return new PreSubmitCallbackResponse<>(asylumCase); + } + documentTag = DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER; + } else { + if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_GRANTED))) { + documentForUpload = internalHoFtpaDecidedGrantedLetter.create(caseDetails); + } else if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_PARTIALLY_GRANTED))) { + documentForUpload = internalHoFtpaDecidedPartiallyGrantedLetter.create(caseDetails); + } else if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_REFUSED)) + || ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_NOT_ADMITTED))) { + documentForUpload = internalHoFtpaDecidedRefusedLetter.create(caseDetails); + } else { + return new PreSubmitCallbackResponse<>(asylumCase); + } + documentTag = DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER; + } + + documentHandler.addWithMetadata( + asylumCase, + documentForUpload, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + documentTag + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGenerator.java new file mode 100644 index 000000000..8ed5f27c0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGenerator.java @@ -0,0 +1,73 @@ +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 InternalHearingAdjustmentsUpdatedLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalHearingAdjustmentsUpdatedLetter; + private final DocumentHandler documentHandler; + + public InternalHearingAdjustmentsUpdatedLetterGenerator( + @Qualifier("internalHearingAdjustmentsUpdatedLetter") DocumentCreator internalHearingAdjustmentsUpdatedLetter, + DocumentHandler documentHandler + ) { + this.internalHearingAdjustmentsUpdatedLetter = internalHearingAdjustmentsUpdatedLetter; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.UPDATE_HEARING_ADJUSTMENTS + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document documentForUpload = internalHearingAdjustmentsUpdatedLetter.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + documentForUpload, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandler.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandler.java new file mode 100644 index 000000000..6dd61d42d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandler.java @@ -0,0 +1,74 @@ +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.entities.DocumentTag.AMEND_HOME_OFFICE_APPEAL_RESPONSE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +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.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.handlers.PreSubmitCallbackHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + + +@Component +public class InternalHomeOfficeAmendAppealResponseHandler implements PreSubmitCallbackHandler { + + private final DocumentCreator internalHomeOfficeAmendAppealResponseLetter; + private final DocumentHandler documentHandler; + private final DirectionFinder directionFinder; + + public InternalHomeOfficeAmendAppealResponseHandler( + @Qualifier("internalHomeOfficeAmendAppealResponseLetter") DocumentCreator internalHomeOfficeAmendAppealResponseLetter, + DocumentHandler documentHandler, + DirectionFinder directionFinder + ) { + this.internalHomeOfficeAmendAppealResponseLetter = internalHomeOfficeAmendAppealResponseLetter; + this.documentHandler = documentHandler; + this.directionFinder = directionFinder; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.REQUEST_RESPONSE_AMEND + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + documentHandler.addWithMetadata( + asylumCase, + internalHomeOfficeAmendAppealResponseLetter.create(caseDetails), + NOTIFICATION_ATTACHMENT_DOCUMENTS, + AMEND_HOME_OFFICE_APPEAL_RESPONSE + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGenerator.java new file mode 100644 index 000000000..3968da729 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGenerator.java @@ -0,0 +1,73 @@ +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.utils.AsylumCaseUtils.isAppellantInDetention; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; + +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 InternalMaintainCaseLinkAppealGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalMaintainCaseLinkAppealGenerator( + @Qualifier("internalMaintainCaseLinkAppealLetter") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.CREATE_CASE_LINK + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalMaintainCaseUnlinkAppeal = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalMaintainCaseUnlinkAppeal, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.MAINTAIN_CASE_LINK_APPEAL_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGenerator.java new file mode 100644 index 000000000..4a4c6f961 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGenerator.java @@ -0,0 +1,73 @@ +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.utils.AsylumCaseUtils.isAppellantInDetention; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; + +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 InternalMaintainCaseUnlinkAppealGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalMaintainCaseUnlinkAppealGenerator( + @Qualifier("internalMaintainCaseUnlinkAppealLetter") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + Objects.requireNonNull(callbackStage, "callbackStage must not be null"); + Objects.requireNonNull(callback, "callback must not be null"); + + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent() == Event.MAINTAIN_CASE_LINKS + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalMaintainCaseUnlinkAppeal = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalMaintainCaseUnlinkAppeal, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.MAINTAIN_CASE_UNLINK_APPEAL_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGenerator.java new file mode 100644 index 000000000..77ea9f4e2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGenerator.java @@ -0,0 +1,87 @@ +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.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; +/* +This class is to generate letter when a Non Standard Direction is sent to appellant or appellant and respondent. + */ + +@Component +public class InternalNonStandardDirectionLetterGenerator implements PreSubmitCallbackHandler { + private final DocumentCreator internalNonStandardDirectionLetterCreator; + private final DocumentHandler documentHandler; + private final DirectionFinder directionFinder; + + public InternalNonStandardDirectionLetterGenerator( + @Qualifier("internalNonStandardDirectionLetter") DocumentCreator internalNonStandardDirectionLetterCreator, + DocumentHandler documentHandler, + DirectionFinder directionFinder) { + this.internalNonStandardDirectionLetterCreator = internalNonStandardDirectionLetterCreator; + this.documentHandler = documentHandler; + this.directionFinder = directionFinder; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.SEND_DIRECTION + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && isRecipientAppellant(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document uploadDocument = internalNonStandardDirectionLetterCreator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + uploadDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private boolean isRecipientAppellant(AsylumCase asylumCase) { + return directionFinder + .findFirst(asylumCase, DirectionTag.NONE) + .map(direction -> direction.getParties().equals(Parties.APPELLANT) || direction.getParties().equals(Parties.APPELLANT_AND_RESPONDENT)) + .orElse(false); + } +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGenerator.java new file mode 100644 index 000000000..2726f492a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGenerator.java @@ -0,0 +1,89 @@ +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.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; +/* +This class is to generate letter when a Non Standard Direction is sent to respondent or appellant and respondent. + */ + +@Component +public class InternalNonStandardDirectionToRespondentLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator homeOfficeNonStandardDirectionLetterCreator; + private final DocumentHandler documentHandler; + private final DirectionFinder directionFinder; + + public InternalNonStandardDirectionToRespondentLetterGenerator( + @Qualifier("homeOfficeNonStandardDirectionLetter") + DocumentCreator homeOfficeNonStandardDirectionLetterCreator, + DocumentHandler documentHandler, + DirectionFinder directionFinder) { + this.homeOfficeNonStandardDirectionLetterCreator = homeOfficeNonStandardDirectionLetterCreator; + this.documentHandler = documentHandler; + this.directionFinder = directionFinder; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.SEND_DIRECTION + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase) + && isRecipientRespondent(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document uploadDocument = homeOfficeNonStandardDirectionLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + uploadDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private boolean isRecipientRespondent(AsylumCase asylumCase) { + return directionFinder + .findFirst(asylumCase, DirectionTag.NONE) + .map(direction -> direction.getParties().equals(Parties.RESPONDENT) || direction.getParties().equals(Parties.APPELLANT_AND_RESPONDENT)) + .orElse(false); + } +} + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGenerator.java new file mode 100644 index 000000000..7bb146fe7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGenerator.java @@ -0,0 +1,76 @@ +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.*; +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.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 InternalReinstateAppealLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator documentCreator; + private final DocumentHandler documentHandler; + + public InternalReinstateAppealLetterGenerator( + @Qualifier("internalReinstateAppealLetter") DocumentCreator documentCreator, + DocumentHandler documentHandler + ) { + this.documentCreator = documentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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 + && callback.getEvent() == REINSTATE_APPEAL + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalReinstateAppealLetter = documentCreator.create(caseDetails); + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + internalReinstateAppealLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REINSTATE_APPEAL_LETTER + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalRequestBuildCaseDocumentGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalRequestBuildCaseDocumentGenerator.java new file mode 100644 index 000000000..0f69bd27f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalRequestBuildCaseDocumentGenerator.java @@ -0,0 +1,79 @@ +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.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +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 InternalRequestBuildCaseDocumentGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator internalAdaBuildCaseDocumentGenerator; + private final DocumentCreator internalDetainedBuildCaseDocumentGenerator; + private final DocumentHandler documentHandler; + + public InternalRequestBuildCaseDocumentGenerator( + @Qualifier("internalAdaRequestBuildCase") DocumentCreator internalAdaRequestBuildCaseDocumentCreator, + @Qualifier("internalDetainedRequestBuildCase") DocumentCreator internalDetainedRequestBuildCaseDocumentCreator, + DocumentHandler documentHandler + ) { + this.internalAdaBuildCaseDocumentGenerator = internalAdaRequestBuildCaseDocumentCreator; + this.internalDetainedBuildCaseDocumentGenerator = internalDetainedRequestBuildCaseDocumentCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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.REQUEST_CASE_BUILDING + && isInternalCase(asylumCase) + && isDetainedAppeal(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document internalBuildCaseDocument = isAcceleratedDetainedAppeal(asylumCase) + ? + internalAdaBuildCaseDocumentGenerator.create(caseDetails) : internalDetainedBuildCaseDocumentGenerator.create(caseDetails); + + documentHandler.addWithMetadata( + asylumCase, + internalBuildCaseDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.REQUEST_CASE_BUILDING + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} + + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGenerator.java new file mode 100644 index 000000000..e9be66772 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGenerator.java @@ -0,0 +1,128 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.Event.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; +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.DocumentWithMetadata; +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.entities.ccd.field.IdValue; +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 { + + private static final String LEGAL_OFFICER_ADDENDUM_UPLOADED_BY_LABEL = "TCW"; + private static final String LEGAL_OFFICER_ADDENDUM_SUPPLIED_BY_LABEL = "The respondent"; + private final DocumentCreator adminUploadEvidence; + private final DocumentCreator homeOfficeUploadEvidence; + private final DocumentCreator legalOfficereUploadEvidence; + private final DocumentHandler documentHandler; + + public InternalUploadAdditionalEvidenceGenerator( + // First DocumentCreator bean represents admin upload however cannot rename as it will require too much refactoring + @Qualifier("internalUploadAdditionalEvidenceLetter") DocumentCreator adminUploadEvidence, + @Qualifier("internalHomeOfficeUploadAdditionalAddendumEvidenceLetter") DocumentCreator homeOfficeUploadEvidence, + @Qualifier("internalLegalOfficerUploadAdditionalEvidenceLetter") DocumentCreator legalOfficereUploadEvidence, + DocumentHandler documentHandler + ) { + this.adminUploadEvidence = adminUploadEvidence; + this.homeOfficeUploadEvidence = homeOfficeUploadEvidence; + this.legalOfficereUploadEvidence = legalOfficereUploadEvidence; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback 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(); + + Optional> latestAddendum; + + if (event.equals(UPLOAD_ADDENDUM_EVIDENCE)) { + latestAddendum = getLatestAddendumEvidenceDocument(asylumCase); + if (latestAddendum.isEmpty()) { + return false; + } + + DocumentWithMetadata addendum = latestAddendum.get().getValue(); + + if (addendum.getSuppliedBy() == null || addendum.getUploadedBy() == null) { + return false; + } + + if (!addendum.getUploadedBy().equals(LEGAL_OFFICER_ADDENDUM_UPLOADED_BY_LABEL) || + !addendum.getSuppliedBy().equals(LEGAL_OFFICER_ADDENDUM_SUPPLIED_BY_LABEL)) { + return false; + } + } + + return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && List.of( + UPLOAD_ADDITIONAL_EVIDENCE, + UPLOAD_ADDENDUM_EVIDENCE, + UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER, + UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE, + UPLOAD_ADDENDUM_EVIDENCE_HOME_OFFICE) + .contains(event) + && isInternalCase(asylumCase) + && isAppellantInDetention(asylumCase); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document documentToUpload; + DocumentTag documentTagForUpload; + + if (List.of(UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE, UPLOAD_ADDENDUM_EVIDENCE_HOME_OFFICE).contains(callback.getEvent())) { + documentToUpload = homeOfficeUploadEvidence.create(caseDetails); + documentTagForUpload = HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER; + } else if (callback.getEvent().equals(UPLOAD_ADDENDUM_EVIDENCE)) { + documentToUpload = legalOfficereUploadEvidence.create(caseDetails); + documentTagForUpload = LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER; + } else { + documentToUpload = adminUploadEvidence.create(caseDetails); + documentTagForUpload = DocumentTag.INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER; + } + + documentHandler.addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + documentToUpload, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + documentTagForUpload + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/UploadTheAppealResponseLetterGenerator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/UploadTheAppealResponseLetterGenerator.java new file mode 100644 index 000000000..5037dd334 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/UploadTheAppealResponseLetterGenerator.java @@ -0,0 +1,80 @@ +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.APPEAL_REVIEW_OUTCOME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealReviewOutcome; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils; + +@Component +public class UploadTheAppealResponseLetterGenerator implements PreSubmitCallbackHandler { + + private final DocumentCreator uploadTheAppealResponseLetterCreator; + private final DocumentHandler documentHandler; + + public UploadTheAppealResponseLetterGenerator( + @Qualifier("uploadTheAppealResponseLetter") DocumentCreator uploadTheAppealResponseLetterCreator, + DocumentHandler documentHandler + ) { + this.uploadTheAppealResponseLetterCreator = uploadTheAppealResponseLetterCreator; + this.documentHandler = documentHandler; + } + + public boolean canHandle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + requireNonNull(callbackStage, "callbackStage must not be null"); + requireNonNull(callback, "callback must not be null"); + AsylumCase asylumCase = callback.getCaseDetails().getCaseData(); + + return callback.getEvent() == Event.UPLOAD_HOME_OFFICE_APPEAL_RESPONSE + && callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && AsylumCaseUtils.isInternalCase(asylumCase) + && AsylumCaseUtils.isAcceleratedDetainedAppeal(asylumCase) + && getAppealReviewOutcome(asylumCase).equals("decisionMaintained"); + } + + public PreSubmitCallbackResponse handle( + PreSubmitCallbackStage callbackStage, + Callback callback + ) { + if (!canHandle(callbackStage, callback)) { + throw new IllegalStateException("Cannot handle callback"); + } + + final CaseDetails caseDetails = callback.getCaseDetails(); + final AsylumCase asylumCase = caseDetails.getCaseData(); + + Document uploadTheAppealResponseLetter = uploadTheAppealResponseLetterCreator.create(caseDetails); + documentHandler.addWithMetadata( + asylumCase, + uploadTheAppealResponseLetter, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.UPLOAD_THE_APPEAL_RESPONSE + ); + + return new PreSubmitCallbackResponse<>(asylumCase); + } + + private String getAppealReviewOutcome(AsylumCase asylumCase) { + AppealReviewOutcome appealReviewOutcome = asylumCase.read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class) + .orElseThrow(() -> new IllegalStateException("Appeal review outcome is not present")); + + return appealReviewOutcome.toString(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/AppointmentRequirementsFieldMapper.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/AppointmentRequirementsFieldMapper.java index e289762a3..234827c08 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/AppointmentRequirementsFieldMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/AppointmentRequirementsFieldMapper.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; import com.google.common.collect.ImmutableMap; import java.time.LocalDate; @@ -20,12 +21,7 @@ public AppointmentRequirementsFieldMapper() { public Map mapFields(AsylumCase asylumCase) { final Map fieldValues = new HashMap<>(); - - fieldValues.put("hmcts", "[userImage:hmcts.png]"); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); fieldValues.put("isInterpreterServicesNeeded", asylumCase.read(IS_INTERPRETER_SERVICES_NEEDED, YesOrNo.class).orElse(YesOrNo.NO)); @@ -53,7 +49,6 @@ public Map mapFields(AsylumCase asylumCase) { fieldValues.put("physicalOrMentalHealthIssuesDescription", asylumCase.read(PHYSICAL_OR_MENTAL_HEALTH_ISSUES_DESCRIPTION, String.class).orElse("")); fieldValues.put("pastExperiences", asylumCase.read(PAST_EXPERIENCES, YesOrNo.class).orElse(YesOrNo.NO)); fieldValues.put("pastExperiencesDescription", asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class).orElse("")); - fieldValues.put("isOutOfCountryEnabled", asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class).orElse(YesOrNo.NO)); fieldValues.put("remoteVideoCall", asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class).orElse(YesOrNo.NO)); fieldValues.put("remoteVideoCallDescription", asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class).orElse("")); fieldValues.put("multimediaEvidence", asylumCase.read(MULTIMEDIA_EVIDENCE, YesOrNo.class).orElse(YesOrNo.NO)); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrder.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrder.java index a9e2b71a0..6d946a276 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrder.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrder.java @@ -23,7 +23,7 @@ private int bundlePositionIndex(DocumentWithMetadata document) { case CASE_SUMMARY: return 1; case REHEARD_HEARING_NOTICE: - return 2; + return 2; case HEARING_NOTICE: return 3; case APPEAL_SUBMISSION: @@ -88,10 +88,146 @@ private int bundlePositionIndex(DocumentWithMetadata document) { return 27; case CLARIFYING_QUESTIONS: return 28; - case NOTICE_OF_ADJOURNED_HEARING: + case FINAL_DECISION_AND_REASONS_DOCUMENT: + log.warn("FINAL_DECISION_AND_REASONS_DOCUMENT tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); return 29; - case NONE: + case ADA_SUITABILITY: return 30; + case APPEAL_FORM: + return 31; + case NOTICE_OF_DECISION_UT_TRANSFER: + return 32; + case REQUEST_CASE_BUILDING: + log.warn("REQUEST_CASE_BUILDING tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 33; + case INTERNAL_ADA_SUITABILITY: + log.warn("INTERNAL_ADA_SUITABILITY tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 34; + case REQUEST_RESPONDENT_REVIEW: + log.warn("REQUEST_RESPONDENT_REVIEW tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 35; + case INTERNAL_DET_DECISION_AND_REASONS_LETTER: + log.warn("INTERNAL_DET_DECISION_AND_REASONS_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 36; + case UPLOAD_THE_APPEAL_RESPONSE: + log.warn("UPLOAD_THE_APPEAL_RESPONSE tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 37; + case HEARING_BUNDLE_READY_LETTER: + log.warn("HEARING BUNDLE READY_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 38; + case INTERNAL_APPEAL_SUBMISSION: + log.warn("INTERNAL_APPEAL_SUBMISSION tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 39; + case INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER: + log.warn("INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 40; + case INTERNAL_END_APPEAL_AUTOMATICALLY: + log.warn("INTERNAL_END_APPEAL_AUTOMATICALLY tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 41; + case INTERNAL_APPEAL_FEE_DUE_LETTER: + log.warn("INTERNAL_APPEAL_FEE_DUE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 42; + case INTERNAL_DET_MARK_AS_PAID_LETTER: + log.warn("INTERNAL_DET_MARK_AS_PAID_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 43; + case INTERNAL_LIST_CASE_LETTER: + log.warn("INTERNAL_LIST_CASE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 44; + case INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER: + log.warn("INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 45; + case INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW: + log.warn("INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 46; + case INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER: + log.warn("INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 47; + case INTERNAL_DET_MARK_AS_ADA_LETTER: + log.warn("INTERNAL_DET_MARK_AS_ADA_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 48; + case INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER: + log.warn("INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 49; + case INTERNAL_APPLY_FOR_FTPA_RESPONDENT: + log.warn("INTERNAL_APPLY_FOR_FTPA_RESPONDENT_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 50; + case INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER: + log.warn("INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 51; + case INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER: + log.warn("INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 52; + case INTERNAL_APPELLANT_FTPA_DECIDED_LETTER: + log.warn("INTERNAL_FTPA_DECIDED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 53; + case INTERNAL_HO_FTPA_DECIDED_LETTER: + log.warn("INTERNAL_HO_FTPA_DECIDED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 54; + case INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER: + log.warn("INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 55; + case INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER: + log.warn("INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 56; + case MAINTAIN_CASE_UNLINK_APPEAL_LETTER: + log.warn("MAINTAIN_CASE_UNLINK_APPEAL_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 57; + case INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER: + log.warn("INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 58; + case INTERNAL_CHANGE_HEARING_CENTRE_LETTER: + log.warn("INTERNAL_CHANGE_HEARING_CENTRE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 59; + case MAINTAIN_CASE_LINK_APPEAL_LETTER: + log.warn("MAINTAIN_CASE_LINK_APPEAL_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 60; + case AMEND_HOME_OFFICE_APPEAL_RESPONSE: + log.warn("AMEND_HOME_OFFICE_APPEAL_RESPONSE tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 61; + case INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER: + log.warn("INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 62; + case INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER: + log.warn("INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 63; + case INTERNAL_EDIT_APPEAL_LETTER: + log.warn("INTERNAL_EDIT_APPEAL_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 64; + case HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER: + log.warn("HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 65; + case LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER: + log.warn("LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 66; + case INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER: + log.warn("INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 67; + case INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER: + log.warn("INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 68; + case INTERNAL_REINSTATE_APPEAL_LETTER: + log.warn("INTERNAL_REINSTATE_APPEAL_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 69; + case INTERNAL_ADJOURN_HEARING_WITHOUT_DATE: + log.warn("INTERNAL_ADJOURN_HEARING_WITHOUT_DATE tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 70; + case UPPER_TRIBUNAL_TRANSFER_ORDER_DOCUMENT: + log.warn("UPPER_TRIBUNAL_TRANSFER_ORDER_DOCUMENT tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 71; + case IAUT_2_FORM: + log.warn("IAUT_2_FORM tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 72; + case UPDATED_DECISION_AND_REASONS_COVER_LETTER: + return 73; + case UPDATED_FINAL_DECISION_AND_REASONS_PDF: + log.warn("UPDATED_FINAL_DECISION_AND_REASONS_PDF tag should not be checked for bundle ordering, document desc: {}", document.getDescription()); + return 74; + case REMITTAL_DECISION: + return 75; + case NOTICE_OF_ADJOURNED_HEARING: + return 76; + case NONE: + return 77; default: throw new IllegalStateException("document has unknown tag: " + document.getTag() + ", description: " + document.getDescription()); } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateService.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateService.java new file mode 100644 index 000000000..6432456ca --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateService.java @@ -0,0 +1,62 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; + +import java.time.LocalTime; +import java.time.ZonedDateTime; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates.HolidayService; + +@Component +public class DueDateService { + + private final HolidayService holidayService; + + public DueDateService(HolidayService holidayService) { + this.holidayService = holidayService; + } + + public ZonedDateTime calculateDelayUntil(ZonedDateTime eventDateTime, int delayDuration) { + if (delayDuration <= 0) { + return eventDateTime; + } + + final ZonedDateTime zonedDateTime = addWorkingDaysForDelayDuration(eventDateTime, delayDuration); + + return resetTo4PmTime(zonedDateTime); + } + + public ZonedDateTime calculateDueDate(ZonedDateTime delayUntil, int workingDaysAllowed) { + final ZonedDateTime zonedDateTime = addWorkingDays(delayUntil, workingDaysAllowed); + + return resetTo4PmTime(zonedDateTime); + } + + private ZonedDateTime addWorkingDays(ZonedDateTime dueDate, int numberOfDays) { + if (numberOfDays == 0) { + return dueDate; + } + + ZonedDateTime newDate = dueDate.plusDays(1); + if (holidayService.isWeekend(newDate) || holidayService.isHoliday(newDate)) { + return addWorkingDays(newDate, numberOfDays); + } else { + return addWorkingDays(newDate, numberOfDays - 1); + } + } + + private ZonedDateTime addWorkingDaysForDelayDuration(ZonedDateTime eventDate, int delayDuration) { + + ZonedDateTime newDate = eventDate.plusDays(delayDuration); + + if (holidayService.isWeekend(newDate) || holidayService.isHoliday(newDate)) { + return addWorkingDaysForDelayDuration(eventDate, delayDuration + 1); + } + + return newDate; + } + + private ZonedDateTime resetTo4PmTime(ZonedDateTime eventDateTime) { + final LocalTime fourPmTime = LocalTime.of(16, 0, 0, 0); + + return ZonedDateTime.of(eventDateTime.toLocalDate(), fourPmTime, eventDateTime.getZone()); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/HearingNoticeFieldMapper.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/HearingNoticeFieldMapper.java index 284a8a601..6a0cdeb5f 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/HearingNoticeFieldMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/HearingNoticeFieldMapper.java @@ -1,9 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; -import com.google.common.base.Strings; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Map; @@ -40,14 +40,10 @@ public Map mapFields(AsylumCase asylumCase) { .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present")); final Optional isSubmitRequirementsAvailable = asylumCase.read(SUBMIT_HEARING_REQUIREMENTS_AVAILABLE); - fieldValues.put("hmcts", "[userImage:hmcts.png]"); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("hearingDate", formatDateForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""))); - fieldValues.put("hearingTime", formatTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""))); + fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("hearingTime", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT)); if (listedHearingCentre.equals(HearingCentre.REMOTE_HEARING)) { fieldValues.put("remoteHearing", "Remote hearing"); @@ -81,23 +77,4 @@ public Map mapFields(AsylumCase asylumCase) { return fieldValues; } - public String formatDateForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDateTime.parse(date).format(DOCUMENT_DATE_FORMAT); - } - - return ""; - } - - public String formatTimeForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDateTime.parse(date).format(DOCUMENT_TIME_FORMAT); - } - - return ""; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestrator.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestrator.java index 6fba48def..ef5c242b8 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestrator.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestrator.java @@ -1,15 +1,21 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; +import static java.util.Collections.emptyList; import static java.util.Objects.requireNonNull; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import java.util.Collections; +import java.util.List; import java.util.Optional; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ReheardHearingDocuments; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; @Service @@ -18,15 +24,27 @@ public class SendDecisionAndReasonsOrchestrator { private final DocumentHandler documentHandler; private final SendDecisionAndReasonsRenameFileService sendDecisionAndReasonsPdfService; private final SendDecisionAndReasonsCoverLetterService sendDecisionAndReasonsCoverLetterService; + private final FeatureToggler featureToggler; + private final DocumentReceiver documentReceiver; + private final DocumentsAppender documentsAppender; + private final Appender reheardHearingAppender; public SendDecisionAndReasonsOrchestrator( - DocumentHandler documentHandler, - SendDecisionAndReasonsRenameFileService sendDecisionAndReasonsPdfService, - SendDecisionAndReasonsCoverLetterService sendDecisionAndReasonsCoverLetterService + DocumentHandler documentHandler, + SendDecisionAndReasonsRenameFileService sendDecisionAndReasonsPdfService, + SendDecisionAndReasonsCoverLetterService sendDecisionAndReasonsCoverLetterService, + FeatureToggler featureToggler, + DocumentReceiver documentReceiver, + DocumentsAppender documentsAppender, + Appender reheardHearingAppender ) { this.documentHandler = documentHandler; this.sendDecisionAndReasonsPdfService = sendDecisionAndReasonsPdfService; this.sendDecisionAndReasonsCoverLetterService = sendDecisionAndReasonsCoverLetterService; + this.featureToggler = featureToggler; + this.documentReceiver = documentReceiver; + this.documentsAppender = documentsAppender; + this.reheardHearingAppender = reheardHearingAppender; } public void sendDecisionAndReasons(CaseDetails caseDetails) { @@ -47,20 +65,23 @@ public void sendDecisionAndReasons(CaseDetails caseDetails) { if ((asylumCase.read(AsylumCaseDefinition.IS_REHEARD_APPEAL_ENABLED, YesOrNo.class).equals(Optional.of(YesOrNo.YES)) && (asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YesOrNo.YES)).orElse(false)))) { - documentHandler.addWithMetadata( - asylumCase, - coverLetter, - REHEARD_DECISION_REASONS_DOCUMENTS, - DocumentTag.DECISION_AND_REASONS_COVER_LETTER - ); - - documentHandler.addWithMetadata( - asylumCase, - finalDecisionAndReasonsPdf, - REHEARD_DECISION_REASONS_DOCUMENTS, - DocumentTag.FINAL_DECISION_AND_REASONS_PDF - ); - + if (featureToggler.getValue("dlrm-remitted-feature-flag", false)) { + appendReheardHearingDocuments(asylumCase, coverLetter, finalDecisionAndReasonsPdf); + } else { + documentHandler.addWithMetadata( + asylumCase, + coverLetter, + REHEARD_DECISION_REASONS_DOCUMENTS, + DocumentTag.DECISION_AND_REASONS_COVER_LETTER + ); + + documentHandler.addWithMetadata( + asylumCase, + finalDecisionAndReasonsPdf, + REHEARD_DECISION_REASONS_DOCUMENTS, + DocumentTag.FINAL_DECISION_AND_REASONS_PDF + ); + } } else { documentHandler.addWithMetadata( @@ -90,4 +111,34 @@ public void sendDecisionAndReasons(CaseDetails caseDetails) { throw e; } } + + private void appendReheardHearingDocuments(AsylumCase asylumCase, Document coverLetter, Document finalDecisionAndReasonsPdf) { + DocumentWithMetadata coverLetterWithMetadata = + documentReceiver.receive( + coverLetter, + "", + DocumentTag.DECISION_AND_REASONS_COVER_LETTER + ); + + DocumentWithMetadata decisionWithMetadata = + documentReceiver.receive( + finalDecisionAndReasonsPdf, + "", + DocumentTag.FINAL_DECISION_AND_REASONS_PDF + ); + + List> allDocuments = + documentsAppender.append( + Collections.emptyList(), + List.of(decisionWithMetadata, coverLetterWithMetadata) + ); + + ReheardHearingDocuments newReheardDocuments = new ReheardHearingDocuments(allDocuments); + + Optional>> maybeExistingReheardDocuments = + asylumCase.read(REHEARD_DECISION_REASONS_COLLECTION); + List> allReheardDocuments = + reheardHearingAppender.append(newReheardDocuments, maybeExistingReheardDocuments.orElse(emptyList())); + asylumCase.write(REHEARD_DECISION_REASONS_COLLECTION, allReheardDocuments); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileService.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileService.java index 373c6f85f..823afae77 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileService.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileService.java @@ -9,6 +9,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.StreamUtils; 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.DocumentWithMetadata; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients.DocumentDownloadClient; @@ -21,15 +23,18 @@ public class SendDecisionAndReasonsRenameFileService { private final DocumentDownloadClient documentDownloadClient; private final DocumentUploader documentUploader; private final String decisionAndReasonsFinalPdfFilename; + private final DocumentReceiver documentReceiver; public SendDecisionAndReasonsRenameFileService( DocumentDownloadClient documentDownloadClient, DocumentUploader documentUploader, + DocumentReceiver documentReceiver, @Value("${decisionAndReasonsFinalPdf.fileName}") String decisionAndReasonsFinalPdfFilename ) { this.documentDownloadClient = documentDownloadClient; this.documentUploader = documentUploader; this.decisionAndReasonsFinalPdfFilename = decisionAndReasonsFinalPdfFilename; + this.documentReceiver = documentReceiver; } public Document updateDecisionAndReasonsFileName(CaseDetails caseDetails) { @@ -46,10 +51,14 @@ private Document createFinalPdf(AsylumCase asylumCase) { Document finalDecisionAndReasonsDoc = asylumCase.read(FINAL_DECISION_AND_REASONS_DOCUMENT, Document.class) .orElseThrow( () -> new IllegalStateException("finalDecisionAndReasonsDocument must be present")); - + DocumentWithMetadata documentWithMetadata = + documentReceiver.receive( + finalDecisionAndReasonsDoc, + "", + DocumentTag.FINAL_DECISION_AND_REASONS_DOCUMENT + ); Resource finalDecisionAndReasonsPdf = - documentDownloadClient.download(finalDecisionAndReasonsDoc.getDocumentBinaryUrl()); - + documentDownloadClient.download(documentWithMetadata.getDocument().getDocumentBinaryUrl()); ByteArrayResource byteArrayResource = getByteArrayResource( finalDecisionAndReasonsPdf, getDecisionAndReasonsFilename(asylumCase)); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/CountryHolidayDates.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/CountryHolidayDates.java new file mode 100644 index 000000000..239267c96 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/CountryHolidayDates.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +@ToString +public class CountryHolidayDates { + private List events; + + private CountryHolidayDates() { + } + + public CountryHolidayDates(List events) { + this.events = events; + } + + public List getEvents() { + return events; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/GovUkHolidayDatesClient.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/GovUkHolidayDatesClient.java new file mode 100644 index 000000000..ee1253a55 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/GovUkHolidayDatesClient.java @@ -0,0 +1,14 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; + +@FeignClient( + name = "GovUkHolidayDatesClient", + url = "${govUkHolidays.url}" +) +public interface GovUkHolidayDatesClient { + @GetMapping(value = "/bank-holidays.json", produces = MediaType.APPLICATION_JSON_VALUE) + UkHolidayDates getHolidayDates(); +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayDate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayDate.java new file mode 100644 index 000000000..f5130fd3c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayDate.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.time.LocalDate; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@EqualsAndHashCode +@ToString +public class HolidayDate { + private LocalDate date; + + private HolidayDate() { + } + + public HolidayDate(LocalDate date) { + this.date = date; + } + + public LocalDate getDate() { + return date; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoader.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoader.java new file mode 100644 index 000000000..13d27d433 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoader.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import java.time.LocalDate; +import java.util.List; +import java.util.stream.Collectors; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Component +public class HolidayLoader { + private final GovUkHolidayDatesClient govUkHolidayDatesClient; + + public HolidayLoader(GovUkHolidayDatesClient govUkHolidayDatesClient) { + this.govUkHolidayDatesClient = govUkHolidayDatesClient; + } + + @Bean + public List loadHolidays() { + UkHolidayDates holidayDates = govUkHolidayDatesClient.getHolidayDates(); + return holidayDates.getEnglandAndWales().getEvents().stream() + .map(HolidayDate::getDate) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayService.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayService.java new file mode 100644 index 000000000..fb774d04e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayService.java @@ -0,0 +1,32 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.List; +import org.springframework.stereotype.Component; + +@Component +public class HolidayService { + private final List holidays; + + public HolidayService(List holidays) { + this.holidays = holidays; + } + + public boolean isHoliday(ZonedDateTime zonedDateTime) { + return holidays.contains(zonedDateTime.toLocalDate()); + } + + public boolean isHoliday(LocalDate localDate) { + return holidays.contains(localDate); + } + + public boolean isWeekend(ZonedDateTime date) { + return date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY; + } + + public boolean isWeekend(LocalDate localDate) { + return localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/UkHolidayDates.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/UkHolidayDates.java new file mode 100644 index 000000000..dcea9f2c6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/UkHolidayDates.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.ToString; + +@JsonIgnoreProperties(ignoreUnknown = true) +@ToString +public class UkHolidayDates { + @JsonProperty("england-and-wales") + private CountryHolidayDates englandAndWales; + + private UkHolidayDates() { + } + + public UkHolidayDates(CountryHolidayDates englandAndWales) { + this.englandAndWales = englandAndWales; + } + + public CountryHolidayDates getEnglandAndWales() { + return englandAndWales; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaHearingNoticeUpdatedDetailsTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaHearingNoticeUpdatedDetailsTemplate.java new file mode 100644 index 000000000..4f9ccf107 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaHearingNoticeUpdatedDetailsTemplate.java @@ -0,0 +1,38 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +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.service.StringProvider; + +@Component +public class AdaHearingNoticeUpdatedDetailsTemplate implements DocumentTemplate { + + private final String templateName; + private final StringProvider stringProvider; + private final HearingNoticeUpdatedTemplateProvider hearingNoticeUpdatedTemplateProvider; + + public AdaHearingNoticeUpdatedDetailsTemplate( + @Value("${adaHearingNoticeUpdatedDetailsDocument.templateName}") String templateName, + StringProvider stringProvider, + HearingNoticeUpdatedTemplateProvider hearingNoticeUpdatedTemplateProvider + ) { + this.templateName = templateName; + this.stringProvider = stringProvider; + this.hearingNoticeUpdatedTemplateProvider = hearingNoticeUpdatedTemplateProvider; + } + + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails, + CaseDetails caseDetailsBefore + ) { + return hearingNoticeUpdatedTemplateProvider.mapFieldValues(caseDetails, caseDetailsBefore); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplate.java new file mode 100644 index 000000000..75af611c7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplate.java @@ -0,0 +1,66 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +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.AdaSuitabilityReviewDecision; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; + +@Component +public class AdaSuitabilityTemplate implements DocumentTemplate { + + private final String templateName; + + public AdaSuitabilityTemplate( + @Value("${adaSuitabilityDocument.templateName}") String templateName + ) { + this.templateName = templateName; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("hmcts", "[userImage:decisionsandreasons.png]"); + fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + + final String givenName = asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse(""); + final String familyName = asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse(""); + final String fullName = givenName.concat(" " + familyName); + fieldValues.put("appellantFullName", fullName); + + final AdaSuitabilityReviewDecision adaSuitabilityReviewDecision = + asylumCase.read(AsylumCaseDefinition.SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class) + .orElseThrow(() -> new RequiredFieldMissingException("ADA suitability review decision unavailable.")); + fieldValues.put("suitability", adaSuitabilityReviewDecision); + + final String adaSuitabilityReason = asylumCase.read(SUITABILITY_REVIEW_REASON, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("ADA suitability review decision reason unavailable.")); + fieldValues.put("suitabilityReason", adaSuitabilityReason); + + final String judgeName = asylumCase.read(SUITABILITY_REVIEW_JUDGE, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("ADA suitability review decision judge details unavailable.")); + fieldValues.put("judgeName", judgeName); + + fieldValues.put("decisionDate", LocalDate.now().toString()); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealReasonsTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealReasonsTemplate.java index 822c3832f..467bb86bf 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealReasonsTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealReasonsTemplate.java @@ -1,12 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; import static java.util.Collections.emptyList; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REASONS_FOR_APPEAL_DECISION; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REASONS_FOR_APPEAL_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisationWithoutUserImage; import java.util.HashMap; import java.util.List; @@ -49,10 +46,7 @@ public Map mapFieldValues( final Map fieldValues = new HashMap<>(); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisationWithoutUserImage(asylumCase)); fieldValues.put("appealReasons", asylumCase.read(REASONS_FOR_APPEAL_DECISION, String.class).orElse("")); fieldValues.put("customerServicesTelephone", customerServicesProvider.getCustomerServicesTelephone()); fieldValues.put("customerServicesEmail", customerServicesProvider.getCustomerServicesEmail()); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplate.java index 663b942a8..5f3bdfd64 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplate.java @@ -2,25 +2,25 @@ import static java.util.stream.Collectors.joining; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateForRendering; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; -import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; + import lombok.NonNull; +import com.google.common.collect.ImmutableMap; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.OutOfCountryDecisionType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ContactPreference; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HasOtherAppeals; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.AddressUk; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.*; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; @Component @@ -51,23 +51,32 @@ public Map mapFieldValues( final Map fieldValues = new HashMap<>(); - fieldValues.put("hmcts", "[userImage:hmcts.png]"); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("CREATED_DATE", caseDetails.getCreatedDate().format(DOCUMENT_DATE_FORMAT)); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appealSubmissionDate", formatDateForRendering(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class).orElse(""))); + fieldValues.put("appealSubmissionDate", formatDateForRendering(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); fieldValues.put("legalRepresentativeEmailAddress", asylumCase.read(LEGAL_REPRESENTATIVE_EMAIL_ADDRESS, String.class).orElse("")); fieldValues.put("legalRepName", formatLegalRepName( asylumCase.read(LEGAL_REP_NAME, String.class).orElse(""), asylumCase.read(LEGAL_REP_FAMILY_NAME, String.class).orElse(""))); fieldValues.put("legalRepCompany", asylumCase.read(LEGAL_REP_COMPANY, String.class).orElse("")); fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("homeOfficeDecisionDate", formatDateForRendering(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class).orElse(""))); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("appellantDateOfBirth", formatDateForRendering(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class).orElse(""))); + fieldValues.put("appellantDateOfBirth", formatDateForRendering(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); fieldValues.put("appellantTitle", asylumCase.read(APPELLANT_TITLE, String.class).orElse("")); + Optional homeOfficeDecisionDate = asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class); + fieldValues.put("homeOfficeDecisionDate", homeOfficeDecisionDate.isPresent() + ? formatDateForRendering(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT) : null); + + Optional decisionLetterReceivedDate = asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class); + fieldValues.put("decisionLetterReceivedDate", decisionLetterReceivedDate.isPresent() + ? formatDateForRendering(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT) : null); + + Optional isDetained = Optional.of(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class).orElse(YesOrNo.NO)); + if (isDetained.equals(Optional.of(YesOrNo.YES))) { + populateDetainedFields(asylumCase, fieldValues); + } + fieldValues.put("appellantInDetention", isDetained); + Optional contactPreference = asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class); if (contactPreference.isPresent() && contactPreference.get().toString().equals(ContactPreference.WANTS_EMAIL.toString())) { @@ -81,7 +90,6 @@ public Map mapFieldValues( fieldValues.put("appealOutOfCountry", asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class).orElse(YesOrNo.NO)); if (asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class).orElse(YesOrNo.NO) == YesOrNo.YES) { - fieldValues.put("decisionLetterReceivedDate", formatDateForRendering(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class).orElse(""))); Optional maybeOutOfCountryDecisionType = asylumCase.read(OUT_OF_COUNTRY_DECISION_TYPE, OutOfCountryDecisionType.class); @@ -93,11 +101,11 @@ public Map mapFieldValues( if (decisionType == OutOfCountryDecisionType.REFUSAL_OF_HUMAN_RIGHTS || decisionType == OutOfCountryDecisionType.REFUSE_PERMIT) { fieldValues.put("gwfReferenceNumber", asylumCase.read(GWF_REFERENCE_NUMBER, String.class).orElse(null)); - fieldValues.put("dateEntryClearanceDecision", formatDateForRendering(asylumCase.read(DATE_ENTRY_CLEARANCE_DECISION, String.class).orElse(null))); + fieldValues.put("dateEntryClearanceDecision", formatDateForRendering(asylumCase.read(DATE_ENTRY_CLEARANCE_DECISION, String.class).orElse(null), DOCUMENT_DATE_FORMAT)); fieldValues.put("decisionLetterReceived", YesOrNo.NO); } else if (decisionType == OutOfCountryDecisionType.REFUSAL_OF_PROTECTION) { - fieldValues.put("dateClientLeaveUk", formatDateForRendering(asylumCase.read(DATE_CLIENT_LEAVE_UK, String.class).orElse(null))); + fieldValues.put("dateClientLeaveUk", formatDateForRendering(asylumCase.read(DATE_CLIENT_LEAVE_UK, String.class).orElse(null), DOCUMENT_DATE_FORMAT)); fieldValues.put("didClientLeaveUk", YesOrNo.YES); } } @@ -123,42 +131,31 @@ public Map mapFieldValues( } } - Optional optionalAppealType = asylumCase.read(APPEAL_TYPE); + Optional optionalAppealType = asylumCase.read(APPEAL_TYPE, AsylumAppealType.class); if (optionalAppealType.isPresent()) { - - String appealType = optionalAppealType.get(); - + String appealType = optionalAppealType.get().getValue(); fieldValues.put( "appealType", stringProvider.get("appealType", appealType).orElse("") ); } + YesOrNo removalOrderOption = asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class).orElse(YesOrNo.NO); + if (removalOrderOption.equals(YesOrNo.YES)) { + String removalOrderDate = asylumCase.read(REMOVAL_ORDER_DATE, String.class).orElse(""); + if (removalOrderDate.isBlank()) { + removalOrderOption = YesOrNo.NO; + } else { + fieldValues.put("removalOrderDate", removalOrderDate); + } + } + fieldValues.put("removalOrderOption", removalOrderOption); + fieldValues.put("newMatters", asylumCase.read(NEW_MATTERS, String.class).orElse("")); if (asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class).orElse(YesOrNo.NO) == YesOrNo.YES) { - - Optional optionalAppellantAddress = asylumCase.read(APPELLANT_ADDRESS); - - if (optionalAppellantAddress.isPresent()) { - - AddressUk appellantAddress = optionalAppellantAddress.get(); - - fieldValues.put( - "appellantAddress", - ImmutableMap - .builder() - .put("appellantAddressLine1", appellantAddress.getAddressLine1().orElse("")) - .put("appellantAddressLine2", appellantAddress.getAddressLine2().orElse("")) - .put("appellantAddressLine3", appellantAddress.getAddressLine3().orElse("")) - .put("appellantAddressPostTown", appellantAddress.getPostTown().orElse("")) - .put("appellantAddressCounty", appellantAddress.getCounty().orElse("")) - .put("appellantAddressPostCode", appellantAddress.getPostCode().orElse("")) - .put("appellantAddressCountry", appellantAddress.getCountry().orElse("")) - .build() - ); - } + populateAddressFields(asylumCase, fieldValues); } Optional>>> appellantNationalities = asylumCase @@ -206,6 +203,13 @@ public Map mapFieldValues( .collect(joining(", ")) ); + Optional hasOtherAppeals = asylumCase.read(HAS_OTHER_APPEALS, HasOtherAppeals.class); + if (hasOtherAppeals.isPresent() && hasOtherAppeals.get().toString().equals(HasOtherAppeals.YES.toString())) { + fieldValues.put("hasOtherAppeals", YesOrNo.YES); + } else { + fieldValues.put("hasOtherAppeals", YesOrNo.NO); + } + fieldValues.put("applicationOutOfTimeExplanation", asylumCase.read(APPLICATION_OUT_OF_TIME_EXPLANATION, String.class).orElse("")); fieldValues.put("submissionOutOfTime", asylumCase.read(SUBMISSION_OUT_OF_TIME, YesOrNo.class).orElse(YesOrNo.NO)); fieldValues.put( @@ -215,17 +219,69 @@ public Map mapFieldValues( .orElse("") ); + fieldValues.put("isAdmin", asylumCase.read(IS_ADMIN, YesOrNo.class).orElse(YesOrNo.NO)); + return fieldValues; } - private String formatDateForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDate.parse(date).format(DOCUMENT_DATE_FORMAT); + private void populateDetainedFields(AsylumCase asylumCase, Map fieldValues) { + StringBuilder sb = new StringBuilder("Detained"); + YesOrNo isAcceleratedDetainedAppeal = asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class).orElse(YesOrNo.NO); + if (isAcceleratedDetainedAppeal.equals(YesOrNo.YES)) { + sb.append(" - Accelerated"); + } + fieldValues.put("isAcceleratedDetainedAppeal", isAcceleratedDetainedAppeal); + fieldValues.put("detentionStatus", sb.toString()); + sb.setLength(0); + + String detentionFacility = asylumCase.read(DETENTION_FACILITY, String.class).orElse(""); + String detentionFacilityName = ""; + switch (detentionFacility) { + case "immigrationRemovalCentre": + detentionFacility = "Immigration Removal Centre"; + detentionFacilityName = asylumCase.read(IRC_NAME, String.class).orElse(""); + break; + case "prison": + detentionFacility = "Prison"; + detentionFacilityName = asylumCase.read(PRISON_NAME, String.class).orElse(""); + + YesOrNo nomsAvailable = YesOrNo.NO; + String nomsNumber = formatComplexString(asylumCase + .get("prisonNOMSNumber") + .toString()); + if (!nomsNumber.isBlank()) { + nomsAvailable = YesOrNo.YES; + fieldValues.put("nomsNumber", nomsNumber); + } + fieldValues.put("nomsAvailable", nomsAvailable); + + YesOrNo releaseDateProvided = YesOrNo.NO; + if (asylumCase.containsKey("dateCustodialSentence")) { + String prisonerReleaseDate = formatComplexString(asylumCase + .get("dateCustodialSentence") + .toString()); + if (!prisonerReleaseDate.isBlank()) { + releaseDateProvided = YesOrNo.YES; + fieldValues.put("releaseDate", prisonerReleaseDate); + } + } + fieldValues.put("releaseDateProvided", releaseDateProvided); + break; + case "other": + detentionFacility = "Other"; + detentionFacilityName = formatComplexString(asylumCase.get("otherDetentionFacilityName").toString()); + break; + default: + // Required for sonar scan. Can never reach here. } + fieldValues.put("detentionFacility", detentionFacility); + fieldValues.put("detentionFacilityName", detentionFacilityName); - return ""; + BailApplicationStatus hasBailApplication = asylumCase.read(HAS_PENDING_BAIL_APPLICATIONS, BailApplicationStatus.class).orElse(BailApplicationStatus.NO); + if (hasBailApplication.equals(BailApplicationStatus.YES)) { + fieldValues.put("bailApplicationNumber", asylumCase.read(BAIL_APPLICATION_NUMBER, String.class)); + } + fieldValues.put("hasPendingBailApplication", hasBailApplication); } private String formatLegalRepName(@NonNull String firstName, @NonNull String lastName) { @@ -235,4 +291,33 @@ private String formatLegalRepName(@NonNull String firstName, @NonNull String las return firstName; } + + private void populateAddressFields(AsylumCase asylumCase, Map fieldValues) { + Optional optionalAppellantAddress = asylumCase.read(APPELLANT_ADDRESS); + + if (optionalAppellantAddress.isPresent()) { + + AddressUk appellantAddress = optionalAppellantAddress.get(); + + fieldValues.put( + "appellantAddress", + ImmutableMap + .builder() + .put("appellantAddressLine1", appellantAddress.getAddressLine1().orElse("")) + .put("appellantAddressLine2", appellantAddress.getAddressLine2().orElse("")) + .put("appellantAddressLine3", appellantAddress.getAddressLine3().orElse("")) + .put("appellantAddressPostTown", appellantAddress.getPostTown().orElse("")) + .put("appellantAddressCounty", appellantAddress.getCounty().orElse("")) + .put("appellantAddressPostCode", appellantAddress.getPostCode().orElse("")) + .put("appellantAddressCountry", appellantAddress.getCountry().orElse("")) + .build() + ); + } + } + + protected static String formatComplexString(String data) { + data = data.replaceAll("[\\[\\](){}]", ""); + return data.substring(data.lastIndexOf("=") + 1); + } + } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppellantDecisionAndReasonsCoverLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppellantDecisionAndReasonsCoverLetterTemplate.java index 3f01e1f93..363c9813a 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppellantDecisionAndReasonsCoverLetterTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppellantDecisionAndReasonsCoverLetterTemplate.java @@ -1,11 +1,8 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealDecision.ALLOWED; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_DECISION_ALLOWED; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisationWithoutUserImage; import java.util.HashMap; import java.util.Map; @@ -41,10 +38,7 @@ public Map mapFieldValues( final AsylumCase asylumCase = caseDetails.getCaseData(); final Map fieldValues = new HashMap<>(); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisationWithoutUserImage(asylumCase)); fieldValues.put("allowed", asylumCase.read(IS_DECISION_ALLOWED, AppealDecision.class) .map(appealDecision -> appealDecision.equals(ALLOWED) ? "Yes" : "No") .orElseThrow(() -> new IllegalStateException("appeal decision must be present"))); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/ClarifyingQuestionsAnswersTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/ClarifyingQuestionsAnswersTemplate.java index 636ce4156..fbb2a90af 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/ClarifyingQuestionsAnswersTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/ClarifyingQuestionsAnswersTemplate.java @@ -1,14 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; import static java.util.Collections.emptyList; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CLARIFYING_QUESTIONS_ANSWERS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisationWithoutUserImage; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.HashMap; @@ -17,14 +12,12 @@ import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; import org.apache.commons.lang3.StringUtils; 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.ClarifyingQuestion; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ClarifyingQuestionAnswer; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; @@ -65,10 +58,7 @@ public Map mapFieldValues( .findFirst(asylumCase, DirectionTag.REQUEST_CLARIFYING_QUESTIONS) .orElseThrow(() -> new IllegalStateException("direction '" + DirectionTag.REQUEST_CLARIFYING_QUESTIONS + "' is not present")); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisationWithoutUserImage(asylumCase)); fieldValues.put("customerServicesTelephone", customerServicesProvider.getCustomerServicesTelephone()); fieldValues.put("customerServicesEmail", customerServicesProvider.getCustomerServicesEmail()); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsCoverLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsCoverLetterTemplate.java index 2b95fe71c..eb2866815 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsCoverLetterTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsCoverLetterTemplate.java @@ -2,6 +2,7 @@ import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealDecision.ALLOWED; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; import java.util.HashMap; import java.util.Map; @@ -36,13 +37,8 @@ public Map mapFieldValues( final AsylumCase asylumCase = caseDetails.getCaseData(); final Map fieldValues = new HashMap<>(); - - fieldValues.put("hmcts", "[userImage:hmcts.png]"); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); fieldValues.put("allowed", asylumCase.read(IS_DECISION_ALLOWED, AppealDecision.class) .map(appealDecision -> appealDecision.equals(ALLOWED) ? "Yes" : "No") .orElseThrow(() -> new IllegalStateException("appeal decision must be present"))); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsTemplate.java index dd0ed84a3..16dbdd9fb 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/DecisionAndReasonsTemplate.java @@ -1,10 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; -import com.google.common.base.Strings; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Map; @@ -57,8 +56,8 @@ public Map mapFieldValues( ); fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("hearingDate", formatDateForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""))); - fieldValues.put("hearingTime", formatTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""))); + fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("hearingTime", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT)); fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); fieldValues.put("anonymityOrder", asylumCase.read(ANONYMITY_ORDER, YesOrNo.class) @@ -86,23 +85,4 @@ public Map mapFieldValues( return fieldValues; } - private String formatDateForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDateTime.parse(date).format(DOCUMENT_DATE_FORMAT); - } - - return ""; - } - - private String formatTimeForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDateTime.parse(date).format(DOCUMENT_TIME_FORMAT); - } - - return ""; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/EndAppealAutomaticallyTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/EndAppealAutomaticallyTemplate.java index a1f46849d..5a6aaa1be 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/EndAppealAutomaticallyTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/EndAppealAutomaticallyTemplate.java @@ -1,14 +1,10 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.END_APPEAL_DATE; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REP_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateForRendering; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; -import com.google.common.base.Strings; -import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Map; @@ -39,24 +35,10 @@ public Map mapFieldValues( final AsylumCase asylumCase = caseDetails.getCaseData(); final Map fieldValues = new HashMap<>(); - - fieldValues.put("hmcts", "[userImage:hmcts.png]"); - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("endAppealDate", formatDateForRendering(asylumCase.read(END_APPEAL_DATE, String.class).orElse(""))); + fieldValues.put("endAppealDate", formatDateForRendering(asylumCase.read(END_APPEAL_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); return fieldValues; } - private String formatDateForRendering( - String date - ) { - if (!Strings.isNullOrEmpty(date)) { - return LocalDate.parse(date).format(DOCUMENT_DATE_FORMAT); - } - return ""; - } - } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingNoticeUpdatedTemplateProvider.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingNoticeUpdatedTemplateProvider.java index 920bb8740..0971c3e9e 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingNoticeUpdatedTemplateProvider.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingNoticeUpdatedTemplateProvider.java @@ -1,7 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; +import java.time.format.DateTimeFormatter; import java.util.Map; import java.util.Optional; import org.springframework.stereotype.Component; @@ -14,7 +16,7 @@ @Component public class HearingNoticeUpdatedTemplateProvider { - + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); private final StringProvider stringProvider; private final CustomerServicesProvider customerServicesProvider; @@ -53,7 +55,7 @@ public Map mapFieldValues( .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); fieldValues.put("oldHearingCentre", hearingCentreNameBefore); - fieldValues.put("oldHearingDate", fieldMapper.formatDateForRendering(asylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class).orElse(""))); + fieldValues.put("oldHearingDate", formatDateTimeForRendering(asylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); if (asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class).equals(Optional.of(HearingCentre.REMOTE_HEARING))) { diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplate.java new file mode 100644 index 000000000..2418c9808 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplate.java @@ -0,0 +1,62 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalAdaRequestBuildCaseTemplate implements DocumentTemplate { + + private final int hearingSupportResponseDueInWorkingDays; + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + + + public InternalAdaRequestBuildCaseTemplate( + @Value("${internalAdaRequestBuildCaseDocument.hearingSupportResponseDueInWorkingDays}") int hearingSupportResponseDueInWorkingDays, + @Value("${internalAdaRequestBuildCaseDocument.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService + ) { + this.hearingSupportResponseDueInWorkingDays = hearingSupportResponseDueInWorkingDays; + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put("responseDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)))); + + fieldValues.put("hearingSupportRequirementsDueDate", formatDateForNotificationAttachmentDocument(dueDateService + .calculateDueDate(ZonedDateTime.now(), hearingSupportResponseDueInWorkingDays) + .toLocalDate())); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestBuildCaseTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestBuildCaseTemplate.java new file mode 100644 index 000000000..314ce9e8b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestBuildCaseTemplate.java @@ -0,0 +1,53 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getDirectionDueDate; +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.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedRequestBuildCaseTemplate implements DocumentTemplate { + + private final String nonAdaTemplateName; + private final CustomerServicesProvider customerServicesProvider; + + + public InternalDetainedRequestBuildCaseTemplate( + @Value("${internalDetainedRequestBuildCaseDocument.templateName}") String nonAdaTemplateName, + CustomerServicesProvider customerServicesProvider + ) { + this.nonAdaTemplateName = nonAdaTemplateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + + return nonAdaTemplateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put("responseDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)))); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplate.java new file mode 100644 index 000000000..42f909b80 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplate.java @@ -0,0 +1,56 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +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.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@Component +public class InternalDetainedRequestHearingRequirementsTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalDetainedRequestHearingRequirementsTemplate( + @Value("${internalDetainedRequestHearingRequirements.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + String hearingRequirementsSubmissionDeadline = getHearingRequirementsSubmissionDeadline(asylumCase); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("hearingReqSubmissionDeadline", hearingRequirementsSubmissionDeadline); + fieldValues.put("directionDueDate", hearingRequirementsSubmissionDeadline); + + return fieldValues; + } + + private String getHearingRequirementsSubmissionDeadline(AsylumCase asylumCase) { + LocalDate directionDueDate = LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_RESPONSE_REVIEW)); + return formatDateForNotificationAttachmentDocument(directionDueDate.plusDays(5)); + } + +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplate.java new file mode 100644 index 000000000..76c06a4e5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplate.java @@ -0,0 +1,51 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getDirectionDueDate; +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.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedRequestRespondentEvidenceTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalDetainedRequestRespondentEvidenceTemplate( + @Value("${internalDetainedRequestRespondentEvidence.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("requestRespondentEvidenceDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.RESPONDENT_EVIDENCE)))); + + return fieldValues; + } + +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate.java new file mode 100644 index 000000000..cd85dd9a7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate.java @@ -0,0 +1,34 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +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.helper.UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper; + +@Component +public class UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper; + + public UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate( + @Value("${aipDecisionAndReasonsCoverLetter.templateName}") String templateName, + UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper + ) { + this.templateName = templateName; + this.templateHelper = templateHelper; + } + + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + return templateHelper.getCommonMapFieldValues(caseDetails); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplate.java new file mode 100644 index 000000000..b665bcd55 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplate.java @@ -0,0 +1,40 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REP_REFERENCE_NUMBER; + +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.helper.UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper; + +@Component +public class UpdatedTribunalDecisionAndReasonsCoverLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper; + + public UpdatedTribunalDecisionAndReasonsCoverLetterTemplate( + @Value("${decisionAndReasonsCoverLetter.templateName}") String templateName, + UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper + ) { + this.templateName = templateName; + this.templateHelper = templateHelper; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues(CaseDetails caseDetails) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = templateHelper.getCommonMapFieldValues(caseDetails); + + fieldValues.put("legalRepReferenceNumber", asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class) + .orElse("")); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplate.java index ee410658b..8bd9adc80 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplate.java @@ -35,4 +35,5 @@ public Map mapFieldValues(CaseDetails caseDetails) { return super.mapFieldValues(caseDetails); } + } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingTemplate.java index 55c273887..0e603cd37 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingTemplate.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingTemplate.java @@ -21,6 +21,7 @@ import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Map; + import java.util.Optional; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ApplicantDetainedLocation; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.BailCase; @@ -35,6 +36,7 @@ public class BailNoticeOfHearingTemplate { private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); private static final DateTimeFormatter DOCUMENT_TIME_FORMAT = DateTimeFormatter.ofPattern("HHmm"); private static final String REMOTE_HEARING_LOCATION = "Cloud Video Platform (CVP)"; + private final CustomerServicesProvider customerServicesProvider; private final StringProvider stringProvider; @@ -121,11 +123,13 @@ private String getListinglocationAddress(BailCase bailCase) { private String getApplicantDetainedLocation(BailCase bailCase) { String location = bailCase.read(APPLICANT_DETAINED_LOC, String.class).orElse(""); + String detentionLocation = location.equals(ApplicantDetainedLocation.PRISON.getCode()) ? bailCase.read(PRISON_NAME, String.class).orElse("") : location.equals(ApplicantDetainedLocation.IMIGRATION_REMOVAL_CENTER.getCode()) ? bailCase.read(IRC_NAME, String.class).orElse("") : ""; return detentionLocation; + } private boolean isNullOrEmptyString(String str) { diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/EndAppealTemplateHelper.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/EndAppealTemplateHelper.java index b2f61e5d2..7c1003b59 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/EndAppealTemplateHelper.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/EndAppealTemplateHelper.java @@ -1,12 +1,9 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.helper; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.END_APPEAL_DATE; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.END_APPEAL_OUTCOME; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.END_APPEAL_OUTCOME_REASON; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; import com.google.common.base.Strings; import java.time.LocalDate; @@ -37,13 +34,7 @@ public Map getCommonMapFieldValues( final Map fieldValues = new HashMap<>(); - fieldValues.put("hmcts", "[userImage:hmcts.png]"); - - fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); - fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); - fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); - fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); - + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); fieldValues.put("outcomeOfAppeal", asylumCase.read(END_APPEAL_OUTCOME, String.class).orElse("")); fieldValues.put("reasonsOfOutcome", asylumCase.read(END_APPEAL_OUTCOME_REASON, String.class).orElse("")); fieldValues.put("endAppealDate", formatDateForRendering(asylumCase.read(END_APPEAL_DATE, String.class).orElse(""))); diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper.java new file mode 100644 index 000000000..e06d0d9d9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper.java @@ -0,0 +1,44 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.helper; + +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.infrastructure.CustomerServicesProvider; + +import java.util.HashMap; +import java.util.Map; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + + +@Component +public class UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper { + + private final CustomerServicesProvider customerServicesProvider; + + public UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper(CustomerServicesProvider customerServicesProvider) { + this.customerServicesProvider = customerServicesProvider; + } + + public Map getCommonMapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("hmcts", "[userImage:hmcts.png]"); + fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")); + fieldValues.put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")); + fieldValues.put("appellantFamilyName", asylumCase.read(APPELLANT_FAMILY_NAME, String.class).orElse("")); + fieldValues.put("allowed", asylumCase.read(UPDATED_APPEAL_DECISION, String.class) + .orElseThrow(() -> new IllegalStateException("update appeal decision must be present")) + .equals("Allowed") ? "Yes" : "No"); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getCustomerServicesTelephone()); + fieldValues.put("customerServicesEmail", customerServicesProvider.getCustomerServicesEmail()); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplate.java new file mode 100644 index 000000000..3bff161a8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplate.java @@ -0,0 +1,56 @@ +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.AsylumCaseUtils.getDirectionDueDate; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +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 HoReviewEvidenceLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + public HoReviewEvidenceLetterTemplate( + @Value("${hoReviewEvidenceLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("dateLetterSent", getFormattedDate(dateProvider.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("directionDueDate", getFormattedDate(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.RESPONDENT_REVIEW)))); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + return fieldValues; + } + + private String getFormattedDate(LocalDate localDate) { + return formatDateForNotificationAttachmentDocument(localDate); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplate.java new file mode 100644 index 000000000..c1983e00c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplate.java @@ -0,0 +1,67 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + + +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.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@Component +public class HomeOfficeNonStandardDirectionLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DirectionFinder directionFinder; + + public HomeOfficeNonStandardDirectionLetterTemplate( + @Value("${homeOfficeNonStandardDirectionLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DirectionFinder directionFinder) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.directionFinder = directionFinder; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional direction = directionFinder.findFirst(asylumCase, DirectionTag.NONE); + + if (direction.isEmpty()) { + throw new IllegalStateException("Could not find non-standard direction"); + + } + + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("directionExplanation", direction.get().getExplanation()); + fieldValues.put("directionDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(direction.get().getDateDue()))); + + return fieldValues; + } +} + + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaDecisionsAndReasonsDismissedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaDecisionsAndReasonsDismissedLetterTemplate.java new file mode 100644 index 000000000..6696dc27b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaDecisionsAndReasonsDismissedLetterTemplate.java @@ -0,0 +1,89 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.HashMap; +import java.util.List; +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.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalAdaDecisionsAndReasonsDismissedLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + private final int ftpaDueInWorkingDays; + + public InternalAdaDecisionsAndReasonsDismissedLetterTemplate( + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService, + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.ftpaDueInWorkingDays}") int ftpaDueInWorkingDays + + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + this.ftpaDueInWorkingDays = ftpaDueInWorkingDays; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + List requestBuildCaseDirectionList = getCaseDirectionsBasedOnTag(asylumCase, DirectionTag.REQUEST_CASE_BUILDING); + List respondendReviewDirectionList = getCaseDirectionsBasedOnTag(asylumCase, DirectionTag.RESPONDENT_REVIEW); + + if (requestBuildCaseDirectionList.isEmpty()) { + throw new RequiredFieldMissingException("No requestBuildCase directions found"); + } + + if (requestBuildCaseDirectionList.size() > 1) { + throw new IllegalStateException("More than 1 requestCaseBuilding direction"); + } + + if (respondendReviewDirectionList.isEmpty()) { + throw new RequiredFieldMissingException("No respondent review directions found"); + } + + if (respondendReviewDirectionList.size() > 1) { + throw new IllegalStateException("More than 1 respondent review direction"); + } + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + + fieldValues.put("ftpaDueDate", formatDateForNotificationAttachmentDocument(dueDateService + .calculateDueDate(ZonedDateTime.now(), ftpaDueInWorkingDays) + .toLocalDate())); + + fieldValues.put("responseDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)))); + fieldValues.put("hoReviewAppealDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.RESPONDENT_REVIEW)))); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplate.java new file mode 100644 index 000000000..6e1aa5949 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplate.java @@ -0,0 +1,65 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +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.DirectionTag; +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 InternalAdaSuitabilityReviewSuitableLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + + + public InternalAdaSuitabilityReviewSuitableLetterTemplate( + @Value("${adaInternalSuitabilityReviewSuitableDocument.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("hearingType", asylumCase.read(REMOTE_VIDEO_CALL_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("vulnerabilities", asylumCase.read(VULNERABILITIES_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("pastExperiences", asylumCase.read(PAST_EXPERIENCES_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("multimedia", asylumCase.read(MULTIMEDIA_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("singleSexCourt", asylumCase.read(SINGLE_SEX_COURT_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("inCamera", asylumCase.read(IN_CAMERA_COURT_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("otherHearingRequest", asylumCase.read(ADDITIONAL_TRIBUNAL_RESPONSE, String.class).orElse(null)); + + fieldValues.put("caseBuildingDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)))); + fieldValues.put("requestRespondentReviewDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.RESPONDENT_REVIEW)))); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplate.java new file mode 100644 index 000000000..fc5b5afc7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplate.java @@ -0,0 +1,56 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +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 InternalAdaSuitabilityReviewUnsuitableLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalAdaSuitabilityReviewUnsuitableLetterTemplate( + @Value("${adaInternalSuitabilityReviewUnsuitableDocument.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("hearingType", asylumCase.read(REMOTE_VIDEO_CALL_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("vulnerabilities", asylumCase.read(VULNERABILITIES_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("pastExperiences", asylumCase.read(PAST_EXPERIENCES_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("multimedia", asylumCase.read(MULTIMEDIA_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("singleSexCourt", asylumCase.read(SINGLE_SEX_COURT_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("inCamera", asylumCase.read(IN_CAMERA_COURT_TRIBUNAL_RESPONSE, String.class).orElse(null)); + fieldValues.put("otherHearingRequest", asylumCase.read(ADDITIONAL_TRIBUNAL_RESPONSE, String.class).orElse(null)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplate.java new file mode 100644 index 000000000..ee9516ce7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplate.java @@ -0,0 +1,52 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.dueDatePlusNumberOfWeeks; +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 InternalAppealCanProceedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private int fourWeeksPeriodAfterSubmissionDate = 4; + + public InternalAppealCanProceedLetterTemplate( + @Value("${internalAppealCanProceedDocument.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues(CaseDetails caseDetails) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("detainedEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("dueDate", dueDatePlusNumberOfWeeks(asylumCase, fourWeeksPeriodAfterSubmissionDate)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplate.java new file mode 100644 index 000000000..f19fe970a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplate.java @@ -0,0 +1,52 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.dueDatePlusNumberOfWeeks; +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 InternalAppealSubmissionTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private int fourWeeksPeriodAfterSubmissionDate = 4; + + public InternalAppealSubmissionTemplate( + @Value("${internalAppealSubmissionDocument.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues(CaseDetails caseDetails) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("detainedEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("dueDate", dueDatePlusNumberOfWeeks(asylumCase, fourWeeksPeriodAfterSubmissionDate)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplate.java new file mode 100644 index 000000000..3ff953692 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplate.java @@ -0,0 +1,50 @@ +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.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.DateProvider; +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 InternalAppellantFtpaDecidedGrantedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + + public InternalAppellantFtpaDecidedGrantedLetterTemplate( + @Value("${internalAppellantFtpaDecidedGrantedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplate.java new file mode 100644 index 000000000..b104c49ce --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplate.java @@ -0,0 +1,67 @@ +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.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +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.DateProvider; +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.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalAppellantFtpaDecidedPartiallyGrantedTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + private final int adaDueWorkingDays; + private final int nonAdaDueInCalendarDays; + + public InternalAppellantFtpaDecidedPartiallyGrantedTemplate( + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService, + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaAdaDueWorkingDays}") int adaDueWorkingDays, + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaNonAdaDueCalendarDays}") int nonAdaDueInCalendarDays) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + this.adaDueWorkingDays = adaDueWorkingDays; + this.nonAdaDueInCalendarDays = nonAdaDueInCalendarDays; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + LocalDate dueDate = isAcceleratedDetainedAppeal(asylumCase) + ? dueDateService.calculateDueDate(ZonedDateTime.now(), adaDueWorkingDays).toLocalDate() + : LocalDate.now().plusDays(nonAdaDueInCalendarDays); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("utApplicationDeadline", formatDateForNotificationAttachmentDocument(dueDate)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplate.java new file mode 100644 index 000000000..f57495329 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplate.java @@ -0,0 +1,68 @@ +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.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +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.DateProvider; +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.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalAppellantFtpaDecidedRefusedTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + private final int adaDueInWorkingDays; + private final int nonAdaDueInCalendarDays; + + + public InternalAppellantFtpaDecidedRefusedTemplate( + @Value("${internalAppellantFtpaDecidedRefusedLetter.templateName}") String templateName, + @Value("${internalAppellantFtpaDecidedRefusedLetter.ftpaAdaDueWorkingDays}") int adaDueInWorkingDays, + @Value("${internalAppellantFtpaDecidedRefusedLetter.ftpaNonAdaDueCalendarDays}") int nonAdaDueInCalendarDays, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService) { + this.templateName = templateName; + this.adaDueInWorkingDays = adaDueInWorkingDays; + this.nonAdaDueInCalendarDays = nonAdaDueInCalendarDays; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + LocalDate dueDate = isAcceleratedDetainedAppeal(asylumCase) + ? dueDateService.calculateDueDate(ZonedDateTime.now(), adaDueInWorkingDays).toLocalDate() + : LocalDate.now().plusDays(nonAdaDueInCalendarDays); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("utApplicationDeadline", formatDateForNotificationAttachmentDocument(dueDate)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplate.java new file mode 100644 index 000000000..1dee099d6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplate.java @@ -0,0 +1,51 @@ +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.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.DateProvider; +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 InternalApplyForFtpaAppellantLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + + public InternalApplyForFtpaAppellantLetterTemplate( + @Value("${internalApplyForFtpaAppellantLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeDirectionDueDateLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeDirectionDueDateLetterTemplate.java new file mode 100644 index 000000000..6f4967db7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeDirectionDueDateLetterTemplate.java @@ -0,0 +1,50 @@ +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.AsylumCaseUtils.getDirectionDueDateAndExplanation; +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 InternalChangeDirectionDueDateLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalChangeDirectionDueDateLetterTemplate( + @Value("${internalChangeDueDateLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.putAll(getDirectionDueDateAndExplanation(asylumCase)); + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplate.java new file mode 100644 index 000000000..16daa5a00 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplate.java @@ -0,0 +1,75 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HEARING_CENTRE; +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.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalChangeHearingCentreLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final StringProvider stringProvider; + + public InternalChangeHearingCentreLetterTemplate( + @Value("${internalChangeHearingCentreLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + StringProvider stringProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.stringProvider = stringProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails, + CaseDetails caseDetailsBefore + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final AsylumCase asylumCaseBefore = + caseDetailsBefore.getCaseData(); + + final HearingCentre listedHearingCentre = + asylumCase + .read(HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present")); + + final HearingCentre listedHearingCentreBefore = + asylumCaseBefore + .read(HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + final String hearingCentreNameBefore = + stringProvider + .get("hearingCentreName", listedHearingCentreBefore.toString()) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + final Map 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("oldHearingCentre", hearingCentreNameBefore); + fieldValues.put( + "newHearingCentre", + stringProvider.get("hearingCentreName", listedHearingCentre.toString()).orElse("")); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate.java new file mode 100644 index 000000000..2ac9ad9a1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate.java @@ -0,0 +1,68 @@ +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 static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.WhatHappensNextContentUtils.getWhatHappensNextContent; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_DECISION_REASON; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_TYPE; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + +@Component +public class InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final MakeAnApplicationService makeAnApplicationService; + + + public InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate( + @Value("${internalDecideAnAppellantApplicationDecisionGrantedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + MakeAnApplicationService makeAnApplicationService) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.makeAnApplicationService = makeAnApplicationService; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional optionalMakeAnApplication = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + Map applicationPropeties = makeAnApplicationService.retrieveApplicationProperties(optionalMakeAnApplication); + MakeAnApplicationTypes makeAnApplicationTypes = makeAnApplicationService.getApplicationTypes(applicationPropeties.get(APPLICATION_TYPE)); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("applicationType", applicationPropeties.get(APPLICATION_TYPE)); + fieldValues.put("applicationReason", applicationPropeties.get(APPLICATION_DECISION_REASON)); + fieldValues.put("whatHappensNextContent", getWhatHappensNextContent(makeAnApplicationTypes, true)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate.java new file mode 100644 index 000000000..d589f23af --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate.java @@ -0,0 +1,89 @@ +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.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_DECISION_REASON; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_TYPE; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.UserDetailsProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + +@Component +public class InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate implements DocumentTemplate { + + private static final String judgeRole = "caseworker-ia-iacjudge"; + private static final String legalOfficerRole = "caseworker-ia-caseofficer"; + private static final String applicationRefusedAdaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private static final String applicationRefusedDetainedNonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final MakeAnApplicationService makeAnApplicationService; + private final UserDetailsProvider userDetailsProvider; + + + public InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate( + @Value("${internalDecideAnAppellantApplicationDecisionRefusedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + MakeAnApplicationService makeAnApplicationService, + UserDetailsProvider userDetailsProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.makeAnApplicationService = makeAnApplicationService; + this.userDetailsProvider = userDetailsProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional optionalMakeAnApplication = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + Map applicationPropeties = makeAnApplicationService.retrieveApplicationProperties(optionalMakeAnApplication); + makeAnApplicationService.getApplicationTypes(applicationPropeties.get(APPLICATION_TYPE)); + + final boolean applicationDecidedByLegalOfficer = userDetailsProvider.getUserDetails().getRoles().contains(legalOfficerRole); + final boolean applicationDecidedByJudge = userDetailsProvider.getUserDetails().getRoles().contains(judgeRole); + + String applicationDecidedBy = ""; + if (applicationDecidedByLegalOfficer) { + applicationDecidedBy = "Legal Officer"; + } else if (applicationDecidedByJudge) { + applicationDecidedBy = "Judge"; + } + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("applicationType", applicationPropeties.get(APPLICATION_TYPE)); + fieldValues.put("applicationReason", applicationPropeties.get(APPLICATION_DECISION_REASON)); + fieldValues.put("decisionMaker", applicationDecidedBy); + fieldValues.put("formName", getFormName(asylumCase)); + + return fieldValues; + } + + private String getFormName(AsylumCase asylumCase) { + return isAcceleratedDetainedAppeal(asylumCase) ? applicationRefusedAdaFormName : applicationRefusedDetainedNonAdaFormName; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate.java new file mode 100644 index 000000000..946237e3d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate.java @@ -0,0 +1,79 @@ +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 static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.WhatHappensNextContentUtils.getWhatHappensNextContent; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@Component +public class InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final MakeAnApplicationService makeAnApplicationService; + + + public InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate( + @Value("${internalDecideHomeOfficeApplicationDecisionGrantedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + MakeAnApplicationService makeAnApplicationService) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.makeAnApplicationService = makeAnApplicationService; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional optionalMakeAnApplication = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + + String applicationType = ""; + String applicationDecision = ""; + String applicationDecisionReason = ""; + if (optionalMakeAnApplication.isPresent()) { + MakeAnApplication makeAnApplication = optionalMakeAnApplication.get(); + applicationType = makeAnApplication.getType(); + applicationDecision = makeAnApplication.getDecision(); + applicationDecisionReason = makeAnApplication.getDecisionReason(); + } else { + throw new IllegalStateException("Home Office application not found."); + } + + MakeAnApplicationTypes makeAnApplicationTypes = makeAnApplicationService.getApplicationTypes(applicationType); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("applicationType", applicationType); + fieldValues.put("applicationReason", applicationDecisionReason); + fieldValues.put("whatHappensNextContent", getWhatHappensNextContent(makeAnApplicationTypes, false)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate.java new file mode 100644 index 000000000..7b6c644ad --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate.java @@ -0,0 +1,65 @@ +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 static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_DECISION_REASON; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.APPLICATION_TYPE; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@Component +public class InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate implements DocumentTemplate { + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final MakeAnApplicationService makeAnApplicationService; + + public InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate( + @Value("${internalDecideHomeOfficeApplicationDecisionRefusedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + MakeAnApplicationService makeAnApplicationService + ) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.makeAnApplicationService = makeAnApplicationService; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional optionalMakeAnApplication = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + Map applicationPropeties = makeAnApplicationService.retrieveApplicationProperties(optionalMakeAnApplication); + makeAnApplicationService.getApplicationTypes(applicationPropeties.get(APPLICATION_TYPE)); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("applicationType", applicationPropeties.get(APPLICATION_TYPE)); + fieldValues.put("applicationReason", applicationPropeties.get(APPLICATION_DECISION_REASON)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplate.java new file mode 100644 index 000000000..9e780d8f1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplate.java @@ -0,0 +1,62 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +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.time.LocalDateTime; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.HearingDetailsFinder; + +@Component +public class InternalDetGenerateHearingBundleTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final HearingDetailsFinder hearingDetailsFinder; + + public InternalDetGenerateHearingBundleTemplate( + @Value("${internalAdaHearingBundle.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + HearingDetailsFinder hearingDetailsFinder + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.hearingDetailsFinder = hearingDetailsFinder; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + + final String listCaseHearingDate = asylumCase.read(LIST_CASE_HEARING_DATE, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("List case hearing date not found.")); + LocalDateTime hearingDateTime = LocalDateTime.parse(listCaseHearingDate); + fieldValues.put("hearingDate", formatDateForNotificationAttachmentDocument(hearingDateTime.toLocalDate())); + fieldValues.put("hearingTime", hearingDateTime.toLocalTime()); + fieldValues.put("hearingLocation", hearingDetailsFinder.getHearingCentreName(asylumCase)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplate.java new file mode 100644 index 000000000..8a99c55c8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplate.java @@ -0,0 +1,65 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CCD_REFERENCE_NUMBER_FOR_DISPLAY; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.PAID_AMOUNT; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@Component +public class InternalDetMarkAsPaidLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + public InternalDetMarkAsPaidLetterTemplate( + @Value("${internalDetainedMarkAppealPaid.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("dateLetterSent", getFormattedDate(dateProvider.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("ccdReferenceNumber", asylumCase.read(CCD_REFERENCE_NUMBER_FOR_DISPLAY)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("feeBeforeRemission", String.valueOf(getFeeBeforeRemission(asylumCase))); + fieldValues.put("feeRemission", String.valueOf(getFeeRemission(asylumCase))); + String paidAmount = asylumCase.read(PAID_AMOUNT, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("Paid amount is not present")); + fieldValues.put("totalAmountToPay", String.valueOf(Double.parseDouble(paidAmount) / 100)); + return fieldValues; + } + + private String getFormattedDate(LocalDate localDate) { + return formatDateForNotificationAttachmentDocument(localDate); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplate.java new file mode 100644 index 000000000..80155c988 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplate.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +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.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@Component +public class InternalDetainedAdjournHearingWithoutDateLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final StringProvider stringProvider; + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + + public InternalDetainedAdjournHearingWithoutDateLetterTemplate( + @Value("${internalDetainedAdjournHearingWithoutDateLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + StringProvider stringProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.stringProvider = stringProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails, + CaseDetails caseDetailsBefore + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final AsylumCase asylumCaseBefore = caseDetailsBefore.getCaseData(); + + final String listedHearingDateBefore = + asylumCaseBefore + .read(LIST_CASE_HEARING_DATE, String.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingDate (before) is not present")); + + final HearingCentre listedHearingCentreBefore = + asylumCaseBefore + .read(HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + final String hearingCentreNameBefore = + stringProvider + .get("hearingCentreName", listedHearingCentreBefore.toString()) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + + final Map 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("oldHearingCentre", hearingCentreNameBefore); + fieldValues.put("oldHearingDate", formatDateTimeForRendering(listedHearingDateBefore, DOCUMENT_DATE_FORMAT)); + fieldValues.put("adjournHearingWithoutDateReasons", asylumCase.read(ADJOURN_HEARING_WITHOUT_DATE_REASONS,String.class).orElse("")); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplate.java new file mode 100644 index 000000000..8a6c02f8b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplate.java @@ -0,0 +1,59 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +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 InternalDetainedAppealFeeDueTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final int calenderDaysToPayAppealFee = 14; + + public InternalDetainedAppealFeeDueTemplate( + @Value("${internalDetainedAppealFeeDue.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("ccdReferenceNumber", asylumCase.read(CCD_REFERENCE_NUMBER_FOR_DISPLAY)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("deadlineDate", formatDateForNotificationAttachmentDocument(LocalDate.now().plusDays(calenderDaysToPayAppealFee))); + + double feeAmountInPounds = getFeeBeforeRemission(asylumCase); + double remissionAmount = getFeeRemission(asylumCase); + fieldValues.put("feeBeforeRemission", String.valueOf(feeAmountInPounds)); + fieldValues.put("feeRemission", String.valueOf(remissionAmount)); + fieldValues.put("totalAmountToPay", feeAmountInPounds - remissionAmount); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplate.java new file mode 100644 index 000000000..7b3506557 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplate.java @@ -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 InternalDetainedApplyForFtpaRespondentLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalDetainedApplyForFtpaRespondentLetterTemplate( + @Value("${internalDetainedApplyForFtpaRespondentLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplate.java new file mode 100644 index 000000000..92348a3c3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplate.java @@ -0,0 +1,66 @@ +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.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +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.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedDecisionsAndReasonsAllowedLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + private final int ftpaDueInWorkingDays; + private final int ftpaDueInCalendarDays; + + public InternalDetainedDecisionsAndReasonsAllowedLetterTemplate( + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService, + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.ftpaDueInWorkingDays}") int ftpaDueInWorkingDays, + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.ftpaDueCalendarDays}") int ftpaDueInCalendarDays + + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + this.ftpaDueInWorkingDays = ftpaDueInWorkingDays; + this.ftpaDueInCalendarDays = ftpaDueInCalendarDays; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + LocalDate dueDate = isAcceleratedDetainedAppeal(asylumCase) + ? dueDateService.calculateDueDate(ZonedDateTime.now(), ftpaDueInWorkingDays).toLocalDate() + : LocalDate.now().plusDays(ftpaDueInCalendarDays); + fieldValues.put("ftpaDueDate", formatDateForNotificationAttachmentDocument(dueDate)); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplate.java new file mode 100644 index 000000000..4f2c24c4d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplate.java @@ -0,0 +1,54 @@ +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 InternalDetainedDecisionsAndReasonsDismissedLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final int ftpaDueCalendarDays; + + public InternalDetainedDecisionsAndReasonsDismissedLetterTemplate( + @Value("${internalDetainedDecisionsAndReasonsDismissedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + @Value("${internalDetainedDecisionsAndReasonsDismissedLetter.ftpaDueCalendarDays}") int ftpaDueCalendarDays + + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.ftpaDueCalendarDays = ftpaDueCalendarDays; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("ftpaDueDate", formatDateForNotificationAttachmentDocument(LocalDate.now().plusDays(ftpaDueCalendarDays))); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplate.java new file mode 100644 index 000000000..26b904404 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplate.java @@ -0,0 +1,86 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_CENTRE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_DATE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; +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.time.format.DateTimeFormatter; +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.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedEditCaseListingLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + private static final DateTimeFormatter DOCUMENT_TIME_FORMAT = DateTimeFormatter.ofPattern("HHmm"); + private final StringProvider stringProvider; + + public InternalDetainedEditCaseListingLetterTemplate( + @Value("${internalDetainedEditCaseListingLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + StringProvider stringProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.stringProvider = stringProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails, + CaseDetails caseDetailsBefore + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final AsylumCase asylumCaseBefore = + caseDetailsBefore.getCaseData(); + + final HearingCentre listedHearingCentre = + asylumCase + .read(LIST_CASE_HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present")); + + final HearingCentre listedHearingCentreBefore = + asylumCaseBefore + .read(LIST_CASE_HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + final String hearingCentreNameBefore = + stringProvider + .get("hearingCentreName", listedHearingCentreBefore.toString()) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre (before) is not present")); + + final Map 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("oldHearingCentre", hearingCentreNameBefore); + fieldValues.put("oldHearingDate", formatDateTimeForRendering(asylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("oldHearingTime", formatDateTimeForRendering(asylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT)); + fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("hearingTime", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT)); + fieldValues.put( + "hearingCentreAddress", + stringProvider.get("hearingCentreAddress", listedHearingCentre.toString()).orElse("") + .replaceAll(",\\s*", "\n") + ); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplate.java new file mode 100644 index 000000000..23e882713 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplate.java @@ -0,0 +1,71 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering; +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.time.format.DateTimeFormatter; +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.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedListCaseLetterTemplate implements DocumentTemplate { + + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + private static final DateTimeFormatter DOCUMENT_TIME_FORMAT = DateTimeFormatter.ofPattern("HHmm"); + private final StringProvider stringProvider; + + public InternalDetainedListCaseLetterTemplate( + @Value("${internalDetainedListCaseLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + StringProvider stringProvider + ) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.stringProvider = stringProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + final HearingCentre listedHearingCentre = + asylumCase + .read(LIST_CASE_HEARING_CENTRE, HearingCentre.class) + .orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present")); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("hearingTime", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT)); + fieldValues.put( + "hearingCentreAddress", + stringProvider.get("hearingCentreAddress", listedHearingCentre.toString()).orElse("") + .replaceAll(",\\s*", "\n") + ); + + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplate.java new file mode 100644 index 000000000..fee3a37b7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplate.java @@ -0,0 +1,69 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_SUBMISSION_DATE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REASON_APPEAL_MARKED_AS_ADA; +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.time.ZoneOffset; +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.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalDetainedMarkAsAdaLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + private final int responseToTribunalDueInWorkingDays = 13; + private final int homeOfficeResponseDueInWorkingDays = 15; + + public InternalDetainedMarkAsAdaLetterTemplate( + @Value("${internalMarkAppealAsAda.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put("reason", asylumCase.read(REASON_APPEAL_MARKED_AS_ADA, String.class).orElse("")); + fieldValues.put("responseDueDate", resolveResponseDueDate(asylumCase, responseToTribunalDueInWorkingDays)); + fieldValues.put("hoReviewAppealDueDate", resolveResponseDueDate(asylumCase, homeOfficeResponseDueInWorkingDays)); + return fieldValues; + } + + private String resolveResponseDueDate(AsylumCase asylumCase, int dueDays) { + LocalDate appealSubmissionDate = LocalDate.parse(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class) + .orElseThrow(() -> new IllegalStateException("Appeal submission date is missing"))); + + return formatDateForNotificationAttachmentDocument(dueDateService + .calculateDueDate(appealSubmissionDate.atStartOfDay(ZoneOffset.UTC), dueDays) + .toLocalDate()); + } +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate.java new file mode 100644 index 000000000..4b34aef4c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate.java @@ -0,0 +1,59 @@ +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.AsylumCaseUtils.getDirectionDueDate; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +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.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +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 InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate implements DocumentTemplate { + + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final int dueInCalendarDays; + + public InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate( + @Value("${internalDetainedReviewHomeOfficeResponseMaintainedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + @Value("${internalDetainedReviewHomeOfficeResponseMaintainedLetter.dueCalendarDays}") int dueInCalendarDays) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.dueInCalendarDays = dueInCalendarDays; + } + + public String getName() { + + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_RESPONSE_REVIEW)).plusDays(dueInCalendarDays))); + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate.java new file mode 100644 index 000000000..aaa6cf0a0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate.java @@ -0,0 +1,49 @@ +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.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.DateProvider; +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 InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate implements DocumentTemplate { + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + public InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate( + @Value("${internalDetainedReviewHomeOfficeResponseWithdrawnLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplate.java new file mode 100644 index 000000000..a69b1a016 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplate.java @@ -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 { + + 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 mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplate.java new file mode 100644 index 000000000..303aa1423 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplate.java @@ -0,0 +1,50 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +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; + +import java.time.LocalDate; +import java.util.HashMap; +import java.util.Map; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@Component +public class InternalEditAppealLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalEditAppealLetterTemplate( + @Value("${internalDetainedEditAppeal.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplate.java new file mode 100644 index 000000000..c2122a3bf --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplate.java @@ -0,0 +1,69 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +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 java.util.Optional; +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.RemissionType; +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 InternalEndAppealAutomaticallyTemplate implements DocumentTemplate { + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalEndAppealAutomaticallyTemplate( + @Value("${internalDetainedEndAppealAutomatically.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put("deadLineDate", resolveDeadLineDate(asylumCase)); + return fieldValues; + } + + private String resolveDeadLineDate(AsylumCase asylumCase) { + String deadLineDate; + if (hasNoRemission(asylumCase)) { + final int appealEndDueDays = 14; + deadLineDate = formatDateForNotificationAttachmentDocument(LocalDate.parse(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class) + .orElseThrow(() -> new IllegalStateException("Appeal submission date is missing"))) + .plusDays(appealEndDueDays)); + } else { + deadLineDate = asylumCase.read(REMISSION_REJECTED_DATE_PLUS_14DAYS, String.class) + .orElseThrow(() -> new IllegalStateException("Remission rejected date is missing")); + } + return deadLineDate; + } + + private boolean hasNoRemission(AsylumCase asylumCase) { + Optional optRemissionType = asylumCase.read(REMISSION_TYPE, RemissionType.class); + return optRemissionType.isPresent() && optRemissionType.get() == RemissionType.NO_REMISSION; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplate.java new file mode 100644 index 000000000..1cfcd4fe3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplate.java @@ -0,0 +1,60 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +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 InternalEndAppealTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final String adaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private final String nonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + + public InternalEndAppealTemplate( + @Value("${internalDetainedEndAppeal.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put("decisionMaker", caseDetails.getCaseData().read(END_APPEAL_APPROVER_TYPE, String.class).orElse("")); + fieldValues.put("endAppealDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(asylumCase.read(END_APPEAL_DATE, String.class) + .orElseThrow(() -> new IllegalStateException("End appeal date is missing"))))); + fieldValues.put("formName", resolveFormName(asylumCase)); + return fieldValues; + } + + private String resolveFormName(AsylumCase asylumCase) { + return isAcceleratedDetainedAppeal(asylumCase) + ? adaFormName + : nonAdaFormName; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplate.java new file mode 100644 index 000000000..718797a23 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplate.java @@ -0,0 +1,51 @@ +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.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.DateProvider; +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 InternalHearingAdjustmentsUpdatedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + + public InternalHearingAdjustmentsUpdatedLetterTemplate( + @Value("${internalHearingAdjustmentsUpdated.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplate.java new file mode 100644 index 000000000..d21236c07 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplate.java @@ -0,0 +1,50 @@ +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.AsylumCaseUtils.getDirectionDueDateAndExplanation; +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 InternalHoChangeDirectionDueDateLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalHoChangeDirectionDueDateLetterTemplate( + @Value("${internalHoChangeDirectionDueDateLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.putAll(getDirectionDueDateAndExplanation(asylumCase)); + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplate.java new file mode 100644 index 000000000..eba60f729 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplate.java @@ -0,0 +1,47 @@ +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 InternalHoFtpaDecidedGrantedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalHoFtpaDecidedGrantedLetterTemplate( + @Value("${internalDetainedHoFtpaDecidedGrantedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(getAppellantPersonalisation(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplate.java new file mode 100644 index 000000000..d90ffe4de --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplate.java @@ -0,0 +1,47 @@ +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 InternalHoFtpaDecidedPartiallyGrantedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalHoFtpaDecidedPartiallyGrantedLetterTemplate( + @Value("${internalDetainedHoFtpaDecidedPartiallyGrantedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(getAppellantPersonalisation(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplate.java new file mode 100644 index 000000000..0580d65c5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplate.java @@ -0,0 +1,55 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.FtpaDecisionOutcomeType.FTPA_REFUSED; +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.FtpaDecisionOutcomeType; +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 InternalHoFtpaDecidedRefusedLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final String refused = "refused"; + private final String notAdmitted = "not admitted"; + + public InternalHoFtpaDecidedRefusedLetterTemplate( + @Value("${internalDetainedHoFtpaDecidedRefusedLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + @Override + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(getAppellantPersonalisation(asylumCase)); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("refused", asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class) + .map(it -> it.equals(FTPA_REFUSED) ? refused : notAdmitted) + .orElseThrow(() -> new IllegalStateException("Judge decision 'refused' or 'not admitted' must be present"))); + return fieldValues; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplate.java new file mode 100644 index 000000000..6b0f27a7f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplate.java @@ -0,0 +1,68 @@ +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 java.util.Optional; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + + +@Component +public class InternalHomeOfficeAmendAppealResponseTemplate implements DocumentTemplate { + + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final DirectionFinder directionFinder; + + public InternalHomeOfficeAmendAppealResponseTemplate( + @Value("${internalHomeOfficeAmendAppealResponse.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + DirectionFinder directionFinder) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.directionFinder = directionFinder; + } + + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional optionalDirection = directionFinder.findFirst(asylumCase, DirectionTag.REQUEST_RESPONSE_AMEND); + + if (optionalDirection.isEmpty()) { + throw new IllegalStateException("Could not find requestResponseAmend direction"); + } + + String directionDueDate = optionalDirection.get().getDateDue(); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("directionDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(directionDueDate))); + + return fieldValues; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate.java new file mode 100644 index 000000000..026b34e3a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate.java @@ -0,0 +1,49 @@ +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 InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate( + @Value("${internalHomeOfficeUploadAdditionalAddendumEvidence.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate.java new file mode 100644 index 000000000..23dfc9263 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate.java @@ -0,0 +1,49 @@ +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 InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate( + @Value("${internalLegalOfficerUploadAdditionalEvidence.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } + +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplate.java new file mode 100644 index 000000000..6c297a641 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplate.java @@ -0,0 +1,91 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CASE_LINKS; +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.*; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking.CaseLink; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class InternalMaintainCaseLinkAppealTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private static final String reasonKey = "reason"; + private static final Map reasons = Map.ofEntries( + Map.entry("CLRC001", "Related appeal"), + Map.entry("CLRC002", "Related proceedings"), + Map.entry("CLRC003", "Same Party"), + Map.entry("CLRC004", "Same child/ren"), + Map.entry("CLRC005", "Familial"), + Map.entry("CLRC006", "Guardian"), + Map.entry("CLRC007", "Referred to the same judge"), + Map.entry("CLRC008", "Shared evidence"), + Map.entry("CLRC009", "Common circumstance"), + Map.entry("CLRC010", "Bail"), + Map.entry("CLRC011", "Findings of fact"), + Map.entry("CLRC012", "First Tier Agency (FTA) Request"), + Map.entry("CLRC013", "Point of law"), + Map.entry("CLRC014", "Other"), + Map.entry("CLRC015", "Case consolidated"), + Map.entry("CLRC016", "Progressed as part of this lead case"), + Map.entry("CLRC017", "Linked for a hearing") + ); + + public InternalMaintainCaseLinkAppealTemplate( + @Value("${internalDetainedMaintainCaseLinkAppeal.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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())); + fieldValues.put(reasonKey, resolveReasons(asylumCase)); + return fieldValues; + } + + private List> resolveReasons(AsylumCase asylumCase) { + return retrieveLatestCaseLink(asylumCase) + .getReasonsForLink() + .stream() + .map(IdValue::getValue) + .map(reasonForLink -> new AbstractMap.SimpleEntry<>(reasonKey, reasons.get(reasonForLink.getReason()))) + .toList(); + } + + private CaseLink retrieveLatestCaseLink(AsylumCase asylumCase) { + Optional>> maybeCaseLinks = asylumCase.read(CASE_LINKS); + + return maybeCaseLinks + .orElseThrow(() -> new IllegalStateException("caseLinks are not present")) + .stream() + .map(IdValue::getValue) + .max(Comparator.comparing(CaseLink::getCreatedDateTime)) + .orElseThrow(() -> new IllegalStateException("caseLink is not present")); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplate.java new file mode 100644 index 000000000..ce4ca73e6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplate.java @@ -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 InternalMaintainCaseUnlinkAppealTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + + public InternalMaintainCaseUnlinkAppealTemplate( + @Value("${internalDetainedMaintainCaseUnlinkAppeal.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplate.java new file mode 100644 index 000000000..c22326828 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplate.java @@ -0,0 +1,64 @@ +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 java.util.Optional; + +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.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +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; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@Component +public class InternalNonStandardDirectionLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private final DirectionFinder directionFinder; + + public InternalNonStandardDirectionLetterTemplate( + @Value("${internalNonStandardDirectionLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider, + DirectionFinder directionFinder) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + this.directionFinder = directionFinder; + } + + public String getName() { + + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + final Map fieldValues = new HashMap<>(); + + Optional direction = directionFinder.findFirst(asylumCase, DirectionTag.NONE); + + if (direction.isEmpty()) { + throw new IllegalStateException("Could not find non-standard direction"); + + } + + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("sendDirectionContent", direction.get().getExplanation()); + fieldValues.put("directionDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(direction.get().getDateDue()))); + + return fieldValues; + } +} \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplate.java new file mode 100644 index 000000000..2f5ef0024 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplate.java @@ -0,0 +1,61 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +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 InternalReinstateAppealLetterTemplate implements DocumentTemplate { + + private final String templateName; + private final CustomerServicesProvider customerServicesProvider; + private static final String reinstateAppealAdaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private static final String reinstateAppealNonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("dd MMMM yyyy"); + + public InternalReinstateAppealLetterTemplate( + @Value("${internalDetainedReinstateAppealLetter.templateName}") String templateName, + CustomerServicesProvider customerServicesProvider) { + this.templateName = templateName; + this.customerServicesProvider = customerServicesProvider; + } + + @Override + public String getName() { + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("reinstatedDecisionMaker", asylumCase.read(REINSTATED_DECISION_MAKER, String.class).orElse("")); + fieldValues.put("reinstateAppealDate", formatDateForRendering(asylumCase.read(REINSTATE_APPEAL_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT)); + fieldValues.put("reinstateAppealReason", asylumCase.read(REINSTATE_APPEAL_REASON, String.class).orElse("")); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("customerServicesEmail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(LocalDate.now())); + fieldValues.put("formName", getFormName(asylumCase)); + return fieldValues; + } + + private String getFormName(AsylumCase asylumCase) { + return isAcceleratedDetainedAppeal(asylumCase) ? reinstateAppealAdaFormName : reinstateAppealNonAdaFormName; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplate.java new file mode 100644 index 000000000..0eb82d7ee --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplate.java @@ -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 { + + 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 mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map 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; + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplate.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplate.java new file mode 100644 index 000000000..762368c1f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplate.java @@ -0,0 +1,80 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_DATE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getAppellantPersonalisation; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.getDirectionDueDate; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.*; +import java.time.format.DateTimeFormatter; +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.DateProvider; +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.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.DocumentTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@Component +public class UploadAppealResponseMaintainedDecisionLetterTemplate implements DocumentTemplate { + + private static final DateTimeFormatter DOCUMENT_DATE_FORMAT = DateTimeFormatter.ofPattern("ddMMyyyy"); + private final String templateName; + private final DateProvider dateProvider; + private final CustomerServicesProvider customerServicesProvider; + private final DueDateService dueDateService; + + public UploadAppealResponseMaintainedDecisionLetterTemplate( + @Value("${uploadAppealResponseMaintainedLetter.templateName}") String templateName, + DateProvider dateProvider, + CustomerServicesProvider customerServicesProvider, + DueDateService dueDateService) { + this.templateName = templateName; + this.dateProvider = dateProvider; + this.customerServicesProvider = customerServicesProvider; + this.dueDateService = dueDateService; + } + + public String getName() { + + return templateName; + } + + public Map mapFieldValues( + CaseDetails caseDetails + ) { + final AsylumCase asylumCase = caseDetails.getCaseData(); + + final Map fieldValues = new HashMap<>(); + + fieldValues.put("dateLetterSent", formatDateForNotificationAttachmentDocument(dateProvider.now())); + fieldValues.putAll(getAppellantPersonalisation(asylumCase)); + fieldValues.put("customerServicesTelephone", customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + fieldValues.put("ADAemail", customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + fieldValues.put("suitabilityAssessmentHearingDate", getFormattedDate(getSaHearingDate(asylumCase))); + fieldValues.put("hearingDate", getFormattedDate(getLocalDateForFieldValue(asylumCase, LIST_CASE_HEARING_DATE))); + fieldValues.put("caseBuildingDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)))); + fieldValues.put("requestRespondentReviewDueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.RESPONDENT_REVIEW)))); + return fieldValues; + } + + private String getFormattedDate(LocalDate localDate) { + return localDate.format(DOCUMENT_DATE_FORMAT); + } + + private LocalDate getLocalDateForFieldValue(AsylumCase asylumCase, AsylumCaseDefinition field) { + return LocalDateTime.parse(asylumCase.read(field, String.class).orElseThrow(() -> new RequiredFieldMissingException(field.toString() + " not found."))).toLocalDate(); + } + + private LocalDate getSaHearingDate(AsylumCase asylumCase) { + LocalDate appealSubmissionDate = LocalDate.parse(asylumCase.read(AsylumCaseDefinition.APPEAL_SUBMISSION_DATE, String.class).orElseThrow(() -> new RequiredFieldMissingException("Appeal Submission Date is missing"))); + return dueDateService.calculateDueDate(appealSubmissionDate.atStartOfDay(ZoneOffset.UTC), 16).toLocalDate(); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtils.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtils.java new file mode 100644 index 000000000..2a31b549e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtils.java @@ -0,0 +1,209 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils; + +import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.NO; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.YES; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + + +public class AsylumCaseUtils { + + private AsylumCaseUtils() { + // prevent public constructor for Sonar + } + + public static boolean isAppellantInDetention(AsylumCase asylumCase) { + return asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class).orElse(NO).equals(YES); + } + + public static boolean isAcceleratedDetainedAppeal(AsylumCase asylumCase) { + return asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class) + .orElse(NO) + .equals(YES); + } + + public static boolean isDetainedAppeal(AsylumCase asylumCase) { + return asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class) + .orElse(NO) + .equals(YES); + } + + public static boolean isInternalCase(AsylumCase asylumCase) { + return asylumCase.read(IS_ADMIN, YesOrNo.class).map(isAdmin -> YES == isAdmin).orElse(false); + } + + public static List> getCaseDirections(AsylumCase asylumCase) { + final Optional>> maybeDirections = asylumCase.read(DIRECTIONS); + final List> existingDirections = maybeDirections + .orElse(Collections.emptyList()); + return existingDirections; + } + + public static List getCaseDirectionsBasedOnTag(AsylumCase asylumCase, DirectionTag directionTag) { + List> directions = getCaseDirections(asylumCase); + + return directions + .stream() + .map(IdValue::getValue) + .filter(direction -> direction.getTag() == directionTag) + .collect(Collectors.toList()); + } + + public static String getDirectionDueDate(AsylumCase asylumCase, DirectionTag tag) { + Direction direction = getCaseDirectionsBasedOnTag(asylumCase, tag).get(0); + return direction.getDateDue(); + } + + public static Map getAppellantPersonalisation(AsylumCase asylumCase) { + requireNonNull(asylumCase, "asylumCase must not be null"); + + return ImmutableMap + .builder() + .put("hmcts", "[userImage:hmcts.png]") + .putAll(getAppellantPersonalisationWithoutUserImage(asylumCase)) + .build(); + } + + public static Map getAppellantPersonalisationWithoutUserImage(AsylumCase asylumCase) { + requireNonNull(asylumCase, "asylumCase must not be null"); + + return ImmutableMap + .builder() + .put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse("")) + .put("homeOfficeReferenceNumber", asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class).orElse("")) + .put("appellantGivenNames", asylumCase.read(APPELLANT_GIVEN_NAMES, String.class).orElse("")) + .put("appellantFamilyName", asylumCase.read(AsylumCaseDefinition.APPELLANT_FAMILY_NAME, String.class).orElse("")) + .build(); + } + + public static String dueDatePlusNumberOfWeeks(AsylumCase asylumCase, int numberOfWeeks) { + LocalDate appealSubmissionDate = asylumCase.read(APPEAL_SUBMISSION_DATE, String.class) + .map(LocalDate::parse) + .orElseThrow(() -> new IllegalStateException("appealSubmissionDate is missing")); + + return formatDateForNotificationAttachmentDocument(appealSubmissionDate.plusWeeks(numberOfWeeks)); + } + + public static String formatDateForRendering(String date, DateTimeFormatter formatter) { + if (!Strings.isNullOrEmpty(date)) { + return LocalDate.parse(date).format(formatter); + } + return ""; + } + + public static String formatDateTimeForRendering(String date, DateTimeFormatter formatter) { + if (!Strings.isNullOrEmpty(date)) { + return LocalDateTime.parse(date).format(formatter); + } + return ""; + } + + public static boolean isEaHuEuAppeal(AsylumCase asylumCase) { + return asylumCase + .read(APPEAL_TYPE, AsylumAppealType.class) + .map(type -> type == EA || type == HU || type == EU).orElse(false); + } + + public static double getFeeBeforeRemission(AsylumCase asylumCase) { + double feeAmountInPence = Double.parseDouble(asylumCase.read(FEE_AMOUNT_GBP, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("Fee amount not found"))); + return feeAmountInPence / 100; + } + + private static double getAmountRemitted(AsylumCase asylumCase) { + Optional remissionDecision = asylumCase.read(REMISSION_DECISION, RemissionDecision.class); + + if (remissionDecision.isPresent() && remissionDecision.get().equals(RemissionDecision.REJECTED)) { + return 0; + } else { + double feeAmountInPence = Double.parseDouble(asylumCase.read(AMOUNT_REMITTED, String.class) + .orElseThrow(() -> new RequiredFieldMissingException("Amount remitted not found"))); + return feeAmountInPence / 100; + } + } + + public static double getFeeRemission(AsylumCase asylumCase) { + RemissionType remissionType = asylumCase.read(REMISSION_TYPE, RemissionType.class) + .orElseThrow(() -> new RequiredFieldMissingException("Remission type not found")); + + if (remissionType.equals(RemissionType.NO_REMISSION)) { + return 0; + } else { + return getAmountRemitted(asylumCase); + } + } + + public static boolean isValidUserDirection( + DirectionFinder directionFinder, AsylumCase asylumCase, + DirectionTag directionTag, Parties parties + ) { + return directionFinder + .findFirst(asylumCase, directionTag) + .map(direction -> direction.getParties().equals(parties)) + .orElse(false); + } + + public static List> getAddendumEvidenceDocuments(AsylumCase asylumCase) { + Optional>> maybeExistingAdditionalEvidenceDocuments = + asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS); + if (maybeExistingAdditionalEvidenceDocuments.isEmpty()) { + return Collections.emptyList(); + } + + return maybeExistingAdditionalEvidenceDocuments.get(); + } + + + public static Optional> getLatestAddendumEvidenceDocument(AsylumCase asylumCase) { + List> addendums = getAddendumEvidenceDocuments(asylumCase); + + if (addendums.isEmpty()) { + return Optional.empty(); + } + + Optional> optionalLatestAddendum = addendums.stream().findFirst(); + + return optionalLatestAddendum.isEmpty() ? Optional.empty() : Optional.of(optionalLatestAddendum.get()); + } + + public static boolean isDirectionPartyRespondent(AsylumCase asylumCase) { + return asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class) + .map(parties -> parties.equals(Parties.RESPONDENT)) + .orElse(false); + } + + public static Map getDirectionDueDateAndExplanation(AsylumCase asylumCase) { + requireNonNull(asylumCase, "asylumCase must not be null"); + + String directionEditDueDate = asylumCase.read(DIRECTION_EDIT_DATE_DUE, String.class) + .orElseThrow(() -> new IllegalStateException("Direction edit date due is not present")); + + String directionEditExplanation = asylumCase.read(DIRECTION_EDIT_EXPLANATION, String.class) + .orElseThrow(() -> new IllegalStateException("Direction edit explanation is not present")); + + return ImmutableMap + .builder() + .put("dueDate", formatDateForNotificationAttachmentDocument(LocalDate.parse(directionEditDueDate))) + .put("directionExplaination", directionEditExplanation) + .build(); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtils.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtils.java new file mode 100644 index 000000000..45a941218 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtils.java @@ -0,0 +1,16 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class DateUtils { + + private DateUtils() { + // prevent public constructor for Sonar + } + + // Formatting to be used for dates within notification attachment documents + public static String formatDateForNotificationAttachmentDocument(LocalDate localDate) { + return localDate.format(DateTimeFormatter.ofPattern("d MMM yyyy")); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/WhatHappensNextContentUtils.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/WhatHappensNextContentUtils.java new file mode 100644 index 000000000..8119e3f7c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/WhatHappensNextContentUtils.java @@ -0,0 +1,58 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils; + +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; + +public final class WhatHappensNextContentUtils { + + private WhatHappensNextContentUtils() { + // prevent public constructor for Sonar + } + + private static final String timeExtentionContent = "The Tribunal will give you more time to complete your next task. You will get a notification with the new date soon."; + private static final String adjournExpediteTransferOrUpdateHearingReqsContent = "The details of your hearing will be updated. The Tribunal will contact you when this happens."; + private static final String judgesReviewContent = "The decision on your original request will be overturned. The Tribunal will contact you if there is something you need to do next."; + private static final String linkOrUnlinkContent = "This appeal will be linked or unlinked. The Tribunal will contact you when this happens."; + private static final String withdrawnContent = "The Tribunal will end the appeal. The Tribunal will contact you when this happens."; + private static final String updateUpdateDetailsOrOtherContent = "The Tribunal will contact you when it makes the changes you requested."; + private static final String transferOutOfAdaContent = "Your appeal will continue but will no longer be decided within 25 working days. The Tribunal will change the date of your hearing. The Tribunal will contact you with a new date for your hearing and to tell you what will happen next with your appeal."; + private static final String reinstateAppealContent = "This appeal will be reinstated and will continue from the point where it was ended. You will be notified when this happens."; + + //Home office constants + private static final String homeOfficetimeExtentionContent = "The Tribunal will give the Home Office more time to complete its next task. You will get a notification with the new date soon."; + private static final String homeOfficeAdjournExpediteTransferOrUpdateHearingReqsContent = "The details of the hearing will be updated and you will be sent a new Notice of Hearing with the agreed changes."; + private static final String homeOfficeJudgesReviewContent = "The decision on the Home Office’s original request will be overturned. You will be notified if there is something you need to do next."; + private static final String homeOfficeLinkOrUnlinkContent = "This appeal will be linked to or unlinked from the appeal in the Home Office application. You will be notified when this happens."; + private static final String homeOfficeWithdrawnContent = "The Tribunal will end the appeal. You will be notified when this happens."; + private static final String homeOfficeReinstateAppealContent = "This appeal will be reinstated and will continue from the point where it was ended. You will be notified when this happens."; + private static final String applicationTypeOtherContent = "You will be notified when the Tribunal makes the changes the Home Office asked for."; + + public static String getWhatHappensNextContent(MakeAnApplicationTypes makeAnApplicationTypes, boolean isAppelantApplication) { + if (isAppelantApplication) { + return switch (makeAnApplicationTypes) { + case TIME_EXTENSION -> timeExtentionContent; + case ADJOURN, EXPEDITE, TRANSFER, UPDATE_HEARING_REQUIREMENTS -> + adjournExpediteTransferOrUpdateHearingReqsContent; + case JUDGE_REVIEW, JUDGE_REVIEW_LO -> judgesReviewContent; + case LINK_OR_UNLINK -> linkOrUnlinkContent; + case WITHDRAW -> withdrawnContent; + case REINSTATE -> reinstateAppealContent; + case UPDATE_APPEAL_DETAILS, OTHER -> updateUpdateDetailsOrOtherContent; + case TRANSFER_OUT_OF_ACCELERATED_DETAINED_APPEALS_PROCESS -> transferOutOfAdaContent; + default -> "Unknown"; + }; + } else { + return switch (makeAnApplicationTypes) { + case TIME_EXTENSION -> homeOfficetimeExtentionContent; + case ADJOURN, EXPEDITE, TRANSFER, UPDATE_HEARING_REQUIREMENTS -> + homeOfficeAdjournExpediteTransferOrUpdateHearingReqsContent; + case JUDGE_REVIEW, JUDGE_REVIEW_LO -> homeOfficeJudgesReviewContent; + case LINK_OR_UNLINK -> homeOfficeLinkOrUnlinkContent; + case WITHDRAW -> homeOfficeWithdrawnContent; + case REINSTATE -> homeOfficeReinstateAppealContent; + case OTHER -> applicationTypeOtherContent; + default -> ""; + }; + } + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProvider.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProvider.java index 4c884237d..202f0dade 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProvider.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProvider.java @@ -1,11 +1,15 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure; import static java.util.Objects.requireNonNull; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAcceleratedDetainedAppeal; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAppellantInDetention; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase; import com.google.common.collect.ImmutableMap; import java.util.Map; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; @Service @@ -13,6 +17,11 @@ public class CustomerServicesProvider { private final String customerServicesTelephone; private final String customerServicesEmail; + @Value("${customerServices.internal.telephoneNumber.ada}") + private String internalAdaCustomerServicesTelephone; + @Value("${customerServices.internal.emailAddress.ada}") + private String internalAdaCustomerServicesEmail; + public CustomerServicesProvider( @Value("${customerServices.telephoneNumber}") String customerServicesTelephone, @@ -44,4 +53,16 @@ public String getCustomerServicesEmail() { requireNonNull(customerServicesEmail); return customerServicesEmail; } + + public String getInternalCustomerServicesTelephone(AsylumCase asylumCase) { + return isInternalCase(asylumCase) && isAppellantInDetention(asylumCase) + ? internalAdaCustomerServicesTelephone + : customerServicesTelephone; + } + + public String getInternalCustomerServicesEmail(AsylumCase asylumCase) { + return isInternalCase(asylumCase) && isAcceleratedDetainedAppeal(asylumCase) + ? internalAdaCustomerServicesEmail + : customerServicesEmail; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationService.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationService.java new file mode 100644 index 000000000..ee7d78de9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationService.java @@ -0,0 +1,96 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure; + +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.DECIDE_AN_APPLICATION_ID; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes.*; + +import java.util.*; +import java.util.stream.Collectors; +import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +@Service +public class MakeAnApplicationService { + public static final String APPLICATION_TYPE = "applicationType"; + public static final String APPLICATION_DECISION = "applicationDecision"; + public static final String APPLICATION_DECISION_REASON = "applicationDecisionReason"; + private static final Map APPLICATION_PHRASE = Map.ofEntries( + Map.entry(ADJOURN.toString(), "change the hearing date"), + Map.entry(EXPEDITE.toString(), "have the hearing sooner"), + Map.entry(JUDGE_REVIEW.toString(), "ask a judge to review the decision"), + Map.entry(LINK_OR_UNLINK.toString(), "link or unlink the appeal"), + Map.entry(TIME_EXTENSION.toString(), "ask for more time"), + Map.entry(TRANSFER.toString(), "move the hearing to a different location"), + Map.entry(WITHDRAW.toString(), "withdraw from the appeal"), + Map.entry(UPDATE_HEARING_REQUIREMENTS.toString(), "change some of the hearing requirements"), + Map.entry(UPDATE_APPEAL_DETAILS.toString(), "change some of the appeal details"), + Map.entry(REINSTATE.toString(), "reinstate the appeal"), + Map.entry(OTHER.toString(), "change something about the appeal") + ); + + public Optional getMakeAnApplication(AsylumCase asylumCase, boolean decided) { + Optional makeApplicationOptional = Optional.empty(); + Optional>> makeAnApplicationsOptional = asylumCase.read(AsylumCaseDefinition.MAKE_AN_APPLICATIONS); + if (makeAnApplicationsOptional.isPresent()) { + List> idValues = makeAnApplicationsOptional.orElse(Collections.emptyList()); + if (idValues.size() > 0) { + if (decided) { + Optional decideAnApplicationIdOptional = asylumCase.read(DECIDE_AN_APPLICATION_ID); + String decideAnApplicationId = decideAnApplicationIdOptional.orElse(""); + makeApplicationOptional = idValues.stream().filter(idValue -> idValue.getId().equals(decideAnApplicationId)).map(idValue -> idValue.getValue()).findAny(); + } else { + int targetIndex = Collections.max(idValues.stream().map(idValue -> Integer.parseInt(idValue.getId())).collect(Collectors.toList())); + makeApplicationOptional = idValues.stream().filter(idValue -> idValue.getId().equals(String.valueOf(targetIndex))).map(idValue -> idValue.getValue()).findAny(); + } + } + } + return makeApplicationOptional; + } + + public boolean isApplicationListed(State state) { + return Arrays.asList( + State.ADJOURNED, + State.PREPARE_FOR_HEARING, + State.FINAL_BUNDLING, + State.PRE_HEARING, + State.DECISION, + State.DECIDED, + State.FTPA_SUBMITTED, + State.FTPA_DECIDED + ).contains(state); + } + + public String mapApplicationTypeToPhrase(MakeAnApplication application) { + return APPLICATION_PHRASE.get(application.getType()); + } + + public Map retrieveApplicationProperties(Optional optionalMakeAnApplication) { + String applicationType = ""; + String applicationDecision = ""; + String applicationDecisionReason = "No reason given"; + if (optionalMakeAnApplication.isPresent()) { + MakeAnApplication makeAnApplication = optionalMakeAnApplication.get(); + applicationType = makeAnApplication.getType(); + applicationDecision = makeAnApplication.getDecision(); + applicationDecisionReason = makeAnApplication.getDecisionReason(); + } + + return Map.of(APPLICATION_TYPE, applicationType, + APPLICATION_DECISION, applicationDecision, + APPLICATION_DECISION_REASON, applicationDecisionReason); + } + + public MakeAnApplicationTypes getApplicationTypes(String applicationType) { + Optional optionalApplicationType = MakeAnApplicationTypes.from(applicationType); + if (optionalApplicationType.isPresent()) { + return optionalApplicationType.get(); + } else { + throw new IllegalStateException("Application type could not be parsed"); + } + } +} + diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/DocumentCreatorConfiguration.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/DocumentCreatorConfiguration.java index 040b4dfdc..2591c5360 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/DocumentCreatorConfiguration.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/DocumentCreatorConfiguration.java @@ -10,6 +10,7 @@ import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentGenerator; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentUploader; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter.*; @Configuration public class DocumentCreatorConfiguration { @@ -203,6 +204,27 @@ public DocumentCreator getHearingNoticeUpdatedDetailsDocumentCreator ); } + @Bean("adaHearingNoticeUpdatedDetails") + public DocumentCreator getAdaHearingNoticeUpdatedDetailsDocumentCreator( + @Value("${adaHearingNoticeUpdatedDetailsDocument.contentType}") String contentType, + @Value("${adaHearingNoticeUpdatedDetailsDocument.fileExtension}") String fileExtension, + @Value("${adaHearingNoticeUpdatedDetailsDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + AdaHearingNoticeUpdatedDetailsTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + @Bean("remoteHearingNoticeUpdatedDetails") public DocumentCreator getRemoteHearingNoticeUpdatedDetailsDocumentCreator( @Value("${remoteHearingNoticeUpdatedDetailsDocument.contentType}") String contentType, @@ -224,6 +246,90 @@ public DocumentCreator getRemoteHearingNoticeUpdatedDetailsDocumentC ); } + @Bean("adaHearingNotice") + public DocumentCreator getAdaHearingNoticeDocumentCreator( + @Value("${hearingNoticeDocument.contentType}") String contentType, + @Value("${hearingNoticeDocument.fileExtension}") String fileExtension, + @Value("${hearingNoticeDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + @Qualifier("adaHearingNoticeTemplate") HearingNoticeTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("adaSuitability") + public DocumentCreator getAdaSuitabilityDocumentCreator( + @Value("${adaSuitabilityDocument.contentType}") String contentType, + @Value("${adaSuitabilityDocument.fileExtension}") String fileExtension, + @Value("${adaSuitabilityDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + AdaSuitabilityTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAdaSuitabilitySuitable") + public DocumentCreator getInternalAdaSuitabilityLetterSuitableDocumentCreator( + @Value("${adaInternalSuitabilityReviewSuitableDocument.contentType}") String contentType, + @Value("${adaInternalSuitabilityReviewSuitableDocument.fileExtension}") String fileExtension, + @Value("${adaInternalSuitabilityReviewSuitableDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAdaSuitabilityReviewSuitableLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAdaSuitabilityUnsuitable") + public DocumentCreator getInternalAdaSuitabilityLetterUnsuitableDocumentCreator( + @Value("${adaInternalSuitabilityReviewUnsuitableDocument.contentType}") String contentType, + @Value("${adaInternalSuitabilityReviewUnsuitableDocument.fileExtension}") String fileExtension, + @Value("${adaInternalSuitabilityReviewUnsuitableDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAdaSuitabilityReviewUnsuitableLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + @Bean("decisionAndReasons") public DocumentCreator getAndDecisionAndReasonsDocumentCreator( @Value("${decisionAndReasons.contentType}") String contentType, @@ -434,4 +540,1077 @@ public DocumentCreator getAppealReasonsDocumentCreator( ); } + @Bean("internalAdaRequestBuildCase") + public DocumentCreator getInternalAdaBuildCaseDocumentCreator( + @Value("${internalAdaRequestBuildCaseDocument.contentType}") String contentType, + @Value("${internalAdaRequestBuildCaseDocument.fileExtension}") String fileExtension, + @Value("${internalAdaRequestBuildCaseDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAdaRequestBuildCaseTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedRequestBuildCase") + public DocumentCreator getInternalDetainedBuildCaseDocumentCreator( + @Value("${internalDetainedRequestBuildCaseDocument.contentType}") String contentType, + @Value("${internalDetainedRequestBuildCaseDocument.fileExtension}") String fileExtension, + @Value("${internalDetainedRequestBuildCaseDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedRequestBuildCaseTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("hoReviewEvidenceLetter") + public DocumentCreator getHoReviewEvidenceLetterCreator( + @Value("${hoReviewEvidenceLetter.contentType}") String contentType, + @Value("${hoReviewEvidenceLetter.fileExtension}") String fileExtension, + @Value("${hoReviewEvidenceLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + HoReviewEvidenceLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedDecisionsAndReasonsAllowed") + public DocumentCreator getInternalDetainedDecisionsAndReasonsAllowedDocumentCreator( + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.contentType}") String contentType, + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedDecisionsAndReasonsAllowedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedDecisionsAndReasonsAllowedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAdaDecisionsAndReasonsDismissed") + public DocumentCreator getInternalAdaDecisionsAndReasonsDismissedDocumentCreator( + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.contentType}") String contentType, + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.fileExtension}") String fileExtension, + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAdaDecisionsAndReasonsDismissedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedDecisionsAndReasonsDismissed") + public DocumentCreator getInternalDetainedDecisionsAndReasonsDismissedDocumentCreator( + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.contentType}") String contentType, + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.fileExtension}") String fileExtension, + @Value("${internalAdaDecisionsAndReasonsDismissedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedDecisionsAndReasonsDismissedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("uploadTheAppealResponseLetter") + public DocumentCreator getUploadAppealResponseMaintainedLetterCreator( + @Value("${uploadAppealResponseMaintainedLetter.contentType}") String contentType, + @Value("${uploadAppealResponseMaintainedLetter.fileExtension}") String fileExtension, + @Value("${uploadAppealResponseMaintainedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + UploadAppealResponseMaintainedDecisionLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetHearingBundle") + public DocumentCreator getInternalDetHearingBundleDocumentCreator( + @Value("${internalAdaHearingBundle.contentType}") String contentType, + @Value("${internalAdaHearingBundle.fileExtension}") String fileExtension, + @Value("${internalAdaHearingBundle.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetGenerateHearingBundleTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAppealSubmission") + public DocumentCreator getInternalAppealSubmissionDocumentCreator( + @Value("${internalAppealSubmissionDocument.contentType}") String contentType, + @Value("${internalAppealSubmissionDocument.fileExtension}") String fileExtension, + @Value("${internalAppealSubmissionDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAppealSubmissionTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAppealCanProceedLetter") + public DocumentCreator getInternalAppealCanProceedLetterCreator( + @Value("${internalAppealCanProceedDocument.contentType}") String contentType, + @Value("${internalAppealCanProceedDocument.fileExtension}") String fileExtension, + @Value("${internalAppealCanProceedDocument.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAppealCanProceedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedRequestRespondentEvidence") + public DocumentCreator getInternalDetainedRequestRespondentEvidenceCreator( + @Value("${internalDetainedRequestRespondentEvidence.contentType}") String contentType, + @Value("${internalDetainedRequestRespondentEvidence.fileExtension}") String fileExtension, + @Value("${internalDetainedRequestRespondentEvidence.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedRequestRespondentEvidenceTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalEndAppealAutomaticallyNotice") + public DocumentCreator getInternalEndAppealAutomaticallyDocumentCreator( + @Value("${internalDetainedEndAppealAutomatically.contentType}") String contentType, + @Value("${internalDetainedEndAppealAutomatically.fileExtension}") String fileExtension, + @Value("${internalDetainedEndAppealAutomatically.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalEndAppealAutomaticallyTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedAppealFeeDue") + public DocumentCreator getinternalDetainedAppealFeeDueCreator( + @Value("${internalDetainedAppealFeeDue.contentType}") String contentType, + @Value("${internalDetainedAppealFeeDue.fileExtension}") String fileExtension, + @Value("${internalDetainedAppealFeeDue.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedAppealFeeDueTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetMarkAsPaidLetter") + public DocumentCreator getInternalDetMarkAsPaidLetterLetterCreator( + @Value("${internalDetainedMarkAppealPaid.contentType}") String contentType, + @Value("${internalDetainedMarkAppealPaid.fileExtension}") String fileExtension, + @Value("${internalDetainedMarkAppealPaid.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetMarkAsPaidLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetter") + public DocumentCreator getInternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterCreator( + @Value("${internalDetainedReviewHomeOfficeResponseMaintainedLetter.contentType}") String contentType, + @Value("${internalDetainedReviewHomeOfficeResponseMaintainedLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedReviewHomeOfficeResponseMaintainedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetter") + public DocumentCreator getInternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterCreator( + @Value("${internalDetainedReviewHomeOfficeResponseWithdrawnLetter.contentType}") String contentType, + @Value("${internalDetainedReviewHomeOfficeResponseWithdrawnLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedReviewHomeOfficeResponseWithdrawnLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedListCase") + public DocumentCreator getInternalDetainedListCaseDocumentCreator( + @Value("${internalDetainedListCaseLetter.contentType}") String contentType, + @Value("${internalDetainedListCaseLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedListCaseLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedListCaseLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + + @Bean("internalDetainedRequestHearingRequirements") + public DocumentCreator getInternalDetainedRequestHearingRequirementsCreator( + @Value("${internalDetainedRequestHearingRequirements.contentType}") String contentType, + @Value("${internalDetainedRequestHearingRequirements.fileExtension}") String fileExtension, + @Value("${internalDetainedRequestHearingRequirements.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedRequestHearingRequirementsTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalEndAppealNotice") + public DocumentCreator getInternalEndAppealDocumentCreator( + @Value("${internalDetainedEndAppeal.contentType}") String contentType, + @Value("${internalDetainedEndAppeal.fileExtension}") String fileExtension, + @Value("${internalDetainedEndAppeal.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalEndAppealTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetEditCaseListingLetter") + public DocumentCreator getInternalDetEditCaseListingLetterCreator( + @Value("${internalDetainedEditCaseListingLetter.contentType}") String contentType, + @Value("${internalDetainedEditCaseListingLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedEditCaseListingLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedEditCaseListingLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalMarkAsAdaNotice") + public DocumentCreator getInternalMarkAsAdaDocumentCreator( + @Value("${internalMarkAppealAsAda.contentType}") String contentType, + @Value("${internalMarkAppealAsAda.fileExtension}") String fileExtension, + @Value("${internalMarkAppealAsAda.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedMarkAsAdaLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDecideAnAppellantApplicationDecisionGrantedLetter") + public DocumentCreator getinternalDecideAnAppellantApplicationDecisionGrantedLetterCreator( + @Value("${internalDecideAnAppellantApplicationDecisionGrantedLetter.contentType}") String contentType, + @Value("${internalDecideAnAppellantApplicationDecisionGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalDecideAnAppellantApplicationDecisionGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDecideHomeOfficeApplicationDecisionGrantedLetter") + public DocumentCreator getinternalDecideHomeOfficeApplicationDecisionGrantedLetterCreator( + @Value("${internalDecideHomeOfficeApplicationDecisionGrantedLetter.contentType}") String contentType, + @Value("${internalDecideHomeOfficeApplicationDecisionGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalDecideHomeOfficeApplicationDecisionGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDecideAnAppellantApplicationDecisionRefusedLetter") + public DocumentCreator getinternalDetainedDecideAnAppellantApplicationDecisionRefusedLetterCreator( + @Value("${internalDecideAnAppellantApplicationDecisionRefusedLetter.contentType}") String contentType, + @Value("${internalDecideAnAppellantApplicationDecisionRefusedLetter.fileExtension}") String fileExtension, + @Value("${internalDecideAnAppellantApplicationDecisionRefusedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDecideHomeOfficeApplicationDecisionRefusedLetter") + public DocumentCreator getinternalDecideHomeOfficeApplicationDecisionRefusedLetterCreator( + @Value("${internalDecideHomeOfficeApplicationDecisionRefusedLetter.contentType}") String contentType, + @Value("${internalDecideHomeOfficeApplicationDecisionRefusedLetter.fileExtension}") String fileExtension, + @Value("${internalDecideHomeOfficeApplicationDecisionRefusedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalApplyForFtpaRespondent") + public DocumentCreator getInternalFtpaSubmittedDocumentCreator( + @Value("${internalDetainedApplyForFtpaRespondentLetter.contentType}") String contentType, + @Value("${internalDetainedApplyForFtpaRespondentLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedApplyForFtpaRespondentLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedApplyForFtpaRespondentLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalDetainedTransferOutOfAdaLetter") + public DocumentCreator getInternalDetainedTransferOutOfAdaLetterCreator( + @Value("${internalDetainedTransferOutOfAdaLetter.contentType}") String contentType, + @Value("${internalDetainedTransferOutOfAdaLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedTransferOutOfAdaLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedTransferOutOfAdaTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalApplyForFtpaAppellantLetter") + public DocumentCreator getInternalApplyForFtpaAppellantLetterCreator( + @Value("${internalApplyForFtpaAppellantLetter.contentType}") String contentType, + @Value("${internalApplyForFtpaAppellantLetter.fileExtension}") String fileExtension, + @Value("${internalApplyForFtpaAppellantLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalApplyForFtpaAppellantLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAppellantFtpaDecidedGrantedLetter") + public DocumentCreator getInternalAppellantFtpaDecidedGrantedLetterCreator( + @Value("${internalAppellantFtpaDecidedGrantedLetter.contentType}") String contentType, + @Value("${internalAppellantFtpaDecidedGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalAppellantFtpaDecidedGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAppellantFtpaDecidedGrantedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHoFtpaDecidedGrantedLetter") + public DocumentCreator getInternalHoFtpaDecidedGrantedDocumentCreator( + @Value("${internalDetainedHoFtpaDecidedGrantedLetter.contentType}") String contentType, + @Value("${internalDetainedHoFtpaDecidedGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedHoFtpaDecidedGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHoFtpaDecidedGrantedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHoFtpaDecidedPartiallyGrantedLetter") + public DocumentCreator getInternalHoFtpaDecidedPartiallyGrantedDocumentCreator( + @Value("${internalDetainedHoFtpaDecidedPartiallyGrantedLetter.contentType}") String contentType, + @Value("${internalDetainedHoFtpaDecidedPartiallyGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedHoFtpaDecidedPartiallyGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHoFtpaDecidedPartiallyGrantedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHoFtpaDecidedRefusedLetter") + public DocumentCreator getInternalHoFtpaDecidedRefusedDocumentCreator( + @Value("${internalDetainedHoFtpaDecidedRefusedLetter.contentType}") String contentType, + @Value("${internalDetainedHoFtpaDecidedRefusedLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedHoFtpaDecidedRefusedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHoFtpaDecidedRefusedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAppellantFtpaDecidedPartiallyGrantedLetter") + public DocumentCreator getInternalAppellantFtpaDecidedPartiallyGrantedLetterCreator( + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.contentType}") String contentType, + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.fileExtension}") String fileExtension, + @Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAppellantFtpaDecidedPartiallyGrantedTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalAppellantFtpaDecidedRefusedLetter") + public DocumentCreator getInternalAppellantFtpaDecidedRefusedLetterCreator( + @Value("${internalAppellantFtpaDecidedRefusedLetter.contentType}") String contentType, + @Value("${internalAppellantFtpaDecidedRefusedLetter.fileExtension}") String fileExtension, + @Value("${internalAppellantFtpaDecidedRefusedLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalAppellantFtpaDecidedRefusedTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHearingAdjustmentsUpdatedLetter") + public DocumentCreator getInternalHearingAdjustmentsUpdatedLetterCreator( + @Value("${internalHearingAdjustmentsUpdated.contentType}") String contentType, + @Value("${internalHearingAdjustmentsUpdated.fileExtension}") String fileExtension, + @Value("${internalHearingAdjustmentsUpdated.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHearingAdjustmentsUpdatedLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalMaintainCaseUnlinkAppealLetter") + public DocumentCreator getInternalMaintainCaseUnlinkAppealLetterCreator( + @Value("${internalDetainedMaintainCaseUnlinkAppeal.contentType}") String contentType, + @Value("${internalDetainedMaintainCaseUnlinkAppeal.fileExtension}") String fileExtension, + @Value("${internalDetainedMaintainCaseUnlinkAppeal.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalMaintainCaseUnlinkAppealTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalUploadAdditionalEvidenceLetter") + public DocumentCreator getInternalUploadAdditionalEvidenceLetterCreator( + @Value("${internalUploadAdditionalEvidence.contentType}") String contentType, + @Value("${internalUploadAdditionalEvidence.fileExtension}") String fileExtension, + @Value("${internalUploadAdditionalEvidence.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalUploadAdditionalEvidenceLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHomeOfficeUploadAdditionalAddendumEvidenceLetter") + public DocumentCreator getInternalHomeOfficeUploadAdditionalAddendumEvidenceLetterCreator( + @Value("${internalHomeOfficeUploadAdditionalAddendumEvidence.contentType}") String contentType, + @Value("${internalHomeOfficeUploadAdditionalAddendumEvidence.fileExtension}") String fileExtension, + @Value("${internalHomeOfficeUploadAdditionalAddendumEvidence.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalLegalOfficerUploadAdditionalEvidenceLetter") + public DocumentCreator getInternalLegalOfficerUploadAdditionalEvidenceLetterCreator( + @Value("${internalLegalOfficerUploadAdditionalEvidence.contentType}") String contentType, + @Value("${internalLegalOfficerUploadAdditionalEvidence.fileExtension}") String fileExtension, + @Value("${internalLegalOfficerUploadAdditionalEvidence.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalMaintainCaseLinkAppealLetter") + public DocumentCreator getInternalMaintainCaseLinkAppealLetterCreator( + @Value("${internalDetainedMaintainCaseLinkAppeal.contentType}") String contentType, + @Value("${internalDetainedMaintainCaseLinkAppeal.fileExtension}") String fileExtension, + @Value("${internalDetainedMaintainCaseLinkAppeal.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalMaintainCaseLinkAppealTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalChangeHearingCentreLetter") + public DocumentCreator getInternalChangeHearingCentreLetterCreator( + @Value("${internalChangeHearingCentreLetter.contentType}") String contentType, + @Value("${internalChangeHearingCentreLetter.fileExtension}") String fileExtension, + @Value("${internalChangeHearingCentreLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalChangeHearingCentreLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalHomeOfficeAmendAppealResponseLetter") + public DocumentCreator getInternalHomeOfficeAmendAppealResponseLetterCreator( + @Value("${internalHomeOfficeAmendAppealResponse.contentType}") String contentType, + @Value("${internalHomeOfficeAmendAppealResponse.fileExtension}") String fileExtension, + @Value("${internalHomeOfficeAmendAppealResponse.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHomeOfficeAmendAppealResponseTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalNonStandardDirectionLetter") + public DocumentCreator getInternalNonStandardDirCreator( + @Value("${internalNonStandardDirectionLetter.contentType}") String contentType, + @Value("${internalNonStandardDirectionLetter.fileExtension}") String fileExtension, + @Value("${internalNonStandardDirectionLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalNonStandardDirectionLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalChangeDueDateLetter") + public DocumentCreator getInternalChangeDueDateLetterCreator( + @Value("${internalChangeDueDateLetter.contentType}") String contentType, + @Value("${internalChangeDueDateLetter.fileExtension}") String fileExtension, + @Value("${internalChangeDueDateLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalChangeDirectionDueDateLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalEditAppealNotice") + public DocumentCreator getInternalEditAppealDocumentCreator( + @Value("${internalDetainedEditAppeal.contentType}") String contentType, + @Value("${internalDetainedEditAppeal.fileExtension}") String fileExtension, + @Value("${internalDetainedEditAppeal.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalEditAppealLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("homeOfficeNonStandardDirectionLetter") + public DocumentCreator getHomeOfficeNonStandardDirCreator( + @Value("${homeOfficeNonStandardDirectionLetter.contentType}") String contentType, + @Value("${homeOfficeNonStandardDirectionLetter.fileExtension}") String fileExtension, + @Value("${homeOfficeNonStandardDirectionLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + HomeOfficeNonStandardDirectionLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + + ); + } + + @Bean("internalHoChangeDueDateLetter") + public DocumentCreator getInternalHoChangeDueDateLetterCreator( + @Value("${internalHoChangeDirectionDueDateLetter.contentType}") String contentType, + @Value("${internalHoChangeDirectionDueDateLetter.fileExtension}") String fileExtension, + @Value("${internalHoChangeDirectionDueDateLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalHoChangeDirectionDueDateLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("internalReinstateAppealLetter") + public DocumentCreator getInternalReinstateAppealLetterCreator( + @Value("${internalDetainedReinstateAppealLetter.contentType}") String contentType, + @Value("${internalDetainedReinstateAppealLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedReinstateAppealLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalReinstateAppealLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + + @Bean("internalAdjournHearingWithoutDateLetter") + public DocumentCreator getInternalAdjournHearingWithoutDateLetter( + @Value("${internalDetainedAdjournHearingWithoutDateLetter.contentType}") String contentType, + @Value("${internalDetainedAdjournHearingWithoutDateLetter.fileExtension}") String fileExtension, + @Value("${internalDetainedAdjournHearingWithoutDateLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + InternalDetainedAdjournHearingWithoutDateLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("updatedDecisionAndReasonsCoverLetter") + public DocumentCreator getUpdatedDecisionAndReasonsCoverLetterDocumentCreator( + @Value("${decisionAndReasonsCoverLetter.contentType}") String contentType, + @Value("${decisionAndReasonsCoverLetter.fileExtension}") String fileExtension, + @Value("${updatedDecisionAndReasonsCoverLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + UpdatedTribunalDecisionAndReasonsCoverLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } + + @Bean("aipUpdatedDecisionAndReasonsCoverLetter") + public DocumentCreator getAipUpdatedDecisionAndReasonsCoverLetterDocumentCreator( + @Value("${aipDecisionAndReasonsCoverLetter.contentType}") String contentType, + @Value("${aipDecisionAndReasonsCoverLetter.fileExtension}") String fileExtension, + @Value("${updatedDecisionAndReasonsCoverLetter.fileName}") String fileName, + AsylumCaseFileNameQualifier fileNameQualifier, + UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate documentTemplate, + DocumentGenerator documentGenerator, + DocumentUploader documentUploader + ) { + return new DocumentCreator<>( + contentType, + fileExtension, + fileName, + fileNameQualifier, + documentTemplate, + documentGenerator, + documentUploader + ); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/HearingNoticeTemplateConfiguration.java b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/HearingNoticeTemplateConfiguration.java index b9a4afe4b..dcb089ba8 100644 --- a/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/HearingNoticeTemplateConfiguration.java +++ b/src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/HearingNoticeTemplateConfiguration.java @@ -33,6 +33,12 @@ public HearingNoticeTemplate getRemoteHearingNoticeTemplate( return new HearingNoticeTemplate(templateName, stringProvider, customerServicesProvider); } + @Bean("adaHearingNoticeTemplate") + public HearingNoticeTemplate getAdaHearingNoticeTemplate( + @Value("${hearingNoticeAdaDocument.templateName}") String templateName, StringProvider stringProvider) { + return new HearingNoticeTemplate(templateName, stringProvider, customerServicesProvider); + } + @Bean("noticeOfAdjournedHearingTemplate") public HearingNoticeTemplate getNoticeOfAdjournedHearingTemplate( @Value("${noticeOfAdjournedHearingDocument.templateName}") String templateName, StringProvider stringProvider) { diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b299ca66c..dfeb7619a 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -70,6 +70,8 @@ hearingNoticeDocument.fileExtension: PDF hearingNoticeDocument.fileName: "hearing-notice" hearingNoticeDocument.templateName: ${IA_HEARING_NOTICE_TEMPLATE:TB-IAC-HNO-ENG-00241.docx} +hearingNoticeAdaDocument.templateName: ${IA_ADA_HEARING_NOTICE_TEMPLATE:TB-IAC-HNO-ENG-ADA-0001.docx} + remoteHearingNoticeDocument.contentType: application/pdf remoteHearingNoticeDocument.fileExtension: PDF remoteHearingNoticeDocument.fileName: "hearing-notice" @@ -100,6 +102,37 @@ hearingNoticeUpdatedDetailsDocument.fileExtension: PDF hearingNoticeUpdatedDetailsDocument.fileName: "hearing-notice" hearingNoticeUpdatedDetailsDocument.templateName: ${IA_HEARING_NOTICE_UPDATED_DETAILS_TEMPLATE:TB-IAC-HNO-ENG-00641.docx} +adaHearingNoticeUpdatedDetailsDocument.contentType: application/pdf +adaHearingNoticeUpdatedDetailsDocument.fileExtension: PDF +adaHearingNoticeUpdatedDetailsDocument.fileName: "hearing-notice" +adaHearingNoticeUpdatedDetailsDocument.templateName: ${IA_ADA_HEARING_NOTICE_UPDATED_DETAILS_TEMPLATE:TB-IAC-HNO-ENG-ADA-0002.docx} + +adaSuitabilityDocument.contentType: application/pdf +adaSuitabilityDocument.fileExtension: PDF +adaSuitabilityDocument.fileName: "ADA-suitability-decision" +adaSuitabilityDocument.templateName: ${IA_ADA_SUITABILITY_TEMPLATE:TB-IAC-DEC-ENG-00001.docx} + +adaInternalSuitabilityReviewSuitableDocument.contentType: application/pdf +adaInternalSuitabilityReviewSuitableDocument.fileExtension: PDF +adaInternalSuitabilityReviewSuitableDocument.fileName: "ADA-Appellant-letter-suitability-decision-suitable" +adaInternalSuitabilityReviewSuitableDocument.templateName: ${IA_ADA_INTERNAL_SUITABILITY_SUITABLE_TEMPLATE:TB-IAC-DEC-ENG-00003.docx} + +adaInternalSuitabilityReviewUnsuitableDocument.contentType: application/pdf +adaInternalSuitabilityReviewUnsuitableDocument.fileExtension: PDF +adaInternalSuitabilityReviewUnsuitableDocument.fileName: "ADA-Appellant-letter-suitability-decision-unsuitable" +adaInternalSuitabilityReviewUnsuitableDocument.templateName: ${IA_ADA_INTERNAL_SUITABILITY_UNSUITABLE_TEMPLATE:TB-IAC-DEC-ENG-00005.docx} + +internalAdaRequestBuildCaseDocument.contentType: application/pdf +internalAdaRequestBuildCaseDocument.fileExtension: PDF +internalAdaRequestBuildCaseDocument.fileName: "ADA appellant letter-appeal reasons" +internalAdaRequestBuildCaseDocument.templateName: ${IA_INTERNAL_ADA_BUILD_CASE_TEMPLATE:TB-IAC-DEC-ENG-00002.docx} +internalAdaRequestBuildCaseDocument.hearingSupportResponseDueInWorkingDays: 15 + +internalDetainedRequestBuildCaseDocument.contentType: application/pdf +internalDetainedRequestBuildCaseDocument.fileExtension: PDF +internalDetainedRequestBuildCaseDocument.fileName: "Appellant letter-detained-appeal reasons" +internalDetainedRequestBuildCaseDocument.templateName: ${IA_INTERNAL_DETAINED_BUILD_CASE_TEMPLATE:TB-IAC-DEC-ENG-00009.docx} + remoteHearingNoticeUpdatedDetailsDocument.contentType: application/pdf remoteHearingNoticeUpdatedDetailsDocument.fileExtension: PDF remoteHearingNoticeUpdatedDetailsDocument.fileName: "hearing-notice" @@ -114,17 +147,38 @@ decisionAndReasonsCoverLetter.contentType: application/pdf decisionAndReasonsCoverLetter.fileExtension: PDF decisionAndReasonsCoverLetter.fileName: "Decision-and-reasons-Cover-letter" decisionAndReasonsCoverLetter.templateName: ${IA_DECISION_AND_REASONS_COVER_LETTER_TEMPLATE:TB-IAC-LET-ENG-00756.docx} +updatedDecisionAndReasonsCoverLetter.fileName: "Decision-and-reasons-Cover-letter-AMENDED" + +internalDetainedDecisionsAndReasonsAllowedLetter.contentType: application/pdf +internalDetainedDecisionsAndReasonsAllowedLetter.fileExtension: PDF +internalDetainedDecisionsAndReasonsAllowedLetter.fileName: "ADA-Appellant-letter-appeal-decided-allowed" +internalDetainedDecisionsAndReasonsAllowedLetter.templateName: ${IA_ADA_INTERNAL_DECISIONS_AND_REASONS_ALLOWED_TEMPLATE:TB-IAC-DEC-ENG-00006.docx} +internalDetainedDecisionsAndReasonsAllowedLetter.ftpaDueInWorkingDays: 7 +internalDetainedDecisionsAndReasonsAllowedLetter.ftpaDueCalendarDays: 14 aipDecisionAndReasonsCoverLetter.contentType: application/pdf aipDecisionAndReasonsCoverLetter.fileExtension: PDF aipDecisionAndReasonsCoverLetter.fileName: "Decision-and-reasons-Cover-letter" aipDecisionAndReasonsCoverLetter.templateName: ${IA_AIP_DECISION_AND_REASONS_COVER_LETTER_TEMPLATE:TB-IAC-LET-ENG-00807.docx} +internalAdaDecisionsAndReasonsDismissedLetter.contentType: application/pdf +internalAdaDecisionsAndReasonsDismissedLetter.fileExtension: PDF +internalAdaDecisionsAndReasonsDismissedLetter.fileName: "ADA-Appellant-letter-appeal-decided-dismissed" +internalAdaDecisionsAndReasonsDismissedLetter.templateName: ${IA_ADA_INTERNAL_DECISIONS_AND_REASONS_DISMISSED_TEMPLATE:TB-IAC-DEC-ENG-00008.docx} +internalDetainedDecisionsAndReasonsDismissedLetter.templateName: ${IA_DET_INTERNAL_DECISIONS_AND_REASONS_DISMISSED_TEMPLATE:TB-IAC-DEC-ENG-00011.docx} +internalAdaDecisionsAndReasonsDismissedLetter.ftpaDueInWorkingDays: 7 +internalDetainedDecisionsAndReasonsDismissedLetter.ftpaDueCalendarDays: 14 + decisionAndReasonsFinalPdf.fileName: "Decision-and-reasons-FINAL" hearingBundle.fileExtension: PDF hearingBundle.fileName: "hearing-bundle" +internalAdaHearingBundle.contentType: application/pdf +internalAdaHearingBundle.fileExtension: PDF +internalAdaHearingBundle.fileName: "ADA appellant hearing bundle" +internalAdaHearingBundle.templateName: ${IA_INTERNAL_ADA_HEARING_BUNDLE_TEMPLATE:TB-IAC-DEC-ENG-00007.docx} + appealSkeletonBundle.fileExtension: PDF appealSkeletonBundle.fileName: "appeal-skeleton-argument" @@ -167,7 +221,7 @@ bailSubmissionDocument.templateName: ${IA_BAIL_SUBMISSION_TEMPLATE:TB-IAC-SUM-EN bailSubmissionDocumentWithUt.contentType: application/pdf bailSubmissionDocumentWithUt.fileExtension: PDF bailSubmissionDocumentWithUt.fileName: "bail-application-details-with-ut" -bailSubmissionDocumentWithUt.templateName: ${IA_BAIL_SUBMISSION_TEMPLATE_WITH_UT:TB-IAC-SUM-ENG-01135.docx} +bailSubmissionDocumentWithUt.templateName: ${IA_BAIL_SUBMISSION_TEMPLATE_WITH_UT:TB-IAC-SUM-ENG-01136.docx} decisionUnsignedDocument.contentType: application/vnd.openxmlformats-officedocument.wordprocessingml.document decisionUnsignedDocument.fileExtension: docx @@ -178,12 +232,231 @@ decisionUnsignedDocument.refusal.templateName: ${IA_BAIL_DECISION_REFUSAL_TEMPLA decisionSignedDocumentFinalPdf.fileName: "decision-notice" +hoReviewEvidenceLetter.contentType: application/pdf +hoReviewEvidenceLetter.fileExtension: PDF +hoReviewEvidenceLetter.fileName: "HO-Review-Evidence-Letter" +hoReviewEvidenceLetter.templateName: ${IA_HO_REVIEW_EVIDENCE_TEMPLATE:TB-IAC-GNO-ENG-00240.docx} + +uploadAppealResponseMaintainedLetter.contentType: application/pdf +uploadAppealResponseMaintainedLetter.fileExtension: PDF +uploadAppealResponseMaintainedLetter.fileName: "HO-Response-Letter" +uploadAppealResponseMaintainedLetter.templateName: ${IA_HO_REVIEW_DECISION_MAINTAINED_TEMPLATE:TB-IAC-DEC-ENG-00004.docx} + +internalDetainedReviewHomeOfficeResponseMaintainedLetter.contentType: application/pdf +internalDetainedReviewHomeOfficeResponseMaintainedLetter.fileExtension: PDF +internalDetainedReviewHomeOfficeResponseMaintainedLetter.fileName: "Detained appellant letter_HO response when decision maintained" +internalDetainedReviewHomeOfficeResponseMaintainedLetter.templateName: ${IA_REVIEW_HO_RESPONSE_DECISION_MAINTAINED_TEMPLATE:TB-IAC-DEC-ENG-00013.doc} +internalDetainedReviewHomeOfficeResponseMaintainedLetter.dueCalendarDays: 5 + +internalDetainedReviewHomeOfficeResponseWithdrawnLetter.contentType: application/pdf +internalDetainedReviewHomeOfficeResponseWithdrawnLetter.fileExtension: PDF +internalDetainedReviewHomeOfficeResponseWithdrawnLetter.fileName: "Detained appellant letter_HO response when decision withdrawn" +internalDetainedReviewHomeOfficeResponseWithdrawnLetter.templateName: ${IA_REVIEW_HO_RESPONSE_DECISION_WITHDRAWN_TEMPLATE:TB-IAC-LET-ENG-00014.docx} bailEndApplication.contentType: application/pdf bailEndApplication.fileExtension: PDF bailEndApplication.fileName: "ended-application-notice" bailEndApplication.templateName: ${IA_BAIL_END_APPLICATION_TEMPLATE:TB-IAC-APP-ENG-01138.docx} +internalAppealSubmissionDocument.contentType: application/pdf +internalAppealSubmissionDocument.fileExtension: PDF +internalAppealSubmissionDocument.fileName: "appeal-form" +internalAppealSubmissionDocument.templateName: ${IA_INTERNAL_APPEAL_SUBMISSION_TEMPLATE:TB-IAC-DEC-ENG-00010.docx} + +internalAppealCanProceedDocument.contentType: application/pdf +internalAppealCanProceedDocument.fileExtension: PDF +internalAppealCanProceedDocument.fileName: "appeal-form" +internalAppealCanProceedDocument.templateName: ${IA_INTERNAL_APPEAL_CAN_PROCEED_TEMPLATE:TB-IAC-DEC-ENG-00012.docx} + +internalDetainedRequestRespondentEvidence.contentType: application/pdf +internalDetainedRequestRespondentEvidence.fileExtension: PDF +internalDetainedRequestRespondentEvidence.fileName: "detained-appellant-request-respondent-evidence-notice" +internalDetainedRequestRespondentEvidence.templateName: ${IA_INTERNAL_DETAINED_REQUEST_RESPONDENT_EVIDENCE_TEMPLATE:TB-IAC-GNO-ENG-00010.docx} + +internalDetainedEndAppealAutomatically.contentType: application/pdf +internalDetainedEndAppealAutomatically.fileExtension: PDF +internalDetainedEndAppealAutomatically.fileName: "detained-appellant-end-appeal-automaticaly-notice" +internalDetainedEndAppealAutomatically.templateName: ${IA_INTERNAL_DETAINED_END_APPEAL_AUTOMATICALLY_TEMPLATE:TB-IAC-LET-ENG-00003.docx} + +internalDetainedAppealFeeDue.contentType: application/pdf +internalDetainedAppealFeeDue.fileExtension: PDF +internalDetainedAppealFeeDue.fileName: "internal-detained-appeal-fee-is-due-letter" +internalDetainedAppealFeeDue.templateName: ${IA_INTERNAL_DETAINED_APPEAL_FEE_IS_DUE_TEMPLATE:TB-IAC-LET-ENG-00001.docx} + +internalDetainedMarkAppealPaid.contentType: application/pdf +internalDetainedMarkAppealPaid.fileExtension: PDF +internalDetainedMarkAppealPaid.fileName: "detained-appellant-mark-appeal-paid-notice" +internalDetainedMarkAppealPaid.templateName: ${IA_INTERNAL_DETAINED_MARK_APPEAL_PAID_TEMPLATE:TB-IAC-LET-ENG-00004.docx} + +internalDetainedListCaseLetter.contentType: application/pdf +internalDetainedListCaseLetter.fileExtension: PDF +internalDetainedListCaseLetter.fileName: "detained-appellant-list-case-letter" +internalDetainedListCaseLetter.templateName: ${IA_INTERNAL_DETAINED_LIST_CASE_LETTER_TEMPLATE:TB-IAC-LET-ENG-00005.docx} + +internalDetainedRequestHearingRequirements.contentType: application/pdf +internalDetainedRequestHearingRequirements.fileExtension: PDF +internalDetainedRequestHearingRequirements.fileName: "detained-appellant-request-hearing-requirements-letter" +internalDetainedRequestHearingRequirements.templateName: ${IA_INTERNAL_DETAINED_REQUEST_HEARING_REQUIREMENTS_TEMPLATE:TB-IAC-LET-ENG-00006.docx} + +internalDetainedEndAppeal.contentType: application/pdf +internalDetainedEndAppeal.fileExtension: PDF +internalDetainedEndAppeal.fileName: "detained-appellant-end-appeal-notice" +internalDetainedEndAppeal.templateName: ${IA_INTERNAL_DETAINED_END_APPEAL_TEMPLATE:TB-IAC-LET-ENG-00007.docx} + +internalDetainedEditCaseListingLetter.contentType: application/pdf +internalDetainedEditCaseListingLetter.fileExtension: PDF +internalDetainedEditCaseListingLetter.fileName: "detained-appellant-edit-case-listing-letter" +internalDetainedEditCaseListingLetter.templateName: ${IA_INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER_TEMPLATE:TB-IAC-HNO-ENG-00700.docx} + +internalMarkAppealAsAda.contentType: application/pdf +internalMarkAppealAsAda.fileExtension: PDF +internalMarkAppealAsAda.fileName: "detained-appellant-mark-as-ada-notice" +internalMarkAppealAsAda.templateName: ${IA_INTERNAL_MARK_APPEAL_AS_ADA_TEMPLATE:TB-IAC-LET-ENG-00008.docx} + +internalDecideAnAppellantApplicationDecisionGrantedLetter.contentType: application/pdf +internalDecideAnAppellantApplicationDecisionGrantedLetter.fileExtension: PDF +internalDecideAnAppellantApplicationDecisionGrantedLetter.fileName: "appellant-letter-application-granted" +internalDecideAnAppellantApplicationDecisionGrantedLetter.templateName: ${IA_INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_DECISION_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00015.docx} + +internalDecideHomeOfficeApplicationDecisionGrantedLetter.contentType: application/pdf +internalDecideHomeOfficeApplicationDecisionGrantedLetter.fileExtension: PDF +internalDecideHomeOfficeApplicationDecisionGrantedLetter.fileName: "respondent-letter-application-granted" +internalDecideHomeOfficeApplicationDecisionGrantedLetter.templateName: ${IA_INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_DECISION_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00024.docx} + +internalDecideAnAppellantApplicationDecisionRefusedLetter.contentType: application/pdf +internalDecideAnAppellantApplicationDecisionRefusedLetter.fileExtension: PDF +internalDecideAnAppellantApplicationDecisionRefusedLetter.fileName: "appellant-letter-application-refused" +internalDecideAnAppellantApplicationDecisionRefusedLetter.templateName: ${IA_INTERNAL_DECIDE_AN_APPLICATION_DECISION_REFUSED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00016.docx} + +internalDecideHomeOfficeApplicationDecisionRefusedLetter.contentType: application/pdf +internalDecideHomeOfficeApplicationDecisionRefusedLetter.fileExtension: PDF +internalDecideHomeOfficeApplicationDecisionRefusedLetter.fileName: "respondent-letter-application-refused" +internalDecideHomeOfficeApplicationDecisionRefusedLetter.templateName: ${IA_INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_DECISION_REFUSED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00025.docx} + +internalDetainedApplyForFtpaRespondentLetter.contentType: application/pdf +internalDetainedApplyForFtpaRespondentLetter.fileExtension: PDF +internalDetainedApplyForFtpaRespondentLetter.fileName: "apply-for-ftpa-respondent-letter" +internalDetainedApplyForFtpaRespondentLetter.templateName: ${IA_INTERNAL_DETAINED_APPLY_FOR_FTPA_RESPONDENT_LETTER_TEMPLATE:TB-IAC-LET-ENG-00009.docx} + +internalDetainedTransferOutOfAdaLetter.contentType: application/pdf +internalDetainedTransferOutOfAdaLetter.fileExtension: PDF +internalDetainedTransferOutOfAdaLetter.fileName: "detained-appellant-transferred-out-of-ada" +internalDetainedTransferOutOfAdaLetter.templateName: ${IA_INTERNAL_DETAINED_TRANSFERRED_OUT_OF_ADA_LETTER_TEMPLATE:TB-IAC-DEC-ENG-00014.docx} + +internalApplyForFtpaAppellantLetter.contentType: application/pdf +internalApplyForFtpaAppellantLetter.fileExtension: PDF +internalApplyForFtpaAppellantLetter.fileName: "apply-for-ftpa-appellant-letter" +internalApplyForFtpaAppellantLetter.templateName: ${IA_INTERNAL_APPLY_FOR_FTPA_APPELLANT_LETTER_TEMPLATE:TB-IAC-LET-ENG-00017.docx} + +internalAppellantFtpaDecidedGrantedLetter.contentType: application/pdf +internalAppellantFtpaDecidedGrantedLetter.fileExtension: PDF +internalAppellantFtpaDecidedGrantedLetter.fileName: "appellant-ftpa-decided-granted-letter" +internalAppellantFtpaDecidedGrantedLetter.templateName: ${IA_INTERNAL_APPELLANT_FTPA_DECIDED_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00018.docx} + +internalDetainedHoFtpaDecidedGrantedLetter.contentType: application/pdf +internalDetainedHoFtpaDecidedGrantedLetter.fileExtension: PDF +internalDetainedHoFtpaDecidedGrantedLetter.fileName: "ho-ftpa-decided-granted-letter" +internalDetainedHoFtpaDecidedGrantedLetter.templateName: ${IA_INTERNAL_DETAINED_HO_FTPA_DECIDED_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00019.docx} + +internalDetainedHoFtpaDecidedPartiallyGrantedLetter.contentType: application/pdf +internalDetainedHoFtpaDecidedPartiallyGrantedLetter.fileExtension: PDF +internalDetainedHoFtpaDecidedPartiallyGrantedLetter.fileName: "ho-ftpa-decided-partially-granted-letter" +internalDetainedHoFtpaDecidedPartiallyGrantedLetter.templateName: ${IA_INTERNAL_DETAINED_HO_FTPA_DECIDED_PARTIALLY_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00021.docx} + +internalDetainedHoFtpaDecidedRefusedLetter.contentType: application/pdf +internalDetainedHoFtpaDecidedRefusedLetter.fileExtension: PDF +internalDetainedHoFtpaDecidedRefusedLetter.fileName: "ho-ftpa-decided-refused-letter" +internalDetainedHoFtpaDecidedRefusedLetter.templateName: ${IA_INTERNAL_DETAINED_HO_FTPA_DECIDED_REFUSED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00022.docx} + +internalAppellantFtpaDecidedPartiallyGrantedLetter.contentType: application/pdf +internalAppellantFtpaDecidedPartiallyGrantedLetter.fileExtension: PDF +internalAppellantFtpaDecidedPartiallyGrantedLetter.fileName: "appellant-ftpa-decided-partially-granted-letter" +internalAppellantFtpaDecidedPartiallyGrantedLetter.templateName: ${IA_INTERNAL_APPELLANT_FTPA_DECIDED_PARTIALLY_GRANTED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00020.docx} +internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaAdaDueWorkingDays: 7 +internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaNonAdaDueCalendarDays: 14 + +internalAppellantFtpaDecidedRefusedLetter.contentType: application/pdf +internalAppellantFtpaDecidedRefusedLetter.fileExtension: PDF +internalAppellantFtpaDecidedRefusedLetter.fileName: "appellant-ftpa-decided-refused-letter" +internalAppellantFtpaDecidedRefusedLetter.templateName: ${IA_INTERNAL_APPELLANT_FTPA_DECIDED_REFUSED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00023.docx} +internalAppellantFtpaDecidedRefusedLetter.ftpaAdaDueWorkingDays: 7 +internalAppellantFtpaDecidedRefusedLetter.ftpaNonAdaDueCalendarDays: 14 + +internalHearingAdjustmentsUpdated.contentType: application/pdf +internalHearingAdjustmentsUpdated.fileExtension: PDF +internalHearingAdjustmentsUpdated.fileName: "hearing-adjustments-updated-letter" +internalHearingAdjustmentsUpdated.templateName: ${IA_INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER_TEMPLATE:TB-IAC-LET-ENG-00030.docx} + +internalDetainedMaintainCaseUnlinkAppeal.contentType: application/pdf +internalDetainedMaintainCaseUnlinkAppeal.fileExtension: PDF +internalDetainedMaintainCaseUnlinkAppeal.fileName: "detained-appellant-maintain-case-unlink-appeal-notice" +internalDetainedMaintainCaseUnlinkAppeal.templateName: ${IA_INTERNAL_DETAINED_MAINTAIN_CASE_UNLINK_APPEAL_TEMPLATE:TB-IAC-LET-ENG-00026.docx} + +internalUploadAdditionalEvidence.contentType: application/pdf +internalUploadAdditionalEvidence.fileExtension: PDF +internalUploadAdditionalEvidence.fileName: "additional-evidence-uploaded-letter" +internalUploadAdditionalEvidence.templateName: ${IA_INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_TEMPLATE:TB-IAC-LET-ENG-00031.docx} + +internalChangeHearingCentreLetter.contentType: application/pdf +internalChangeHearingCentreLetter.fileExtension: PDF +internalChangeHearingCentreLetter.fileName: "appellant-change-hearing-centre-letter" +internalChangeHearingCentreLetter.templateName: ${IA_INTERNAL_CHANGE_HEARING_CENTRE_TEMPLATE:TB-IAC-LET-ENG-00032.docx} + +internalHomeOfficeUploadAdditionalAddendumEvidence.contentType: application/pdf +internalHomeOfficeUploadAdditionalAddendumEvidence.fileExtension: PDF +internalHomeOfficeUploadAdditionalAddendumEvidence.fileName: "appellant letter_HO-evidence" +internalHomeOfficeUploadAdditionalAddendumEvidence.templateName: ${IA_INTERNAL_HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_TEMPLATE:TB-IAC-LET-ENG-00035.docx} + +internalLegalOfficerUploadAdditionalEvidence.contentType: application/pdf +internalLegalOfficerUploadAdditionalEvidence.fileExtension: PDF +internalLegalOfficerUploadAdditionalEvidence.fileName: "appellant letter_LO-evidence" +internalLegalOfficerUploadAdditionalEvidence.templateName: ${IA_INTERNAL_LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_TEMPLATE:TB-IAC-LET-ENG-00036.docx} + +internalDetainedMaintainCaseLinkAppeal.contentType: application/pdf +internalDetainedMaintainCaseLinkAppeal.fileExtension: PDF +internalDetainedMaintainCaseLinkAppeal.fileName: "detained-appellant-maintain-case-link-appeal-notice" +internalDetainedMaintainCaseLinkAppeal.templateName: ${IA_INTERNAL_DETAINED_MAINTAIN_CASE_LINK_APPEAL_TEMPLATE:TB-IAC-LET-ENG-00033.docx} + +internalHomeOfficeAmendAppealResponse.contentType: application/pdf +internalHomeOfficeAmendAppealResponse.fileExtension: PDF +internalHomeOfficeAmendAppealResponse.fileName: "home-office-amend-appeal-response" +internalHomeOfficeAmendAppealResponse.templateName: ${IA_INTERNAL_HOME_OFFICE_AMEND_APPEAL_RESPONSE_TEMPLATE:TB-IAC-LET-ENG-00029.docx} + +internalNonStandardDirectionLetter.contentType: application/pdf +internalNonStandardDirectionLetter.fileExtension: PDF +internalNonStandardDirectionLetter.fileName: "non-standard-direction-to-appellant-letter" +internalNonStandardDirectionLetter.templateName: ${IA_INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER_TEMPLATE:TB-IAC-LET-ENG-00028.docx} + +internalChangeDueDateLetter.contentType: application/pdf +internalChangeDueDateLetter.fileExtension: PDF +internalChangeDueDateLetter.fileName: "appellant-change-direction-due-date-letter" +internalChangeDueDateLetter.templateName: ${IA_INTERNAL_CHANGE_DUE_DATE_LETTER_TEMPLATE :TB-IAC-LET-ENG-00034.docx} + +internalDetainedEditAppeal.contentType: application/pdf +internalDetainedEditAppeal.fileExtension: PDF +internalDetainedEditAppeal.fileName: "detained-appellant-edit-appeal-notice" +internalDetainedEditAppeal.templateName: ${INTERNAL_EDIT_APPEAL_NOTICE_TEMPLATE:TB-IAC-LET-ENG-00038.docx} + +homeOfficeNonStandardDirectionLetter.contentType: application/pdf +homeOfficeNonStandardDirectionLetter.fileExtension: PDF +homeOfficeNonStandardDirectionLetter.fileName: "home-office-non-standard-direction-letter" +homeOfficeNonStandardDirectionLetter.templateName: ${IA_HOME_OFFICE_NON_STANDARD_DIRECTION_LETTER:TB-IAC-LET-ENG-00041.docx} + +internalHoChangeDirectionDueDateLetter.contentType: application/pdf +internalHoChangeDirectionDueDateLetter.fileExtension: PDF +internalHoChangeDirectionDueDateLetter.fileName: "internal-ho-change-direction-due-date-letter" +internalHoChangeDirectionDueDateLetter.templateName: ${IA_INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_TEMPLATE:TB-IAC-LET-ENG-00037.docx} + +internalDetainedReinstateAppealLetter.contentType: application/pdf +internalDetainedReinstateAppealLetter.fileExtension: PDF +internalDetainedReinstateAppealLetter.fileName: "internal-detained-reinstate-appeal-letter" +internalDetainedReinstateAppealLetter.templateName: ${INTERNAL_REINSTATE_APPEAL_LETTER_TEMPLATE:TB-IAC-LET-ENG-00050.docx} + +internalDetainedAdjournHearingWithoutDateLetter.contentType: application/pdf +internalDetainedAdjournHearingWithoutDateLetter.fileExtension: PDF +internalDetainedAdjournHearingWithoutDateLetter.fileName: "internal-detained-adjourn-hearing-without-date-letter" +internalDetainedAdjournHearingWithoutDateLetter.templateName: ${INTERNAL_ADJOURN_HEARING_WITHOUT_DATE_LETTER_TEMPLATE:TB-IAC-LET-ENG-00040.docx} + bailNoticeOfHearing.contentType: application/pdf bailNoticeOfHearing.fileExtension: PDF bailNoticeOfHearing.fileName: "hearing-notice" @@ -237,6 +510,8 @@ security: - "payAndSubmitAppeal" - "submitApplication" - "makeNewApplication" + - "requestHearingRequirementsFeature" + - "applyForFTPAAppellant" caseworker-ia-caseofficer: - "sendDirection" - "changeDirectionDueDate" @@ -258,8 +533,34 @@ security: - "generateHearingBundle" - "customiseHearingBundle" - "recordAdjournmentDetails" + - "requestCaseBuilding" + - "asyncStitchingComplete" + - "recordOutOfTimeDecision" + - "markAppealPaid" + - "requestResponseReview" + - "requestHearingRequirementsFeature" + - "markAppealAsAda" + - "decideAnApplication" + - "transferOutOfAda" + - "maintainCaseLinks" + - "changeHearingCentre" + - "createCaseLink" + - "requestResponseAmend" + - "uploadAddendumEvidence" + - "reinstateAppeal" + - "UpdateHearingAdjustments" + - "buildCase" + - "listCase" + - "draftHearingRequirements" caseworker-ia-admofficer: - "listCase" + - "submitAppeal" + - "editAppeal" + - "draftHearingRequirements" + - "buildCase" + - "submitCase" + - "generateHearingBundle" + - "uploadAdditionalEvidence" - "editCaseListing" - "sendDecisionAndReasons" - "adjournHearingWithoutDate" @@ -274,6 +575,18 @@ security: - "uploadSignedDecisionNotice" - "caseListing" - "recordAdjournmentDetails" + - "editAppealAfterSubmit" + - "markAppealPaid" + - "recordRemissionDecision" + - "markAppealAsAda" + - "applyForFTPAAppellant" + - "maintainCaseLinks" + - "uploadAddendumEvidenceAdminOfficer" + - "createCaseLink" + - "reinstateAppeal" + - "buildCase" + - "caseListing" + - "asyncStitchingComplete" citizen: - "startAppeal" - "editAppeal" @@ -283,7 +596,9 @@ security: - "submitReasonsForAppeal" - "submitClarifyingQuestionAnswers" - "draftHearingRequirements" + - "applyForFTPAAppellant" caseworker-ia-iacjudge: + - "sendDirection" - "generateDecisionAndReasons" - "endAppeal" - "sendDecisionAndReasons" @@ -293,15 +608,47 @@ security: - "recordTheDecision" - "endApplication" - "uploadSignedDecisionNotice" + - "updateTribunalDecision" + - "adaSuitabilityReview" + - "generateHearingBundle" + - "decideAnApplication" + - "transferOutOfAda" + - "residentJudgeFtpaDecision" + - "maintainCaseLinks" + - "createCaseLink" + - "changeDirectionDueDate" + - "reinstateAppeal" + - "UpdateHearingAdjustments" + - "asyncStitchingComplete" caseworker-ia-homeofficebail: - "submitApplication" - "makeNewApplication" caseworker-ia-system: + - "submitReasonsForAppeal" - "endAppealAutomatically" - "listCase" - "editCaseListing" - "caseListing" - "recordAdjournmentDetails" + - "requestHearingRequirementsFeature" + caseworker-ia-homeofficelart: + - "uploadHomeOfficeAppealResponse" + - "uploadAdditionalEvidenceHomeOffice" + - "uploadAddendumEvidenceHomeOffice" + caseworker-ia-homeofficepou: + - "applyForFTPARespondent" + - "uploadAdditionalEvidenceHomeOffice" + - "uploadAddendumEvidenceHomeOffice" + - "submitApplication" + - "makeNewApplication" + caseworker-ia-respondentofficer: + - "applyForFTPARespondent" + - "uploadAdditionalEvidenceHomeOffice" + - "uploadAddendumEvidenceHomeOffice" + - "uploadHomeOfficeAppealResponse" + caseworker-ia-homeofficeapc: + - "uploadAdditionalEvidenceHomeOffice" + - "uploadAddendumEvidenceHomeOffice" ### dependency configuration core_case_data_api_url: ${CCD_URL:http://127.0.0.1:4452} @@ -325,6 +672,11 @@ launchDarkly: customerServices: emailAddress: ${IA_CUSTOMER_SERVICES_EMAIL:contactia@example.com} telephoneNumber: ${IA_CUSTOMER_SERVICES_TELEPHONE:0300 777 7777} + internal: + telephoneNumber: + ada: ${IA_INTERNAL_ADA_CUSTOMER_SERVICES_TELEPHONE:0300 123 1711} + emailAddress: + ada: ${IA_INTERNAL_ADA_CUSTOMER_SERVICES_EMAIL:IAC-ADA-HW@justice.gov.uk} govCallChargesUrl: ${IA_BAIL_GOV_CALL_CHARGES_URL:Find out about call charges|https://www.gov.uk/call-charges} @@ -342,6 +694,10 @@ hearingCentreEmailAddresses: hattonCross: ${IA_HEARING_CENTRE_HATTON_CROSS_EMAIL:hc-hatton-cross@example.com} glasgow: ${IA_HEARING_CENTRE_GLASGOW_EMAIL:hc-glasgow@example.com} belfast: ${IA_HEARING_CENTRE_GLASGOW_EMAIL:hc-glasgow@example.com} + harmondsworth: ${IA_HEARING_CENTRE_HARMONDSWORTH_EMAIL:hc-harmondsworth@example.com} + +govUkHolidays: + url: https://www.gov.uk/ ia: config: diff --git a/src/main/resources/strings.tsv b/src/main/resources/strings.tsv index 78f625c58..f45a857e4 100644 --- a/src/main/resources/strings.tsv +++ b/src/main/resources/strings.tsv @@ -74,6 +74,7 @@ hearingCentreAddress leedsMags Leeds Magistrates' Court and Family Court, Westga hearingCentreAddress alloaSherrif Alloa Sheriff Court, 47 Drysdale Street, Alloa, FK10 1JA hearingCentreAddress remoteHearing Cloud Video Platform (CVP) hearingCentreAddress decisionWithoutHearing No hearing centre +hearingCentreAddress harmondsworth Harmondsworth Tribunal Hearing Centre, Colnbrook Bypass, UB7 0HB isoCountries AF Afghanistan isoCountries AX Aland Islands isoCountries AL Albania diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealDecisionTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealDecisionTest.java index c2ec37792..fe3ab69bb 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealDecisionTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealDecisionTest.java @@ -23,7 +23,6 @@ public void correct_enum_returned_for_valid_values() { @Test public void throws_when_trying_to_create_from_invalid_value() { - assertThatThrownBy(() -> AppealDecision.from("invalid-value")) .isExactlyInstanceOf(IllegalArgumentException.class) .hasMessage("invalid-value not an AppealDecision"); @@ -31,7 +30,6 @@ public void throws_when_trying_to_create_from_invalid_value() { @Test public void correct_string_values_mapped_to_enum() { - assertEquals(AppealDecision.ALLOWED.toString(), "allowed"); assertEquals(AppealDecision.DISMISSED.toString(), "dismissed"); } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealTypeTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealTypeTest.java new file mode 100644 index 000000000..8a9739f9c --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/AppealTypeTest.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Optional; +import org.junit.jupiter.api.Test; + +public class AppealTypeTest { + + @Test + public void has_correct_asylum_appeal_types() { + assertEquals(AppealType.from("revocationOfProtection").get(), AppealType.RP); + assertEquals(AppealType.from("protection").get(), AppealType.PA); + assertEquals(AppealType.from("refusalOfEu").get(), AppealType.EA); + assertEquals(AppealType.from("refusalOfHumanRights").get(), AppealType.HU); + assertEquals(AppealType.from("deprivation").get(), AppealType.DC); + assertEquals(AppealType.from("euSettlementScheme").get(), AppealType.EU); + assertEquals(AppealType.from("ageAssessment").get(), AppealType.AG); + } + + @Test + public void returns_optional_for_unknown_appeal_type() { + assertEquals(AppealType.from("some_unknown_type"), Optional.empty()); + } + + @Test + public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(7, AppealType.values().length); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasonsTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasonsTest.java new file mode 100644 index 000000000..5b2073776 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DecisionAndReasonsTest.java @@ -0,0 +1,42 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +class DecisionAndReasonsTest { + + private final String updatedDecisionDate = "some-date"; + private final String dateCoverLetterDocumentUploaded = "some-date"; + private final Document coverLetterDocument = mock(Document.class); + private final String dateDocumentAndReasonsDocumentUploaded = "some-other-date"; + private final String summariseChanges = "summarise-example"; + private final Document documentAndReasonsDocument = mock(Document.class); + + private DecisionAndReasons decisionAndReasons; + + @BeforeEach + public void setUp() { + decisionAndReasons = new DecisionAndReasons( + updatedDecisionDate, + dateCoverLetterDocumentUploaded, + coverLetterDocument, + dateDocumentAndReasonsDocumentUploaded, + documentAndReasonsDocument, + summariseChanges); + } + + @Test + void should_hold_onto_values() { + + assertThat(decisionAndReasons.getUpdatedDecisionDate()).isEqualTo(updatedDecisionDate); + assertThat(decisionAndReasons.getDateCoverLetterDocumentUploaded()).isEqualTo(dateCoverLetterDocumentUploaded); + assertThat(decisionAndReasons.getCoverLetterDocument()).isEqualTo(coverLetterDocument); + assertThat(decisionAndReasons.getDateDocumentAndReasonsDocumentUploaded()).isEqualTo(dateDocumentAndReasonsDocumentUploaded); + assertThat(decisionAndReasons.getDocumentAndReasonsDocument()).isEqualTo(documentAndReasonsDocument); + assertThat(decisionAndReasons.getSummariseChanges()).isEqualTo(summariseChanges); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTagTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTagTest.java index 7d8f246b8..c3284a224 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTagTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DirectionTagTest.java @@ -22,10 +22,11 @@ public void has_correct_values() { assertEquals("requestClarifyingQuestions", DirectionTag.REQUEST_CLARIFYING_QUESTIONS.toString()); assertEquals("requestCmaRequirements", DirectionTag.REQUEST_CMA_REQUIREMENTS.toString()); assertEquals("", DirectionTag.NONE.toString()); + assertEquals("adaListCase", DirectionTag.ADA_LIST_CASE.toString()); } @Test public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { - assertEquals(14, DirectionTag.values().length); + assertEquals(15, DirectionTag.values().length); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTagTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTagTest.java index 61df1e74e..17752cfde 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTagTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentTagTest.java @@ -4,10 +4,10 @@ import org.junit.jupiter.api.Test; -public class DocumentTagTest { +class DocumentTagTest { @Test - public void has_correct_values() { + void has_correct_values() { assertEquals("caseArgument", DocumentTag.CASE_ARGUMENT.toString()); assertEquals("respondentEvidence", DocumentTag.RESPONDENT_EVIDENCE.toString()); assertEquals("appealResponse", DocumentTag.APPEAL_RESPONSE.toString()); @@ -27,11 +27,17 @@ public void has_correct_values() { assertEquals("cmaRequirements", DocumentTag.CMA_REQUIREMENTS.toString()); assertEquals("cmaNotice", DocumentTag.CMA_NOTICE.toString()); assertEquals("homeOfficeDecisionLetter", DocumentTag.HO_DECISION_LETTER.toString()); + assertEquals("finalDecisionAndReasonsDocument", DocumentTag.FINAL_DECISION_AND_REASONS_DOCUMENT.toString()); assertEquals("recordOutOfTimeDecisionDocument", DocumentTag.RECORD_OUT_OF_TIME_DECISION_DOCUMENT.toString()); assertEquals("upperTribunalBundle", DocumentTag.UPPER_TRIBUNAL_BUNDLE.toString()); assertEquals("appealReasons", DocumentTag.APPEAL_REASONS.toString()); assertEquals("clarifyingQuestions", DocumentTag.CLARIFYING_QUESTIONS.toString()); assertEquals("noticeOfAdjournedHearing", DocumentTag.NOTICE_OF_ADJOURNED_HEARING.toString()); + assertEquals("appealForm", DocumentTag.APPEAL_FORM.toString()); + assertEquals("noticeOfDecisionUtTransfer", DocumentTag.NOTICE_OF_DECISION_UT_TRANSFER.toString()); + assertEquals("remittalDecision", DocumentTag.REMITTAL_DECISION.toString()); + assertEquals("decisionAndReasonsCoverLetter", DocumentTag.DECISION_AND_REASONS_COVER_LETTER.toString()); + assertEquals("updatedDecisionAndReasonsCoverLetter", DocumentTag.UPDATED_DECISION_AND_REASONS_COVER_LETTER.toString()); assertEquals("bailSubmission", DocumentTag.BAIL_SUBMISSION.toString()); assertEquals("uploadTheBailEvidenceDocs", DocumentTag.BAIL_EVIDENCE.toString()); assertEquals("bailDecisionUnsigned", DocumentTag.BAIL_DECISION_UNSIGNED.toString()); @@ -40,12 +46,50 @@ public void has_correct_values() { assertEquals("uploadDocument", DocumentTag.UPLOAD_DOCUMENT.toString()); assertEquals("uploadBailSummary", DocumentTag.BAIL_SUMMARY.toString()); assertEquals("b1Document", DocumentTag.B1_DOCUMENT.toString()); + assertEquals("updatedFinalDecisionAndReasonsPdf", DocumentTag.UPDATED_FINAL_DECISION_AND_REASONS_PDF.toString()); assertEquals("bailNoticeOfHearing", DocumentTag.BAIL_NOTICE_OF_HEARING.toString()); + assertEquals("requestCaseBuilding", DocumentTag.REQUEST_CASE_BUILDING.toString()); + assertEquals("internalAdaSuitability", DocumentTag.INTERNAL_ADA_SUITABILITY.toString()); + assertEquals("requestRespondentReview", DocumentTag.REQUEST_RESPONDENT_REVIEW.toString()); + assertEquals("internalDetDecisionAndReasonsLetter", DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER.toString()); + assertEquals("uploadTheAppealResponse", DocumentTag.UPLOAD_THE_APPEAL_RESPONSE.toString()); + assertEquals("hearingBundleReadyLetter", DocumentTag.HEARING_BUNDLE_READY_LETTER.toString()); + assertEquals("internalAppealSubmission", DocumentTag.INTERNAL_APPEAL_SUBMISSION.toString()); + assertEquals("internalEndAppealAutomatically", DocumentTag.INTERNAL_END_APPEAL_AUTOMATICALLY.toString()); + assertEquals("internalAppealFeeDueLetter", DocumentTag.INTERNAL_APPEAL_FEE_DUE_LETTER.toString()); + assertEquals("internalDetMarkAsPaidLetter", DocumentTag.INTERNAL_DET_MARK_AS_PAID_LETTER.toString()); + assertEquals("internalListCaseLetter", DocumentTag.INTERNAL_LIST_CASE_LETTER.toString()); + assertEquals("internalRequestHearingRequirementsLetter", DocumentTag.INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER.toString()); + assertEquals("internalDetainedRequestHomeOfficeResponseReview", DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW.toString()); + assertEquals("internalDetainedEditCaseListingLetter", DocumentTag.INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER.toString()); + assertEquals("internalDetMarkAsAdaLetter", DocumentTag.INTERNAL_DET_MARK_AS_ADA_LETTER.toString()); + assertEquals("internalDecideAnAppellantApplicationLetter", DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER.toString()); + assertEquals("internalApplyForFtpaRespondent", DocumentTag.INTERNAL_APPLY_FOR_FTPA_RESPONDENT.toString()); + assertEquals("internalDetainedTransferOutOfAdaLetter", DocumentTag.INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER.toString()); + assertEquals("internalFtpaSubmittedAppellantLetter", DocumentTag.INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER.toString()); + assertEquals("internalAppellantFtpaDecidedLetter", DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER.toString()); + assertEquals("internalHoFtpaDecidedLetter", DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER.toString()); + assertEquals("internalHearingAdjustmentsUpdatedLetter", DocumentTag.INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER.toString()); + assertEquals("maintainCaseUnlinkAppealLetter", DocumentTag.MAINTAIN_CASE_UNLINK_APPEAL_LETTER.toString()); + assertEquals("internalUploadAdditionalEvidenceLetter", DocumentTag.INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER.toString()); + assertEquals("internalChangeHearingCentreLetter", DocumentTag.INTERNAL_CHANGE_HEARING_CENTRE_LETTER.toString()); + assertEquals("maintainCaseLinkAppealLetter", DocumentTag.MAINTAIN_CASE_LINK_APPEAL_LETTER.toString()); + assertEquals("amendHomeOfficeAppealResponse", DocumentTag.AMEND_HOME_OFFICE_APPEAL_RESPONSE.toString()); + assertEquals("internalNonStandardDirectionToAppellantLetter", DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER.toString()); + assertEquals("internalChangeDirectionDueDateLetter", DocumentTag.INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER.toString()); + assertEquals("internalEditAppealLetter", DocumentTag.INTERNAL_EDIT_APPEAL_LETTER.toString()); + assertEquals("homeOfficeUploadAdditionalAddendumEvidenceLetter", DocumentTag.HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER.toString()); + assertEquals("legalOfficerUploadAdditionalEvidenceLetter", DocumentTag.LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER.toString()); + assertEquals("internalHoChangeDirectionDueDateLetter", DocumentTag.INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER.toString()); + assertEquals("internalReinstateAppealLetter", DocumentTag.INTERNAL_REINSTATE_APPEAL_LETTER.toString()); + assertEquals("internalAdjournHearingWithoutDate", DocumentTag.INTERNAL_ADJOURN_HEARING_WITHOUT_DATE.toString()); + assertEquals("upperTribunalTransferOrderDocument", DocumentTag.UPPER_TRIBUNAL_TRANSFER_ORDER_DOCUMENT.toString()); + assertEquals("iAUT2Form", DocumentTag.IAUT_2_FORM.toString()); assertEquals("", DocumentTag.NONE.toString()); } @Test public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { - assertEquals(39, DocumentTag.values().length); + assertEquals(86, DocumentTag.values().length); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadataTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadataTest.java index e8ba1a263..98ddc23d5 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadataTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/DocumentWithMetadataTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; -public class DocumentWithMetadataTest { +class DocumentWithMetadataTest { private final Document document = mock(Document.class); private final String description = "Some evidence"; @@ -14,19 +14,20 @@ public class DocumentWithMetadataTest { private final DocumentTag tag = DocumentTag.CASE_ARGUMENT; private DocumentWithMetadata documentWithMetadata = - new DocumentWithMetadata( - document, - description, - dateUploaded, - tag,"test" - ); + new DocumentWithMetadata( + document, + description, + dateUploaded, + tag + ); @Test - public void should_hold_onto_values() { + void should_hold_onto_values() { assertEquals(document, documentWithMetadata.getDocument()); assertEquals(description, documentWithMetadata.getDescription()); assertEquals(dateUploaded, documentWithMetadata.getDateUploaded()); assertEquals(tag, documentWithMetadata.getTag()); } + } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppealsTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppealsTest.java new file mode 100644 index 000000000..c0195f4c0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/HasOtherAppealsTest.java @@ -0,0 +1,36 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.Optional; +import org.junit.jupiter.api.Test; + +class HasOtherAppealsTest { + + @Test + public void has_correct_hasOtherappeals_value() { + assertEquals(HasOtherAppeals.from("Yes").get(), HasOtherAppeals.YES); + assertEquals(HasOtherAppeals.from("YesWithoutAppealNumber").get(), HasOtherAppeals.YES_WITHOUT_APPEAL_NUMBER); + assertEquals(HasOtherAppeals.from("No").get(), HasOtherAppeals.NO); + assertEquals(HasOtherAppeals.from("NotSure").get(), HasOtherAppeals.NOT_SURE); + } + + @Test + public void has_correct_string_values_for_hasOtherappeals() { + assertEquals("Yes", HasOtherAppeals.YES.toString()); + assertEquals("YesWithoutAppealNumber", HasOtherAppeals.YES_WITHOUT_APPEAL_NUMBER.toString()); + assertEquals("No", HasOtherAppeals.NO.toString()); + assertEquals("NotSure", HasOtherAppeals.NOT_SURE.toString()); + } + + @Test + public void returns_optional_for_unknown_hasOtherappeals_value() { + assertEquals(HasOtherAppeals.from("unknown_value"), Optional.empty()); + } + + @Test + public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(4, HasOtherAppeals.values().length); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTest.java new file mode 100644 index 000000000..c0e47b2cc --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTest.java @@ -0,0 +1,95 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + + +@ExtendWith(MockitoExtension.class) +public class MakeAnApplicationTest { + + private final String type = "Adjourn"; + private final String details = "Some application text"; + private final List> evidence = Collections.emptyList(); + private final String applicant = "Legal representative"; + private final String date = "2020-09-21"; + private final String decision = "Pending"; + private final String state = "LISTING"; + private final String applicantRole = UserRole.LEGAL_REPRESENTATIVE.toString(); + + public MakeAnApplication makeAnApplication = + new MakeAnApplication( + applicant, + type, + details, + evidence, + date, + decision, + state, + applicantRole + ); + + @Test + public void should_hold_onto_values() { + assertEquals(type, makeAnApplication.getType()); + assertEquals(details, makeAnApplication.getDetails()); + assertEquals(evidence, makeAnApplication.getEvidence()); + assertEquals(applicant, makeAnApplication.getApplicant()); + assertEquals(date, makeAnApplication.getDate()); + assertEquals(decision, makeAnApplication.getDecision()); + assertEquals(state, makeAnApplication.getState()); + assertEquals(applicantRole, makeAnApplication.getApplicantRole()); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> new MakeAnApplication( + null, type, details, evidence, + date, decision, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, null, details, evidence, + date, decision, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, null, evidence, + date, decision, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, details, null, + date, decision, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, details, evidence, + null, decision, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, details, evidence, + date, null, state, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, details, evidence, + date, decision, null, applicantRole)) + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> new MakeAnApplication( + applicant, type, details, evidence, + date, decision, state, null)) + .isExactlyInstanceOf(NullPointerException.class); + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypesTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypesTest.java new file mode 100644 index 000000000..963eb5d1a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/MakeAnApplicationTypesTest.java @@ -0,0 +1,33 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class MakeAnApplicationTypesTest { + + @Test + void has_correct_values() { + assertEquals("Adjourn", MakeAnApplicationTypes.ADJOURN.toString()); + assertEquals("Expedite", MakeAnApplicationTypes.EXPEDITE.toString()); + assertEquals("Link/unlink appeals", MakeAnApplicationTypes.LINK_OR_UNLINK.toString()); + assertEquals("Judge's review of application decision", MakeAnApplicationTypes.JUDGE_REVIEW.toString()); + assertEquals("Judge's review of Legal Officer decision", MakeAnApplicationTypes.JUDGE_REVIEW_LO.toString()); + assertEquals("Time extension", MakeAnApplicationTypes.TIME_EXTENSION.toString()); + assertEquals("Transfer", MakeAnApplicationTypes.TRANSFER.toString()); + assertEquals("Withdraw", MakeAnApplicationTypes.WITHDRAW.toString()); + assertEquals("Update hearing requirements", MakeAnApplicationTypes.UPDATE_HEARING_REQUIREMENTS.toString()); + assertEquals("Update appeal details", MakeAnApplicationTypes.UPDATE_APPEAL_DETAILS.toString()); + assertEquals("Reinstate an ended appeal", MakeAnApplicationTypes.REINSTATE.toString()); + assertEquals("Transfer out of accelerated detained appeals process", + MakeAnApplicationTypes.TRANSFER_OUT_OF_ACCELERATED_DETAINED_APPEALS_PROCESS.toString()); + assertEquals("Other", MakeAnApplicationTypes.OTHER.toString()); + } + + @Test + void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(13, MakeAnApplicationTypes.values().length); + } +} + + diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocumentsTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocumentsTest.java new file mode 100644 index 000000000..82eee3c3f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ReheardHearingDocumentsTest.java @@ -0,0 +1,39 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static com.google.common.collect.Lists.newArrayList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +class ReheardHearingDocumentsTest { + + private final Document document = mock(Document.class); + private final String description = "Some evidence"; + private final String dateUploaded = "2018-12-25"; + private final DocumentTag tag = DocumentTag.CASE_ARGUMENT; + private final DocumentWithMetadata documentWithMetadata = + new DocumentWithMetadata( + document, + description, + dateUploaded, + tag, + "test" + ); + private List> reheardHearingDocs = newArrayList(new IdValue<>("1", documentWithMetadata)); + private ReheardHearingDocuments reheardHearingDocuments; + + @BeforeEach + public void setUp() { + reheardHearingDocuments = new ReheardHearingDocuments(reheardHearingDocs); + } + + @Test + void should_hold_onto_values() { + assertThat(reheardHearingDocuments.getReheardHearingDocs()).isEqualTo(reheardHearingDocs); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecisionTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecisionTest.java new file mode 100644 index 000000000..fde65d308 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionDecisionTest.java @@ -0,0 +1,20 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +class RemissionDecisionTest { + + @Test + void has_correct_values() { + assertEquals("approved", RemissionDecision.APPROVED.toString()); + assertEquals("partiallyApproved", RemissionDecision.PARTIALLY_APPROVED.toString()); + assertEquals("rejected", RemissionDecision.REJECTED.toString()); + } + + @Test + void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(3, RemissionDecision.values().length); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionTypeTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionTypeTest.java new file mode 100644 index 000000000..55ff596a3 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/RemissionTypeTest.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class RemissionTypeTest { + + @Test + void has_correct_values() { + assertEquals("noRemission", RemissionType.NO_REMISSION.toString()); + assertEquals("hoWaiverRemission", RemissionType.HO_WAIVER_REMISSION.toString()); + assertEquals("helpWithFees", RemissionType.HELP_WITH_FEES.toString()); + assertEquals("exceptionalCircumstancesRemission", RemissionType.EXCEPTIONAL_CIRCUMSTANCES_REMISSION.toString()); + } + + @Test + void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(4, RemissionType.values().length); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/EventTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/EventTest.java index 894f4924c..9217b4506 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/EventTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/EventTest.java @@ -43,6 +43,7 @@ public void has_correct_values() { assertEquals("submitReasonsForAppeal", Event.SUBMIT_REASONS_FOR_APPEAL.toString()); assertEquals("submitClarifyingQuestionAnswers",Event.SUBMIT_CLARIFYING_QUESTION_ANSWERS.toString()); assertEquals("recordAdjournmentDetails", Event.RECORD_ADJOURNMENT_DETAILS.toString()); + assertEquals("updateTribunalDecision",Event.UPDATE_TRIBUNAL_DECISION.toString()); assertEquals("submitApplication",Event.SUBMIT_APPLICATION.toString()); assertEquals("recordTheDecision",Event.RECORD_THE_DECISION.toString()); assertEquals("endApplication",Event.END_APPLICATION.toString()); @@ -51,10 +52,32 @@ public void has_correct_values() { assertEquals("uploadSignedDecisionNotice", Event.UPLOAD_SIGNED_DECISION_NOTICE.toString()); assertEquals("caseListing", Event.CASE_LISTING.toString()); assertEquals("unknown", Event.UNKNOWN.toString()); + assertEquals("requestCaseBuilding", Event.REQUEST_CASE_BUILDING.toString()); + assertEquals("uploadHomeOfficeAppealResponse", Event.UPLOAD_HOME_OFFICE_APPEAL_RESPONSE.toString()); + assertEquals("recordOutOfTimeDecision", Event.RECORD_OUT_OF_TIME_DECISION.toString()); + assertEquals("markAppealPaid", Event.MARK_APPEAL_PAID.toString()); + assertEquals("recordRemissionDecision", Event.RECORD_REMISSION_DECISION.toString()); + assertEquals("requestHearingRequirementsFeature", Event.REQUEST_HEARING_REQUIREMENTS_FEATURE.toString()); + assertEquals("markAppealAsAda", Event.MARK_APPEAL_AS_ADA.toString()); + assertEquals("decideAnApplication", Event.DECIDE_AN_APPLICATION.toString()); + assertEquals("applyForFTPARespondent", Event.APPLY_FOR_FTPA_RESPONDENT.toString()); + assertEquals("transferOutOfAda", Event.TRANSFER_OUT_OF_ADA.toString()); + assertEquals("applyForFTPAAppellant", Event.APPLY_FOR_FTPA_APPELLANT.toString()); + assertEquals("residentJudgeFtpaDecision", Event.RESIDENT_JUDGE_FTPA_DECISION.toString()); + assertEquals("maintainCaseLinks", Event.MAINTAIN_CASE_LINKS.toString()); + assertEquals("uploadAddendumEvidenceAdminOfficer", Event.UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER.toString()); + assertEquals("changeHearingCentre", Event.CHANGE_HEARING_CENTRE.toString()); + assertEquals("createCaseLink", Event.CREATE_CASE_LINK.toString()); + assertEquals("requestResponseAmend", Event.REQUEST_RESPONSE_AMEND.toString()); + assertEquals("uploadAdditionalEvidenceHomeOffice", Event.UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE.toString()); + assertEquals("uploadAddendumEvidenceHomeOffice", Event.UPLOAD_ADDENDUM_EVIDENCE_HOME_OFFICE.toString()); + assertEquals("uploadAddendumEvidence", Event.UPLOAD_ADDENDUM_EVIDENCE.toString()); + assertEquals("reinstateAppeal", Event.REINSTATE_APPEAL.toString()); + assertEquals("updateHearingAdjustments", Event.UPDATE_HEARING_ADJUSTMENTS.toString()); } @Test public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { - assertEquals(43, Event.values().length); + assertEquals(69, Event.values().length); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/StateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/StateTest.java index 6d56a96dc..250d77aff 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/StateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/StateTest.java @@ -9,6 +9,7 @@ public class StateTest { @Test public void has_correct_values() { assertEquals("appealStarted", State.APPEAL_STARTED.toString()); + assertEquals("appealStartedByAdmin", State.APPEAL_STARTED_BY_ADMIN.toString()); assertEquals("appealSubmitted", State.APPEAL_SUBMITTED.toString()); assertEquals("appealSubmittedOutOfTime", State.APPEAL_SUBMITTED_OUT_OF_TIME.toString()); assertEquals("awaitingRespondentEvidence", State.AWAITING_RESPONDENT_EVIDENCE.toString()); @@ -27,11 +28,14 @@ public void has_correct_values() { assertEquals("unknown", State.UNKNOWN.toString()); assertEquals("awaitingCmaRequirements", State.AWAITING_CMA_REQUIREMENTS.toString()); assertEquals("cmaAdjustmentsAgreed", State.CMA_ADJUSTMENTS_AGREED.toString()); + assertEquals("pendingPayment", State.PENDING_PAYMENT.toString()); + assertEquals("adjourned", State.ADJOURNED.toString()); + assertEquals("ftpaSubmitted", State.FTPA_SUBMITTED.toString()); } @Test public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { - assertEquals(19, State.values().length); + assertEquals(24, State.values().length); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatusTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatusTest.java new file mode 100644 index 000000000..42ae4bc23 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/entities/ccd/field/BailApplicationStatusTest.java @@ -0,0 +1,21 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class BailApplicationStatusTest { + + @Test + public void has_correct_values() { + assertEquals("Yes", BailApplicationStatus.YES.toString()); + assertEquals("YesWithoutBailApplicationNumber", BailApplicationStatus.YES_WITHOUT_BAIL_APPLICATION_NUMBER.toString()); + assertEquals("No", BailApplicationStatus.NO.toString()); + assertEquals("NotSure", BailApplicationStatus.NOT_SURE.toString()); + } + + @Test + public void if_this_test_fails_it_is_because_it_needs_updating_with_your_changes() { + assertEquals(4, BailApplicationStatus.values().length); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandlerTest.java index a7e318f7a..c50d086f4 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AdvancedBundlingCallbackHandlerTest.java @@ -14,17 +14,17 @@ import java.util.Collections; import java.util.List; import java.util.Optional; +import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; 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; @@ -33,13 +33,15 @@ import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentsAppender; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients.EmBundleRequestExecutor; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.Bundle; @ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") -@MockitoSettings(strictness = Strictness.WARN) +@MockitoSettings(strictness = Strictness.LENIENT) class AdvancedBundlingCallbackHandlerTest { @Mock private EmBundleRequestExecutor emBundleRequestExecutor; @@ -48,6 +50,9 @@ class AdvancedBundlingCallbackHandlerTest { @Mock private AsylumCase asylumCase; @Mock private PreSubmitCallbackResponse callbackResponse; @Mock private Document document; + @Mock private DocumentsAppender documentsAppender; + @Mock private FeatureToggler featureToggler; + @Mock private List> latestRemittalDocs; private String emBundlerUrl = "bundleurl"; private String emBundlerStitchUri = "stitchingUri"; @@ -62,7 +67,9 @@ void setUp() { new AdvancedBundlingCallbackHandler( emBundlerUrl, emBundlerStitchUri, - emBundleRequestExecutor); + emBundleRequestExecutor, + documentsAppender, + featureToggler); when(callback.getEvent()).thenReturn(Event.GENERATE_HEARING_BUNDLE); when(callback.getCaseDetails()).thenReturn(caseDetails); @@ -81,9 +88,11 @@ void setUp() { caseBundles.add(new IdValue<>("1", bundle)); } - @Test - void should_successfully_handle_the_callback() { - + @ParameterizedTest + @ValueSource(strings = {"", "SUITABLE", "UNSUITABLE"}) + void should_successfully_handle_the_callback(String maybeDecision) { + when(asylumCase.read(SUITABILITY_REVIEW_DECISION)).thenReturn(maybeDecision.isEmpty() + ? Optional.empty() : Optional.of(AdaSuitabilityReviewDecision.valueOf(maybeDecision))); PreSubmitCallbackResponse callbackResponse = advancedBundlingCallbackHandler.handle(ABOUT_TO_SUBMIT, callback); @@ -97,7 +106,8 @@ void should_successfully_handle_the_callback() { verify(asylumCase).clear(AsylumCaseDefinition.HMCTS); verify(asylumCase).write(AsylumCaseDefinition.HMCTS, "[userImage:hmcts.png]"); verify(asylumCase).clear(AsylumCaseDefinition.CASE_BUNDLES); - verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-hearing-bundle-config.yaml"); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + maybeDecision.isEmpty() ? "iac-hearing-bundle-config.yaml" : "iac-hearing-bundle-inc-tribunal-config.yaml"); verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, "PA 50002 2020-" + appellantFamilyName); } @@ -139,9 +149,105 @@ void should_successfully_handle_the_callback_in_reheard() { verify(asylumCase, times(1)).read(ADDITIONAL_EVIDENCE_DOCUMENTS); verify(asylumCase, times(1)).read(RESPONDENT_DOCUMENTS); + verify(asylumCase, never()).read(TRIBUNAL_DOCUMENTS); verify(asylumCase).write(AsylumCaseDefinition.APP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); verify(asylumCase).write(AsylumCaseDefinition.RESP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); + } + + @Test + void should_successfully_handle_the_callback_in_reheard_and_remitted_all_data_present() { + + final List> reheardDecisionDocs = buildReheardDocuments(); + final List> reheardHearingDocs = buildReheardDocuments(); + final List> remittalDocuments = buildRemittalDocuments(); + + DocumentWithMetadata addendumEvidenceAppellantDocument = new DocumentWithMetadata( + document, "test","2020-12-12", DocumentTag.ADDENDUM_EVIDENCE, "The appellant"); + DocumentWithMetadata addendumEvidenceRespondentDocument = new DocumentWithMetadata( + document, "test","2020-12-12", DocumentTag.ADDENDUM_EVIDENCE, "The respondent"); + List> documents = new ArrayList<>(); + documents.add(new IdValue<>("0", addendumEvidenceAppellantDocument)); + documents.add(new IdValue<>("1", addendumEvidenceRespondentDocument)); + + when(asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.of(documents)); + when(featureToggler.getValue("dlrm-remitted-feature-flag", false)).thenReturn(true); + when(asylumCase.read(REHEARD_DECISION_REASONS_COLLECTION)).thenReturn(Optional.of(reheardDecisionDocs)); + when(asylumCase.read(REHEARD_HEARING_DOCUMENTS_COLLECTION)).thenReturn(Optional.of(reheardHearingDocs)); + when(asylumCase.read(REMITTAL_DOCUMENTS)).thenReturn(Optional.of(remittalDocuments)); + when(documentsAppender.append(remittalDocuments.get(0).getValue().getOtherRemittalDocs(), + Collections.singletonList(remittalDocuments.get(0).getValue().getDecisionDocument()))) + .thenReturn(latestRemittalDocs); + + PreSubmitCallbackResponse callbackResponse = + advancedBundlingCallbackHandler.handle(ABOUT_TO_SUBMIT, callback); + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(asylumCase, times(1)).read(APPEAL_REFERENCE_NUMBER, String.class); + verify(asylumCase, times(1)).read(APPELLANT_FAMILY_NAME, String.class); + + verify(asylumCase, times(1)).write(STITCHING_STATUS, "NEW"); + verify(asylumCase).clear(AsylumCaseDefinition.CASE_BUNDLES); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-remitted-reheard-hearing-bundle-config.yaml"); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, "PA 50002 2020-" + appellantFamilyName); + + documents.remove(1); + verify(asylumCase, times(2)).read(ADDENDUM_EVIDENCE_DOCUMENTS); + verify(asylumCase).write(AsylumCaseDefinition.APPELLANT_ADDENDUM_EVIDENCE_DOCS, documents); + documents.clear(); + documents.add(new IdValue("1", addendumEvidenceRespondentDocument)); + + verify(asylumCase, times(1)).read(ADDITIONAL_EVIDENCE_DOCUMENTS); + verify(asylumCase, times(1)).read(RESPONDENT_DOCUMENTS); + verify(asylumCase).write(AsylumCaseDefinition.APP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); + verify(asylumCase).write(AsylumCaseDefinition.RESP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); + verify(asylumCase).write(LATEST_DECISION_AND_REASONS_DOCUMENTS, reheardDecisionDocs.get(0).getValue().getReheardHearingDocs()); + verify(asylumCase).write(LATEST_REHEARD_HEARING_DOCUMENTS, reheardHearingDocs.get(0).getValue().getReheardHearingDocs()); + verify(asylumCase).write(LATEST_REMITTAL_DOCUMENTS, latestRemittalDocs); + verify(asylumCase).clear(LATEST_DECISION_AND_REASONS_DOCUMENTS); + verify(asylumCase).clear(LATEST_REMITTAL_DOCUMENTS); + verify(asylumCase).clear(LATEST_REHEARD_HEARING_DOCUMENTS); + } + + @Test + void should_successfully_handle_the_callback_in_reheard_and_remitted_minimum_data_present() { + IdValue finalDecisionsAndReasonsDoc = + new IdValue<>("1", + new DocumentWithMetadata(document, "test","2020-12-12", + DocumentTag.FTPA_DECISION_AND_REASONS, "The appellant")); + final List> finalDecisionsAndReasonsDocs = + Lists.newArrayList(finalDecisionsAndReasonsDoc); + + when(asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.empty()); + when(featureToggler.getValue("dlrm-remitted-feature-flag", false)).thenReturn(true); + when(asylumCase.read(REHEARD_DECISION_REASONS_COLLECTION)).thenReturn(Optional.empty()); + when(asylumCase.read(FINAL_DECISION_AND_REASONS_DOCUMENTS)).thenReturn(Optional.of(finalDecisionsAndReasonsDocs)); + + PreSubmitCallbackResponse callbackResponse = + advancedBundlingCallbackHandler.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(asylumCase, times(1)).read(APPEAL_REFERENCE_NUMBER, String.class); + verify(asylumCase, times(1)).read(APPELLANT_FAMILY_NAME, String.class); + + verify(asylumCase, times(1)).write(STITCHING_STATUS, "NEW"); + verify(asylumCase).clear(AsylumCaseDefinition.CASE_BUNDLES); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-remitted-reheard-hearing-bundle-config.yaml"); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, "PA 50002 2020-" + appellantFamilyName); + + verify(asylumCase).write(AsylumCaseDefinition.APP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); + verify(asylumCase).write(AsylumCaseDefinition.RESP_ADDITIONAL_EVIDENCE_DOCS, Collections.emptyList()); + verify(asylumCase).write(LATEST_DECISION_AND_REASONS_DOCUMENTS, finalDecisionsAndReasonsDocs); + verify(asylumCase).write(LATEST_REHEARD_HEARING_DOCUMENTS, Collections.emptyList()); + verify(asylumCase).write(LATEST_REMITTAL_DOCUMENTS, Collections.emptyList()); + verify(asylumCase).clear(LATEST_DECISION_AND_REASONS_DOCUMENTS); + verify(asylumCase).clear(LATEST_REMITTAL_DOCUMENTS); + verify(asylumCase).clear(LATEST_REHEARD_HEARING_DOCUMENTS); } @Test @@ -240,4 +346,41 @@ void should_not_allow_null_arguments() { .hasMessage("callback must not be null") .isExactlyInstanceOf(NullPointerException.class); } + + private List> buildReheardDocuments() { + String description = "Some evidence"; + String dateUploaded = "2018-12-25"; + final DocumentWithMetadata coverLetterDocumentWithMetadata = new DocumentWithMetadata( + document, description, dateUploaded, DocumentTag.DECISION_AND_REASONS_COVER_LETTER, ""); + final DocumentWithMetadata decisionDocumentWithMetadata = new DocumentWithMetadata( + document, description, dateUploaded, DocumentTag.FINAL_DECISION_AND_REASONS_PDF, ""); + + IdValue decisionDocWithMetadata = + new IdValue<>("2", decisionDocumentWithMetadata); + IdValue coverLetterDocWithMetadata = + new IdValue<>("1", coverLetterDocumentWithMetadata); + final List> listOfDocumentsWithMetadata = Lists.newArrayList(decisionDocWithMetadata, coverLetterDocWithMetadata); + IdValue reheardHearingDocuments = + new IdValue<>("1", new ReheardHearingDocuments(listOfDocumentsWithMetadata)); + return Lists.newArrayList(reheardHearingDocuments); + } + + private List> buildRemittalDocuments() { + + final DocumentWithMetadata remittalDec = new DocumentWithMetadata( + document, "test","2023-12-12", DocumentTag.REMITTAL_DECISION, ""); + final DocumentWithMetadata remittalOtherDoc1 = new DocumentWithMetadata( + document, "other-test-1","2023-12-12", DocumentTag.REMITTAL_DECISION, ""); + final DocumentWithMetadata remittalOtherDoc2 = new DocumentWithMetadata( + document, "other-test-1","2023-12-12", DocumentTag.REMITTAL_DECISION, ""); + IdValue decisionDocWithMetadata = + new IdValue<>("11", remittalOtherDoc1); + IdValue coverLetterDocWithMetadata = + new IdValue<>("12", remittalOtherDoc2); + + final List> listOfDocumentsWithMetadata = Lists.newArrayList(decisionDocWithMetadata, coverLetterDocWithMetadata); + IdValue remittalDocuments = + new IdValue<>("1", new RemittalDocument(remittalDec, listOfDocumentsWithMetadata)); + return Lists.newArrayList(remittalDocuments); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreatorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreatorTest.java index 6fd5bc2e4..8d7669d42 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/AppealSubmissionCreatorTest.java @@ -4,14 +4,17 @@ import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.PaymentStatus.PAID; import java.util.Arrays; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; 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; @@ -19,6 +22,8 @@ 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.entities.ccd.field.PaymentStatus; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; @@ -27,6 +32,7 @@ public class AppealSubmissionCreatorTest { @Mock private DocumentCreator appealSubmissionDocumentCreator; + @Mock private DocumentCreator internalAppealSubmissionDocumentCreator; @Mock private DocumentHandler documentHandler; @Mock private Callback callback; @@ -42,6 +48,7 @@ public void setUp() { appealSubmissionCreator = new AppealSubmissionCreator( appealSubmissionDocumentCreator, + internalAppealSubmissionDocumentCreator, documentHandler ); } @@ -220,4 +227,50 @@ public void should_not_allow_null_arguments() { .hasMessage("callback must not be null") .isExactlyInstanceOf(NullPointerException.class); } + + @Test + public void should_call_internal_appeal_submission_creator_when_case_is_internal_non_ada_appealant_in_detention() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(AsylumCaseDefinition.PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PAID)); + + when(asylumCase.read(PA_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.of("payOffline")); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + PreSubmitCallbackResponse callbackResponse = + appealSubmissionCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(internalAppealSubmissionDocumentCreator, times(1)).create(caseDetails); + verify(documentHandler, times(1)).addWithMetadata(eq(asylumCase), any(), eq(NOTIFICATION_ATTACHMENT_DOCUMENTS), eq(DocumentTag.INTERNAL_APPEAL_SUBMISSION)); + } + + @Test + public void should_generate_internal_appeal_summary_and_det_letter_when_case_is_internal_non_ada_appellant_in_detention() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(AsylumCaseDefinition.PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PAID)); + when(asylumCase.read(PA_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.of("payOffline")); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + PreSubmitCallbackResponse callbackResponse = + appealSubmissionCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(appealSubmissionDocumentCreator, times(1)).create(caseDetails); + verify(documentHandler, times(1)).addWithMetadata(eq(asylumCase), any(), eq(LEGAL_REPRESENTATIVE_DOCUMENTS), eq(DocumentTag.APPEAL_SUBMISSION)); + + verify(internalAppealSubmissionDocumentCreator, times(1)).create(caseDetails); + verify(documentHandler, times(1)).addWithMetadata(eq(asylumCase), any(), eq(NOTIFICATION_ATTACHMENT_DOCUMENTS), eq(DocumentTag.INTERNAL_APPEAL_SUBMISSION)); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandlerTest.java index d52b383f5..bff6c294a 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundleHandlerTest.java @@ -8,43 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyList; -import static org.mockito.Mockito.anyString; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.ADDENDUM_EVIDENCE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.ADDITIONAL_EVIDENCE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CASE_BUNDLES; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CASE_FLAG_SET_ASIDE_REHEARD_EXISTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_APP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FINAL_DECISION_AND_REASONS_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FTPA_APPELLANT_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FTPA_RESPONDENT_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_HEARING_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_LEGAL_REP_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_REHEARD_HEARING_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_RESPONDENT_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_RESP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.FINAL_DECISION_AND_REASONS_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.FTPA_APPELLANT_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.FTPA_RESPONDENT_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HEARING_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HMCTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REPRESENTATIVE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REHEARD_HEARING_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.RESPONDENT_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.RESPONDENT_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.RESP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.STITCHING_STATUS; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_START; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_SUBMIT; @@ -59,16 +24,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithDescription; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; 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; @@ -160,14 +123,18 @@ public void setUp() throws JsonProcessingException { when(dateProvider.now()).thenReturn(LocalDate.now()); } - @Test - void should_successfully_handle_the_callback() throws JsonProcessingException { + @ParameterizedTest + @ValueSource(strings = {"", "SUITABLE", "UNSUITABLE"}) + void should_successfully_handle_the_callback(String maybeDecision) throws JsonProcessingException { + when(asylumCase.read(SUITABILITY_REVIEW_DECISION)).thenReturn(maybeDecision.isEmpty() + ? Optional.empty() : Optional.of(AdaSuitabilityReviewDecision.valueOf(maybeDecision))); IdValue legalRepDoc = new IdValue<>("1", createDocumentWithDescription()); IdValue respondentDoc = new IdValue<>("1", createDocumentWithDescription()); IdValue hearingDoc = new IdValue<>("1", createDocumentWithDescription()); IdValue additionalEvidenceDoc = new IdValue<>("1", createDocumentWithDescription()); - + List> tribunalDocumentList = asList( + new IdValue("1", createDocumentWithMetadata(DocumentTag.ADA_SUITABILITY, "test"))); when(asylumCaseCopy.read(CUSTOM_HEARING_DOCUMENTS)).thenReturn(Optional.of(Lists.newArrayList(hearingDoc))); when(asylumCaseCopy.read(CUSTOM_LEGAL_REP_DOCUMENTS)).thenReturn(Optional.of(Lists.newArrayList(legalRepDoc))); @@ -175,6 +142,8 @@ void should_successfully_handle_the_callback() throws JsonProcessingException { .thenReturn(Optional.of(Lists.newArrayList(respondentDoc))); when(asylumCaseCopy.read(CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS)) .thenReturn(Optional.of(Lists.newArrayList(additionalEvidenceDoc))); + when(asylumCase.read(CUSTOM_TRIBUNAL_DOCUMENTS)) + .thenReturn(Optional.of(tribunalDocumentList)); IdValue legalRepDocWithMetadata = new IdValue<>("1", createDocumentWithMetadata(DocumentTag.ADDITIONAL_EVIDENCE, "test")); @@ -210,6 +179,8 @@ void should_successfully_handle_the_callback() throws JsonProcessingException { verify(asylumCaseCopy, times(2)).read(CUSTOM_LEGAL_REP_DOCUMENTS); verify(asylumCaseCopy, times(2)).read(CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS); verify(asylumCaseCopy, times(2)).read(CUSTOM_RESPONDENT_DOCUMENTS); + verify(asylumCaseCopy, maybeDecision.isEmpty() ? never() : times(1)) + .read(CUSTOM_TRIBUNAL_DOCUMENTS); verify(asylumCase, times(1)).write(HEARING_DOCUMENTS, hearingDocuments); verify(asylumCase, times(1)).write(LEGAL_REPRESENTATIVE_DOCUMENTS, legalRepresentativeDocuments); @@ -221,7 +192,8 @@ void should_successfully_handle_the_callback() throws JsonProcessingException { verify(asylumCase, times(1)).clear(AsylumCaseDefinition.CASE_BUNDLES); verify(asylumCase, times(1)).write(CASE_BUNDLES, Optional.of(caseBundles)); - verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-hearing-bundle-config.yaml"); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + maybeDecision.isEmpty() ? "iac-hearing-bundle-config.yaml" : "iac-hearing-bundle-inc-tribunal-config.yaml"); verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, "PA 50002 2020-" + appellantFamilyName); verify(asylumCase, times(1)).write(STITCHING_STATUS, "NEW"); verify(objectMapper, times(1)).readValue(anyString(), eq(AsylumCase.class)); diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparerTest.java index fcaa3ffe2..321a8cc46 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/CustomiseHearingBundlePreparerTest.java @@ -14,20 +14,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.ADDENDUM_EVIDENCE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CASE_FLAG_SET_ASIDE_REHEARD_EXISTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_APP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FINAL_DECISION_AND_REASONS_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FTPA_APPELLANT_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_FTPA_RESPONDENT_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_LEGAL_REP_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_REHEARD_HEARING_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CUSTOM_RESP_ADDITIONAL_EVIDENCE_DOCS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REPRESENTATIVE_DOCUMENTS; -import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.RESP_ADDITIONAL_EVIDENCE_DOCS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; import java.util.ArrayList; import java.util.List; @@ -36,17 +23,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithDescription; -import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; 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; @@ -90,9 +75,12 @@ void setUp() { when(caseDetails.getCaseData()).thenReturn(asylumCase); } - @Test - void should_create_custom_collections() { + @ParameterizedTest + @ValueSource(strings = {"", "SUITABLE", "UNSUITABLE"}) + void should_create_custom_collections(String maybeDecision) { when(callback.getEvent()).thenReturn(Event.CUSTOMISE_HEARING_BUNDLE); + when(asylumCase.read(SUITABILITY_REVIEW_DECISION)).thenReturn(maybeDecision.isEmpty() + ? Optional.empty() : Optional.of(AdaSuitabilityReviewDecision.valueOf(maybeDecision))); List> customCollections = asList(new IdValue("1", createDocumentWithDescription())); @@ -104,6 +92,9 @@ void should_create_custom_collections() { new IdValue("2", createDocumentWithMetadata(DocumentTag.APPEAL_SUBMISSION, "tes")), new IdValue("3", createDocumentWithMetadata(DocumentTag.CASE_SUMMARY, "test"))); + List> tribunalDocumentList = asList( + new IdValue("1", createDocumentWithMetadata(DocumentTag.ADA_SUITABILITY, "test"))); + List> additionalEvidenceList = asList(new IdValue("1", createDocumentWithMetadata(DocumentTag.ADDITIONAL_EVIDENCE, "test"))); List> respondentList = @@ -124,6 +115,9 @@ void should_create_custom_collections() { when(asylumCase.read(AsylumCaseDefinition.RESPONDENT_DOCUMENTS)) .thenReturn(Optional.of(respondentList)); + when(asylumCase.read(AsylumCaseDefinition.TRIBUNAL_DOCUMENTS)) + .thenReturn(Optional.of(tribunalDocumentList)); + customiseHearingBundlePreparer.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback); verify(asylumCase).write(AsylumCaseDefinition.CUSTOM_HEARING_DOCUMENTS, customCollections); @@ -132,7 +126,8 @@ void should_create_custom_collections() { verify(asylumCase).write(AsylumCaseDefinition.CUSTOM_RESPONDENT_DOCUMENTS, customCollections); verify(asylumCase,times(0)).write(AsylumCaseDefinition.CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS,customCollections); verify(asylumCase,times(0)).read(AsylumCaseDefinition.ADDENDUM_EVIDENCE_DOCUMENTS); - + verify(asylumCase,times(maybeDecision.isEmpty() ? 0 : 1)) + .write(AsylumCaseDefinition.CUSTOM_TRIBUNAL_DOCUMENTS,customCollections); } @Test @@ -203,7 +198,7 @@ void should_create_custom_collections_in_reheard_case() { verify(asylumCase).write(CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS, customDocumentList); verify(asylumCase,times(1)).write(AsylumCaseDefinition.CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS,customDocumentList); verify(asylumCase,times(4)).read(AsylumCaseDefinition.ADDENDUM_EVIDENCE_DOCUMENTS); - + verify(asylumCase, never()).read(TRIBUNAL_DOCUMENTS); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreatorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreatorTest.java index 3ed11145b..e005bd2a2 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeCreatorTest.java @@ -2,43 +2,79 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import java.util.Collections; +import java.util.List; import java.util.Optional; +import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; 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.DocumentWithMetadata; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ReheardHearingDocuments; 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.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.Appender; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentReceiver; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentsAppender; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler; @ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) @SuppressWarnings("unchecked") class HearingNoticeCreatorTest { @Mock private DocumentCreator hearingNoticeDocumentCreator; @Mock private DocumentCreator remoteHearingNoticeDocumentCreator; + @Mock private DocumentCreator adaHearingNoticeDocumentCreator; @Mock private DocumentHandler documentHandler; @Mock private Callback callback; @Mock private CaseDetails caseDetails; @Mock private AsylumCase asylumCase; @Mock private Document uploadedDocument; + @Mock + private FeatureToggler featureToggler; + @Mock private DocumentReceiver documentReceiver; + @Mock private DocumentsAppender documentsAppender; + @Mock + private Appender reheardAppender; + + private final Document document = mock(Document.class); + private final String description = "Some evidence"; + private final String dateUploaded = "2018-12-25"; + private final DocumentTag tag = DocumentTag.CASE_ARGUMENT; + private final DocumentWithMetadata documentWithMetadata = + new DocumentWithMetadata( + document, + description, + dateUploaded, + tag, + "test" + ); private HearingNoticeCreator hearingNoticeCreator; @@ -49,8 +85,14 @@ public void setUp() { new HearingNoticeCreator( hearingNoticeDocumentCreator, remoteHearingNoticeDocumentCreator, - documentHandler + adaHearingNoticeDocumentCreator, + documentHandler, + featureToggler, + documentReceiver, + documentsAppender, + reheardAppender ); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); } @Test @@ -138,6 +180,63 @@ void should_create_remote_hearing_notice_pdf_and_append_to_reheard_hearing_docum verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments(asylumCase, uploadedDocument, REHEARD_HEARING_DOCUMENTS, DocumentTag.REHEARD_HEARING_NOTICE); } + @Test + void should_create_hearing_notice_pdf_and_append_to_hearing_documents_for_ada_case() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.LIST_CASE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(adaHearingNoticeDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.HARMONDSWORTH)); + when(asylumCase.read(IS_REHEARD_APPEAL_ENABLED, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + PreSubmitCallbackResponse callbackResponse = + hearingNoticeCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(adaHearingNoticeDocumentCreator, times(1)).create(caseDetails); + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments(asylumCase, uploadedDocument, HEARING_DOCUMENTS, DocumentTag.HEARING_NOTICE); + } + + @Test + void should_create_hearing_notice_pdf_and_append_to_reheard_hearing_documents_complex_collection() { + + IdValue hearingDocWithMetadata = + new IdValue<>("1", documentWithMetadata); + final List> listOfDocumentsWithMetadata = Lists.newArrayList(hearingDocWithMetadata); + IdValue reheardHearingDocuments = + new IdValue<>("1", new ReheardHearingDocuments(listOfDocumentsWithMetadata)); + final List> listOfReheardDocs = Lists.newArrayList(reheardHearingDocuments); + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.LIST_CASE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(hearingNoticeDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.TAYLOR_HOUSE)); + when(asylumCase.read(IS_REHEARD_APPEAL_ENABLED, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(featureToggler.getValue("dlrm-remitted-feature-flag", false)).thenReturn(true); + when(documentReceiver.receive(uploadedDocument, "", DocumentTag.REHEARD_HEARING_NOTICE)).thenReturn(documentWithMetadata); + when(documentsAppender.append(Collections.emptyList(), Collections.singletonList(documentWithMetadata))).thenReturn(listOfDocumentsWithMetadata); + when(asylumCase.read(REHEARD_HEARING_DOCUMENTS_COLLECTION)).thenReturn(Optional.of(Collections.emptyList())); + when(reheardAppender.append(any(ReheardHearingDocuments.class), anyList())).thenReturn(listOfReheardDocs); + + PreSubmitCallbackResponse callbackResponse = + hearingNoticeCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(hearingNoticeDocumentCreator, times(1)).create(caseDetails); + verify(documentReceiver, times(1)).receive(uploadedDocument, "", DocumentTag.REHEARD_HEARING_NOTICE); + verify(documentsAppender, times(1)).append(Collections.emptyList(), Collections.singletonList(documentWithMetadata)); + verify(reheardAppender, times(1)).append(any(ReheardHearingDocuments.class), anyList()); + verify(asylumCase, times(1)).write(REHEARD_HEARING_DOCUMENTS_COLLECTION, listOfReheardDocs); + } + @Test void handling_should_throw_if_cannot_actually_handle() { diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreatorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreatorTest.java index c64066d1e..2c0b20fe1 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/HearingNoticeEditedCreatorTest.java @@ -32,6 +32,7 @@ class HearingNoticeEditedCreatorTest { @Mock private DocumentCreator hearingNoticeUpdatedRequirementsDocumentCreator; @Mock private DocumentCreator hearingNoticeUpdatedDetailsDocumentCreator; @Mock private DocumentCreator remoteHearingNoticeUpdatedDetailsDocumentCreator; + @Mock private DocumentCreator adaHearingNoticeUpdatedDetailsDocumentCreator; @Mock private HearingDetailsFinder hearingDetailsFinder; @Mock private DocumentHandler documentHandler; @Mock private Callback callback; @@ -53,6 +54,7 @@ public void setUp() { hearingNoticeUpdatedRequirementsDocumentCreator, hearingNoticeUpdatedDetailsDocumentCreator, remoteHearingNoticeUpdatedDetailsDocumentCreator, + adaHearingNoticeUpdatedDetailsDocumentCreator, documentHandler, hearingDetailsFinder ); @@ -103,6 +105,8 @@ void should_create_hearing_notice_pdf_and_append_to_legal_representative_documen when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.TAYLOR_HOUSE)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + final String listCaseHearingCentre = hearingCentreNameBefore; final String hearingDate = oldHearingDate; @@ -138,6 +142,8 @@ void should_create_hearing_notice_pdf_and_append_to_legal_representative_documen when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.REMOTE_HEARING)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + final String listCaseHearingCentre = hearingCentreNameBefore; final String hearingDate = oldHearingDate; @@ -174,6 +180,8 @@ void should_create_hearing_notice_pdf_and_append_to_legal_representative_documen when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.REMOTE_HEARING)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + final String listCaseHearingCentre = hearingCentreNameBefore; final String hearingDate = oldHearingDate; @@ -211,6 +219,8 @@ void should_create_reheard_hearing_notice_pdf_and_append_to_legal_representative when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.TAYLOR_HOUSE)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + final String listCaseHearingCentre = hearingCentreNameBefore; final String hearingDate = oldHearingDate; @@ -293,6 +303,39 @@ void should_create_hearing_notice_pdf_for_updated_hearing_centre_and_append_to_l //verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments(asylumCase, uploadedDocument, HEARING_DOCUMENTS, DocumentTag.HEARING_NOTICE); } + @Test + void should_create_hearing_notice_pdf_for_ada_updated_hearing_centre_and_append_to_legal_representative_documents_for_the_case() { + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(callback.getEvent()).thenReturn(Event.EDIT_CASE_LISTING); + when(callback.getCaseDetails()).thenReturn(caseDetails); + + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + final String listCaseHearingCentre = HearingCentre.GLASGOW.toString(); + final String hearingDate = oldHearingDate; + + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(hearingDetailsFinder.getHearingCentreName(caseDetailsBefore.getCaseData())).thenReturn(hearingCentreNameBefore); + when(hearingDetailsFinder.getHearingDateTime(caseDetailsBefore.getCaseData())).thenReturn(oldHearingDate); + when(hearingDetailsFinder.getHearingCentreName(caseDetails.getCaseData())).thenReturn(listCaseHearingCentre); + when(hearingDetailsFinder.getHearingDateTime(caseDetails.getCaseData())).thenReturn(hearingDate); + + PreSubmitCallbackResponse callbackResponse = + hearingNoticeEditedCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(remoteHearingNoticeUpdatedDetailsDocumentCreator, times(0)).create(caseDetails, caseDetailsBefore); + verify(hearingNoticeUpdatedDetailsDocumentCreator, times(0)).create(caseDetails, caseDetailsBefore); + verify(hearingNoticeUpdatedRequirementsDocumentCreator, times(0)).create(caseDetails, caseDetailsBefore); + verify(adaHearingNoticeUpdatedDetailsDocumentCreator, times(1)).create(caseDetails, caseDetailsBefore); + //verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments(asylumCase, uploadedDocument, HEARING_DOCUMENTS, DocumentTag.HEARING_NOTICE); + } + @Test void should_throw_when_no_previous_case_data_exists() { when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGeneratorTest.java new file mode 100644 index 000000000..d95d75c99 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewSuitableLetterGeneratorTest.java @@ -0,0 +1,225 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAdaSuitabilityReviewSuitableLetterGeneratorTest { + + @Mock private DocumentCreator internalAdaSuitabilitySuitableDocumentCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private InternalAdaSuitabilityReviewSuitableLetterGenerator internalAdaSuitabilityReviewSuitableLetterGenerator; + + @BeforeEach + public void setUp() { + internalAdaSuitabilityReviewSuitableLetterGenerator = + new InternalAdaSuitabilityReviewSuitableLetterGenerator( + internalAdaSuitabilitySuitableDocumentCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_ada_suitability_suitable_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADA_SUITABILITY_REVIEW); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.of(AdaSuitabilityReviewDecision.SUITABLE)); + + when(internalAdaSuitabilitySuitableDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalAdaSuitabilityReviewSuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_ADA_SUITABILITY); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_ada_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_suitability_decision_is_unsuitable() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.of(AdaSuitabilityReviewDecision.UNSUITABLE)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_suitability_decision_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_suitability_decision_is_not_present() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADA_SUITABILITY_REVIEW); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.empty()); + + when(internalAdaSuitabilitySuitableDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("ADA suitability decision is missing."); + } + + @Test + public void it_should_only_handle_about_to_submit_and_ada_suitability_review_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.ADA_SUITABILITY_REVIEW)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewSuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGeneratorTest.java new file mode 100644 index 000000000..ca2a118c5 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalAdaSuitabilityReviewUnsuitableLetterGeneratorTest.java @@ -0,0 +1,215 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAdaSuitabilityReviewUnsuitableLetterGeneratorTest { + + @Mock private DocumentCreator internalAdaSuitabilityUnsuitableDocumentCreator; + @Mock private DocumentHandler documentHandler; + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + + private InternalAdaSuitabilityReviewUnsuitableLetterGenerator internalAdaSuitabilityReviewUnsuitableLetterGenerator; + + @BeforeEach + public void setUp() { + internalAdaSuitabilityReviewUnsuitableLetterGenerator = + new InternalAdaSuitabilityReviewUnsuitableLetterGenerator( + internalAdaSuitabilityUnsuitableDocumentCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_ada_suitability_unsuitable_document_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADA_SUITABILITY_REVIEW); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.of(AdaSuitabilityReviewDecision.UNSUITABLE)); + + when(internalAdaSuitabilityUnsuitableDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_ADA_SUITABILITY); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_ada_is_missing() { + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_suitability_decision_is_suitable() { + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.of(AdaSuitabilityReviewDecision.SUITABLE)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_suitability_decision_is_not_present() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADA_SUITABILITY_REVIEW); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.empty()); + + when(internalAdaSuitabilityUnsuitableDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("ADA suitability decision is missing."); + } + + @Test + public void it_cannot_handle_callback_if_suitability_decision_is_missing() { + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_ada_suitability_review_event() { + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(callbackStage, callback); + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.ADA_SUITABILITY_REVIEW)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaSuitabilityReviewUnsuitableLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGeneratorTest.java new file mode 100644 index 000000000..7df2af4f1 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedDecisionsAndReasonsLetterGeneratorTest.java @@ -0,0 +1,241 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealDecision; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedDecisionsAndReasonsLetterGeneratorTest { + + @Mock private DocumentCreator internalAdaDecisionsAndReasonsLetterAllowedDocumentCreator; + @Mock private DocumentCreator internalAdaDecisionsAndReasonsLetterDismissedDocumentCreator; + @Mock private DocumentCreator internalDetainedDecisionsAndReasonsLetterDismissedCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private InternalDetainedDecisionsAndReasonsLetterGenerator internalDetainedDecisionsAndReasonsLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedDecisionsAndReasonsLetterGenerator = + new InternalDetainedDecisionsAndReasonsLetterGenerator( + internalAdaDecisionsAndReasonsLetterAllowedDocumentCreator, + internalAdaDecisionsAndReasonsLetterDismissedDocumentCreator, + internalDetainedDecisionsAndReasonsLetterDismissedCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_appeal_decided_allowed_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DECISION_AND_REASONS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_DECISION_ALLOWED, AppealDecision.class)).thenReturn(Optional.of(AppealDecision.ALLOWED)); + + when(internalAdaDecisionsAndReasonsLetterAllowedDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER); + } + + @Test + public void should_call_internal_detained_ada_decisions_and_reasons_letter_dismissed_creator() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DECISION_AND_REASONS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_DECISION_ALLOWED, AppealDecision.class)).thenReturn(Optional.of(AppealDecision.DISMISSED)); + + internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + verify(internalAdaDecisionsAndReasonsLetterDismissedDocumentCreator, times(1)).create(caseDetails); + } + + @Test + public void should_call_internal_detained_non_ada_decisions_and_reasons_letter_dismissed_creator() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DECISION_AND_REASONS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(IS_DECISION_ALLOWED, AppealDecision.class)).thenReturn(Optional.of(AppealDecision.DISMISSED)); + + internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + verify(internalDetainedDecisionsAndReasonsLetterDismissedCreator, times(1)).create(caseDetails); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_appeal_decision_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_appeal_decision_is_not_present() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DECISION_AND_REASONS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_DECISION_ALLOWED, AppealDecision.class)).thenReturn(Optional.empty()); + + when(internalAdaDecisionsAndReasonsLetterAllowedDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Appeal decision is missing."); + } + + @Test + public void it_should_only_handle_about_to_submit_and_send_decisions_and_reasons_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.SEND_DECISION_AND_REASONS)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedDecisionsAndReasonsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGeneratorTest.java new file mode 100644 index 000000000..ffc713e99 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestHearingRequirementsLetterGeneratorTest.java @@ -0,0 +1,169 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedRequestHearingRequirementsLetterGeneratorTest { + @Mock + private DocumentCreator internalDetainedRequestHearingRequirementLetterCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private InternalDetainedRequestHearingRequirementsLetterGenerator internalDetainedRequestHearingRequirementsLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedRequestHearingRequirementsLetterGenerator = + new InternalDetainedRequestHearingRequirementsLetterGenerator( + internalDetainedRequestHearingRequirementLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_request_respondent_evidence_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.REQUEST_HEARING_REQUIREMENTS_FEATURE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedRequestHearingRequirementLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedRequestHearingRequirementsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestHearingRequirementsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestHearingRequirementsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_it_is_ada() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestHearingRequirementsLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestHearingRequirementsLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGeneratorTest.java new file mode 100644 index 000000000..91cb73c5e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalDetainedRequestRespondentEvidenceGeneratorTest.java @@ -0,0 +1,171 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealDecision; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedRequestRespondentEvidenceGeneratorTest { + @Mock + private DocumentCreator internalDetainedRequestRespondentEvidenceCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private InternalDetainedRequestRespondentEvidenceGenerator internalDetainedRequestRespondentEvidenceGenerator; + + @BeforeEach + public void setUp() { + internalDetainedRequestRespondentEvidenceGenerator = + new InternalDetainedRequestRespondentEvidenceGenerator( + internalDetainedRequestRespondentEvidenceCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_request_respondent_evidence_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.REQUEST_RESPONDENT_EVIDENCE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_DECISION_ALLOWED, AppealDecision.class)).thenReturn(Optional.of(AppealDecision.ALLOWED)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetainedRequestRespondentEvidenceCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedRequestRespondentEvidenceGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestRespondentEvidenceGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestRespondentEvidenceGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_it_is_ada() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedRequestRespondentEvidenceGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedRequestRespondentEvidenceGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGeneratorTest.java new file mode 100644 index 000000000..188272b79 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalHoChangeDirectionDueDateLetterGeneratorTest.java @@ -0,0 +1,150 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.Parties; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalHoChangeDirectionDueDateLetterGeneratorTest { + @Mock + private DocumentCreator internalHoChangeDirectionDueDateLetterGeneratorCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalHoChangeDirectionDueDateLetterGenerator internalHoChangeDirectionDueDateLetterGenerator; + + @BeforeEach + public void setUp() { + internalHoChangeDirectionDueDateLetterGenerator = + new InternalHoChangeDirectionDueDateLetterGenerator( + internalHoChangeDirectionDueDateLetterGeneratorCreator, + documentHandler + ); + when(callback.getEvent()).thenReturn(Event.CHANGE_DIRECTION_DUE_DATE); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class)).thenReturn(Optional.of(Parties.RESPONDENT)); + when(internalHoChangeDirectionDueDateLetterGeneratorCreator.create(caseDetails)).thenReturn(uploadedDocument); + } + + @Test + void should_create_internal_detained_ho_change_direction_due_date_pdf_and_append_to_notifications_documents() { + PreSubmitCallbackResponse callbackResponse = + internalHoChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void handling_should_not_handle_if_direction_sent_not_to_respondent() { + setUp(); + when(asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class)).thenReturn(Optional.of(Parties.APPELLANT)); + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHoChangeDirectionDueDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHoChangeDirectionDueDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalRequestBuildCaseDocumentGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalRequestBuildCaseDocumentGeneratorTest.java new file mode 100644 index 000000000..641175b6b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/InternalRequestBuildCaseDocumentGeneratorTest.java @@ -0,0 +1,174 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter.InternalRequestBuildCaseDocumentGenerator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalRequestBuildCaseDocumentGeneratorTest { + + @Mock private DocumentCreator internalAdaRequestBuildCaseDocumentCreator; + @Mock private DocumentCreator internalDetainedRequestBuildCaseDocumentCreator; + @Mock private DocumentHandler documentHandler; + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private final YesOrNo yes = YesOrNo.YES; + private InternalRequestBuildCaseDocumentGenerator internalAdaRequestBuildCaseDocumentGenerator; + + @BeforeEach + public void setUp() { + internalAdaRequestBuildCaseDocumentGenerator = + new InternalRequestBuildCaseDocumentGenerator( + internalAdaRequestBuildCaseDocumentCreator, + internalDetainedRequestBuildCaseDocumentCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_ada_request_case_building_pdf_and_append_to_notification_attachment_documents_for_the_case() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.REQUEST_CASE_BUILDING); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yes)); + + when(internalAdaRequestBuildCaseDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalAdaRequestBuildCaseDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.REQUEST_CASE_BUILDING); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yes)); + + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yes)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaRequestBuildCaseDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_ada_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaRequestBuildCaseDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_request_case_building_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yes)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAdaRequestBuildCaseDocumentGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.REQUEST_CASE_BUILDING)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAdaRequestBuildCaseDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreatorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreatorTest.java new file mode 100644 index 000000000..a22aa3b82 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpdateTribunalDecisionCreatorTest.java @@ -0,0 +1,224 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.CORRECTED_DECISION_AND_REASONS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.FINAL_DECISION_AND_REASONS_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.JOURNEY_TYPE; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.UPDATE_TRIBUNAL_DECISION_LIST; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.UpdateTribunalRules.UNDER_RULE_31; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_START; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_SUBMIT; + +import java.time.LocalDate; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DecisionAndReasons; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.UpdateTribunalRules; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.JourneyType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +public class UpdateTribunalDecisionCreatorTest { + + @Mock private DocumentCreator updatedDecisionAndReasonsCoverLetterDocumentCreator; + @Mock private DocumentCreator aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator; + @Mock private DocumentHandler documentHandler; + @Mock private DateProvider dateProvider; + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + + private UpdateTribunalDecisionCreator updateTribunalDecisionCreator; + private final LocalDate currentDate = LocalDate.now(); + + @BeforeEach + public void setUp() { + + updateTribunalDecisionCreator = + new UpdateTribunalDecisionCreator( + updatedDecisionAndReasonsCoverLetterDocumentCreator, + aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator, + documentHandler, + dateProvider + ); + } + + @Test + public void handling_should_throw_if_event_not_applicable() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + assertThatThrownBy(() -> updateTribunalDecisionCreator.handle(ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_not_bound_to_about_to_submit_callback_stage() { + assertThatThrownBy(() -> updateTribunalDecisionCreator.handle(ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void should_handle_aip_update_tribunal_decision() { + + List> existingDecisionList = + List.of( + new IdValue<>("1", DecisionAndReasons.builder() + .updatedDecisionDate(currentDate.toString()) + .build()) + ); + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.UPDATE_TRIBUNAL_DECISION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(UPDATE_TRIBUNAL_DECISION_LIST, UpdateTribunalRules.class)) + .thenReturn(Optional.of(UNDER_RULE_31)); + JourneyType journeyType = JourneyType.AIP; + when(asylumCase.read(JOURNEY_TYPE, JourneyType.class)).thenReturn(Optional.of(journeyType)); + when(aipUpdatedDecisionAndReasonsCoverLetterDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(asylumCase.read(CORRECTED_DECISION_AND_REASONS)).thenReturn(Optional.of(existingDecisionList)); + when(dateProvider.now()).thenReturn(currentDate); + + PreSubmitCallbackResponse response = + updateTribunalDecisionCreator.handle(ABOUT_TO_SUBMIT, callback); + + assertEquals(asylumCase, response.getData()); + + verify(documentHandler, times(1)) + .addWithMetadataWithoutReplacingExistingDocuments(asylumCase, + uploadedDocument, + FINAL_DECISION_AND_REASONS_DOCUMENTS, + DocumentTag.UPDATED_DECISION_AND_REASONS_COVER_LETTER); + verify(asylumCase, times(1)).write(CORRECTED_DECISION_AND_REASONS, existingDecisionList); + assertEquals(uploadedDocument, existingDecisionList.get(0).getValue().getCoverLetterDocument()); + assertEquals(currentDate.toString(), existingDecisionList.get(0).getValue().getDateCoverLetterDocumentUploaded()); + } + + @Test + public void should_handle_lr_update_tribunal_decision() { + List> existingDecisionList = + List.of( + new IdValue<>("1", DecisionAndReasons.builder() + .updatedDecisionDate(currentDate.toString()) + .build()) + ); + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.UPDATE_TRIBUNAL_DECISION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(UPDATE_TRIBUNAL_DECISION_LIST, UpdateTribunalRules.class)) + .thenReturn(Optional.of(UNDER_RULE_31)); + when(asylumCase.read(JOURNEY_TYPE, JourneyType.class)).thenReturn(Optional.empty()); + when(updatedDecisionAndReasonsCoverLetterDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(asylumCase.read(CORRECTED_DECISION_AND_REASONS)).thenReturn(Optional.of(existingDecisionList)); + when(dateProvider.now()).thenReturn(currentDate); + + PreSubmitCallbackResponse response = + updateTribunalDecisionCreator.handle(ABOUT_TO_SUBMIT, callback); + + assertEquals(asylumCase, response.getData()); + + verify(documentHandler, times(1)) + .addWithMetadataWithoutReplacingExistingDocuments(asylumCase, + uploadedDocument, + FINAL_DECISION_AND_REASONS_DOCUMENTS, + DocumentTag.UPDATED_DECISION_AND_REASONS_COVER_LETTER); + + verify(asylumCase, times(1)).write(CORRECTED_DECISION_AND_REASONS, existingDecisionList); + assertEquals(uploadedDocument, existingDecisionList.get(0).getValue().getCoverLetterDocument()); + assertEquals(currentDate.toString(), existingDecisionList.get(0).getValue().getDateCoverLetterDocumentUploaded()); + } + + @Test + void should_throw_when_corrected_decision_is_not_present() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.UPDATE_TRIBUNAL_DECISION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(UPDATE_TRIBUNAL_DECISION_LIST, UpdateTribunalRules.class)) + .thenReturn(Optional.of(UNDER_RULE_31)); + when(asylumCase.read(JOURNEY_TYPE, JourneyType.class)).thenReturn(Optional.empty()); + when(updatedDecisionAndReasonsCoverLetterDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(asylumCase.read(CORRECTED_DECISION_AND_REASONS)).thenReturn(Optional.empty()); + + + assertThatThrownBy(() -> updateTribunalDecisionCreator.handle(ABOUT_TO_SUBMIT, callback)) + .hasMessage("updatedDecisionAndReasons is not present in correctedDecisionAndReasons list") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_can_handle_callback() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(UPDATE_TRIBUNAL_DECISION_LIST, UpdateTribunalRules.class)) + .thenReturn(Optional.of(UNDER_RULE_31)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + + boolean canHandle = updateTribunalDecisionCreator.canHandle(callbackStage, callback); + + if (event == Event.UPDATE_TRIBUNAL_DECISION + && callbackStage == ABOUT_TO_SUBMIT) { + + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> updateTribunalDecisionCreator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> updateTribunalDecisionCreator.canHandle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> updateTribunalDecisionCreator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> updateTribunalDecisionCreator.handle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandlerTest.java index 15e4a2bf6..85377fd9b 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/UpperTribunalBundleHandlerTest.java @@ -14,10 +14,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; @@ -70,9 +73,12 @@ void setUp() { caseBundles.add(new IdValue<>("1", bundle)); } - @Test - void should_successfully_handle_the_callback() { + @ParameterizedTest + @ValueSource(strings = {"", "SUITABLE", "UNSUITABLE"}) + void should_successfully_handle_the_callback(String maybeDecision) { + when(asylumCase.read(SUITABILITY_REVIEW_DECISION)).thenReturn(maybeDecision.isEmpty() + ? Optional.empty() : Optional.of(AdaSuitabilityReviewDecision.valueOf(maybeDecision))); PreSubmitCallbackResponse callbackResponse = upperTribunalBundleHandler.handle(ABOUT_TO_SUBMIT, callback); @@ -84,7 +90,8 @@ void should_successfully_handle_the_callback() { verify(asylumCase).clear(AsylumCaseDefinition.HMCTS); verify(asylumCase).write(AsylumCaseDefinition.HMCTS, "[userImage:hmcts.png]"); verify(asylumCase).clear(AsylumCaseDefinition.CASE_BUNDLES); - verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, "iac-upper-tribunal-bundle-config.yaml"); + verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_CONFIGURATION, + maybeDecision.isEmpty() ? "iac-upper-tribunal-bundle-config.yaml" : "iac-upper-tribunal-bundle-inc-tribunal-config.yaml"); verify(asylumCase).write(AsylumCaseDefinition.BUNDLE_FILE_NAME_PREFIX, "PA 50002 2020"); } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreatorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreatorTest.java new file mode 100644 index 000000000..5c8b08b79 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/ChangeHearingCentreLetterCreatorTest.java @@ -0,0 +1,211 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class ChangeHearingCentreLetterCreatorTest { + @Mock + private DocumentCreator internalDetainedEditCaseListingLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private CaseDetails caseDetailsBefore; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private ChangeHearingCentreLetterCreator changeHearingCentreLetterCreator; + + @BeforeEach + public void setUp() { + changeHearingCentreLetterCreator = + new ChangeHearingCentreLetterCreator( + internalDetainedEditCaseListingLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.CHANGE_HEARING_CENTRE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_HEARING_CENTRE_LETTER + ); + } + + @Test + public void should_create_internal_detained_ada_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.CHANGE_HEARING_CENTRE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_HEARING_CENTRE_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_non_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.CHANGE_HEARING_CENTRE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.CHANGE_HEARING_CENTRE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = changeHearingCentreLetterCreator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = changeHearingCentreLetterCreator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> changeHearingCentreLetterCreator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGeneratorTest.java new file mode 100644 index 000000000..4c9002ba0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalAppealCanProceedLetterGeneratorTest.java @@ -0,0 +1,188 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalAppealCanProceedLetterGeneratorTest { + @Mock + private DocumentCreator internalAppealCanProceedLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalAppealCanProceedLetterGenerator internalAppealCanProceedLetterGenerator; + + @BeforeEach + public void setUp() { + internalAppealCanProceedLetterGenerator = + new InternalAppealCanProceedLetterGenerator( + internalAppealCanProceedLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_appeal_can_proceed_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.RECORD_OUT_OF_TIME_DECISION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalAppealCanProceedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalAppealCanProceedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.RECORD_OUT_OF_TIME_DECISION_DOCUMENT + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAppealCanProceedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAppealCanProceedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_it_is_ada() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalAppealCanProceedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_record_out_of_time_decision_is_not_present() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalAppealCanProceedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Cannot handle callback"); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalAppealCanProceedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGeneratorTest.java new file mode 100644 index 000000000..2bafeabf9 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalApplyForFtpaAppellantLetterGeneratorTest.java @@ -0,0 +1,153 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalApplyForFtpaAppellantLetterGeneratorTest { + + @Mock + private DocumentCreator internalApplyForFtpaAppellantLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalApplyForFtpaAppellantLetterGenerator internalApplyForFtpaAppellantLetterGenerator; + + @BeforeEach + public void setUp() { + internalApplyForFtpaAppellantLetterGenerator = + new InternalApplyForFtpaAppellantLetterGenerator( + internalApplyForFtpaAppellantLetterCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.APPLY_FOR_FTPA_APPELLANT); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(internalApplyForFtpaAppellantLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + } + + @Test + public void should_create_internal_ftpa_submitted_appellant_pdf_and_append_to_notification_attachment_documents_for_the_case() { + PreSubmitCallbackResponse callbackResponse = + internalApplyForFtpaAppellantLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalApplyForFtpaAppellantLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalApplyForFtpaAppellantLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalApplyForFtpaAppellantLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalApplyForFtpaAppellantLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + + @Test + public void it_should_only_handle_about_to_submit_and_apply_for_ftpa_appellant_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalApplyForFtpaAppellantLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.APPLY_FOR_FTPA_APPELLANT)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_appellant_is_not_in_detention() { + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalApplyForFtpaAppellantLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalApplyForFtpaAppellantLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo.equals(YesOrNo.YES)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + public void it_should_handle_both_detained_non_ada_and_ada_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalApplyForFtpaAppellantLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + assertTrue(canHandle); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandlerTest.java new file mode 100644 index 000000000..b6a3f866a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDecideAnApplicationLetterHandlerTest.java @@ -0,0 +1,351 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_SUBMIT; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +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.State; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDecideAnApplicationLetterHandlerTest { + + @Mock + private DocumentCreator internalAppellantApplicationGrantedLetterCreator; + @Mock + private DocumentCreator internalAppellantApplicationRefusedLetterCreator; + @Mock + private DocumentCreator internalHomeOfficeApplicationGrantedLetterCreator; + @Mock + private DocumentCreator internalHomeOfficeApplicationRefusedLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + @Mock + private MakeAnApplicationService makeAnApplicationService; + private final YesOrNo yes = YesOrNo.YES; + private final String decisionGranted = "Granted"; + private final String decisionRefused = "Refused"; + private final String decisionPending = "Pending"; + private final String adminOfficerRole = "Admin Officer"; + private final String respondentRole = "Respondent"; + private List> makeAnApplications = new ArrayList<>(); + private final MakeAnApplication makeAnApplication = new MakeAnApplication( + "Admin Officer", + MakeAnApplicationTypes.ADJOURN.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + decisionGranted, + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + private InternalDecideAnApplicationLetterHandler internalDecideAnAppellantApplicationLetterHandler; + + @BeforeEach + public void setUp() { + internalDecideAnAppellantApplicationLetterHandler = + new InternalDecideAnApplicationLetterHandler( + internalAppellantApplicationGrantedLetterCreator, + internalAppellantApplicationRefusedLetterCreator, + internalHomeOfficeApplicationGrantedLetterCreator, + internalHomeOfficeApplicationRefusedLetterCreator, + documentHandler, + makeAnApplicationService + ); + + when(caseDetails.getState()).thenReturn(State.APPEAL_SUBMITTED); + when(callback.getEvent()).thenReturn(Event.DECIDE_AN_APPLICATION); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + + makeAnApplications.add(new IdValue<>("1", makeAnApplication)); + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(makeAnApplication)); + + when(internalAppellantApplicationGrantedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(internalAppellantApplicationRefusedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(internalHomeOfficeApplicationGrantedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(internalHomeOfficeApplicationRefusedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + } + + @Test + public void should_create_application_decided_letter_and_append_to_notification_attachment_documents() { + + PreSubmitCallbackResponse callbackResponse = + internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing_or_set_to_no() { + //isAdmin defaults to false if not present + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDecideAnAppellantApplicationLetterHandler.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing_or_set_to_no() { + //isDetained defaults to false if not present + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDecideAnAppellantApplicationLetterHandler.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_decide_an_application_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDecideAnAppellantApplicationLetterHandler.canHandle(callbackStage, callback); + + if (callbackStage == ABOUT_TO_SUBMIT && callback.getEvent().equals(Event.DECIDE_AN_APPLICATION)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDecideAnAppellantApplicationLetterHandler.canHandle(ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_handle_both_internal_detained_cases_and_internal_ada_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDecideAnAppellantApplicationLetterHandler.canHandle(ABOUT_TO_SUBMIT, callback); + + assertTrue(canHandle); + } + + @ParameterizedTest + @ValueSource(strings = {decisionGranted, decisionRefused, decisionPending}) + public void it_should_only_generate_the_appellant_letter_for_granted_and_refused_applications_only(String decision) { + List> testApplications = new ArrayList<>(); + final MakeAnApplication testApplication = new MakeAnApplication( + "Admin Officer", + MakeAnApplicationTypes.ADJOURN.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + decision.toString(), + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + testApplications.add(new IdValue<>("1", testApplication)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(testApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(testApplication)); + + PreSubmitCallbackResponse callbackResponse = + internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + if (List.of(decisionGranted, decisionRefused).contains(decision)) { + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER); + } else { + verify(documentHandler, times(0)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER); + } + } + + @ParameterizedTest + @ValueSource(strings = {decisionGranted, decisionRefused, decisionPending}) + public void it_should_only_generate_the_home_office_letter_for_granted_and_refused_applications_only(String decision) { + List> testApplications = new ArrayList<>(); + final MakeAnApplication testApplication = new MakeAnApplication( + "Respondent", + MakeAnApplicationTypes.ADJOURN.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + decision.toString(), + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + testApplications.add(new IdValue<>("1", testApplication)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(testApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(testApplication)); + + PreSubmitCallbackResponse callbackResponse = + internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + if (List.of(decisionGranted, decisionRefused).contains(decision)) { + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER); + } else { + verify(documentHandler, times(0)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER); + } + } + + + @ParameterizedTest + @ValueSource(strings = {adminOfficerRole, respondentRole}) + public void it_should_not_generate_any_letters_for_any_user_when_decision_is_pending(String user) { + List> testApplications = new ArrayList<>(); + final MakeAnApplication testApplication = new MakeAnApplication( + user, + MakeAnApplicationTypes.ADJOURN.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + decisionPending, + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + testApplications.add(new IdValue<>("1", testApplication)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(testApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(testApplication)); + + PreSubmitCallbackResponse callbackResponse = + internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(0)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER); + verify(documentHandler, times(0)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER); + } + + @Test + public void should_throw_if_application_not_found() { + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.empty()); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.empty()); + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, callback)) + .hasMessage("Application not found") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.canHandle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDecideAnAppellantApplicationLetterHandler.handle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandlerTest.java new file mode 100644 index 000000000..c7efa407f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetHearingBundleReadyHandlerTest.java @@ -0,0 +1,282 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static java.util.Collections.singletonList; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.State; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.Bundle; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.enties.em.BundleDocument; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetHearingBundleReadyHandlerTest { + + @Mock private DocumentCreator internalAdaGenerateHearingBundleDocumentCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private final YesOrNo yes = YesOrNo.YES; + private final String bundleId = someRandomString(); + private final String bundleTitle = someRandomString(); + private final String bundleDescription = someRandomString(); + private final String bundleEligibleForStitching = someRandomString(); + private final List> bundleDocuments = singletonList(mock(IdValue.class)); + private final Optional bundleStitchStatus = Optional.of("DONE"); + private final Optional bundleStitchedDocument = Optional.of(mock(Document.class)); + private final YesOrNo bundleHasCoversheets = YesOrNo.YES; + private final YesOrNo bundleHasTableOfContents = YesOrNo.NO; + private final String bundleFilename = someRandomString(); + private final Bundle bundle = new Bundle( + bundleId, + bundleTitle, + bundleDescription, + bundleEligibleForStitching, + bundleDocuments, + bundleStitchStatus, + bundleStitchedDocument, + bundleHasCoversheets, + bundleHasTableOfContents, + bundleFilename + ); + private final IdValue bundleEntry = new IdValue("1", bundle); + + private List> caseBundles = new ArrayList<>(); + + private InternalDetHearingBundleReadyHandler internalDetHearingBundleReadyHandler; + + @BeforeEach + public void setUp() { + internalDetHearingBundleReadyHandler = + new InternalDetHearingBundleReadyHandler( + internalAdaGenerateHearingBundleDocumentCreator, + documentHandler + ); + + when(caseDetails.getState()).thenReturn(State.FINAL_BUNDLING); + when(callback.getEvent()).thenReturn(Event.ASYNC_STITCHING_COMPLETE); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + + caseBundles.add(bundleEntry); + + when(asylumCase.read(CASE_BUNDLES)).thenReturn(Optional.of(caseBundles)); + + } + + @Test + public void should_create_hearing_bundle_ready_letter_and_append_to_notification_attachment_documents() { + + when(internalAdaGenerateHearingBundleDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetHearingBundleReadyHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.HEARING_BUNDLE_READY_LETTER); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + // isAdmin defaults to false if not present + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetHearingBundleReadyHandler.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + // isAda defaults to false if not present + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetHearingBundleReadyHandler.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_async_stitching_complete_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetHearingBundleReadyHandler.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT && callback.getEvent().equals(Event.ASYNC_STITCHING_COMPLETE)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.ofNullable(yesOrNo)); + + boolean canHandle = internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_internal_detained_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.ofNullable(yesOrNo)); + + boolean canHandle = internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @Test + public void it_should_only_handle_when_case_bundle_is_provided() { + + when(asylumCase.read(CASE_BUNDLES)).thenReturn(Optional.empty()); + + assertFalse(internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)); + } + + @ParameterizedTest + @ValueSource(strings = {"DONE", "", "FAILED", "someRandomString"}) + public void it_should_only_handle_when_stitching_is_successful(String stitchStatus) { + final Bundle testBundle = new Bundle( + bundleId, + bundleTitle, + bundleDescription, + bundleEligibleForStitching, + bundleDocuments, + Optional.of(stitchStatus), + bundleStitchedDocument, + bundleHasCoversheets, + bundleHasTableOfContents, + bundleFilename + ); + final IdValue testBundleEntry = new IdValue("1", testBundle); + caseBundles.clear(); + caseBundles.add(testBundleEntry); + + when(asylumCase.read(CASE_BUNDLES)).thenReturn(Optional.of(caseBundles)); + + if (stitchStatus.equals(bundleStitchStatus.get())) { + assertTrue(internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)); + } else { + assertFalse(internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetHearingBundleReadyHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + + private String someRandomString() { + return randomAlphabetic(8); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGeneratorTest.java new file mode 100644 index 000000000..9c43c0bcb --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetMarkAsPaidLetterGeneratorTest.java @@ -0,0 +1,258 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType; +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.State; +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.entities.ccd.field.PaymentStatus; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetMarkAsPaidLetterGeneratorTest { + @Mock + private DocumentCreator internalDetMarkAsPaidLetterLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetMarkAsPaidLetterGenerator internalDetMarkAsPaidLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetMarkAsPaidLetterGenerator = + new InternalDetMarkAsPaidLetterGenerator( + internalDetMarkAsPaidLetterLetterCreator, + documentHandler + ); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(caseDetails.getState()).thenReturn(State.APPEAL_SUBMITTED); + when(callback.getCaseDetails().getCaseData().read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(AsylumAppealType.EA)); + when(callback.getCaseDetails().getCaseData().read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); + } + + @Test + public void should_create_internal_detained_mark_as_paid_letter_and_append_to_notifications_documents() { + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetMarkAsPaidLetterLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_MARK_AS_PAID_LETTER + ); + } + + @Test + public void should_handle_appeal_type_pa_any_state() { + for (State state : State.values()) { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(caseDetails.getState()).thenReturn(state); + when(callback.getCaseDetails().getCaseData().read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(AsylumAppealType.PA)); + when(callback.getCaseDetails().getCaseData().read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetMarkAsPaidLetterLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + boolean canHandle = internalDetMarkAsPaidLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + assertTrue(canHandle); + + reset(callback); + } + } + + @ParameterizedTest + @EnumSource(value = AsylumAppealType.class, names = {"EA", "HU", "EU"}) + public void should_handle_if_ea_hu_eu_and_appeal_submitted_state(AsylumAppealType appealType) { + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(callback.getCaseDetails().getCaseData().read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetMarkAsPaidLetterLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_MARK_AS_PAID_LETTER + ); + } + + @ParameterizedTest + @EnumSource(value = AsylumAppealType.class, names = {"EA", "HU", "EU"}) + public void handling_should_throw_if_ea_hu_eu_and_not_appeal_submitted_state() { + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(caseDetails.getState()).thenReturn(State.LISTING); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(caseDetails.getState()).thenReturn(State.APPEAL_SUBMITTED); + when(callback.getCaseDetails().getCaseData().read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(AsylumAppealType.EA)); + when(callback.getCaseDetails().getCaseData().read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetMarkAsPaidLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(caseDetails.getState()).thenReturn(State.APPEAL_SUBMITTED); + when(callback.getCaseDetails().getCaseData().read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(AsylumAppealType.EA)); + when(callback.getCaseDetails().getCaseData().read(PAYMENT_STATUS, PaymentStatus.class)).thenReturn(Optional.of(PaymentStatus.PAID)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetMarkAsPaidLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_it_is_ada() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetMarkAsPaidLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_mark_as_paid_event_is_not_present() { + when(callback.getEvent()).thenReturn(Event.END_APPEAL); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetMarkAsPaidLetterLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Cannot handle callback"); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGeneratorTest.java new file mode 100644 index 000000000..6a7b00106 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedAdjournHearingWithoutDateLetterGeneratorTest.java @@ -0,0 +1,213 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedAdjournHearingWithoutDateLetterGeneratorTest { + @Mock + private DocumentCreator adjournHearingWithoutDateDocumentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private CaseDetails caseDetailsBefore; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedAdjournHearingWithoutDateLetterGenerator internalDetainedAdjournHearingWithoutDateLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedAdjournHearingWithoutDateLetterGenerator = + new InternalDetainedAdjournHearingWithoutDateLetterGenerator( + adjournHearingWithoutDateDocumentCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.ADJOURN_HEARING_WITHOUT_DATE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(adjournHearingWithoutDateDocumentCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_ADJOURN_HEARING_WITHOUT_DATE + ); + } + + @Test + public void should_create_internal_detained_ada_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.ADJOURN_HEARING_WITHOUT_DATE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(adjournHearingWithoutDateDocumentCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_ADJOURN_HEARING_WITHOUT_DATE + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_non_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADJOURN_HEARING_WITHOUT_DATE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(adjournHearingWithoutDateDocumentCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.ADJOURN_HEARING_WITHOUT_DATE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(adjournHearingWithoutDateDocumentCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedAdjournHearingWithoutDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedAdjournHearingWithoutDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGeneratorTest.java new file mode 100644 index 000000000..9338d7d6e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedApplyForFtpaRespondentLetterGeneratorTest.java @@ -0,0 +1,178 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedApplyForFtpaRespondentLetterGeneratorTest { + + @Mock + private DocumentCreator internalDetainedFtpaSubmittedCreator; + @Mock + private DocumentHandler documentHandler; + + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedApplyForFtpaRespondentLetterGenerator internalDetainedApplyForFtpaRespondentLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedApplyForFtpaRespondentLetterGenerator = + new InternalDetainedApplyForFtpaRespondentLetterGenerator( + internalDetainedFtpaSubmittedCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.APPLY_FOR_FTPA_RESPONDENT); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @Test + void should_create_apply_for_ftpa_reposndent_letter_and_append_to_notification_attachment_documents() { + + when(internalDetainedFtpaSubmittedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedApplyForFtpaRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPLY_FOR_FTPA_RESPONDENT + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedApplyForFtpaRespondentLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_not_in_detention() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedApplyForFtpaRespondentLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_should_only_handle_about_to_submit_and_apply_for_ftpa_respondent_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedApplyForFtpaRespondentLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.APPLY_FOR_FTPA_RESPONDENT)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedApplyForFtpaRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedChangeDueDateDocumentGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedChangeDueDateDocumentGeneratorTest.java new file mode 100644 index 000000000..5fc2cef75 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedChangeDueDateDocumentGeneratorTest.java @@ -0,0 +1,157 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.Parties; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedChangeDueDateDocumentGeneratorTest { + @Mock + private DocumentCreator internalDetainedChangeDueDateLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalChangeDirectionDueDateLetterGenerator internalChangeDirectionDueDateLetterGenerator; + + @BeforeEach + public void setUp() { + internalChangeDirectionDueDateLetterGenerator = + new InternalChangeDirectionDueDateLetterGenerator( + internalDetainedChangeDueDateLetterCreator, + documentHandler + ); + when(callback.getEvent()).thenReturn(Event.CHANGE_DIRECTION_DUE_DATE); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class)).thenReturn(Optional.of(Parties.APPELLANT)); + when(internalDetainedChangeDueDateLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + } + + @Test + public void should_create_internal_detained_edit_case_listing_pdf_and_append_to_notifications_documents() { + PreSubmitCallbackResponse callbackResponse = + internalChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER + ); + } + + @Test + public void should_create_internal_detained_ada_edit_case_listing_pdf_and_append_to_notifications_documents() { + PreSubmitCallbackResponse callbackResponse = + internalChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalChangeDirectionDueDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalChangeDirectionDueDateLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalChangeDirectionDueDateLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGeneratorTest.java new file mode 100644 index 000000000..ce0752c73 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedEditCaseListingDocumentGeneratorTest.java @@ -0,0 +1,210 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedEditCaseListingDocumentGeneratorTest { + @Mock + private DocumentCreator internalDetainedEditCaseListingLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private CaseDetails caseDetailsBefore; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedEditCaseListingDocumentGenerator internalDetainedEditCaseListingDocumentGenerator; + + @BeforeEach + public void setUp() { + internalDetainedEditCaseListingDocumentGenerator = + new InternalDetainedEditCaseListingDocumentGenerator( + internalDetainedEditCaseListingLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.EDIT_CASE_LISTING); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER + ); + } + + @Test + public void should_create_internal_detained_ada_edit_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getCaseDetailsBefore()).thenReturn(Optional.of(caseDetailsBefore)); + when(callback.getEvent()).thenReturn(Event.EDIT_CASE_LISTING); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_non_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.EDIT_CASE_LISTING); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void handling_should_throw_if_ada_case_details_before_is_missing() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.EDIT_CASE_LISTING); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedEditCaseListingLetterCreator.create(caseDetails, caseDetailsBefore)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("previous case data is not present") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedEditCaseListingDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedEditCaseListingDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedEditCaseListingDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGeneratorTest.java new file mode 100644 index 000000000..932be0fdf --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedListCaseLetterGeneratorTest.java @@ -0,0 +1,172 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedListCaseLetterGeneratorTest { + @Mock + private DocumentCreator internalDetainedListCaseLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedListCaseLetterGenerator internalDetainedListCaseLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedListCaseLetterGenerator = + new InternalDetainedListCaseLetterGenerator( + internalDetainedListCaseLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_appeal_case_listing_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.LIST_CASE); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(internalDetainedListCaseLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedListCaseLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_LIST_CASE_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedListCaseLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedListCaseLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_it_is_ada() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedListCaseLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedListCaseLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGeneratorTest.java new file mode 100644 index 000000000..01b055511 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedMarkAsAdaLetterGeneratorTest.java @@ -0,0 +1,178 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedMarkAsAdaLetterGeneratorTest { + + @Mock + private DocumentCreator internalDetainedMarkAsAdaLetterCreator; + @Mock + private DocumentHandler documentHandler; + + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedMarkAsAdaLetterGenerator internalDetainedMarkAsAdaLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedMarkAsAdaLetterGenerator = + new InternalDetainedMarkAsAdaLetterGenerator( + internalDetainedMarkAsAdaLetterCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_AS_ADA); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @Test + void should_create_mark_as_ada_letter_and_append_to_notification_attachment_documents() { + + when(internalDetainedMarkAsAdaLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedMarkAsAdaLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DET_MARK_AS_ADA_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedMarkAsAdaLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_not_in_detention() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedMarkAsAdaLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_should_only_handle_about_to_submit_and_mark_as_ada_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedMarkAsAdaLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.MARK_APPEAL_AS_ADA)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedNoRemissionPaymentDueLetterTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedNoRemissionPaymentDueLetterTest.java new file mode 100644 index 000000000..8d724fe9a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedNoRemissionPaymentDueLetterTest.java @@ -0,0 +1,251 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +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.State; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedNoRemissionPaymentDueLetterTest { + + @Mock + private DocumentCreator internalDetainedNoRemissionPaymentDueLetterCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private final YesOrNo yes = YesOrNo.YES; + private final YesOrNo no = YesOrNo.NO; + private InternalDetainedAppealFeeDueLetterGenerator internalDetainedAppealFeeDueLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedAppealFeeDueLetterGenerator = + new InternalDetainedAppealFeeDueLetterGenerator( + internalDetainedNoRemissionPaymentDueLetterCreator, + documentHandler + ); + + when(caseDetails.getState()).thenReturn(State.PENDING_PAYMENT); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(no)); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(HU)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.NO_REMISSION)); + } + + @Test + public void should_create_appeal_fee_letter_and_append_to_notification_attachment_documents() { + + when(internalDetainedNoRemissionPaymentDueLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedAppealFeeDueLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_APPEAL_FEE_DUE_LETTER); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_submit_appeal_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT && callback.getEvent().equals(Event.SUBMIT_APPEAL)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @ParameterizedTest + @EnumSource(State.class) + public void it_should_only_handle_appeals_in_pending_payment_state(State state) { + + when(caseDetails.getState()).thenReturn(state); + + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (state.equals(State.PENDING_PAYMENT)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_detained_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_non_ada_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == no) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(AsylumAppealType.class) + public void it_should_only_handle_hu_ea_eu_appeal_type(AsylumAppealType appealType) { + + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); + + boolean canHandle = internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (List.of(HU.getValue(), EA.getValue(), EU.getValue()).contains(appealType.getValue())) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGeneratorTest.java new file mode 100644 index 000000000..168f0eac7 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGeneratorTest.java @@ -0,0 +1,205 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AppealReviewOutcome; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGeneratorTest { + @Mock + private DocumentCreator internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator = + new InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator( + internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_non_ada_review_home_office_response_pdf_and_append_to_notification_attachment_documents_for_the_case() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.REQUEST_RESPONSE_REVIEW); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_MAINTAINED)); + + when(internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + + @Test + public void it_should_only_handle_about_to_submit_and_request_request_response_review_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_MAINTAINED)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.REQUEST_RESPONSE_REVIEW)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_non_ada_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_MAINTAINED)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_MAINTAINED)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_appeal_review_outcome_is_decision_withdrawn() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_WITHDRAWN)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_appealant_is_not_in_detention() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(callback.getCaseDetails().getCaseData().read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_MAINTAINED)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGeneratorTest.java new file mode 100644 index 000000000..48accbce3 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGeneratorTest.java @@ -0,0 +1,229 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGeneratorTest { + + @Mock + private DocumentCreator internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterCreator; + @Mock private DocumentHandler documentHandler; + + @Mock private Callback callback; + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private Document uploadedDocument; + private final YesOrNo yes = YesOrNo.YES; + private final YesOrNo no = YesOrNo.NO; + private InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator; + + @BeforeEach + public void setUp() { + internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator = + new InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator( + internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.REQUEST_RESPONSE_REVIEW); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yes)); + when(asylumCase.read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(AppealReviewOutcome.DECISION_WITHDRAWN)); + } + + @Test + public void should_create_review_home_office_response_decision_withdrawn_letter_and_append_to_notification_attachment_documents() { + PreSubmitCallbackResponse callbackResponse = + internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_should_only_handle_about_to_submit_and_request_response_review_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT && callback.getEvent().equals(Event.REQUEST_RESPONSE_REVIEW)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_detained_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == yes) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + public void it_should_only_handle_non_ada_cases(YesOrNo yesOrNo) { + + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo == no) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(AppealReviewOutcome.class) + public void it_should_only_handle_appeal_review_outcome_decision_withdrawn(AppealReviewOutcome appealReviewOutcome) { + + when(asylumCase.read(APPEAL_REVIEW_OUTCOME, AppealReviewOutcome.class)).thenReturn(Optional.of(appealReviewOutcome)); + + boolean canHandle = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (appealReviewOutcome.equals(AppealReviewOutcome.DECISION_WITHDRAWN)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGeneratorTest.java new file mode 100644 index 000000000..066cc02d4 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalDetainedTransferOutOfAdaDocumentGeneratorTest.java @@ -0,0 +1,152 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedTransferOutOfAdaDocumentGeneratorTest { + @Mock + private DocumentCreator internalDetainedTransferOutOfAdaLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalDetainedTransferOutOfAdaDocumentGenerator internalDetainedTransferOutOfAdaDocumentGenerator; + + @BeforeEach + public void setUp() { + internalDetainedTransferOutOfAdaDocumentGenerator = + new InternalDetainedTransferOutOfAdaDocumentGenerator( + internalDetainedTransferOutOfAdaLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_detained_transfer_out_of_ada_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.TRANSFER_OUT_OF_ADA); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalDetainedTransferOutOfAdaLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalDetainedTransferOutOfAdaDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedTransferOutOfAdaDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalDetainedTransferOutOfAdaDocumentGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaDocumentGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGeneratorTest.java new file mode 100644 index 000000000..476bf9685 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEditAppealGeneratorTest.java @@ -0,0 +1,154 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalEditAppealGeneratorTest { + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalEditAppealGenerator internalEditAppealGenerator; + + @BeforeEach + void setUp() { + internalEditAppealGenerator = + new InternalEditAppealGenerator(documentCreator, documentHandler); + } + + @Test + void should_create_internal_detained_edit_appeal_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.EDIT_APPEAL_AFTER_SUBMIT); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalEditAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_EDIT_APPEAL_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.EDIT_APPEAL_AFTER_SUBMIT); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalEditAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalEditAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEditAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEditAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalEditAppealGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEditAppealGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEditAppealGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEditAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGeneratorTest.java new file mode 100644 index 000000000..59b22a056 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealAutomaticallyGeneratorTest.java @@ -0,0 +1,168 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalEndAppealAutomaticallyGeneratorTest { + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalEndAppealAutomaticallyGenerator internalEndAppealAutomaticallyGenerator; + + @BeforeEach + void setUp() { + internalEndAppealAutomaticallyGenerator = + new InternalEndAppealAutomaticallyGenerator(documentCreator, documentHandler); + } + + @Test + public void should_create_internal_detained_end_appeal_automatically_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPEAL_AUTOMATICALLY); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalEndAppealAutomaticallyGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_END_APPEAL_AUTOMATICALLY + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPEAL_AUTOMATICALLY); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEndAppealAutomaticallyGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEndAppealAutomaticallyGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_throw_when_record_out_of_time_decision_is_not_present() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPLICATION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Cannot handle callback"); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGeneratorTest.java new file mode 100644 index 000000000..fe1ded5c0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalEndAppealGeneratorTest.java @@ -0,0 +1,152 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalEndAppealGeneratorTest { + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalEndAppealGenerator internalEndAppealGenerator; + + @BeforeEach + void setUp() { + internalEndAppealGenerator = + new InternalEndAppealGenerator(documentCreator, documentHandler); + } + + @Test + void should_create_internal_detained_end_appeal_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalEndAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.END_APPEAL + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.END_APPEAL_AUTOMATICALLY); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalEndAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalEndAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEndAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalEndAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalEndAppealGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalEndAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGeneratorTest.java new file mode 100644 index 000000000..40fde00c9 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalFtpaDecidedLetterGeneratorTest.java @@ -0,0 +1,306 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.FtpaDecisionOutcomeType; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalFtpaDecidedLetterGeneratorTest { + + @Mock + private DocumentCreator internalAppellantFtpaDecidedGrantedCreator; + @Mock + private DocumentCreator internalAppellantFtpaDecidedPartiallyGrantedCreator; + @Mock + private DocumentCreator internalAppellantFtpaDecidedRefusedCreator; + @Mock + private DocumentCreator internalHoFtpaDecidedGrantedCreator; + @Mock + private DocumentCreator internalHoFtpaDecidedPartiallyGrantedCreator; + @Mock + private DocumentCreator internalHoFtpaDecidedRefusedCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private final String ftpaApplicantAppellant = "appellant"; + private final String ftpaApplicantRespondent = "respondent"; + private InternalFtpaDecidedLetterGenerator internalFtpaDecidedLetterGenerator; + + @BeforeEach + public void setUp() { + internalFtpaDecidedLetterGenerator = + new InternalFtpaDecidedLetterGenerator( + internalAppellantFtpaDecidedGrantedCreator, + internalAppellantFtpaDecidedPartiallyGrantedCreator, + internalAppellantFtpaDecidedRefusedCreator, + internalHoFtpaDecidedGrantedCreator, + internalHoFtpaDecidedPartiallyGrantedCreator, + internalHoFtpaDecidedRefusedCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.RESIDENT_JUDGE_FTPA_DECISION); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @Test + void should_create_internal_appellant_ftpa_decided_granted_letter_and_append_to_notification_attachment_documents() { + when(asylumCase.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_GRANTED)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantAppellant)); + + when(internalAppellantFtpaDecidedGrantedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER + ); + } + + @Test + void should_create_internal_appellant_ftpa_decided_partially_granted_letter_and_append_to_notification_attachment_documents() { + when(asylumCase.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_PARTIALLY_GRANTED)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantAppellant)); + + when(internalAppellantFtpaDecidedPartiallyGrantedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER + ); + } + + @Test + void should_create_internal_appellant_ftpa_decided_refused_letter_and_append_to_notification_attachment_documents() { + when(asylumCase.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_REFUSED)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantAppellant)); + + when(internalAppellantFtpaDecidedRefusedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER + ); + } + + @Test + void should_create_internal_ho_ftpa_decided_granted_letter_and_append_to_notification_attachment_documents() { + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_GRANTED)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantRespondent)); + + when(internalHoFtpaDecidedGrantedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER + ); + } + + @Test + void should_create_internal_ho_ftpa_decided_partially_granted_letter_and_append_to_notification_attachment_documents() { + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_PARTIALLY_GRANTED)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantRespondent)); + + when(internalHoFtpaDecidedPartiallyGrantedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER + ); + } + + @ParameterizedTest + @EnumSource(value = FtpaDecisionOutcomeType.class, names = {"FTPA_REFUSED", "FTPA_NOT_ADMITTED"}) + void should_create_internal_ho_ftpa_decided_refused_letter_and_append_to_notification_attachment_documents(FtpaDecisionOutcomeType ftpaDecisionOutcomeType) { + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(ftpaDecisionOutcomeType)); + when(asylumCase.read(FTPA_APPLICANT_TYPE, String.class)).thenReturn(Optional.of(ftpaApplicantRespondent)); + + when(internalHoFtpaDecidedRefusedCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, + uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalFtpaDecidedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_not_in_detention() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalFtpaDecidedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_should_only_handle_about_to_submit_and_resident_judge_ftpa_decision_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalFtpaDecidedLetterGenerator.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.RESIDENT_JUDGE_FTPA_DECISION)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalFtpaDecidedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGeneratorTest.java new file mode 100644 index 000000000..4efd34a4b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHearingAdjustmentsUpdatedLetterGeneratorTest.java @@ -0,0 +1,151 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalHearingAdjustmentsUpdatedLetterGeneratorTest { + @Mock + private DocumentCreator internalHearingAdjustmentsUpdatedLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalHearingAdjustmentsUpdatedLetterGenerator internalHearingAdjustmentsUpdatedLetterGenerator; + + @BeforeEach + public void setUp() { + internalHearingAdjustmentsUpdatedLetterGenerator = + new InternalHearingAdjustmentsUpdatedLetterGenerator( + internalHearingAdjustmentsUpdatedLetterCreator, + documentHandler + ); + } + + @Test + public void should_create_internal_hearing_adjustments_updated_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.UPDATE_HEARING_ADJUSTMENTS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(internalHearingAdjustmentsUpdatedLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalHearingAdjustmentsUpdatedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER + ); + } + + @Test + public void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SUBMIT_APPEAL); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHearingAdjustmentsUpdatedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHearingAdjustmentsUpdatedLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHearingAdjustmentsUpdatedLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandlerTest.java new file mode 100644 index 000000000..a8eca0437 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalHomeOfficeAmendAppealResponseHandlerTest.java @@ -0,0 +1,156 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalHomeOfficeAmendAppealResponseHandlerTest { + @Mock + private DocumentCreator internalHomeOfficeAmendAppealResponseCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + @Mock + private DirectionFinder directionFinder; + + private InternalHomeOfficeAmendAppealResponseHandler internalHomeOfficeAmendAppealResponseHandler; + + @BeforeEach + public void setUp() { + internalHomeOfficeAmendAppealResponseHandler = + new InternalHomeOfficeAmendAppealResponseHandler( + internalHomeOfficeAmendAppealResponseCreator, + documentHandler, + directionFinder + ); + + when(callback.getEvent()).thenReturn(Event.REQUEST_RESPONSE_AMEND); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(internalHomeOfficeAmendAppealResponseCreator.create(caseDetails)).thenReturn(uploadedDocument); + } + + @Test + public void should_create_home_office_amend_appeal_response_pdf_and_append_to_notification_attachment_documents() { + PreSubmitCallbackResponse callbackResponse = + internalHomeOfficeAmendAppealResponseHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata(asylumCase, uploadedDocument, NOTIFICATION_ATTACHMENT_DOCUMENTS, DocumentTag.AMEND_HOME_OFFICE_APPEAL_RESPONSE); + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalHomeOfficeAmendAppealResponseHandler.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHomeOfficeAmendAppealResponseHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHomeOfficeAmendAppealResponseHandler.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalHomeOfficeAmendAppealResponseHandler.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + + @Test + public void it_should_only_handle_about_to_submit_and_send_direction_event() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHomeOfficeAmendAppealResponseHandler.canHandle(callbackStage, callback); + + if (callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT + && callback.getEvent().equals(Event.REQUEST_RESPONSE_AMEND)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_appellant_is_not_in_detention() { + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalHomeOfficeAmendAppealResponseHandler.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + public void it_should_only_handle_internal_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalHomeOfficeAmendAppealResponseHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + if (yesOrNo.equals(YesOrNo.YES)) { + assertTrue(canHandle); + } else { + assertFalse(canHandle); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + public void it_should_handle_both_detained_non_ada_and_ada_cases(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + boolean canHandle = internalHomeOfficeAmendAppealResponseHandler.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + assertTrue(canHandle); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGeneratorTest.java new file mode 100644 index 000000000..10c2b4300 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseLinkAppealGeneratorTest.java @@ -0,0 +1,152 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalMaintainCaseLinkAppealGeneratorTest { + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalMaintainCaseLinkAppealGenerator internalMaintainCaseLinkAppealGenerator; + + @BeforeEach + void setUp() { + internalMaintainCaseLinkAppealGenerator = + new InternalMaintainCaseLinkAppealGenerator(documentCreator, documentHandler); + } + + @Test + void should_create_internal_detained_maintain_case_link_appeal_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.CREATE_CASE_LINK); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalMaintainCaseLinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.MAINTAIN_CASE_LINK_APPEAL_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.MAINTAIN_CASE_LINKS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalMaintainCaseLinkAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalMaintainCaseLinkAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGeneratorTest.java new file mode 100644 index 000000000..7283f18b8 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalMaintainCaseUnlinkAppealGeneratorTest.java @@ -0,0 +1,152 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalMaintainCaseUnlinkAppealGeneratorTest { + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalMaintainCaseUnlinkAppealGenerator internalMaintainCaseUnlinkAppealGenerator; + + @BeforeEach + void setUp() { + internalMaintainCaseUnlinkAppealGenerator = + new InternalMaintainCaseUnlinkAppealGenerator(documentCreator, documentHandler); + } + + @Test + void should_create_internal_detained_maintain_case_unlink_appeal_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.MAINTAIN_CASE_LINKS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalMaintainCaseUnlinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.MAINTAIN_CASE_UNLINK_APPEAL_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.MAINTAIN_CASE_LINKS); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalMaintainCaseUnlinkAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalMaintainCaseUnlinkAppealGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalMaintainCaseUnlinkAppealGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGeneratorTest.java new file mode 100644 index 000000000..3ff7038b7 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionLetterGeneratorTest.java @@ -0,0 +1,276 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_IN_DETENTION; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ACCELERATED_DETAINED_APPEAL; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.SEND_DIRECTION_PARTIES; + + +import java.util.Collections; +import java.util.Optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalNonStandardDirectionLetterGeneratorTest { + + @Mock + private DocumentCreator internalNonStandardDirectionLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private DirectionFinder directionFinder; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalNonStandardDirectionLetterGenerator internalNonStandardDirectionLetterGenerator; + private final String directionExplanation = "some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + + private final Direction directionOne = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + private final Direction directionTwo = new Direction( + directionExplanation, + Parties.LEGAL_REPRESENTATIVE, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + private final Direction directionThree = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.CASE_EDIT, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + + @BeforeEach + public void setUp() { + internalNonStandardDirectionLetterGenerator = + new InternalNonStandardDirectionLetterGenerator( + internalNonStandardDirectionLetterCreator, + documentHandler, + directionFinder); + } + + @Test + public void should_create_internal_non_standard_direction_Nonada_letter_and_append_to_notifications_documents() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionOne)); + when(asylumCase.read(SEND_DIRECTION_PARTIES)).thenReturn(Optional.of(Parties.APPELLANT)); + + when(internalNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalNonStandardDirectionLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER + ); + } + + @Test + public void should_create_internal_non_standard_direction_ada_letter_and_append_to_notifications_documents() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionOne)); + when(asylumCase.read(SEND_DIRECTION_PARTIES)).thenReturn(Optional.of(Parties.APPELLANT)); + + when(internalNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalNonStandardDirectionLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER + + + ); + } + + @Test + public void incorrect_parties_test() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(internalNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionTwo)); + + assertThatThrownBy( + () -> internalNonStandardDirectionLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void incorrect_direction_test() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(internalNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionThree)); + + assertThatThrownBy( + () -> internalNonStandardDirectionLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalNonStandardDirectionLetterGenerator.canHandle(callbackStage, callback); + Assertions.assertFalse(canHandle); + } + Mockito.reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalNonStandardDirectionLetterGenerator.canHandle(callbackStage, callback); + Assertions.assertFalse(canHandle); + } + Mockito.reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalNonStandardDirectionLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy( + () -> internalNonStandardDirectionLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, + null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalNonStandardDirectionLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy( + () -> internalNonStandardDirectionLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, + null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGeneratorTest.java new file mode 100644 index 000000000..f31bbcdfe --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalNonStandardDirectionToRespondentLetterGeneratorTest.java @@ -0,0 +1,260 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_IN_DETENTION; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ACCELERATED_DETAINED_APPEAL; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.NOTIFICATION_ATTACHMENT_DOCUMENTS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.SEND_DIRECTION_PARTIES; + +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalNonStandardDirectionToRespondentLetterGeneratorTest { + + @Mock + private DocumentCreator homeOfficeNonStandardDirectionLetterCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private DirectionFinder directionFinder; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + private InternalNonStandardDirectionToRespondentLetterGenerator internalNonStandardDirectionToRespondentLetterGenerator; + private final String directionExplanation = "some explanation"; + private final Parties directionParties = Parties.RESPONDENT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + + private final Direction directionOne = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + private final Direction directionTwo = new Direction( + directionExplanation, + Parties.LEGAL_REPRESENTATIVE, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + private final Direction directionThree = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.CASE_EDIT, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + + @BeforeEach + public void setUp() { + internalNonStandardDirectionToRespondentLetterGenerator = new + InternalNonStandardDirectionToRespondentLetterGenerator( + homeOfficeNonStandardDirectionLetterCreator, + documentHandler, + directionFinder); + } + + @ParameterizedTest + @MethodSource("getAdaAndNonAdaArguments") + public void should_create_home_office_non_standard_direction_letter_and_append_to_notifications_documents(Parties party, YesOrNo isAda) { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn( + Optional.of(isAda)); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionOne)); + when(asylumCase.read(SEND_DIRECTION_PARTIES)).thenReturn(Optional.of(party)); + + when(homeOfficeNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalNonStandardDirectionToRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadata( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER + ); + } + + @Test + public void incorrect_parties_test() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(callback.getEvent()).thenReturn(Event.SEND_DIRECTION); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(homeOfficeNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionTwo)); + + assertThatThrownBy( + () -> internalNonStandardDirectionToRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + public void incorrect_direction_test() { + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + when(homeOfficeNonStandardDirectionLetterCreator.create(caseDetails)).thenReturn(uploadedDocument); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionThree)); + + assertThatThrownBy( + () -> internalNonStandardDirectionToRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + + @Test + public void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalNonStandardDirectionToRespondentLetterGenerator.canHandle(callbackStage, callback); + Assertions.assertFalse(canHandle); + } + Mockito.reset(callback); + } + } + + @Test + public void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn( + Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalNonStandardDirectionToRespondentLetterGenerator.canHandle(callbackStage, callback); + Assertions.assertFalse(canHandle); + } + Mockito.reset(callback); + } + } + + @Test + public void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalNonStandardDirectionToRespondentLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy( + () -> internalNonStandardDirectionToRespondentLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, + null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalNonStandardDirectionToRespondentLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy( + () -> internalNonStandardDirectionToRespondentLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, + null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + + private static Stream getAdaAndNonAdaArguments() { + + return Stream.of( + Arguments.of("RESPONDENT", YesOrNo.YES), + Arguments.of("RESPONDENT", YesOrNo.NO), + Arguments.of("APPELLANT_AND_RESPONDENT", YesOrNo.YES), + Arguments.of("APPELLANT_AND_RESPONDENT", YesOrNo.NO) + ); + } +} + diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGeneratorTest.java new file mode 100644 index 000000000..c7aa858be --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalReinstateAppealLetterGeneratorTest.java @@ -0,0 +1,150 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; + +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalReinstateAppealLetterGeneratorTest { + + @Mock + private DocumentCreator documentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private InternalReinstateAppealLetterGenerator internalReinstateAppealLetterGenerator; + + @BeforeEach + void setUp() { + internalReinstateAppealLetterGenerator = + new InternalReinstateAppealLetterGenerator(documentCreator, documentHandler); + } + + @Test + void should_create_internal_reinstate_appeal_letter_pdf_and_append_to_notifications_documents() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getEvent()).thenReturn(Event.REINSTATE_APPEAL); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(documentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalReinstateAppealLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_REINSTATE_APPEAL_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_is_admin_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalReinstateAppealLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void it_cannot_handle_callback_if_is_detained_is_missing() { + + for (Event event : Event.values()) { + + when(callback.getEvent()).thenReturn(event); + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + for (PreSubmitCallbackStage callbackStage : PreSubmitCallbackStage.values()) { + boolean canHandle = internalReinstateAppealLetterGenerator.canHandle(callbackStage, callback); + assertFalse(canHandle); + } + reset(callback); + } + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.canHandle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalReinstateAppealLetterGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGeneratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGeneratorTest.java new file mode 100644 index 000000000..87b5547ea --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/handlers/presubmit/letter/InternalUploadAdditionalEvidenceGeneratorTest.java @@ -0,0 +1,216 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.handlers.presubmit.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ADMIN; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_SUBMIT; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.DocumentWithMetadata; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentCreator; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DocumentHandler; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalUploadAdditionalEvidenceGeneratorTest { + + @Mock + private DocumentCreator adminUploadEvidenceDocumentCreator; + @Mock + private DocumentCreator homeOfficeUploadEvidenceDocumentCreator; + @Mock + private DocumentCreator legalOfficereUploadEvidenceDocumentCreator; + @Mock + private DocumentHandler documentHandler; + @Mock + private Callback callback; + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private Document uploadedDocument; + + private static final String LEGAL_OFFICER_ADDENDUM_SUPPLIED_BY_LABEL = "The respondent"; + private static final String LEGAL_OFFICER_ADDENDUM_UPLOADED_BY_LABEL = "TCW"; + + private final IdValue addendumOne = new IdValue<>( + "1", + new DocumentWithMetadata( + uploadedDocument, + "Some description", + "2018-12-25", DocumentTag.ADDENDUM_EVIDENCE, + LEGAL_OFFICER_ADDENDUM_SUPPLIED_BY_LABEL, + LEGAL_OFFICER_ADDENDUM_UPLOADED_BY_LABEL + ) + ); + + private InternalUploadAdditionalEvidenceGenerator internalUploadAdditionalEvidenceGenerator; + + @BeforeEach + void setUp() { + internalUploadAdditionalEvidenceGenerator = + new InternalUploadAdditionalEvidenceGenerator( + adminUploadEvidenceDocumentCreator, + homeOfficeUploadEvidenceDocumentCreator, + legalOfficereUploadEvidenceDocumentCreator, + documentHandler + ); + + when(callback.getEvent()).thenReturn(Event.UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE); + + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @ParameterizedTest + @EnumSource(value = Event.class, names = {"UPLOAD_ADDITIONAL_EVIDENCE", "UPLOAD_ADDENDUM_EVIDENCE_ADMIN_OFFICER"}) + void should_create_internal_admin_upload_additional_evidence_letter_pdf_and_append_to_notifications_documents(Event event) { + when(callback.getEvent()).thenReturn(event); + + when(adminUploadEvidenceDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalUploadAdditionalEvidenceGenerator.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER + ); + } + + @ParameterizedTest + @EnumSource(value = Event.class, names = {"UPLOAD_ADDITIONAL_EVIDENCE_HOME_OFFICE", "UPLOAD_ADDENDUM_EVIDENCE_HOME_OFFICE"}) + void should_create_internal_home_office_upload_additional_evidence_letter_pdf_and_append_to_notifications_documents(Event event) { + when(callback.getEvent()).thenReturn(event); + + when(homeOfficeUploadEvidenceDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalUploadAdditionalEvidenceGenerator.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER + ); + } + + @ParameterizedTest + @EnumSource(value = Event.class, names = {"UPLOAD_ADDENDUM_EVIDENCE"}) + void should_create_internal_legal_officer_upload_additional_evidence_letter_pdf_and_append_to_notifications_documents(Event event) { + when(callback.getEvent()).thenReturn(event); + + List> addendumDocuments = new ArrayList<>(); + addendumDocuments.add(addendumOne); + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.of(addendumDocuments)); + + when(legalOfficereUploadEvidenceDocumentCreator.create(caseDetails)).thenReturn(uploadedDocument); + + PreSubmitCallbackResponse callbackResponse = + internalUploadAdditionalEvidenceGenerator.handle(ABOUT_TO_SUBMIT, callback); + + assertNotNull(callbackResponse); + assertEquals(asylumCase, callbackResponse.getData()); + + verify(documentHandler, times(1)).addWithMetadataWithoutReplacingExistingDocuments( + asylumCase, uploadedDocument, + NOTIFICATION_ATTACHMENT_DOCUMENTS, + DocumentTag.LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER + ); + } + + @Test + void handling_should_throw_if_cannot_actually_handle() { + when(callback.getCaseDetails()).thenReturn(caseDetails); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.handle(PreSubmitCallbackStage.ABOUT_TO_START, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + + when(callback.getEvent()).thenReturn(Event.START_APPEAL); + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.handle(ABOUT_TO_SUBMIT, callback)) + .hasMessage("Cannot handle callback") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void it_cannot_handle_callback_if_not_internal() { + when(callback.getCaseDetails().getCaseData().read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + assertFalse(internalUploadAdditionalEvidenceGenerator.canHandle(ABOUT_TO_SUBMIT, callback)); + } + + @Test + void it_cannot_handle_callback_if_appellant_is_not_in_detention() { + when(callback.getCaseDetails().getCaseData().read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + assertFalse(internalUploadAdditionalEvidenceGenerator.canHandle(ABOUT_TO_SUBMIT, callback)); + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void it_should_handle_both_detained_non_ada_and_detained_ada_cases(YesOrNo yesOrNo) { + when(callback.getCaseDetails().getCaseData().read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + assertTrue(internalUploadAdditionalEvidenceGenerator.canHandle(ABOUT_TO_SUBMIT, callback)); + } + + @Test + void should_not_allow_null_arguments() { + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.canHandle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.canHandle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.handle(null, callback)) + .hasMessage("callbackStage must not be null") + .isExactlyInstanceOf(NullPointerException.class); + + assertThatThrownBy(() -> internalUploadAdditionalEvidenceGenerator.handle(ABOUT_TO_SUBMIT, null)) + .hasMessage("callback must not be null") + .isExactlyInstanceOf(NullPointerException.class); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrderTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrderTest.java index 33cc19049..ebdd8714b 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/BundleOrderTest.java @@ -37,7 +37,7 @@ public void should_sort_in_correct_order_excluding_bail_tags() { .map(DocumentWithMetadata::getTag) .collect(Collectors.toList()); - assertEquals(32, sortedTags.size()); + assertEquals(79, sortedTags.size()); List documentTagList = Arrays.asList( DocumentTag.CASE_SUMMARY, @@ -70,6 +70,53 @@ public void should_sort_in_correct_order_excluding_bail_tags() { DocumentTag.UPPER_TRIBUNAL_BUNDLE, DocumentTag.APPEAL_REASONS, DocumentTag.CLARIFYING_QUESTIONS, + DocumentTag.FINAL_DECISION_AND_REASONS_DOCUMENT, + DocumentTag.ADA_SUITABILITY, + DocumentTag.APPEAL_FORM, + DocumentTag.NOTICE_OF_DECISION_UT_TRANSFER, + DocumentTag.REQUEST_CASE_BUILDING, + DocumentTag.INTERNAL_ADA_SUITABILITY, + DocumentTag.REQUEST_RESPONDENT_REVIEW, + DocumentTag.INTERNAL_DET_DECISION_AND_REASONS_LETTER, + DocumentTag.UPLOAD_THE_APPEAL_RESPONSE, + DocumentTag.HEARING_BUNDLE_READY_LETTER, + DocumentTag.INTERNAL_APPEAL_SUBMISSION, + DocumentTag.INTERNAL_REQUEST_RESPONDENT_EVIDENCE_LETTER, + DocumentTag.INTERNAL_END_APPEAL_AUTOMATICALLY, + DocumentTag.INTERNAL_APPEAL_FEE_DUE_LETTER, + DocumentTag.INTERNAL_DET_MARK_AS_PAID_LETTER, + DocumentTag.INTERNAL_LIST_CASE_LETTER, + DocumentTag.INTERNAL_REQUEST_HEARING_REQUIREMENTS_LETTER, + DocumentTag.INTERNAL_DETAINED_REQUEST_HO_RESPONSE_REVIEW, + DocumentTag.INTERNAL_DETAINED_EDIT_CASE_LISTING_LETTER, + DocumentTag.INTERNAL_DET_MARK_AS_ADA_LETTER, + DocumentTag.INTERNAL_DECIDE_AN_APPELLANT_APPLICATION_LETTER, + DocumentTag.INTERNAL_APPLY_FOR_FTPA_RESPONDENT, + DocumentTag.INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER, + DocumentTag.INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER, + DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER, + DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER, + DocumentTag.INTERNAL_HEARING_ADJUSTMENTS_UPDATED_LETTER, + DocumentTag.INTERNAL_DECIDE_HOME_OFFICE_APPLICATION_LETTER, + DocumentTag.MAINTAIN_CASE_UNLINK_APPEAL_LETTER, + DocumentTag.INTERNAL_UPLOAD_ADDITIONAL_EVIDENCE_LETTER, + DocumentTag.INTERNAL_CHANGE_HEARING_CENTRE_LETTER, + DocumentTag.MAINTAIN_CASE_LINK_APPEAL_LETTER, + DocumentTag.AMEND_HOME_OFFICE_APPEAL_RESPONSE, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_TO_APPELLANT_LETTER, + DocumentTag.INTERNAL_CHANGE_DIRECTION_DUE_DATE_LETTER, + DocumentTag.INTERNAL_EDIT_APPEAL_LETTER, + DocumentTag.HOME_OFFICE_UPLOAD_ADDITIONAL_ADDENDUM_EVIDENCE_LETTER, + DocumentTag.LEGAL_OFFICER_UPLOAD_ADDITIONAL_EVIDENCE_LETTER, + DocumentTag.INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_LETTER, + DocumentTag.INTERNAL_NON_STANDARD_DIRECTION_RESPONDENT_LETTER, + DocumentTag.INTERNAL_REINSTATE_APPEAL_LETTER, + DocumentTag.INTERNAL_ADJOURN_HEARING_WITHOUT_DATE, + DocumentTag.UPPER_TRIBUNAL_TRANSFER_ORDER_DOCUMENT, + DocumentTag.IAUT_2_FORM, + DocumentTag.UPDATED_DECISION_AND_REASONS_COVER_LETTER, + DocumentTag.UPDATED_FINAL_DECISION_AND_REASONS_PDF, + DocumentTag.REMITTAL_DECISION, DocumentTag.NOTICE_OF_ADJOURNED_HEARING, DocumentTag.NONE ); diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateServiceTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateServiceTest.java new file mode 100644 index 000000000..d55812136 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/DueDateServiceTest.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates.HolidayService; + +@ExtendWith(MockitoExtension.class) +class DueDateServiceTest { + + @Mock + HolidayService holidayService; + + private DueDateService dueDateService; + + @BeforeEach + void setUp() { + dueDateService = new DueDateService(holidayService); + } + + @Test + void should_return_next_working_day_4_pm_when_calculated_due_date_matches_holiday() { + ZonedDateTime eventDateTime = + ZonedDateTime.of( + 2022, 7, 19, + 9, 0, 0, 0, + ZoneId.systemDefault() + ); + + int workingDaysAllowed = 2; + + when(holidayService.isHoliday(eventDateTime.plusDays(1))) + .thenReturn(true); + + ZonedDateTime expectedDueDate = eventDateTime.plusDays(workingDaysAllowed + 1); + ZonedDateTime expectedDueDateTime = expectedDueDate.with( + LocalTime.of(16, 0, 0, 0) + ); + ZonedDateTime actualDateTime = dueDateService.calculateDueDate(eventDateTime, workingDaysAllowed); + + assertThat(actualDateTime, is(expectedDueDateTime)); + verify(holidayService, times(3)).isHoliday(any(ZonedDateTime.class)); + } + + @Test + void should_return_next_working_day_4_pm_when_delay_date_matches_holiday() { + ZonedDateTime eventDateTime = + ZonedDateTime.of( + 2022, 7, 19, + 9, 0, 0, 0, + ZoneId.systemDefault() + ); + + int delayDuration = 2; + + when(holidayService.isHoliday(eventDateTime.plusDays(delayDuration))) + .thenReturn(true); + + ZonedDateTime expectedDelayDate = eventDateTime.plusDays(delayDuration + 1); + ZonedDateTime expectedDelayDateTime = expectedDelayDate.with(LocalTime.of(16, 0, 0, 0)); + ZonedDateTime actualDateTime = dueDateService.calculateDelayUntil(eventDateTime, delayDuration); + + assertThat(actualDateTime, is(expectedDelayDateTime)); + verify(holidayService, times(2)).isHoliday(any(ZonedDateTime.class)); + } + + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestratorTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestratorTest.java index 47e5d73a3..19e81e255 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestratorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsOrchestratorTest.java @@ -1,12 +1,13 @@ package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service; -import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.*; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import java.util.Collections; import java.util.List; import java.util.Optional; +import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -15,6 +16,7 @@ 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.DocumentWithMetadata; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ReheardHearingDocuments; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; @@ -31,9 +33,12 @@ class SendDecisionAndReasonsOrchestratorTest { @Mock private AsylumCase asylumCase; @Mock private Document coverLetter; @Mock private Document pdf; + @Mock private FeatureToggler featureToggler; + @Mock private DocumentReceiver documentReceiver; + @Mock private DocumentsAppender documentsAppender; + @Mock private Appender reheardAppender; private SendDecisionAndReasonsOrchestrator sendDecisionAndReasonsOrchestrator; - private List> existingDecisionAnReasonsDocuments = emptyList(); @BeforeEach public void setUp() { @@ -41,7 +46,11 @@ public void setUp() { new SendDecisionAndReasonsOrchestrator( documentHandler, sendDecisionAndReasonsPdfService, - sendDecisionAndReasonsCoverLetterService); + sendDecisionAndReasonsCoverLetterService, + featureToggler, + documentReceiver, + documentsAppender, + reheardAppender); when(caseDetails.getCaseData()).thenReturn(asylumCase); } @@ -238,4 +247,63 @@ void attaches_new_reheard_documents_and_when_cover_letter_and_pdf_generated_for_ verify(asylumCase, times(1)).clear(FINAL_DECISION_AND_REASONS_DOCUMENT); verify(asylumCase, times(1)).clear(DRAFT_DECISION_AND_REASONS_DOCUMENTS); } + + @Test + void attaches_new_reheard_documents_complex_collection_when_reheard() { + + String description = "Some evidence"; + String dateUploaded = "2018-12-25"; + final DocumentWithMetadata coverLetterDocumentWithMetadata = + new DocumentWithMetadata( + coverLetter, + description, + dateUploaded, + DocumentTag.DECISION_AND_REASONS_COVER_LETTER, + "test" + ); + + final DocumentWithMetadata decisionDocumentWithMetadata = + new DocumentWithMetadata( + coverLetter, + description, + dateUploaded, + DocumentTag.FINAL_DECISION_AND_REASONS_PDF, + "test" + ); + + IdValue decisionDocWithMetadata = + new IdValue<>("2", decisionDocumentWithMetadata); + IdValue coverLetterDocWithMetadata = + new IdValue<>("1", coverLetterDocumentWithMetadata); + final List> listOfDocumentsWithMetadata = Lists.newArrayList(decisionDocWithMetadata, coverLetterDocWithMetadata); + IdValue reheardHearingDocuments = + new IdValue<>("1", new ReheardHearingDocuments(listOfDocumentsWithMetadata)); + final List> listOfReheardDocs = Lists.newArrayList(reheardHearingDocuments); + + when(asylumCase.read(IS_REHEARD_APPEAL_ENABLED, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(featureToggler.getValue("dlrm-remitted-feature-flag", false)).thenReturn(true); + + when(sendDecisionAndReasonsCoverLetterService.create(caseDetails)).thenReturn(coverLetter); + when(sendDecisionAndReasonsPdfService.updateDecisionAndReasonsFileName(caseDetails)).thenReturn(pdf); + when(documentReceiver.receive(coverLetter, "", DocumentTag.DECISION_AND_REASONS_COVER_LETTER)) + .thenReturn(coverLetterDocumentWithMetadata); + when(documentReceiver.receive(pdf, "", DocumentTag.FINAL_DECISION_AND_REASONS_PDF)) + .thenReturn(decisionDocumentWithMetadata); + when(documentsAppender.append(Collections.emptyList(), List.of(decisionDocumentWithMetadata, coverLetterDocumentWithMetadata))) + .thenReturn(listOfDocumentsWithMetadata); + when(asylumCase.read(REHEARD_DECISION_REASONS_COLLECTION)).thenReturn(Optional.of(Collections.emptyList())); + when(reheardAppender.append(any(ReheardHearingDocuments.class), anyList())).thenReturn(listOfReheardDocs); + + sendDecisionAndReasonsOrchestrator.sendDecisionAndReasons(caseDetails); + + verify(documentReceiver, times(1)).receive(coverLetter, "", + DocumentTag.DECISION_AND_REASONS_COVER_LETTER); + verify(documentReceiver, times(1)).receive(pdf, "", + DocumentTag.FINAL_DECISION_AND_REASONS_PDF); + verify(documentsAppender, times(1)).append(Collections.emptyList(), + List.of(decisionDocumentWithMetadata, coverLetterDocumentWithMetadata)); + verify(reheardAppender, times(1)).append(any(ReheardHearingDocuments.class), anyList()); + verify(asylumCase, times(1)).write(REHEARD_DECISION_REASONS_COLLECTION, listOfReheardDocs); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileServiceTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileServiceTest.java index 3d8b8cf4b..4e8993e18 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/SendDecisionAndReasonsRenameFileServiceTest.java @@ -9,6 +9,8 @@ import org.springframework.core.io.Resource; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DocumentWithMetadata; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients.DocumentDownloadClient; @@ -34,9 +36,11 @@ public class SendDecisionAndReasonsRenameFileServiceTest { @Mock private DocumentDownloadClient documentDownloadClient; @Mock private DocumentUploader documentUploader; + @Mock private DocumentReceiver documentReceiver; @Mock private CaseDetails caseDetails; @Mock private AsylumCase asylumCase; @Mock private Document finalDecisionAndReasonsDocument; + @Mock private DocumentWithMetadata finalDecisionAndReasonsDocumentWithTag; @Mock private Document uploadedDocument; @Mock private Resource finalDecisionAndReasonsResource; @@ -48,6 +52,7 @@ public void setUp() throws IOException { sendDecisionAndReasonsPdfService = new SendDecisionAndReasonsRenameFileService( documentDownloadClient, documentUploader, + documentReceiver, "some-file-name"); } @@ -60,6 +65,12 @@ public void downloads_and_updates_final_decision_and_reasons_pdf() { when(finalDecisionAndReasonsDocument.getDocumentBinaryUrl()) .thenReturn(binaryDocumentUrl); + when(documentReceiver.receive(any(Document.class), any(String.class), any(DocumentTag.class))) + .thenReturn(finalDecisionAndReasonsDocumentWithTag); + + when(finalDecisionAndReasonsDocumentWithTag.getDocument()) + .thenReturn(finalDecisionAndReasonsDocument); + when(asylumCase.read(AsylumCaseDefinition.FINAL_DECISION_AND_REASONS_DOCUMENT, Document.class)) .thenReturn(Optional.of(finalDecisionAndReasonsDocument)); @@ -113,6 +124,12 @@ public void throws_when_draft_appeal_reference_number_missing() { when(finalDecisionAndReasonsDocument.getDocumentBinaryUrl()) .thenReturn(binaryDocumentUrl); + when(documentReceiver.receive(any(Document.class), any(String.class), any(DocumentTag.class))) + .thenReturn(finalDecisionAndReasonsDocumentWithTag); + + when(finalDecisionAndReasonsDocumentWithTag.getDocument()) + .thenReturn(finalDecisionAndReasonsDocument); + when(asylumCase.read(AsylumCaseDefinition.FINAL_DECISION_AND_REASONS_DOCUMENT, Document.class)) .thenReturn(Optional.of(finalDecisionAndReasonsDocument)); @@ -136,6 +153,12 @@ public void throws_when_draft_appellant_family_name_missing() { when(finalDecisionAndReasonsDocument.getDocumentBinaryUrl()) .thenReturn(binaryDocumentUrl); + when(documentReceiver.receive(any(Document.class), any(String.class), any(DocumentTag.class))) + .thenReturn(finalDecisionAndReasonsDocumentWithTag); + + when(finalDecisionAndReasonsDocumentWithTag.getDocument()) + .thenReturn(finalDecisionAndReasonsDocument); + when(asylumCase.read(AsylumCaseDefinition.FINAL_DECISION_AND_REASONS_DOCUMENT, Document.class)) .thenReturn(Optional.of(finalDecisionAndReasonsDocument)); diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoaderTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoaderTest.java new file mode 100644 index 000000000..ebbadbee2 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayLoaderTest.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import static java.util.Collections.singletonList; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.time.LocalDate; +import java.util.List; +import org.junit.jupiter.api.Test; + +@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage") +class HolidayLoaderTest { + @Test + void loadData() { + GovUkHolidayDatesClient govUkHolidayDatesClient = mock(GovUkHolidayDatesClient.class); + LocalDate holiday = LocalDate.now(); + when(govUkHolidayDatesClient.getHolidayDates()).thenReturn( + new UkHolidayDates(new CountryHolidayDates(singletonList(new HolidayDate(holiday)))) + ); + List holidays = new HolidayLoader(govUkHolidayDatesClient).loadHolidays(); + + assertThat(holidays, is(singletonList(holiday))); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayServiceTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayServiceTest.java new file mode 100644 index 000000000..18f4cbaad --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/service/holidaydates/HolidayServiceTest.java @@ -0,0 +1,89 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.holidaydates; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.time.*; +import java.util.List; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class HolidayServiceTest { + + private static final List HOLIDAYS = List.of( + LocalDate.of(2022, Month.DECEMBER, 25), + LocalDate.of(2022, Month.JANUARY, 1), + LocalDate.of(2022, Month.APRIL, 15) + ); + private HolidayService holidayService; + + @BeforeEach + void setup() { + holidayService = new HolidayService(HOLIDAYS); + } + + @Test + void testIsHolidayZoneDateTimeReturnsTrue() { + HOLIDAYS.stream() + .map(localDate -> ZonedDateTime.of(localDate.atTime(11, 30), ZoneId.systemDefault())) + .forEach(zonedDateTime -> assertTrue(holidayService.isHoliday(zonedDateTime))); + } + + @Test + void testIsHolidayZoneDateTimeReturnsFalse() { + ZonedDateTime zonedDateTime = + ZonedDateTime.of( + LocalDateTime.of(2022, Month.SEPTEMBER, 8, 13, 16), ZoneId.systemDefault()); + assertFalse(holidayService.isHoliday(zonedDateTime)); + } + + @Test + void testIsHolidayLocalDateReturnsTrue() { + HOLIDAYS.forEach(localDate -> assertTrue(holidayService.isHoliday(localDate))); + } + + @Test + void testIsHolidayLocalDateReturnsFalse() { + LocalDate localDate = LocalDate.of(2022, Month.SEPTEMBER, 8); + assertFalse(holidayService.isHoliday(localDate)); + } + + @Test + void testIsWeekendZonedDateTimeReturnsTrue() { + ZonedDateTime saturdaySeptemberTenth = + ZonedDateTime.of( + LocalDateTime.of(2022, Month.SEPTEMBER, 10, 13, 16), ZoneId.systemDefault()); + + ZonedDateTime sundaySeptemberEleventh = + ZonedDateTime.of( + LocalDateTime.of(2022, Month.SEPTEMBER, 11, 13, 16), ZoneId.systemDefault()); + + assertTrue(holidayService.isWeekend(saturdaySeptemberTenth)); + assertTrue(holidayService.isWeekend(sundaySeptemberEleventh)); + } + + @Test + void testIsWeekendZoneDateTimeReturnsFalse() { + ZonedDateTime fridaySeptemberNinth = + ZonedDateTime.of( + LocalDateTime.of(2022, Month.SEPTEMBER, 9, 13, 16), ZoneId.systemDefault()); + + assertFalse(holidayService.isWeekend(fridaySeptemberNinth)); + } + + @Test + void testIsWeekendLocalDateReturnsTrue() { + LocalDate saturdaySeptemberTenth = LocalDate.of(2022, Month.SEPTEMBER, 10); + LocalDate sundaySeptemberEleventh = LocalDate.of(2022, Month.SEPTEMBER, 11); + + assertTrue(holidayService.isWeekend(saturdaySeptemberTenth)); + assertTrue(holidayService.isWeekend(sundaySeptemberEleventh)); + } + + @Test + void testIsWeekendLocalDateReturnsFalse() { + LocalDate fridaySeptemberNinth = LocalDate.of(2022, Month.SEPTEMBER, 9); + + assertFalse(holidayService.isWeekend(fridaySeptemberNinth)); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplateTest.java new file mode 100644 index 000000000..48ec0218c --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AdaSuitabilityTemplateTest.java @@ -0,0 +1,114 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AdaSuitabilityReviewDecision; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class AdaSuitabilityTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + private final String templateName = "ADA_SUITABILITY_TEMPLATE.docx"; + + private AdaSuitabilityTemplate adaSuitabilityTemplate; + private final String now = LocalDate.now().toString(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String legalRepReferenceNumber = "Legal-Rep-Fake-Ref"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final AdaSuitabilityReviewDecision adaSuitability = AdaSuitabilityReviewDecision.UNSUITABLE; + private final String adaSuitabilityReason = "This is the reason"; + private final String adaSuitabilityjudge = "Judgy Judgerson"; + + + @BeforeEach + void setUp() { + adaSuitabilityTemplate = + new AdaSuitabilityTemplate( + templateName + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, adaSuitabilityTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(legalRepReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.of(adaSuitability)); + when(asylumCase.read(SUITABILITY_REVIEW_REASON, String.class)).thenReturn(Optional.ofNullable(adaSuitabilityReason)); + when(asylumCase.read(SUITABILITY_REVIEW_JUDGE, String.class)).thenReturn(Optional.ofNullable(adaSuitabilityjudge)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = adaSuitabilityTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:decisionsandreasons.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(legalRepReferenceNumber, templateFieldValues.get("legalRepReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + + assertEquals(appellantGivenNames.concat(" " + appellantFamilyName), templateFieldValues.get("appellantFullName")); + + assertEquals(adaSuitability, templateFieldValues.get("suitability")); + assertEquals(adaSuitabilityReason, templateFieldValues.get("suitabilityReason")); + assertEquals(adaSuitabilityjudge, templateFieldValues.get("judgeName")); + } + + @ParameterizedTest + @EnumSource(AdaSuitabilityReviewDecision.class) + void test_suitability_and_non_suitability(AdaSuitabilityReviewDecision adaSuitabilityReviewDecision) { + dataSetUp(); + when(asylumCase.read(SUITABILITY_REVIEW_DECISION, AdaSuitabilityReviewDecision.class)).thenReturn(Optional.ofNullable(adaSuitabilityReviewDecision)); + + Map templateFieldValues = adaSuitabilityTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:decisionsandreasons.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(legalRepReferenceNumber, templateFieldValues.get("legalRepReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + + assertEquals(appellantGivenNames.concat(" " + appellantFamilyName), templateFieldValues.get("appellantFullName")); + + assertEquals(adaSuitabilityReviewDecision, templateFieldValues.get("suitability")); + assertEquals(adaSuitabilityReason, templateFieldValues.get("suitabilityReason")); + assertEquals(adaSuitabilityjudge, templateFieldValues.get("judgeName")); + assertEquals(now, templateFieldValues.get("decisionDate")); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplateTest.java index eabf9b3c9..db051961f 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/AppealSubmissionTemplateTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.AppealSubmissionTemplate.formatComplexString; import com.google.common.collect.ImmutableMap; import java.time.LocalDateTime; @@ -15,23 +16,28 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.OutOfCountryDecisionType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ContactPreference; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HasOtherAppeals; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.AddressUk; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.BailApplicationStatus; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; @ExtendWith(MockitoExtension.class) -@MockitoSettings(strictness = Strictness.LENIENT) @SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) public class AppealSubmissionTemplateTest { private final String templateName = "APPEAL_SUBMISSION_TEMPLATE.docx"; @@ -49,6 +55,7 @@ public class AppealSubmissionTemplateTest { private final String legalRepFamilyName = "legalRepFamilyName"; private String homeOfficeReferenceNumber = "A1234567/001"; private String homeOfficeDecisionDate = "2020-12-23"; + private String decisionLetterReceivedDate = "2020-12-23"; private String appellantGivenNames = "Talha"; private String appellantFamilyName = "Awan"; private String appellantDateOfBirth = "1999-12-31"; @@ -59,7 +66,21 @@ public class AppealSubmissionTemplateTest { private String appellantAddressCounty = "South"; private String appellantAddressPostCode = "AB1 2CD"; private String appellantAddressCountry = "Iceland"; - private String appealType = "revocationOfProtection"; + private YesOrNo appellantInDetention = YesOrNo.YES; + private String detentionFacilityPrison = "prison"; + private String detentionFacilityIrc = "immigrationRemovalCentre"; + private String detentionFacilityOther = "other"; + private String prisonName = "HMP Gartree"; + private String nomsNumber = "{noms=Noms1234}"; + private String prisonerReleaseDate = "{release=01-01-2025T06:00:000}"; + private String ircName = "MoJ IRC"; + private String otherName = "{otherName=Other MoJ Facility}"; + private YesOrNo isAcceleratedDetainedAppeal = YesOrNo.YES; + private BailApplicationStatus hasPendingBailApplication = BailApplicationStatus.YES; + private String bailApplicationNumber = "BailRef1234"; + private AsylumAppealType appealType = AsylumAppealType.RP; + private YesOrNo removalOrderOption = YesOrNo.YES; + private String removalOrderDate = "01-01-2023T16:03:002"; private String newMatters = "Some new matters"; private String email = "someone@something.com"; private String mobileNumber = "07987654321"; @@ -100,9 +121,9 @@ public class AppealSubmissionTemplateTest { private String outOfTimeDocumentFileName = "someOutOfTimeDocument.pdf"; private YesOrNo wantsEmail = YesOrNo.YES; - private AppealSubmissionTemplate appealSubmissionTemplate; + @BeforeEach void setUp() { @@ -133,25 +154,31 @@ void should_map_case_data_to_template_field_values() { when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(legalRepReferenceNumber)); when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); when(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class)).thenReturn(Optional.of(homeOfficeDecisionDate)); + when(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class)).thenReturn(Optional.of(decisionLetterReceivedDate)); when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.of(appellantDateOfBirth)); + + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(EMAIL, String.class)).thenReturn(Optional.of(email)); when(asylumCase.read(APPELLANT_ADDRESS)).thenReturn(Optional.of(addressUk)); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.of(appealType)); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(removalOrderOption)); + when(asylumCase.read(REMOVAL_ORDER_DATE, String.class)).thenReturn(Optional.of(removalOrderDate)); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.of(newMatters)); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.of(ContactPreference.WANTS_EMAIL)); when(asylumCase.read(APPELLANT_TITLE, String.class)).thenReturn(Optional.of(appellantTitle)); when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); - when(stringProvider.get("appealType", appealType)).thenReturn(Optional.of(appealType)); - + when(stringProvider.get("appealType", appealType.getValue())).thenReturn(Optional.of(appealType.getValue())); when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.of(appellantNationalities)); when(asylumCase.read(APPEAL_GROUNDS_FOR_DISPLAY)).thenReturn(Optional.of(appealGroundsForDisplay)); when(asylumCase.read(OTHER_APPEALS)).thenReturn(Optional.of(otherAppeals)); + when(asylumCase.read(HAS_OTHER_APPEALS, HasOtherAppeals.class)).thenReturn(Optional.of(HasOtherAppeals.YES)); when(asylumCase.read(APPLICATION_OUT_OF_TIME_EXPLANATION, String.class)).thenReturn(Optional.of(outOfTimeExplanation)); when(asylumCase.read(SUBMISSION_OUT_OF_TIME, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); when(asylumCase.read(APPLICATION_OUT_OF_TIME_DOCUMENT, Document.class)).thenReturn(Optional.of(applicationOutOfTimeDocument)); @@ -163,9 +190,13 @@ void should_map_case_data_to_template_field_values() { when(stringProvider.get("appealGrounds", "protectionHumanRights")).thenReturn(Optional.of("Human rights")); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(27, templateFieldValues.size()); + assertEquals(Optional.of(YesOrNo.NO), templateFieldValues.get("appellantInDetention")); + + assertEquals(33, templateFieldValues.size()); assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); assertEquals("31122020", templateFieldValues.get("CREATED_DATE")); assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); @@ -175,7 +206,7 @@ void should_map_case_data_to_template_field_values() { assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); assertEquals("31121999", templateFieldValues.get("appellantDateOfBirth")); - assertEquals(appealType, templateFieldValues.get("appealType")); + assertEquals(appealType.getValue(), templateFieldValues.get("appealType")); assertEquals(newMatters, templateFieldValues.get("newMatters")); assertEquals(7, ((Map) templateFieldValues.get("appellantAddress")).size()); @@ -203,6 +234,9 @@ void should_map_case_data_to_template_field_values() { assertEquals(wantsEmail, templateFieldValues.get("wantsEmail")); assertEquals(email, templateFieldValues.get("email")); + + assertEquals(YesOrNo.NO, templateFieldValues.get("isAdmin")); + assertEquals(YesOrNo.YES, templateFieldValues.get("hasOtherAppeals")); } @Test @@ -246,11 +280,14 @@ void should_correctly_map_legal_rep_name_when_first_name_and_family_name_provide void should_not_add_appeal_type_if_not_present() { dataSetUp(); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.empty()); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.empty()); + + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(24, templateFieldValues.size()); + assertEquals(29, templateFieldValues.size()); assertFalse(templateFieldValues.containsKey("appealType")); } @@ -263,11 +300,16 @@ void dataSetUp() { when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(legalRepReferenceNumber)); when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); when(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class)).thenReturn(Optional.of(homeOfficeDecisionDate)); + when(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class)).thenReturn(Optional.of(decisionLetterReceivedDate)); when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.of(appellantDateOfBirth)); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.of(appealType)); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(removalOrderOption)); + when(asylumCase.read(REMOVAL_ORDER_DATE, String.class)).thenReturn(Optional.of(removalOrderDate)); + when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.of(newMatters)); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.of(ContactPreference.WANTS_EMAIL)); when(asylumCase.read(LEGAL_REPRESENTATIVE_EMAIL_ADDRESS, String.class)).thenReturn(Optional.empty()); @@ -275,6 +317,27 @@ void dataSetUp() { when(asylumCase.read(MOBILE_NUMBER, String.class)).thenReturn(Optional.of(mobileNumber)); when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(appellantInDetention)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(isAcceleratedDetainedAppeal)); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of(detentionFacilityPrison)); + + when(asylumCase.read(IRC_NAME, String.class)).thenReturn(Optional.of(ircName)); + + asylumCase.put("otherDetentionFacilityName", otherName); + when(asylumCase.get("otherDetentionFacilityName")).thenReturn(Optional.of(otherName)); + + when(asylumCase.read(PRISON_NAME, String.class)).thenReturn(Optional.of(prisonName)); + + asylumCase.put("prisonNOMSNumber", nomsNumber); + when(asylumCase.get("prisonNOMSNumber")).thenReturn(nomsNumber); + + when(asylumCase.containsKey("dateCustodialSentence")).thenReturn(true); + asylumCase.put("dateCustodialSentence", prisonerReleaseDate); + when(asylumCase.get("dateCustodialSentence")).thenReturn(prisonerReleaseDate); + + when(asylumCase.read(HAS_PENDING_BAIL_APPLICATIONS, BailApplicationStatus.class)).thenReturn(Optional.of(hasPendingBailApplication)); + when(asylumCase.read(BAIL_APPLICATION_NUMBER, String.class)).thenReturn(Optional.of(bailApplicationNumber)); + when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.of(appellantNationalities)); when(asylumCase.read(APPEAL_GROUNDS_FOR_DISPLAY)).thenReturn(Optional.of(appealGroundsForDisplay)); when(asylumCase.read(OTHER_APPEALS)).thenReturn(Optional.of(otherAppeals)); @@ -292,7 +355,7 @@ void dataSetUp() { when(asylumCase.read(LEGAL_REP_COMPANY, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.empty()); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.empty()); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.empty()); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.empty()); @@ -302,9 +365,24 @@ void dataSetUp() { when(asylumCase.read(SUBMISSION_OUT_OF_TIME, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPLICATION_OUT_OF_TIME_DOCUMENT, Document.class)).thenReturn(Optional.empty()); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.empty()); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(HAS_OTHER_APPEALS, HasOtherAppeals.class)).thenReturn(Optional.of(HasOtherAppeals.YES)); } + @Test + void should_not_add_removal_date_if_not_present() { + dataSetUp(); + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(39, templateFieldValues.size()); + assertTrue(templateFieldValues.containsKey("removalOrderOption")); + assertEquals(YesOrNo.NO, templateFieldValues.get("removalOrderOption")); + assertFalse(templateFieldValues.containsKey("removalOrderDate")); + } + @Test void should_add_out_of_country_and_no_sponsor() { @@ -317,9 +395,14 @@ void should_add_out_of_country_and_no_sponsor() { when(asylumCase.read(DATE_ENTRY_CLEARANCE_DECISION, String.class)).thenReturn(Optional.of(dateEntryClearanceDecision)); when(asylumCase.read(HAS_CORRESPONDENCE_ADDRESS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(29, templateFieldValues.size()); + assertEquals(33, templateFieldValues.size()); assertTrue(templateFieldValues.containsKey("appealOutOfCountry")); assertTrue(templateFieldValues.containsKey("decisionLetterReceivedDate")); assertTrue(templateFieldValues.containsKey("outOfCountryDecisionType")); @@ -328,6 +411,23 @@ void should_add_out_of_country_and_no_sponsor() { assertTrue(templateFieldValues.containsKey("dateEntryClearanceDecision")); assertTrue(templateFieldValues.containsKey("decisionLetterReceived")); assertFalse(templateFieldValues.containsKey("appellantOutOfCountryAddress")); + + assertTrue(templateFieldValues.containsKey("removalOrderOption")); + assertEquals(YesOrNo.NO, templateFieldValues.get("removalOrderOption")); + assertFalse(templateFieldValues.containsKey("removalOrderDate")); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(YesOrNo.NO), templateFieldValues.get("appellantInDetention")); + assertFalse(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertFalse(templateFieldValues.containsKey("detentionStatus")); + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + assertFalse(templateFieldValues.containsKey("detentionFacility")); + assertFalse(templateFieldValues.containsKey("detentionFacilityName")); + assertFalse(templateFieldValues.containsKey("hasPendingBailApplication")); + assertFalse(templateFieldValues.containsKey("bailApplicationNumber")); } @Test @@ -342,6 +442,7 @@ void should_add_out_of_country_and_with_sponsor() { when(asylumCase.read(HAS_CORRESPONDENCE_ADDRESS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); when(asylumCase.read(APPELLANT_OUT_OF_COUNTRY_ADDRESS, String.class)).thenReturn(Optional.ofNullable(oocAddress)); + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); when(asylumCase.read(HAS_SPONSOR, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); when(asylumCase.read(SPONSOR_GIVEN_NAMES, String.class)).thenReturn(Optional.of("Spencer")); @@ -350,9 +451,11 @@ void should_add_out_of_country_and_with_sponsor() { when(asylumCase.read(SPONSOR_CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.of(ContactPreference.WANTS_EMAIL)); when(asylumCase.read(SPONSOR_EMAIL, String.class)).thenReturn(Optional.of("sponsor@test.com")); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(35, templateFieldValues.size()); + assertEquals(39, templateFieldValues.size()); assertTrue(templateFieldValues.containsKey("appellantOutOfCountryAddress")); assertTrue(templateFieldValues.containsKey("hasSponsor")); assertTrue(templateFieldValues.containsKey("sponsorGivenNames")); @@ -361,6 +464,23 @@ void should_add_out_of_country_and_with_sponsor() { assertTrue(templateFieldValues.containsKey("wantsSponsorEmail")); assertTrue(templateFieldValues.containsKey("sponsorEmail")); assertFalse(templateFieldValues.containsKey("sponsorMobileNumber")); + + assertTrue(templateFieldValues.containsKey("removalOrderOption")); + assertEquals(YesOrNo.NO, templateFieldValues.get("removalOrderOption")); + assertFalse(templateFieldValues.containsKey("removalOrderDate")); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(YesOrNo.NO), templateFieldValues.get("appellantInDetention")); + assertFalse(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertFalse(templateFieldValues.containsKey("detentionStatus")); + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + assertFalse(templateFieldValues.containsKey("detentionFacility")); + assertFalse(templateFieldValues.containsKey("detentionFacilityName")); + assertFalse(templateFieldValues.containsKey("hasPendingBailApplication")); + assertFalse(templateFieldValues.containsKey("bailApplicationNumber")); } @Test @@ -373,10 +493,11 @@ void should_not_add_address_if_no_fixed_address_exists() { when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(legalRepReferenceNumber)); when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); when(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class)).thenReturn(Optional.of(homeOfficeDecisionDate)); + when(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class)).thenReturn(Optional.of(decisionLetterReceivedDate)); when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.of(appellantDateOfBirth)); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.of(appealType)); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.of(newMatters)); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.of(ContactPreference.WANTS_EMAIL)); @@ -384,6 +505,8 @@ void should_not_add_address_if_no_fixed_address_exists() { when(asylumCase.read(APPELLANT_TITLE, String.class)).thenReturn(Optional.of(appellantTitle)); when(asylumCase.read(MOBILE_NUMBER, String.class)).thenReturn(Optional.of(mobileNumber)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.of(appellantNationalities)); @@ -404,7 +527,9 @@ void should_not_add_address_if_no_fixed_address_exists() { when(asylumCase.read(LEGAL_REP_COMPANY, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.empty()); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.empty()); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.empty()); + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(removalOrderOption)); + when(asylumCase.read(REMOVAL_ORDER_DATE, String.class)).thenReturn(Optional.of(removalOrderDate)); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.empty()); @@ -419,7 +544,7 @@ void should_not_add_address_if_no_fixed_address_exists() { Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(24, templateFieldValues.size()); + assertEquals(30, templateFieldValues.size()); assertFalse(templateFieldValues.containsKey("appellantAddress")); } @@ -436,7 +561,10 @@ void should_be_tolerant_of_missing_data() { when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.of(appellantDateOfBirth)); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.of(appealType)); + + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.empty()); + + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); when(asylumCase.read(APPEAL_OUT_OF_COUNTRY, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.of(newMatters)); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.of(ContactPreference.WANTS_EMAIL)); @@ -457,6 +585,7 @@ void should_be_tolerant_of_missing_data() { when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(HOME_OFFICE_DECISION_DATE, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(DECISION_LETTER_RECEIVED_DATE, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.empty()); @@ -464,20 +593,24 @@ void should_be_tolerant_of_missing_data() { when(asylumCase.read(LEGAL_REP_COMPANY, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_DATE_OF_BIRTH, String.class)).thenReturn(Optional.empty()); - when(asylumCase.read(APPEAL_TYPE)).thenReturn(Optional.empty()); + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.empty()); when(asylumCase.read(NEW_MATTERS, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_HAS_FIXED_ADDRESS, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPELLANT_NATIONALITIES)).thenReturn(Optional.empty()); when(asylumCase.read(APPEAL_GROUNDS_FOR_DISPLAY)).thenReturn(Optional.empty()); when(asylumCase.read(OTHER_APPEALS)).thenReturn(Optional.empty()); + when(asylumCase.read(REMOVAL_ORDER_OPTIONS, YesOrNo.class)).thenReturn(Optional.of(removalOrderOption)); + when(asylumCase.read(REMOVAL_ORDER_DATE, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPLICATION_OUT_OF_TIME_EXPLANATION, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(SUBMISSION_OUT_OF_TIME, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(APPLICATION_OUT_OF_TIME_DOCUMENT, Document.class)).thenReturn(Optional.empty()); when(asylumCase.read(CONTACT_PREFERENCE, ContactPreference.class)).thenReturn(Optional.empty()); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.empty()); + when(asylumCase.read(HAS_OTHER_APPEALS, YesOrNo.class)).thenReturn(Optional.empty()); Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); - assertEquals(24, templateFieldValues.size()); + assertEquals(29, templateFieldValues.size()); assertFalse(templateFieldValues.containsKey("appealType")); assertFalse(templateFieldValues.containsKey("appellantAddress")); @@ -487,17 +620,470 @@ void should_be_tolerant_of_missing_data() { assertEquals("", templateFieldValues.get("appealReferenceNumber")); assertEquals("", templateFieldValues.get("legalRepReferenceNumber")); assertEquals("", templateFieldValues.get("homeOfficeReferenceNumber")); - assertEquals("", templateFieldValues.get("homeOfficeDecisionDate")); + assertEquals(null, templateFieldValues.get("homeOfficeDecisionDate")); + assertEquals(null, templateFieldValues.get("decisionLetterReceivedDate")); assertEquals("", templateFieldValues.get("appellantGivenNames")); assertEquals("", templateFieldValues.get("appellantFamilyName")); assertEquals("", templateFieldValues.get("appellantDateOfBirth")); assertEquals("", templateFieldValues.get("newMatters")); assertEquals(0, ((List) templateFieldValues.get("appellantNationalities")).size()); assertEquals(0, ((List) templateFieldValues.get("appealGrounds")).size()); + + assertEquals(YesOrNo.NO, templateFieldValues.get("removalOrderOption")); + assertFalse(templateFieldValues.containsKey("removalOrderDate")); + assertEquals("", templateFieldValues.get("otherAppeals")); assertEquals("", templateFieldValues.get("applicationOutOfTimeExplanation")); assertEquals(YesOrNo.NO, templateFieldValues.get("submissionOutOfTime")); assertEquals("", templateFieldValues.get("applicationOutOfTimeDocumentName")); assertEquals("07987654321", templateFieldValues.get("mobileNumber")); + assertEquals(Optional.of(YesOrNo.NO), templateFieldValues.get("appellantInDetention")); + assertEquals(YesOrNo.NO, templateFieldValues.get("isAdmin")); + assertEquals(YesOrNo.NO, templateFieldValues.get("hasOtherAppeals")); + } + + @Test + void should_be_tolerant_of_missing_detained_data() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.empty()); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(HAS_PENDING_BAIL_APPLICATIONS, BailApplicationStatus.class)).thenReturn(Optional.empty()); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(35, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertEquals(YesOrNo.NO, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertEquals("Detained", templateFieldValues.get("detentionStatus")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals("", templateFieldValues.get("detentionFacilityName")); + + assertEquals(BailApplicationStatus.NO, templateFieldValues.get("hasPendingBailApplication")); + + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + assertFalse(templateFieldValues.containsKey("bailApplicationNumber")); + } + + @Test + void should_be_tolerant_of_missing_detained_irc_data() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.empty()); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of(detentionFacilityIrc)); + when(asylumCase.read(IRC_NAME, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(BAIL_APPLICATION_NUMBER, String.class)).thenReturn(Optional.of("")); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(36, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertEquals(YesOrNo.NO, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertEquals("Detained", templateFieldValues.get("detentionStatus")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Immigration Removal Centre", templateFieldValues.get("detentionFacility")); + assertEquals("", templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals("", templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + assertEquals(Optional.of(""), templateFieldValues.get("bailApplicationNumber")); + + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + } + + @Test + void should_be_tolerant_of_missing_detained_prison_data() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.empty()); + when(asylumCase.read(PRISON_NAME, String.class)).thenReturn(Optional.empty()); + when(asylumCase.read(BAIL_APPLICATION_NUMBER, String.class)).thenReturn(Optional.of("")); + + asylumCase.put("prisonNOMSNumber", ""); + when(asylumCase.get("prisonNOMSNumber")).thenReturn(""); + + asylumCase.put("dateCustodialSentence", ""); + when(asylumCase.get("dateCustodialSentence")).thenReturn(""); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(38, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertEquals(YesOrNo.NO, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertEquals("Detained", templateFieldValues.get("detentionStatus")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals("", templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertEquals(YesOrNo.NO, templateFieldValues.get("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertEquals(YesOrNo.NO, templateFieldValues.get("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(BailApplicationStatus.YES, templateFieldValues.get("hasPendingBailApplication")); + + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + assertEquals(Optional.of(""), templateFieldValues.get("bailApplicationNumber")); + } + + @Test + void should_be_tolerant_of_missing_other_detention_facility_data() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.empty()); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of(detentionFacilityOther)); + when(asylumCase.read(BAIL_APPLICATION_NUMBER, String.class)).thenReturn(Optional.of("")); + + asylumCase.put("otherDetentionFacilityName", ""); + when(asylumCase.get("otherDetentionFacilityName")).thenReturn(""); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(36, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertEquals(YesOrNo.NO, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertEquals("Detained", templateFieldValues.get("detentionStatus")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Other", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals("", templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + assertEquals(Optional.of(""), templateFieldValues.get("bailApplicationNumber")); + + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + } + + @Test + void test_non_detained_template_fields() { + dataSetUp(); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(30, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(YesOrNo.NO), templateFieldValues.get("appellantInDetention")); + + assertFalse(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertFalse(templateFieldValues.containsKey("detentionStatus")); + assertFalse(templateFieldValues.containsKey("detentionFacility")); + assertFalse(templateFieldValues.containsKey("detentionFacilityName")); + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + assertFalse(templateFieldValues.containsKey("hasPendingBailApplication")); + assertFalse(templateFieldValues.containsKey("bailApplicationNumber")); + } + + @Test + void test_detained_non_accelerated_template_fields() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(40, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertTrue(templateFieldValues.containsKey("nomsNumber")); + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertTrue(templateFieldValues.containsKey("releaseDate")); + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + assertEquals(YesOrNo.NO, templateFieldValues.get("isAcceleratedDetainedAppeal")); + assertEquals("Detained", templateFieldValues.get("detentionStatus")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + assertEquals(prisonName, templateFieldValues.get("detentionFacilityName")); + assertEquals(YesOrNo.YES, templateFieldValues.get("nomsAvailable")); + assertEquals(formatComplexString(nomsNumber), templateFieldValues.get("nomsNumber")); + assertEquals(YesOrNo.YES, templateFieldValues.get("releaseDateProvided")); + assertEquals(formatComplexString(prisonerReleaseDate), templateFieldValues.get("releaseDate")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + + } + + @Test + void test_detained_prison_template_fields() { + dataSetUp(); + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(40, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertTrue(templateFieldValues.containsKey("nomsNumber")); + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertTrue(templateFieldValues.containsKey("releaseDate")); + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + assertEquals("Detained - Accelerated", templateFieldValues.get("detentionStatus")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + assertEquals(prisonName, templateFieldValues.get("detentionFacilityName")); + assertEquals(YesOrNo.YES, templateFieldValues.get("nomsAvailable")); + assertEquals(formatComplexString(nomsNumber), templateFieldValues.get("nomsNumber")); + assertEquals(YesOrNo.YES, templateFieldValues.get("releaseDateProvided")); + assertEquals(formatComplexString(prisonerReleaseDate), templateFieldValues.get("releaseDate")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + + } + + @Test + void test_detained_prison_no_bail_template_fields() { + dataSetUp(); + when(asylumCase.read(HAS_PENDING_BAIL_APPLICATIONS, BailApplicationStatus.class)).thenReturn(Optional.of(BailApplicationStatus.NO)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(39, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals(prisonName, templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertEquals(YesOrNo.YES, templateFieldValues.get("nomsAvailable")); + + assertTrue(templateFieldValues.containsKey("nomsNumber")); + assertEquals("Noms1234", templateFieldValues.get("nomsNumber")); + + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertEquals(YesOrNo.YES, templateFieldValues.get("releaseDateProvided")); + + assertTrue(templateFieldValues.containsKey("releaseDate")); + assertEquals(formatComplexString(prisonerReleaseDate), templateFieldValues.get("releaseDate")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(BailApplicationStatus.NO, templateFieldValues.get("hasPendingBailApplication")); + + assertFalse(templateFieldValues.containsKey("bailApplicationNumber")); + } + + @Test + void test_detained_prison_no_release_date_template_fields() { + dataSetUp(); + + asylumCase.put("dateCustodialSentence", ""); + when(asylumCase.get("dateCustodialSentence")).thenReturn(""); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(39, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals(prisonName, templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertEquals(YesOrNo.YES, templateFieldValues.get("nomsAvailable")); + + assertTrue(templateFieldValues.containsKey("nomsNumber")); + assertEquals("Noms1234", templateFieldValues.get("nomsNumber")); + + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertEquals(YesOrNo.NO, templateFieldValues.get("releaseDateProvided")); + + assertFalse(templateFieldValues.containsKey("releaseDate")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(BailApplicationStatus.YES, templateFieldValues.get("hasPendingBailApplication")); + + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + } + + @Test + void test_detained_prison_no_noms_template_fields() { + dataSetUp(); + + asylumCase.put("prisonNOMSNumber", ""); + when(asylumCase.get("prisonNOMSNumber")).thenReturn(""); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(39, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertEquals("Prison", templateFieldValues.get("detentionFacility")); + + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertEquals(prisonName, templateFieldValues.get("detentionFacilityName")); + + assertTrue(templateFieldValues.containsKey("nomsAvailable")); + assertEquals(YesOrNo.NO, templateFieldValues.get("nomsAvailable")); + + assertFalse(templateFieldValues.containsKey("nomsNumber")); + + assertTrue(templateFieldValues.containsKey("releaseDateProvided")); + assertEquals(YesOrNo.YES, templateFieldValues.get("releaseDateProvided")); + + assertTrue(templateFieldValues.containsKey("releaseDate")); + assertEquals(formatComplexString(prisonerReleaseDate), templateFieldValues.get("releaseDate")); + + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertEquals(BailApplicationStatus.YES, templateFieldValues.get("hasPendingBailApplication")); + + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + } + + @Test + void test_detained_irc_template_fields() { + dataSetUp(); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of(detentionFacilityIrc)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(36, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + assertEquals("Detained - Accelerated", templateFieldValues.get("detentionStatus")); + assertEquals("Immigration Removal Centre", templateFieldValues.get("detentionFacility")); + assertEquals(ircName, templateFieldValues.get("detentionFacilityName")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + + } + + @Test + void test_detained_other_facility_template_fields() { + dataSetUp(); + when(asylumCase.read(DETENTION_FACILITY, String.class)).thenReturn(Optional.of(detentionFacilityOther)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(36, templateFieldValues.size()); + + assertTrue(templateFieldValues.containsKey("appellantInDetention")); + assertTrue(templateFieldValues.containsKey("isAcceleratedDetainedAppeal")); + assertTrue(templateFieldValues.containsKey("detentionStatus")); + assertTrue(templateFieldValues.containsKey("detentionFacility")); + assertTrue(templateFieldValues.containsKey("detentionFacilityName")); + assertTrue(templateFieldValues.containsKey("hasPendingBailApplication")); + assertTrue(templateFieldValues.containsKey("bailApplicationNumber")); + + assertFalse(templateFieldValues.containsKey("nomsAvailable")); + assertFalse(templateFieldValues.containsKey("nomsNumber")); + assertFalse(templateFieldValues.containsKey("releaseDateProvided")); + assertFalse(templateFieldValues.containsKey("releaseDate")); + + assertEquals(Optional.of(appellantInDetention), templateFieldValues.get("appellantInDetention")); + assertEquals(isAcceleratedDetainedAppeal, templateFieldValues.get("isAcceleratedDetainedAppeal")); + assertEquals("Detained - Accelerated", templateFieldValues.get("detentionStatus")); + assertEquals("Other", templateFieldValues.get("detentionFacility")); + assertEquals(formatComplexString(otherName), templateFieldValues.get("detentionFacilityName")); + assertEquals(hasPendingBailApplication, templateFieldValues.get("hasPendingBailApplication")); + assertEquals(Optional.of(bailApplicationNumber), templateFieldValues.get("bailApplicationNumber")); + } + + @ParameterizedTest + @EnumSource(YesOrNo.class) + void test_is_admin_field_mapped_to_template_field_values(YesOrNo isAdmin) { + dataSetUp(); + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(isAdmin)); + + Map templateFieldValues = appealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(40, templateFieldValues.size()); + assertTrue(templateFieldValues.containsKey("isAdmin")); + + assertEquals(isAdmin, templateFieldValues.get("isAdmin")); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/CmaRequirementsTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/CmaRequirementsTemplateTest.java index af314f7fb..a6b77d644 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/CmaRequirementsTemplateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/CmaRequirementsTemplateTest.java @@ -55,6 +55,6 @@ void should_return_template_value() { when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(legalRepReferenceNumber)); Map templateFieldValues = cmaRequirementsTemplate.mapFieldValues(caseDetails); - assertEquals(30, templateFieldValues.size()); + assertEquals(29, templateFieldValues.size()); } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingRequirementsTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingRequirementsTemplateTest.java index 24321e367..1c7c1e620 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingRequirementsTemplateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/HearingRequirementsTemplateTest.java @@ -64,7 +64,6 @@ class HearingRequirementsTemplateTest { private YesOrNo pastExperiences = YesOrNo.YES; private String pastExperiencesDescription = "Past experiences description"; - private YesOrNo isOutOfCountryEnabled = YesOrNo.YES; private YesOrNo remoteVideoCall = YesOrNo.YES; private String remoteVideoCallDescription = "Remote video call evidence description"; @@ -190,7 +189,6 @@ void should_map_case_data_to_template_field_values_for_in_country_appeal(Interpr when(asylumCase.read(IS_HEARING_ROOM_NEEDED, YesOrNo.class)).thenReturn(Optional.of(isHearingRoomNeeded)); when(asylumCase.read(IS_HEARING_LOOP_NEEDED, YesOrNo.class)).thenReturn(Optional.of(isHearingLoopNeeded)); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.of(isOutOfCountryEnabled)); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.of(remoteVideoCall)); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.of(remoteVideoCallDescription)); @@ -219,7 +217,8 @@ void should_map_case_data_to_template_field_values_for_in_country_appeal(Interpr Map templateFieldValues = hearingRequirementsTemplate.mapFieldValues(caseDetails); - assertEquals(40, templateFieldValues.size()); + assertEquals(39, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); assertEquals(legalRepReferenceNumber, templateFieldValues.get("legalRepReferenceNumber")); @@ -318,7 +317,6 @@ public void should_map_case_data_to_template_field_values_for_out_of_country_app when(asylumCase.read(PAST_EXPERIENCES, YesOrNo.class)).thenReturn(Optional.of(pastExperiences)); when(asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class)).thenReturn(Optional.of(pastExperiencesDescription)); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.of(isOutOfCountryEnabled)); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.of(remoteVideoCall)); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.of(remoteVideoCallDescription)); @@ -341,7 +339,8 @@ public void should_map_case_data_to_template_field_values_for_out_of_country_app Map templateFieldValues = hearingRequirementsTemplate.mapFieldValues(caseDetails); - assertEquals(40, templateFieldValues.size()); + assertEquals(39, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); assertEquals(legalRepReferenceNumber, templateFieldValues.get("legalRepReferenceNumber")); @@ -377,7 +376,6 @@ public void should_map_case_data_to_template_field_values_for_out_of_country_app ((WitnessInterpreterLanguageInformation)((List) templateFieldValues.get("witnessInterpreterInformationList")).get(1)).getInterpreterLanguage()); assertEquals(isHearingRoomNeeded, templateFieldValues.get("isHearingRoomNeeded")); assertEquals(isHearingLoopNeeded, templateFieldValues.get("isHearingLoopNeeded")); - assertEquals(isOutOfCountryEnabled, templateFieldValues.get("isOutOfCountryEnabled")); assertEquals(remoteVideoCall, templateFieldValues.get("remoteVideoCall")); assertEquals(remoteVideoCallDescription, templateFieldValues.get("remoteVideoCallDescription")); assertEquals(physicalOrMentalHealthIssues, templateFieldValues.get("physicalOrMentalHealthIssues")); @@ -405,7 +403,8 @@ public void should_map_case_data_to_template_field_values_for_out_of_country_app templateFieldValues = hearingRequirementsTemplate.mapFieldValues(caseDetails); - assertEquals(40, templateFieldValues.size()); + assertEquals(39, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); assertEquals(legalRepReferenceNumber, templateFieldValues.get("legalRepReferenceNumber")); @@ -443,7 +442,6 @@ public void should_map_case_data_to_template_field_values_for_out_of_country_app assertEquals(physicalOrMentalHealthIssuesDescription, templateFieldValues.get("physicalOrMentalHealthIssuesDescription")); assertEquals(pastExperiences, templateFieldValues.get("pastExperiences")); assertEquals(pastExperiencesDescription, templateFieldValues.get("pastExperiencesDescription")); - assertEquals(isOutOfCountryEnabled, templateFieldValues.get("isOutOfCountryEnabled")); assertEquals(YesOrNo.NO, templateFieldValues.get("remoteVideoCall")); assertEquals(remoteVideoCallDescription, templateFieldValues.get("remoteVideoCallDescription")); assertEquals(multimediaEvidence, templateFieldValues.get("multimediaEvidence")); @@ -502,7 +500,6 @@ void should_map_case_data_to_template_field_values_no_dates_to_avoid_flag() { when(asylumCase.read(PAST_EXPERIENCES, YesOrNo.class)).thenReturn(Optional.of(pastExperiences)); when(asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class)).thenReturn(Optional.of(pastExperiencesDescription)); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.of(isOutOfCountryEnabled)); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.of(remoteVideoCall)); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.of(remoteVideoCallDescription)); @@ -565,7 +562,6 @@ void should_be_tolerant_of_missing_data() { when(asylumCase.read(PHYSICAL_OR_MENTAL_HEALTH_ISSUES_DESCRIPTION, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(PAST_EXPERIENCES, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class)).thenReturn(Optional.empty()); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.empty()); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.empty()); when(asylumCase.read(MULTIMEDIA_EVIDENCE, YesOrNo.class)).thenReturn(Optional.empty()); @@ -582,7 +578,7 @@ void should_be_tolerant_of_missing_data() { Map templateFieldValues = hearingRequirementsTemplate.mapFieldValues(caseDetails); - assertEquals(40, templateFieldValues.size()); + assertEquals(39, templateFieldValues.size()); assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); assertEquals("", templateFieldValues.get("appealReferenceNumber")); @@ -611,7 +607,6 @@ void should_be_tolerant_of_missing_data() { assertEquals("", templateFieldValues.get("physicalOrMentalHealthIssuesDescription")); assertEquals(YesOrNo.NO, templateFieldValues.get("pastExperiences")); assertEquals("", templateFieldValues.get("pastExperiencesDescription")); - assertEquals(YesOrNo.NO, templateFieldValues.get("isOutOfCountryEnabled")); assertEquals(YesOrNo.NO, templateFieldValues.get("remoteVideoCall")); assertEquals("", templateFieldValues.get("remoteVideoCallDescription")); assertEquals(YesOrNo.NO, templateFieldValues.get("multimediaEvidence")); @@ -666,7 +661,6 @@ void should_default_date_to_avoid_reason_null_values_to_empty_string() { when(asylumCase.read(PAST_EXPERIENCES, YesOrNo.class)).thenReturn(Optional.of(pastExperiences)); when(asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class)).thenReturn(Optional.of(pastExperiencesDescription)); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.of(isOutOfCountryEnabled)); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.of(remoteVideoCall)); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.of(remoteVideoCallDescription)); @@ -751,7 +745,6 @@ void should_default_date_to_avoid_null_values_to_past_date() { when(asylumCase.read(PAST_EXPERIENCES, YesOrNo.class)).thenReturn(Optional.of(pastExperiences)); when(asylumCase.read(PAST_EXPERIENCES_DESCRIPTION, String.class)).thenReturn(Optional.of(pastExperiencesDescription)); - when(asylumCase.read(IS_OUT_OF_COUNTRY_ENABLED, YesOrNo.class)).thenReturn(Optional.of(isOutOfCountryEnabled)); when(asylumCase.read(REMOTE_VIDEO_CALL, YesOrNo.class)).thenReturn(Optional.of(remoteVideoCall)); when(asylumCase.read(REMOTE_VIDEO_CALL_DESCRIPTION, String.class)).thenReturn(Optional.of(remoteVideoCallDescription)); diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplateTest.java new file mode 100644 index 000000000..018f90d19 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalAdaRequestBuildCaseTemplateTest.java @@ -0,0 +1,158 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAdaRequestBuildCaseTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DueDateService dueDateService; + private final String templateName = "TB-IAC-DEC-ENG-00002.docx"; + private final int hearingSupportRequirementsDueInWorkingDays = 15; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1234"; + private final String internalAdaCustomerServicesEmailAddress = "example@email.com"; + private final LocalDate now = LocalDate.now(); + private final ZonedDateTime zonedDueDateTime = LocalDate.parse("2023-01-01").atStartOfDay(ZoneOffset.UTC); + private final LocalDate hearingSupportRequirementsDueDate = zonedDueDateTime.toLocalDate(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String directionExplanation = "Some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final IdValue requestCaseBuildingDirection = new IdValue<>( + "1", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private final IdValue duplicateRequestCaseBuildingDirection = new IdValue<>( + "2", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private final IdValue otherDirection = new IdValue<>( + "3", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.ADA_LIST_CASE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private InternalAdaRequestBuildCaseTemplate internalAdaRequestBuildCaseTemplate; + + @BeforeEach + void setUp() { + internalAdaRequestBuildCaseTemplate = + new InternalAdaRequestBuildCaseTemplate( + hearingSupportRequirementsDueInWorkingDays, + templateName, + customerServicesProvider, + dueDateService + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAdaRequestBuildCaseTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(internalAdaCustomerServicesEmailAddress); + + List> directionList = new ArrayList<>(); + directionList.add(requestCaseBuildingDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + when(dueDateService.calculateDueDate(any(), eq(hearingSupportRequirementsDueInWorkingDays))).thenReturn(zonedDueDateTime); + + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalAdaRequestBuildCaseTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(directionDateDue)), templateFieldValues.get("responseDueDate")); + assertEquals(formatDateForNotificationAttachmentDocument(hearingSupportRequirementsDueDate), templateFieldValues.get("hearingSupportRequirementsDueDate")); + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplateTest.java new file mode 100644 index 000000000..fdf4c79f5 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestHearingRequirementsTemplateTest.java @@ -0,0 +1,117 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +import java.time.LocalDate; +import java.util.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedRequestHearingRequirementsTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-GNO-ENG-00006.docx"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String requestRespondentEvidenceDueDate = "2023-07-10"; + private InternalDetainedRequestHearingRequirementsTemplate internalDetainedRequestHearingRequirementsTemplate; + private final String directionExplanation = "Some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-08-10"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + + private final IdValue requestResponseReviewDirection = new IdValue<>( + "1", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.REQUEST_RESPONSE_REVIEW, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + @BeforeEach + void setUp() { + internalDetainedRequestHearingRequirementsTemplate = + new InternalDetainedRequestHearingRequirementsTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedRequestHearingRequirementsTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(requestRespondentEvidenceDueDate)); + + List> directionList = new ArrayList<>(); + directionList.add(requestResponseReviewDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedRequestHearingRequirementsTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + assertEquals("15 Aug 2023", templateFieldValues.get("hearingReqSubmissionDeadline")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplateTest.java new file mode 100644 index 000000000..5ff497f6f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/InternalDetainedRequestRespondentEvidenceTemplateTest.java @@ -0,0 +1,118 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedRequestRespondentEvidenceTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-GNO-ENG-00010.docx"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String requestRespondentEvidenceDueDate = "2023-07-10"; + private InternalDetainedRequestRespondentEvidenceTemplate internalDetainedRequestRespondentEvidenceTemplate; + private final String directionExplanation = "Some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final ZonedDateTime zonedDueDateTime = LocalDate.parse("2023-01-01").atStartOfDay(ZoneOffset.UTC); + private final IdValue requestRespondentEvidenceDirection = new IdValue<>( + "1", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.RESPONDENT_EVIDENCE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + @BeforeEach + void setUp() { + internalDetainedRequestRespondentEvidenceTemplate = + new InternalDetainedRequestRespondentEvidenceTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedRequestRespondentEvidenceTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(requestRespondentEvidenceDueDate)); + + List> directionList = new ArrayList<>(); + directionList.add(requestRespondentEvidenceDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedRequestRespondentEvidenceTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + assertEquals("16 Jun 2023", templateFieldValues.get("requestRespondentEvidenceDueDate")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplateTest.java new file mode 100644 index 000000000..86b4b5240 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplateTest.java @@ -0,0 +1,46 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +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.helper.UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper; + +@ExtendWith(MockitoExtension.class) +class UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplateTest { + + private final String templateName = ""; + @Mock + private CaseDetails caseDetails; + @Mock + private UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper; + private UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate updatedTribunalAipDecisionAndReasonsCoverLetterTemplate; + + @BeforeEach + public void setUp() { + + updatedTribunalAipDecisionAndReasonsCoverLetterTemplate = new UpdatedTribunalAipDecisionAndReasonsCoverLetterTemplate( + templateName, + templateHelper + ); + } + + @Test + void returns_correctly_mapped_template_values() { + + updatedTribunalAipDecisionAndReasonsCoverLetterTemplate.mapFieldValues(caseDetails); + verify(templateHelper, times(1)).getCommonMapFieldValues(caseDetails); + } + + @Test + void should_return_template_name() { + assertEquals(updatedTribunalAipDecisionAndReasonsCoverLetterTemplate.getName(), templateName); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateTest.java new file mode 100644 index 000000000..d63a4f9a8 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateTest.java @@ -0,0 +1,56 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LEGAL_REP_REFERENCE_NUMBER; + +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +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.helper.UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper; + +@ExtendWith(MockitoExtension.class) +public class UpdatedTribunalDecisionAndReasonsCoverLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper; + + private String templateName = "some-template-name.docx"; + private String someLegalRepReferenceNumber = "some-legal-rep-ref"; + + private UpdatedTribunalDecisionAndReasonsCoverLetterTemplate updatedTribunalDecisionAndReasonsCoverLetterTemplate; + + @BeforeEach + public void setUp() { + + updatedTribunalDecisionAndReasonsCoverLetterTemplate = new UpdatedTribunalDecisionAndReasonsCoverLetterTemplate( + templateName, + templateHelper + ); + } + + @Test + public void returns_correctly_mapped_template_values() { + + when(asylumCase.read(LEGAL_REP_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(someLegalRepReferenceNumber)); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + Map templateValues = updatedTribunalDecisionAndReasonsCoverLetterTemplate.mapFieldValues(caseDetails); + + verify(templateHelper, times(1)).getCommonMapFieldValues(caseDetails); + assertEquals(templateValues.get("legalRepReferenceNumber"), someLegalRepReferenceNumber); + } + + @Test + public void should_return_template_name() { + + assertEquals(updatedTribunalDecisionAndReasonsCoverLetterTemplate.getName(), templateName); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplateTest.java index 125c8a64a..d6adb10fc 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingInitialListingTemplateTest.java @@ -17,6 +17,7 @@ import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.BailCaseFieldDefinition.LISTING_LOCATION; import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.BailCaseFieldDefinition.REF_DATA_LISTING_LOCATION_DETAIL; + import java.util.Map; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingRelistingTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingRelistingTemplateTest.java index 8971a956f..c4480b281 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingRelistingTemplateTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/bail/BailNoticeOfHearingRelistingTemplateTest.java @@ -54,6 +54,7 @@ class BailNoticeOfHearingRelistingTemplateTest { private final String relistingTemplateName = "TB-IAC-HNO-ENG-bails-notice-of-hearings-relisted.docx"; private CourtVenue newCastle; + private BailNoticeOfHearingRelistingTemplate template; private Map fieldValuesMap; @@ -71,6 +72,7 @@ public void setUp() { "Y", "Barras Bridge, Newcastle-Upon-Tyne", "NE1 8QF"); + } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelperTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelperTest.java new file mode 100644 index 000000000..4d670a8d5 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/helper/UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelperTest.java @@ -0,0 +1,102 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.helper; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +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.infrastructure.CustomerServicesProvider; + +import java.util.Map; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.UPDATED_APPEAL_DECISION; + + +@ExtendWith(MockitoExtension.class) +class UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelperTest { + + @Mock + private CustomerServicesProvider customerServicesProvider; + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + + private final String someAppealReferenceNumber = "appealReferenceNumber"; + private final String someHomeOfficeReferenceNumber = "homeOfficeRef"; + private final String someGivenNames = "some-given-name"; + private final String someFamilyName = "some-family-name"; + private String customerServicesTelephone = "555 555 555"; + private String customerServicesEmail = "customer.services@example.com"; + + + private UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper templateHelper; + + @BeforeEach + public void setUp() { + + templateHelper = new UpdatedTribunalDecisionAndReasonsCoverLetterTemplateHelper( + customerServicesProvider + ); + } + + @ParameterizedTest + @ValueSource(strings = {"Allowed", "Dismissed"}) + public void should_map_case_data_to_template_field_values(String updatedAppealDecision) { + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(someAppealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(someHomeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(someGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(someFamilyName)); + when(asylumCase.read(UPDATED_APPEAL_DECISION, String.class)).thenReturn(Optional.of(updatedAppealDecision)); + when((customerServicesProvider.getCustomerServicesTelephone())).thenReturn(customerServicesTelephone); + when((customerServicesProvider.getCustomerServicesEmail())).thenReturn(customerServicesEmail); + + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + Map templateValues = templateHelper.getCommonMapFieldValues(caseDetails); + + assertEquals(8, templateValues.size()); + assertEquals(templateValues.get("hmcts"), "[userImage:hmcts.png]"); + assertEquals(templateValues.get("appealReferenceNumber"), someAppealReferenceNumber); + assertEquals(templateValues.get("homeOfficeReferenceNumber"), someHomeOfficeReferenceNumber); + assertEquals(templateValues.get("appellantGivenNames"), someGivenNames); + assertEquals(templateValues.get("appellantFamilyName"), someFamilyName); + if (updatedAppealDecision.equals("Allowed")) { + assertEquals(templateValues.get("allowed"), "Yes"); + } else { + assertEquals(templateValues.get("allowed"), "No"); + } + assertEquals(customerServicesTelephone, customerServicesProvider.getCustomerServicesTelephone()); + assertEquals(customerServicesEmail, customerServicesProvider.getCustomerServicesEmail()); + } + + @Test + void throws_if_appeal_decision_not_present() { + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(someAppealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(someHomeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(someGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(someFamilyName)); + + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(UPDATED_APPEAL_DECISION, String.class)) + .thenReturn(Optional.empty()); + + assertThatThrownBy(() -> templateHelper.getCommonMapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("update appeal decision must be present"); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplateTest.java new file mode 100644 index 000000000..34e9eef2b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HoReviewEvidenceLetterTemplateTest.java @@ -0,0 +1,104 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class HoReviewEvidenceLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + private final String templateName = "DET_HO_REVIEW.docx"; + @Mock private DateProvider dateProvider; + @Mock private CustomerServicesProvider customerServicesProvider; + private final Parties directionParties = Parties.RESPONDENT; + private final String directionDateDue = "2023-08-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final IdValue hoReviewDirection = new IdValue<>( + "1", + new Direction( + "HO Review Request Direction", + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.RESPONDENT_REVIEW, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private HoReviewEvidenceLetterTemplate hoReviewEvidenceLetterTemplate; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + + + @BeforeEach + void setUp() { + hoReviewEvidenceLetterTemplate = + new HoReviewEvidenceLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, hoReviewEvidenceLetterTemplate.getName()); + } + + void dataSetUp() { + List> directionList = new ArrayList<>(); + directionList.add(hoReviewDirection); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(dateProvider.now()).thenReturn(LocalDate.parse("2023-06-27")); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = hoReviewEvidenceLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals("16 Aug 2023", templateFieldValues.get("directionDueDate")); + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplateTest.java new file mode 100644 index 000000000..d185c0c1e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/HomeOfficeNonStandardDirectionLetterTemplateTest.java @@ -0,0 +1,114 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class HomeOfficeNonStandardDirectionLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DirectionFinder directionFinder; + private HomeOfficeNonStandardDirectionLetterTemplate homeOfficeNonStandardDirectionLetterTemplate; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final LocalDate now = LocalDate.now(); + private final String templateName = "TB-IAC-LET-ENG-00041.docx"; + private final String directionExplanation = "test reasons new direction sent"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final Direction directionOne = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + public HomeOfficeNonStandardDirectionLetterTemplateTest() { + } + + @BeforeEach + public void setUp() { + homeOfficeNonStandardDirectionLetterTemplate = + new HomeOfficeNonStandardDirectionLetterTemplate( + templateName, + customerServicesProvider, + directionFinder + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, homeOfficeNonStandardDirectionLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email);; + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionOne)); + Map templateFieldValues = homeOfficeNonStandardDirectionLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals(telephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(email, templateFieldValues.get("customerServicesEmail")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(directionExplanation, templateFieldValues.get("directionExplanation")); + + + } +} + diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplateTest.java new file mode 100644 index 000000000..dcecbfcfa --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewSuitableLetterTemplateTest.java @@ -0,0 +1,154 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAdaSuitabilityReviewSuitableLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-DEC-ENG-00003.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1234"; + private final String internalAdaCustomerServicesEmailAddress = "example@email.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String listCaseHearingDate = "2023-06-30T00:00:00.000"; + private final String formattedListCaseHearingDate = "30062023"; + private final String hearingType = "Video hearing type response"; + private final String vulnerabilities = "Health issues response"; + private final String pastExperiences = "Past experiences response"; + private final String multimedia = "Multimedia response"; + private final String singleSexCourt = "Single-sex response"; + private final String inCamera = "Private hearing response"; + private final String otherHearingRequest = "Other response"; + private final Parties directionParties = Parties.RESPONDENT; + + private final IdValue respondentReviewDirection = new IdValue<>( + "1", + new Direction( + "HO Review Request Direction", + directionParties, + "2023-08-16", + "2023-06-02", + DirectionTag.RESPONDENT_REVIEW, + Collections.emptyList(), + Collections.emptyList(), + "95e90870-2429-4660-b9c2-4111aff37304", + "someDirectionType" + ) + ); + + private final IdValue requestCaseBuildingDirection = new IdValue<>( + "1", + new Direction( + "Case Building Request Direction", + directionParties, + "2023-08-02", + "2023-06-05", + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + "95e90870-2429-4660-b9c2-4111aff45604", + "someDirectionType" + ) + ); + + private InternalAdaSuitabilityReviewSuitableLetterTemplate internalAdaSuitabilityReviewSuitableLetterTemplate; + + @BeforeEach + void setUp() { + internalAdaSuitabilityReviewSuitableLetterTemplate = + new InternalAdaSuitabilityReviewSuitableLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAdaSuitabilityReviewSuitableLetterTemplate.getName()); + } + + void dataSetUp() { + List> directionList = new ArrayList<>(); + directionList.add(respondentReviewDirection); + directionList.add(requestCaseBuildingDirection); + + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(listCaseHearingDate)); + when(asylumCase.read(REMOTE_VIDEO_CALL_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(hearingType)); + when(asylumCase.read(VULNERABILITIES_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(vulnerabilities)); + when(asylumCase.read(PAST_EXPERIENCES_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(pastExperiences)); + when(asylumCase.read(MULTIMEDIA_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(multimedia)); + when(asylumCase.read(SINGLE_SEX_COURT_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(singleSexCourt)); + when(asylumCase.read(IN_CAMERA_COURT_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(inCamera)); + when(asylumCase.read(ADDITIONAL_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(otherHearingRequest)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalAdaCustomerServicesEmailAddress); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalAdaSuitabilityReviewSuitableLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(18, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("ADAemail")); + assertEquals(formattedListCaseHearingDate, templateFieldValues.get("hearingDate")); + assertEquals(hearingType, templateFieldValues.get("hearingType")); + assertEquals(vulnerabilities, templateFieldValues.get("vulnerabilities")); + assertEquals(pastExperiences, templateFieldValues.get("pastExperiences")); + assertEquals(multimedia, templateFieldValues.get("multimedia")); + assertEquals(singleSexCourt, templateFieldValues.get("singleSexCourt")); + assertEquals(inCamera, templateFieldValues.get("inCamera")); + assertEquals(otherHearingRequest, templateFieldValues.get("otherHearingRequest")); + assertEquals("2 Aug 2023", templateFieldValues.get("caseBuildingDueDate")); + assertEquals("16 Aug 2023", templateFieldValues.get("requestRespondentReviewDueDate")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplateTest.java new file mode 100644 index 000000000..14a20a71a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAdaSuitabilityReviewUnsuitableLetterTemplateTest.java @@ -0,0 +1,107 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.letter.InternalAdaSuitabilityReviewUnsuitableLetterTemplate; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAdaSuitabilityReviewUnsuitableLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-DEC-ENG-00005.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1234"; + private final String internalAdaCustomerServicesEmailAddress = "example@email.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String hearingType = "Video hearing type response"; + private final String vulnerabilities = "Health issues response"; + private final String pastExperiences = "Past experiences response"; + private final String multimedia = "Multimedia response"; + private final String singleSexCourt = "Single-sex response"; + private final String inCamera = "Private hearing response"; + private final String otherHearingRequest = "Other response"; + + private InternalAdaSuitabilityReviewUnsuitableLetterTemplate internalAdaSuitabilityReviewUnsuitableLetterTemplate; + + @BeforeEach + void setUp() { + internalAdaSuitabilityReviewUnsuitableLetterTemplate = + new InternalAdaSuitabilityReviewUnsuitableLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAdaSuitabilityReviewUnsuitableLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(REMOTE_VIDEO_CALL_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(hearingType)); + when(asylumCase.read(VULNERABILITIES_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(vulnerabilities)); + when(asylumCase.read(PAST_EXPERIENCES_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(pastExperiences)); + when(asylumCase.read(MULTIMEDIA_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(multimedia)); + when(asylumCase.read(SINGLE_SEX_COURT_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(singleSexCourt)); + when(asylumCase.read(IN_CAMERA_COURT_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(inCamera)); + when(asylumCase.read(ADDITIONAL_TRIBUNAL_RESPONSE, String.class)).thenReturn(Optional.of(otherHearingRequest)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(internalAdaCustomerServicesEmailAddress); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalAdaSuitabilityReviewUnsuitableLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(15, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("ADAemail")); + assertEquals(hearingType, templateFieldValues.get("hearingType")); + assertEquals(vulnerabilities, templateFieldValues.get("vulnerabilities")); + assertEquals(pastExperiences, templateFieldValues.get("pastExperiences")); + assertEquals(multimedia, templateFieldValues.get("multimedia")); + assertEquals(singleSexCourt, templateFieldValues.get("singleSexCourt")); + assertEquals(inCamera, templateFieldValues.get("inCamera")); + assertEquals(otherHearingRequest, templateFieldValues.get("otherHearingRequest")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplateTest.java new file mode 100644 index 000000000..034eea7df --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealCanProceedLetterTemplateTest.java @@ -0,0 +1,98 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalAppealCanProceedLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-DEC-ENG-00012.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String detainedEmail = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String appealSubmissionDate = "2023-07-10"; + private InternalAppealCanProceedLetterTemplate internalAppealCanProceedLetterTemplate; + + @BeforeEach + void setUp() { + internalAppealCanProceedLetterTemplate = + new InternalAppealCanProceedLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAppealCanProceedLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(detainedEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(appealSubmissionDate)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalAppealCanProceedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(detainedEmail, templateFieldValues.get("detainedEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(appealSubmissionDate).plusWeeks(4)), templateFieldValues.get("dueDate")); + } + + @Test + void should_throw_when_appeal_submission_date_not_present() { + dataSetUp(); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalAppealCanProceedLetterTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("appealSubmissionDate is missing"); + + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplateTest.java new file mode 100644 index 000000000..5af8280fb --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppealSubmissionTemplateTest.java @@ -0,0 +1,98 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalAppealSubmissionTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-DEC-ENG-00010.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String detainedEmail = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String appealSubmissionDate = "2023-07-10"; + private InternalAppealSubmissionTemplate internalAppealSubmissionTemplate; + + @BeforeEach + void setUp() { + internalAppealSubmissionTemplate = + new InternalAppealSubmissionTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAppealSubmissionTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(detainedEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(appealSubmissionDate)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalAppealSubmissionTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(detainedEmail, templateFieldValues.get("detainedEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(appealSubmissionDate).plusWeeks(4)), templateFieldValues.get("dueDate")); + } + + @Test + void should_throw_when_appeal_submission_date_not_present() { + dataSetUp(); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalAppealSubmissionTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("appealSubmissionDate is missing"); + + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplateTest.java new file mode 100644 index 000000000..96ba9995d --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedGrantedLetterTemplateTest.java @@ -0,0 +1,92 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalAppellantFtpaDecidedGrantedLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-LET-ENG-00018.docx"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private InternalAppellantFtpaDecidedGrantedLetterTemplate internalAppellantFtpaDecidedGrantedLetterTemplate; + + @BeforeEach + void setUp() { + internalAppellantFtpaDecidedGrantedLetterTemplate = + new InternalAppellantFtpaDecidedGrantedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(customerServicesEmail); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAppellantFtpaDecidedGrantedLetterTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalAppellantFtpaDecidedGrantedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest.java new file mode 100644 index 000000000..ef01fb85b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest.java @@ -0,0 +1,127 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DueDateService dueDateService; + private final String templateName = "TB-IAC-LET-ENG-00020.docx"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final int adaDueInWorkingDays = 7; + private final int nonAdaDueInCalendarDays = 14; + private final LocalDate now = LocalDate.now(); + private final ZonedDateTime zonedDueDateTime = LocalDate.parse("2023-01-01").atStartOfDay(ZoneOffset.UTC); + private final LocalDate utApplicationDueDate = zonedDueDateTime.toLocalDate(); + private InternalAppellantFtpaDecidedPartiallyGrantedTemplate internalAppellantFtpaDecidedPartiallyGrantedTemplate; + + @BeforeEach + void setUp() { + internalAppellantFtpaDecidedPartiallyGrantedTemplate = + new InternalAppellantFtpaDecidedPartiallyGrantedTemplate( + templateName, + dateProvider, + customerServicesProvider, + dueDateService, + adaDueInWorkingDays, + nonAdaDueInCalendarDays + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(customerServicesEmail); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + when(dueDateService.calculateDueDate(any(), eq(adaDueInWorkingDays))).thenReturn(zonedDueDateTime); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAppellantFtpaDecidedPartiallyGrantedTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalAppellantFtpaDecidedPartiallyGrantedTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + + } + + @Test + void should_return_7_working_days_for_ada() { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + Map templateFieldValues = internalAppellantFtpaDecidedPartiallyGrantedTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(utApplicationDueDate), templateFieldValues.get("utApplicationDeadline")); + } + + @Test + void should_return_14_calendar_days_for_non_ada() { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = internalAppellantFtpaDecidedPartiallyGrantedTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(nonAdaDueInCalendarDays)), templateFieldValues.get("utApplicationDeadline")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplateTest.java new file mode 100644 index 000000000..45c205641 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalAppellantFtpaDecidedRefusedTemplateTest.java @@ -0,0 +1,129 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalAppellantFtpaDecidedRefusedTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DueDateService dueDateService; + private final String templateName = "TB-IAC-LET-ENG-00023.docx"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final int adaDueInWorkingDays = 7; + private final int nonAdaDueInCalendarDays = 14; + private final LocalDate now = LocalDate.now(); + private final ZonedDateTime zonedDueDateTime = LocalDate.parse("2023-01-01").atStartOfDay(ZoneOffset.UTC); + private final LocalDate utApplicationDueDate = zonedDueDateTime.toLocalDate(); + private InternalAppellantFtpaDecidedRefusedTemplate internalAppellantFtpaDecidedRefusedTemplate; + + @BeforeEach + void setUp() { + internalAppellantFtpaDecidedRefusedTemplate = + new InternalAppellantFtpaDecidedRefusedTemplate( + templateName, + adaDueInWorkingDays, + nonAdaDueInCalendarDays, + dateProvider, + customerServicesProvider, + dueDateService + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(customerServicesEmail); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + when(dueDateService.calculateDueDate(any(), eq(adaDueInWorkingDays))).thenReturn(zonedDueDateTime); + + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalAppellantFtpaDecidedRefusedTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalAppellantFtpaDecidedRefusedTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + + } + + @Test + void should_return_7_working_days_for_ada() { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + Map templateFieldValues = internalAppellantFtpaDecidedRefusedTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(utApplicationDueDate), templateFieldValues.get("utApplicationDeadline")); + } + + @Test + void should_return_14_calendar_days_for_non_ada() { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = internalAppellantFtpaDecidedRefusedTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(nonAdaDueInCalendarDays)), templateFieldValues.get("utApplicationDeadline")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplateTest.java new file mode 100644 index 000000000..3c455b811 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalApplyForFtpaAppellantLetterTemplateTest.java @@ -0,0 +1,92 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.infrastructure.CustomerServicesProvider; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalApplyForFtpaAppellantLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "TB-IAC-DEC-ENG-00017.docx"; + private final String customerServicesTelephoneNumber = "0300 123 1711"; + private final String customerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private InternalApplyForFtpaAppellantLetterTemplate internalApplyForFtpaAppellantLetterTemplate; + + @BeforeEach + void setUp() { + internalApplyForFtpaAppellantLetterTemplate = + new InternalApplyForFtpaAppellantLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(customerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(customerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalApplyForFtpaAppellantLetterTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalApplyForFtpaAppellantLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplateTest.java new file mode 100644 index 000000000..17eb7f82f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalChangeHearingCentreLetterTemplateTest.java @@ -0,0 +1,120 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.Callback; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = org.mockito.quality.Strictness.LENIENT) +public class InternalChangeHearingCentreLetterTemplateTest { + @Mock + Callback mockCallback; + @Mock + CaseDetails mockCaseDetails; + @Mock + CaseDetails mockCaseDetailsBefore; + @Mock + AsylumCase mockAsylumCase; + @Mock + AsylumCase mockAsylumCaseBefore; + private static InternalChangeHearingCentreLetterTemplate internalChangeHearingCentreLetterTemplate; + private final String templateName = "someTemplateId"; + @Mock + CustomerServicesProvider customerServicesProvider; + @Mock + StringProvider stringProvider; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "HU/22222/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + + @BeforeEach + void setUp() { + internalChangeHearingCentreLetterTemplate = new InternalChangeHearingCentreLetterTemplate(templateName, customerServicesProvider, stringProvider); + when(mockCallback.getCaseDetails()).thenReturn(mockCaseDetails); + when(mockCaseDetails.getCaseData()).thenReturn(mockAsylumCase); + when(mockCallback.getCaseDetailsBefore()).thenReturn(Optional.of(mockCaseDetailsBefore)); + when(mockCaseDetailsBefore.getCaseData()).thenReturn(mockAsylumCaseBefore); + when(customerServicesProvider.getInternalCustomerServicesTelephone(mockAsylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(mockAsylumCase)).thenReturn(customerServicesEmail); + when(mockAsylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(mockAsylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(mockAsylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(mockAsylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(mockAsylumCase.read(HEARING_CENTRE, HearingCentre.class)) + .thenReturn(Optional.of(HearingCentre.MANCHESTER)); + when(mockAsylumCaseBefore.read(AsylumCaseDefinition.HEARING_CENTRE, HearingCentre.class)) + .thenReturn(Optional.of(HearingCentre.BIRMINGHAM)); + when(stringProvider.get("hearingCentreName", HearingCentre.BIRMINGHAM.toString())).thenReturn(Optional.of("Birmingham")); + when(stringProvider.get("hearingCentreName", HearingCentre.MANCHESTER.toString())).thenReturn(Optional.of("Manchester")); + } + + @Test + void testGetTemplateMethod() { + assertEquals(templateName, internalChangeHearingCentreLetterTemplate.getName()); + } + + @Test + void testMapFieldValues() { + Map templateFieldValues = internalChangeHearingCentreLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore); + assertEquals("Birmingham", templateFieldValues.get("oldHearingCentre")); + assertEquals("Manchester", templateFieldValues.get("newHearingCentre")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + + @Test + void should_throw_when_list_case_hearing_centre_not_present() { + when(mockAsylumCase.read(HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalChangeHearingCentreLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre is not present"); + + } + + @Test + void should_throw_when_list_case_hearing_centre_before_not_present() { + when(mockAsylumCaseBefore.read(HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalChangeHearingCentreLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + + } + + @Test + public void should_throw_exception_when_hearing_centre_name_cannot_be_found() { + when(stringProvider.get("hearingCentreName", HearingCentre.BIRMINGHAM.toString())).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalChangeHearingCentreLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplateTest.java new file mode 100644 index 000000000..497398e01 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplateTest.java @@ -0,0 +1,156 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.*; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private MakeAnApplicationService makeAnApplicationService; + private final String templateName = "TB-IAC-DEC-ENG-00015.docx"; + private final String timeExtentionContent = "The Tribunal will give you more time to complete your next task. You will get a notification with the new date soon."; + private final String adjournExpediteTransferOrUpdateHearingReqsContent = "The details of your hearing will be updated. The Tribunal will contact you when this happens."; + private final String judgesReviewContent = "The decision on your original request will be overturned. The Tribunal will contact you if there is something you need to do next."; + private final String linkOrUnlinkContent = "This appeal will be linked or unlinked. The Tribunal will contact you when this happens."; + private final String withdrawnContent = "The Tribunal will end the appeal. The Tribunal will contact you when this happens."; + private final String updateUpdateDetailsOrOtherContent = "The Tribunal will contact you when it makes the changes you requested."; + private final String transferOutOfAdaContent = "Your appeal will continue but will no longer be decided within 25 working days. The Tribunal will change the date of your hearing. The Tribunal will contact you with a new date for your hearing and to tell you what will happen next with your appeal."; + private static final String reinstateAppealContent = "This appeal will be reinstated and will continue from the point where it was ended. You will be notified when this happens."; + + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate internalDecideAnAppellantApplicationDecisionGrantedLetterTemplate; + + @BeforeEach + void setUp() { + internalDecideAnAppellantApplicationDecisionGrantedLetterTemplate = + new InternalDecideAnAppellantApplicationDecisionGrantedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + makeAnApplicationService + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalAdaCustomerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDecideAnAppellantApplicationDecisionGrantedLetterTemplate.getName()); + } + + @ParameterizedTest + @EnumSource(value = MakeAnApplicationTypes.class) + void should_map_case_data_to_template_field_values(MakeAnApplicationTypes makeAnApplicationTypes) { + dataSetup(); + List> makeAnApplications = new ArrayList<>(); + final MakeAnApplication testApplication = new MakeAnApplication( + "Admin Officer", + makeAnApplicationTypes.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + "Granted", + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + testApplication.setDecisionReason("No reason"); + makeAnApplications.add(new IdValue<>("1", testApplication)); + + Map applicationPropeties = Map.of( + APPLICATION_TYPE, testApplication.getType(), + APPLICATION_DECISION, testApplication.getDecision(), + APPLICATION_DECISION_REASON, testApplication.getDecisionReason() + ); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(testApplication)); + when(makeAnApplicationService.retrieveApplicationProperties(any())).thenReturn(applicationPropeties); + when(makeAnApplicationService.getApplicationTypes(any())).thenReturn(makeAnApplicationTypes); + + Map templateFieldValues = internalDecideAnAppellantApplicationDecisionGrantedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(11, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(testApplication.getType(), templateFieldValues.get("applicationType")); + assertEquals(testApplication.getDecisionReason(), templateFieldValues.get("applicationReason")); + + switch (makeAnApplicationTypes) { + case TIME_EXTENSION -> assertEquals(timeExtentionContent, templateFieldValues.get("whatHappensNextContent")); + case ADJOURN, EXPEDITE, TRANSFER, UPDATE_HEARING_REQUIREMENTS -> assertEquals(adjournExpediteTransferOrUpdateHearingReqsContent, templateFieldValues.get("whatHappensNextContent")); + case JUDGE_REVIEW, JUDGE_REVIEW_LO -> assertEquals(judgesReviewContent, templateFieldValues.get("whatHappensNextContent")); + case LINK_OR_UNLINK -> assertEquals(linkOrUnlinkContent, templateFieldValues.get("whatHappensNextContent")); + case WITHDRAW -> assertEquals(withdrawnContent, templateFieldValues.get("whatHappensNextContent")); + case REINSTATE -> assertEquals(reinstateAppealContent, templateFieldValues.get("whatHappensNextContent")); + case UPDATE_APPEAL_DETAILS, OTHER -> assertEquals(updateUpdateDetailsOrOtherContent, templateFieldValues.get("whatHappensNextContent")); + case TRANSFER_OUT_OF_ACCELERATED_DETAINED_APPEALS_PROCESS -> assertEquals(transferOutOfAdaContent, templateFieldValues.get("whatHappensNextContent")); + default -> { } + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplateTest.java new file mode 100644 index 000000000..680a5b009 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplateTest.java @@ -0,0 +1,188 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.*; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.UserDetailsProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.UserDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private MakeAnApplicationService makeAnApplicationService; + @Mock + UserDetailsProvider userDetailsProvider; + @Mock + UserDetails userDetails; + private final String judgeRole = "caseworker-ia-iacjudge"; + private final String legalOfficerRole = "caseworker-ia-caseofficer"; + private final String applicationRefusedAdaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private final String applicationRefusedDetainedNonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + private final String templateName = "TB-IAC-DEC-ENG-00016.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private List> makeAnApplications = new ArrayList<>(); + private final MakeAnApplication application = new MakeAnApplication( + "Admin Officer", + "Adjourn", + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + "Refused", + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + private InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate internalDecideAnApplicationDecisionRefusedLetterTemplate; + + @BeforeEach + void setUp() { + internalDecideAnApplicationDecisionRefusedLetterTemplate = + new InternalDecideAnAppellantApplicationDecisionRefusedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + makeAnApplicationService, + userDetailsProvider + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalAdaCustomerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + + when(userDetailsProvider.getUserDetails()).thenReturn(userDetails); + when(userDetails.getRoles()).thenReturn(List.of(judgeRole)); + + application.setDecisionReason("No reason"); + makeAnApplications.add(new IdValue<>("1", application)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + + Map applicationPropeties = Map.of( + APPLICATION_TYPE, application.getType(), + APPLICATION_DECISION, application.getDecision(), + APPLICATION_DECISION_REASON, application.getDecisionReason() + ); + + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(application)); + when(makeAnApplicationService.retrieveApplicationProperties(any())).thenReturn(applicationPropeties); + when(makeAnApplicationService.getApplicationTypes(any())).thenReturn(MakeAnApplicationTypes.ADJOURN); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDecideAnApplicationDecisionRefusedLetterTemplate.getName()); + } + + @ParameterizedTest + @ValueSource(strings = {judgeRole, legalOfficerRole}) + void should_map_case_data_to_template_field_values_and_map_decision_maker_field_correctly(String role) { + dataSetup(); + + when(userDetailsProvider.getUserDetails().getRoles()).thenReturn(List.of(role)); + + Map templateFieldValues = internalDecideAnApplicationDecisionRefusedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(application.getType(), templateFieldValues.get("applicationType")); + assertEquals(application.getDecisionReason(), templateFieldValues.get("applicationReason")); + assertEquals(applicationRefusedDetainedNonAdaFormName, templateFieldValues.get("formName")); + + if (role.equals(judgeRole)) { + assertEquals("Judge", templateFieldValues.get("decisionMaker")); + } else if (role.equals(legalOfficerRole)) { + assertEquals("Legal Officer", templateFieldValues.get("decisionMaker")); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void should_map_case_data_to_template_field_values_and_map_decision_maker_field_correctly(YesOrNo yesOrNo) { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + Map templateFieldValues = internalDecideAnApplicationDecisionRefusedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(application.getType(), templateFieldValues.get("applicationType")); + assertEquals(application.getDecisionReason(), templateFieldValues.get("applicationReason")); + assertEquals("Judge", templateFieldValues.get("decisionMaker")); + + + if (yesOrNo.equals(YesOrNo.YES)) { + assertEquals(applicationRefusedAdaFormName, templateFieldValues.get("formName")); + } else { + assertEquals(applicationRefusedDetainedNonAdaFormName, templateFieldValues.get("formName")); + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplateTest.java new file mode 100644 index 000000000..e8168af90 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplateTest.java @@ -0,0 +1,144 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private MakeAnApplicationService makeAnApplicationService; + private final String templateName = "TB-IAC-DEC-ENG-00024.docx"; + private static final String timeExtentionContent = "The Tribunal will give the Home Office more time to complete its next task. You will get a notification with the new date soon."; + private static final String adjournExpediteTransferOrUpdateHearingReqsContent = "The details of the hearing will be updated and you will be sent a new Notice of Hearing with the agreed changes."; + private static final String judgesReviewContent = "The decision on the Home Office’s original request will be overturned. You will be notified if there is something you need to do next."; + private static final String linkOrUnlinkContent = "This appeal will be linked to or unlinked from the appeal in the Home Office application. You will be notified when this happens."; + private static final String withdrawnContent = "The Tribunal will end the appeal. You will be notified when this happens."; + private static final String reinstateAppealContent = "This appeal will be reinstated and will continue from the point where it was ended. You will be notified when this happens."; + private static final String applicationTypeOtherContent = "You will be notified when the Tribunal makes the changes the Home Office asked for."; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate internalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate; + + @BeforeEach + void setUp() { + internalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate = + new InternalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + makeAnApplicationService + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalAdaCustomerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate.getName()); + } + + @ParameterizedTest + @EnumSource(value = MakeAnApplicationTypes.class) + void should_map_case_data_to_template_field_values(MakeAnApplicationTypes makeAnApplicationTypes) { + dataSetup(); + List> makeAnApplications = new ArrayList<>(); + final MakeAnApplication testApplication = new MakeAnApplication( + "Respondent", + makeAnApplicationTypes.getValue(), + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + "Granted", + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + makeAnApplications.add(new IdValue<>("1", testApplication)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(testApplication)); + when(makeAnApplicationService.getApplicationTypes(any())).thenReturn(makeAnApplicationTypes); + + Map templateFieldValues = internalDecideHomeOfficeApplicationDecisionGrantedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(11, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(testApplication.getType(), templateFieldValues.get("applicationType")); + assertEquals(testApplication.getDecisionReason(), templateFieldValues.get("applicationReason")); + + switch (makeAnApplicationTypes) { + case TIME_EXTENSION -> assertEquals(timeExtentionContent, templateFieldValues.get("whatHappensNextContent")); + case ADJOURN, EXPEDITE, TRANSFER, UPDATE_HEARING_REQUIREMENTS -> assertEquals(adjournExpediteTransferOrUpdateHearingReqsContent, templateFieldValues.get("whatHappensNextContent")); + case JUDGE_REVIEW, JUDGE_REVIEW_LO -> assertEquals(judgesReviewContent, templateFieldValues.get("whatHappensNextContent")); + case LINK_OR_UNLINK -> assertEquals(linkOrUnlinkContent, templateFieldValues.get("whatHappensNextContent")); + case WITHDRAW -> assertEquals(withdrawnContent, templateFieldValues.get("whatHappensNextContent")); + case REINSTATE -> assertEquals(reinstateAppealContent, templateFieldValues.get("whatHappensNextContent")); + case OTHER -> assertEquals(applicationTypeOtherContent, templateFieldValues.get("whatHappensNextContent")); + default -> { } + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplateTest.java new file mode 100644 index 000000000..66b4c8715 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplateTest.java @@ -0,0 +1,135 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.*; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private MakeAnApplicationService makeAnApplicationService; + private final String templateName = "TB-IAC-DEC-ENG-00016.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private List> makeAnApplications = new ArrayList<>(); + private final MakeAnApplication application = new MakeAnApplication( + "Admin Officer", + "Adjourn", + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + "Refused", + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + private InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate internalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate; + + @BeforeEach + void setUp() { + internalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate = + new InternalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + makeAnApplicationService + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalAdaCustomerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + + application.setDecisionReason("No reason"); + makeAnApplications.add(new IdValue<>("1", application)); + + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of("1")); + + Map applicationPropeties = Map.of( + APPLICATION_TYPE, application.getType(), + APPLICATION_DECISION, application.getDecision(), + APPLICATION_DECISION_REASON, application.getDecisionReason() + ); + + when(makeAnApplicationService.getMakeAnApplication(asylumCase, true)).thenReturn(Optional.of(application)); + when(makeAnApplicationService.retrieveApplicationProperties(any())).thenReturn(applicationPropeties); + when(makeAnApplicationService.getApplicationTypes(any())).thenReturn(MakeAnApplicationTypes.ADJOURN); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalDecideHomeOfficeApplicationDecisionRefusedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(application.getType(), templateFieldValues.get("applicationType")); + assertEquals(application.getDecisionReason(), templateFieldValues.get("applicationReason")); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplateTest.java new file mode 100644 index 000000000..3b659606e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetGenerateHearingBundleTemplateTest.java @@ -0,0 +1,115 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.HearingDetailsFinder; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetGenerateHearingBundleTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock private HearingDetailsFinder hearingDetailsFinder; + private final String templateName = "TB-IAC-DEC-ENG-00007.docx"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String listCaseHearingDateTime = "2023-07-10T20:23:35"; + private final String listCaseHearingDate = "2023-07-10"; + private final String listCaseHearingCentre = HearingCentre.BIRMINGHAM.toString(); + private InternalDetGenerateHearingBundleTemplate internalDetGenerateHearingBundleTemplate; + + @BeforeEach + void setUp() { + internalDetGenerateHearingBundleTemplate = + new InternalDetGenerateHearingBundleTemplate( + templateName, + customerServicesProvider, + hearingDetailsFinder + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetGenerateHearingBundleTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(internalAdaCustomerServicesEmailAddress); + + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(listCaseHearingDateTime)); + when(hearingDetailsFinder.getHearingCentreName(asylumCase)).thenReturn(listCaseHearingCentre); + when(customerServicesProvider.getCustomerServicesEmail()).thenReturn(internalAdaCustomerServicesEmailAddress); + when(customerServicesProvider.getCustomerServicesTelephone()).thenReturn(internalAdaCustomerServicesTelephoneNumber); + + + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetGenerateHearingBundleTemplate.mapFieldValues(caseDetails); + + assertEquals(11, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(listCaseHearingDate)), templateFieldValues.get("hearingDate")); + assertEquals(LocalDateTime.parse(listCaseHearingDateTime).toLocalTime(), templateFieldValues.get("hearingTime")); + assertEquals(listCaseHearingCentre, templateFieldValues.get("hearingLocation")); + + } + + @Test + void should_throw_when_list_case_hearing_date_not_present() { + dataSetUp(); + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetGenerateHearingBundleTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("List case hearing date not found."); + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplateTest.java new file mode 100644 index 000000000..2840bf796 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetMarkAsPaidLetterTemplateTest.java @@ -0,0 +1,138 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.RemissionType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetMarkAsPaidLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "Some template name"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String feeAmountInPence = "14000"; + private final String totalAmountPaid = "8000"; + private final double feeAmountInPounds = Double.parseDouble(feeAmountInPence) / 100; + private final double feeRemission = 80; + private final double totalAmountPaidDouble = Double.parseDouble(totalAmountPaid) / 100; + private InternalDetMarkAsPaidLetterTemplate internalDetMarkAsPaidLetterTemplate; + + @BeforeEach + void setUp() { + internalDetMarkAsPaidLetterTemplate = + new InternalDetMarkAsPaidLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetMarkAsPaidLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(dateProvider.now()).thenReturn(now); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(PAID_AMOUNT, String.class)).thenReturn(Optional.of(feeAmountInPence)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(internalAdaCustomerServicesEmailAddress); + + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.NO_REMISSION)); + when(asylumCase.read(FEE_AMOUNT_GBP, String.class)).thenReturn(Optional.of(feeAmountInPence)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetMarkAsPaidLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + + assertEquals(String.valueOf(feeAmountInPounds), templateFieldValues.get("feeBeforeRemission")); + assertEquals("0.0", templateFieldValues.get("feeRemission")); + assertEquals(String.valueOf(feeAmountInPounds), templateFieldValues.get("totalAmountToPay")); + } + + @Test + void should_map_case_data_to_template_field_values_with_remission_fee() { + dataSetUp(); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); + when(asylumCase.read(PAID_AMOUNT, String.class)).thenReturn(Optional.of(totalAmountPaid)); + when(asylumCase.read(AMOUNT_REMITTED, String.class)).thenReturn(Optional.of("8000")); + Map templateFieldValues = internalDetMarkAsPaidLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + + assertEquals(String.valueOf(feeAmountInPounds), templateFieldValues.get("feeBeforeRemission")); + assertEquals(String.valueOf(feeRemission), templateFieldValues.get("feeRemission")); + assertEquals(String.valueOf(totalAmountPaidDouble), templateFieldValues.get("totalAmountToPay")); + } + + @Test + void should_throw_when_paid_amount_not_present() { + dataSetUp(); + when(asylumCase.read(PAID_AMOUNT, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetMarkAsPaidLetterTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Paid amount is not present"); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplateTest.java new file mode 100644 index 000000000..dc3d5dcdd --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAdjournHearingWithoutDateLetterTemplateTest.java @@ -0,0 +1,124 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.callback.Callback; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = org.mockito.quality.Strictness.LENIENT) +public class InternalDetainedAdjournHearingWithoutDateLetterTemplateTest { + @Mock + Callback mockCallback; + @Mock + CaseDetails mockCaseDetails; + @Mock + CaseDetails mockCaseDetailsBefore; + @Mock + AsylumCase mockAsylumCase; + @Mock + AsylumCase mockAsylumCaseBefore; + private static InternalDetainedAdjournHearingWithoutDateLetterTemplate internalDetainedAdjournHearingWithoutDateLetterTemplate; + private final String templateName = "someTemplateId"; + @Mock + CustomerServicesProvider customerServicesProvider; + @Mock + StringProvider stringProvider; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "HU/22222/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String hearingDateBefore = "2023-08-10T10:15:00"; + private final String formattedListCaseHearingDateBefore = "10082023"; + private final String hearingWithoutDateReasons = "Sample reasons"; + + @BeforeEach + void setUp() { + internalDetainedAdjournHearingWithoutDateLetterTemplate = new InternalDetainedAdjournHearingWithoutDateLetterTemplate(templateName, customerServicesProvider, stringProvider); + when(mockCallback.getCaseDetails()).thenReturn(mockCaseDetails); + when(mockCaseDetails.getCaseData()).thenReturn(mockAsylumCase); + when(mockCallback.getCaseDetailsBefore()).thenReturn(Optional.of(mockCaseDetailsBefore)); + when(mockCaseDetailsBefore.getCaseData()).thenReturn(mockAsylumCaseBefore); + when(customerServicesProvider.getInternalCustomerServicesTelephone(mockAsylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(mockAsylumCase)).thenReturn(customerServicesEmail); + when(mockAsylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(mockAsylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(mockAsylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(mockAsylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(mockAsylumCase.read(ADJOURN_HEARING_WITHOUT_DATE_REASONS, String.class)).thenReturn(Optional.of(hearingWithoutDateReasons)); + when(mockAsylumCaseBefore.read(AsylumCaseDefinition.HEARING_CENTRE, HearingCentre.class)) + .thenReturn(Optional.of(HearingCentre.BIRMINGHAM)); + when(mockAsylumCaseBefore.read(AsylumCaseDefinition.LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(hearingDateBefore)); + when(stringProvider.get("hearingCentreName", HearingCentre.BIRMINGHAM.toString())).thenReturn(Optional.of("Birmingham")); + } + + @Test + void testGetTemplateMethod() { + assertEquals(templateName, internalDetainedAdjournHearingWithoutDateLetterTemplate.getName()); + } + + @Test + void testMapFieldValues() { + Map templateFieldValues = internalDetainedAdjournHearingWithoutDateLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore); + assertEquals("Birmingham", templateFieldValues.get("oldHearingCentre")); + assertEquals(formattedListCaseHearingDateBefore, templateFieldValues.get("oldHearingDate")); + assertEquals(hearingWithoutDateReasons, templateFieldValues.get("adjournHearingWithoutDateReasons")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + + @Test + void should_throw_when_list_case_hearing_centre_before_not_present() { + when(mockAsylumCaseBefore.read(HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + + } + + @Test + public void should_throw_exception_when_hearing_centre_name_cannot_be_found() { + when(stringProvider.get("hearingCentreName", HearingCentre.BIRMINGHAM.toString())).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + } + + @Test + void should_throw_when_list_case_hearing_date_before_not_present() { + when(mockAsylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedAdjournHearingWithoutDateLetterTemplate.mapFieldValues(mockCaseDetails, mockCaseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingDate (before) is not present"); + + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplateTest.java new file mode 100644 index 000000000..a2bb91336 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedAppealFeeDueTemplateTest.java @@ -0,0 +1,123 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedAppealFeeDueTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String templateName = "Some template name"; + private final String internalAdaCustomerServicesTelephoneNumber = "0300 123 1711"; + private final String internalAdaCustomerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final LocalDate now = LocalDate.now(); + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final int calenderDaysToPayAppealFee = 14; + private final String feeAmountInPence = "14000"; + private final double feeAmountInPounds = Double.parseDouble(feeAmountInPence) / 100; + private final double feeRemission = 0; + private final double totalAmountToPay = feeAmountInPounds - feeRemission; + private final String deadlineDate = formatDateForNotificationAttachmentDocument(now.plusDays(calenderDaysToPayAppealFee)); + private InternalDetainedAppealFeeDueTemplate internalDetainedAppealFeeDueTemplate; + + @BeforeEach + void setUp() { + internalDetainedAppealFeeDueTemplate = + new InternalDetainedAppealFeeDueTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedAppealFeeDueTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(internalAdaCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(internalAdaCustomerServicesEmailAddress); + + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.NO_REMISSION)); + when(asylumCase.read(FEE_AMOUNT_GBP, String.class)).thenReturn(Optional.of(feeAmountInPence)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedAppealFeeDueTemplate.mapFieldValues(caseDetails); + + assertEquals(13, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(internalAdaCustomerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(internalAdaCustomerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(deadlineDate, templateFieldValues.get("deadlineDate")); + + assertEquals(String.valueOf(feeAmountInPounds), templateFieldValues.get("feeBeforeRemission")); + assertEquals("0.0", templateFieldValues.get("feeRemission")); + assertEquals(totalAmountToPay, templateFieldValues.get("totalAmountToPay")); + } + + @Test + void should_throw_when_fee_amount_not_present() { + dataSetUp(); + when(asylumCase.read(FEE_AMOUNT_GBP, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Fee amount not found"); + + } + + @Test + void should_throw_when_remission_type_not_present() { + dataSetUp(); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedAppealFeeDueTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Remission type not found"); + + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplateTest.java new file mode 100644 index 000000000..90df1a74a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedApplyForFtpaRespondentLetterTemplateTest.java @@ -0,0 +1,82 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedApplyForFtpaRespondentLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private InternalDetainedApplyForFtpaRespondentLetterTemplate internalDetainedApplyForFtpaRespondentLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00009.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalDetainedApplyForFtpaRespondentLetterTemplate = + new InternalDetainedApplyForFtpaRespondentLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedApplyForFtpaRespondentLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedApplyForFtpaRespondentLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplateTest.java new file mode 100644 index 000000000..14cd343cf --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsAllowedLetterTemplateTest.java @@ -0,0 +1,109 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedDecisionsAndReasonsAllowedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + private final String templateName = "Internal_Detained_Decisions_And_Reasons_Allowed.docx"; + @Mock private DueDateService dueDateService; + @Mock private CustomerServicesProvider customerServicesProvider; + + private InternalDetainedDecisionsAndReasonsAllowedLetterTemplate internalDetainedDecisionsAndReasonsAllowedLetterTemplate; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final ZonedDateTime nowZonedDateTime = ZonedDateTime.now(); + private static final int FTPA_DUE_IN_WORKING_DAYS = 7; + private static final int FTPA_DUE_CALENDAR_DAYS = 14; + + + @BeforeEach + void setUp() { + internalDetainedDecisionsAndReasonsAllowedLetterTemplate = + new InternalDetainedDecisionsAndReasonsAllowedLetterTemplate( + templateName, + customerServicesProvider, + dueDateService, + FTPA_DUE_IN_WORKING_DAYS, + FTPA_DUE_CALENDAR_DAYS + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalDetainedDecisionsAndReasonsAllowedLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedDecisionsAndReasonsAllowedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + + @Test + void should_return_7_working_days() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(dueDateService.calculateDueDate(any(), eq(FTPA_DUE_IN_WORKING_DAYS))).thenReturn(nowZonedDateTime.plusDays(FTPA_DUE_IN_WORKING_DAYS)); + Map templateFieldValues = internalDetainedDecisionsAndReasonsAllowedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(FTPA_DUE_IN_WORKING_DAYS)), templateFieldValues.get("ftpaDueDate")); + } + + @Test + void should_return_14_calendar_days() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = internalDetainedDecisionsAndReasonsAllowedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(FTPA_DUE_CALENDAR_DAYS)), templateFieldValues.get("ftpaDueDate")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplateTest.java new file mode 100644 index 000000000..96e7cfffc --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedDecisionsAndReasonsDismissedLetterTemplateTest.java @@ -0,0 +1,99 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPEAL_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ACCELERATED_DETAINED_APPEAL; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedDecisionsAndReasonsDismissedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + private final String templateName = "Internal_Detained_Decisions_And_Reasons_Dimissed.docx"; + @Mock private DueDateService dueDateService; + @Mock private CustomerServicesProvider customerServicesProvider; + + private InternalDetainedDecisionsAndReasonsDismissedLetterTemplate internalDetainedDecisionsAndReasonsDismissedLetterTemplate; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final ZonedDateTime nowZonedDateTime = ZonedDateTime.now(); + private static final int FTPA_DUE_CALENDAR_DAYS = 14; + + + @BeforeEach + void setUp() { + internalDetainedDecisionsAndReasonsDismissedLetterTemplate = + new InternalDetainedDecisionsAndReasonsDismissedLetterTemplate( + templateName, + customerServicesProvider, + FTPA_DUE_CALENDAR_DAYS + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalDetainedDecisionsAndReasonsDismissedLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedDecisionsAndReasonsDismissedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } + + @Test + void should_return_14_calendar_days() { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + Map templateFieldValues = internalDetainedDecisionsAndReasonsDismissedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(FTPA_DUE_CALENDAR_DAYS)), templateFieldValues.get("ftpaDueDate")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplateTest.java new file mode 100644 index 000000000..ab6ed5c95 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedEditCaseListingLetterTemplateTest.java @@ -0,0 +1,142 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedEditCaseListingLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private CaseDetails caseDetailsBefore; + @Mock private AsylumCase asylumCase; + @Mock private AsylumCase asylumCaseBefore; + @Mock private CustomerServicesProvider customerServicesProvider; + @Mock private StringProvider stringProvider; + private InternalDetainedEditCaseListingLetterTemplate internalDetainedEditCaseListingLetterTemplate; + private final String templateName = "TB-IAC-HNO-ENG-00700.docx"; + private final String appealReferenceNumber = "HU/22222/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String listCaseHearingDate = "2023-08-14T14:30:00.000"; + private final String formattedListCaseHearingDate = "14082023"; + private String formattedListCaseHearingTime = "1430"; + private String manchesterHearingCentreAddress = "Manchester, 123 Somewhere, North"; + private String formattedManchesterHearingCentreAddress = "Manchester\n123 Somewhere\nNorth"; + private String hearingDateBefore = "2023-08-10T10:15:00"; + private final String formattedListCaseHearingDateBefore = "10082023"; + private String formattedListCaseHearingTimeBefore = "1015"; + private String expectedFormattedTaylorHouseHearingCentreName = "Taylor House"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalDetainedEditCaseListingLetterTemplate = + new InternalDetainedEditCaseListingLetterTemplate( + templateName, + customerServicesProvider, + stringProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalDetainedEditCaseListingLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(caseDetailsBefore.getCaseData()).thenReturn(asylumCaseBefore); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.MANCHESTER)); + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(listCaseHearingDate)); + when(asylumCaseBefore.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(hearingDateBefore)); + when(asylumCaseBefore.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.TAYLOR_HOUSE)); + when(stringProvider.get("hearingCentreName", "taylorHouse")).thenReturn(Optional.of(expectedFormattedTaylorHouseHearingCentreName)); + when(stringProvider.get("hearingCentreAddress", "manchester")).thenReturn(Optional.of(manchesterHearingCentreAddress)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedEditCaseListingLetterTemplate.mapFieldValues(caseDetails, caseDetailsBefore); + + assertEquals(14, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formattedListCaseHearingDate, templateFieldValues.get("hearingDate")); + assertEquals(formattedListCaseHearingTime, templateFieldValues.get("hearingTime")); + assertEquals(formattedListCaseHearingDateBefore, templateFieldValues.get("oldHearingDate")); + assertEquals(formattedListCaseHearingTimeBefore, templateFieldValues.get("oldHearingTime")); + assertEquals(expectedFormattedTaylorHouseHearingCentreName, templateFieldValues.get("oldHearingCentre")); + assertEquals(formattedManchesterHearingCentreAddress, templateFieldValues.get("hearingCentreAddress")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + + @Test + void should_throw_when_list_case_hearing_centre_not_present() { + dataSetUp(); + when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedEditCaseListingLetterTemplate.mapFieldValues(caseDetails, caseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre is not present"); + + } + + @Test + void should_throw_when_list_case_hearing_centre_before_not_present() { + dataSetUp(); + when(asylumCaseBefore.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedEditCaseListingLetterTemplate.mapFieldValues(caseDetails, caseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + + } + + @Test + public void should_throw_exception_when_hearing_centre_name_cannot_be_found() { + dataSetUp(); + when(stringProvider.get("hearingCentreName", HearingCentre.TAYLOR_HOUSE.toString())).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedEditCaseListingLetterTemplate.mapFieldValues(caseDetails, caseDetailsBefore)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("listCaseHearingCentre (before) is not present"); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplateTest.java new file mode 100644 index 000000000..90b1a08e4 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedListCaseLetterTemplateTest.java @@ -0,0 +1,96 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedListCaseLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + @Mock private StringProvider stringProvider; + private InternalDetainedListCaseLetterTemplate internalDetainedListCaseLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00005.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String listCaseHearingDate = "2023-08-14T14:30:00.000"; + private final String formattedListCaseHearingDate = "14082023"; + private String formattedListCaseHearingTime = "1430"; + private String manchesterHearingCentreAddress = "Manchester, 123 Somewhere, North"; + private String formattedManchesterHearingCentreAddress = "Manchester\n123 Somewhere\nNorth"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalDetainedListCaseLetterTemplate = + new InternalDetainedListCaseLetterTemplate( + templateName, + customerServicesProvider, + stringProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalDetainedListCaseLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)).thenReturn(Optional.of(HearingCentre.MANCHESTER)); + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of(listCaseHearingDate)); + when(stringProvider.get("hearingCentreAddress", "manchester")).thenReturn(Optional.of(manchesterHearingCentreAddress)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedListCaseLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(11, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(formattedListCaseHearingDate, templateFieldValues.get("hearingDate")); + assertEquals(formattedListCaseHearingTime, templateFieldValues.get("hearingTime")); + assertEquals(formattedManchesterHearingCentreAddress, templateFieldValues.get("hearingCentreAddress")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplateTest.java new file mode 100644 index 000000000..1fff66827 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedMarkAsAdaLetterTemplateTest.java @@ -0,0 +1,117 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalDetainedMarkAsAdaLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DueDateService dueDateService; + private InternalDetainedMarkAsAdaLetterTemplate internalDetainedMarkAsAdaLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00008.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String appealSubmissionDate = "2023-08-01"; + private String reasonForAda = "Reason for ada"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final ZonedDateTime zonedDueDateTime = LocalDate.parse(appealSubmissionDate).atStartOfDay(ZoneOffset.UTC); + private final int responseToTribunalDueInWorkingDays = 13; + private final int homeOfficeResponseDueInWorkingDays = 15; + + @BeforeEach + void setUp() { + internalDetainedMarkAsAdaLetterTemplate = + new InternalDetainedMarkAsAdaLetterTemplate( + templateName, + customerServicesProvider, + dueDateService + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedMarkAsAdaLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(appealSubmissionDate)); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(REASON_APPEAL_MARKED_AS_ADA, String.class)).thenReturn(Optional.of(reasonForAda)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + + when(dueDateService.calculateDueDate(any(), eq(responseToTribunalDueInWorkingDays))).thenReturn(zonedDueDateTime.plusDays(13)); + when(dueDateService.calculateDueDate(any(), eq(homeOfficeResponseDueInWorkingDays))).thenReturn(zonedDueDateTime.plusDays(15)); + + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedMarkAsAdaLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(11, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + assertEquals(reasonForAda, templateFieldValues.get("reason")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(appealSubmissionDate).plusDays(13)), templateFieldValues.get("responseDueDate")); + assertEquals(formatDateForNotificationAttachmentDocument(LocalDate.parse(appealSubmissionDate).plusDays(15)), templateFieldValues.get("hoReviewAppealDueDate")); + } + + @Test + void should_throw_when_appeal_submission_date_is_not_present() { + dataSetUp(); + when(asylumCase.read(AsylumCaseDefinition.APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedMarkAsAdaLetterTemplate.mapFieldValues(caseDetails)) + .hasMessage("Appeal submission date is missing") + .isExactlyInstanceOf(IllegalStateException.class); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplateTest.java new file mode 100644 index 000000000..d5a48193b --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplateTest.java @@ -0,0 +1,112 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DateProvider dateProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_REVIEW_HOME_OFFICE_RESPONSE_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private final int dueInCalendarDays = 5; + private InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate; + private Map fieldValuesMap; + private final String directionExplanation = "Some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final IdValue hoReviewMaintainedDirection = new IdValue<>( + "1", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.REQUEST_RESPONSE_REVIEW, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + @BeforeEach + public void setUp() { + internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate = + new InternalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + dueInCalendarDays); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + List> directionList = new ArrayList<>(); + directionList.add(hoReviewMaintainedDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_populate_template() { + dataSetup(); + fieldValuesMap = internalDetainedReviewHomeOfficeResponseDecisionMaintainedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + assertEquals("21 Jun 2023", fieldValuesMap.get("dueDate")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplateTest.java new file mode 100644 index 000000000..2c6b7f59e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplateTest.java @@ -0,0 +1,87 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.infrastructure.CustomerServicesProvider; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DateProvider dateProvider; + private final String templateName = "TB-IAC-LET-ENG-00014.docx"; + private final String internalDetainedCustomerServicesTelephoneNumber = "0300 123 1234"; + private final String internalDetainedCustomerServicesEmailAddress = "example@email.com"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate; + + @BeforeEach + void setUp() { + internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate = + new InternalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(internalDetainedCustomerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(internalDetainedCustomerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(now); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + Map templateFieldValues = internalDetainedReviewHomeOfficeResponseDecisionWithdrawnLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplateTest.java new file mode 100644 index 000000000..81d48c3d4 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalDetainedTransferOutOfAdaTemplateTest.java @@ -0,0 +1,100 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalDetainedTransferOutOfAdaTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + private InternalDetainedTransferOutOfAdaTemplate internalDetainedTransferOutOfAdaTemplate; + private final String templateName = "TB-IAC-DEC-ENG-00014.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String transferOutOfAdaReason = "Test reason"; + private final String transferOutOfAdaMoreDetails = "Test reason more details"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalDetainedTransferOutOfAdaTemplate = + new InternalDetainedTransferOutOfAdaTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalDetainedTransferOutOfAdaTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(TRANSFER_OUT_OF_ADA_REASON, String.class)).thenReturn(Optional.of(transferOutOfAdaReason)); + when(asylumCase.read(TRANSFER_OUT_OF_ADA_MORE_DETAILS, String.class)).thenReturn(Optional.of(transferOutOfAdaMoreDetails)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalDetainedTransferOutOfAdaTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(transferOutOfAdaReason, templateFieldValues.get("transferOutOfAdaReason")); + assertEquals(transferOutOfAdaMoreDetails, templateFieldValues.get("transferOutOfAdaMoreDetails")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + + @Test + void should_throw_when_transfer_out_of_ada_reason_present() { + dataSetUp(); + when(asylumCase.read(TRANSFER_OUT_OF_ADA_REASON, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalDetainedTransferOutOfAdaTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Transfer out of ADA reason is not present"); + + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplateTest.java new file mode 100644 index 000000000..5d9b9239d --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEditAppealLetterTemplateTest.java @@ -0,0 +1,98 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalEditAppealLetterTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String adaEmail = "IAC-ADA-HW@justice.gov.uk"; + private final String nonAdaEmail = "contactia@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_EDIT_APPEAL_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalEditAppealLetterTemplate internalEditAppealTemplateTest; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalEditAppealTemplateTest = + new InternalEditAppealLetterTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalEditAppealTemplateTest.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + } + + @ParameterizedTest + @MethodSource("getAdaAndNonAdaArguments") + void should_populate_template_correctly(String email, YesOrNo yesOrNo) { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + fieldValuesMap = internalEditAppealTemplateTest.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(telephoneNumber, fieldValuesMap.get("customerServicesTelephone")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + if (yesOrNo.equals(YesOrNo.YES)) { + assertEquals(adaEmail, fieldValuesMap.get("customerServicesEmail")); + } else { + assertEquals(nonAdaEmail, fieldValuesMap.get("customerServicesEmail")); + } + } + + private static Stream getAdaAndNonAdaArguments() { + + return Stream.of( + Arguments.of("IAC-ADA-HW@justice.gov.uk", YesOrNo.YES), + Arguments.of("contactia@justice.gov.uk", YesOrNo.NO) + ); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplateTest.java new file mode 100644 index 000000000..e0d40274f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealAutomaticallyTemplateTest.java @@ -0,0 +1,114 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalEndAppealAutomaticallyTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private String appealSubmissionDate = "2023-07-01"; + private String remissionRejectedDate = "14 Jul 2023"; + private final String templateName = "INTERNAL_END_APPEAL_AUTOMATICALLY_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalEndAppealAutomaticallyTemplate internalEndAppealAutomaticallyTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalEndAppealAutomaticallyTemplate = + new InternalEndAppealAutomaticallyTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalEndAppealAutomaticallyTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(appealSubmissionDate)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.NO_REMISSION)); + } + + @Test + void should_populate_template() { + dataSetup(); + fieldValuesMap = internalEndAppealAutomaticallyTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + assertEquals(LocalDate.parse(appealSubmissionDate).plusDays(14).format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("deadLineDate")); + } + + @Test + void should_return_remission_rejected_date() { + dataSetup(); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); + when(asylumCase.read(REMISSION_REJECTED_DATE_PLUS_14DAYS, String.class)).thenReturn(Optional.of(remissionRejectedDate)); + fieldValuesMap = internalEndAppealAutomaticallyTemplate.mapFieldValues(caseDetails); + assertEquals(remissionRejectedDate, fieldValuesMap.get("deadLineDate")); + } + + @Test + void should_throw_when_appeal_submission_date_not_present() { + dataSetup(); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Appeal submission date is missing"); + + } + + @Test + void should_throw_when_remission_date_not_present() { + dataSetup(); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); + when(asylumCase.read(REMISSION_REJECTED_DATE_PLUS_14DAYS, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalEndAppealAutomaticallyTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Remission rejected date is missing"); + + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplateTest.java new file mode 100644 index 000000000..a498b5f25 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalEndAppealTemplateTest.java @@ -0,0 +1,118 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalEndAppealTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String adaEmail = "IAC-ADA-HW@justice.gov.uk"; + private final String nonAdaEmail = "contactia@justice.gov.uk"; + private final String adaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private final String nonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private String appealEndDate = "2023-07-01"; + private String approverType = "Legal Officer"; + private final String templateName = "INTERNAL_END_APPEAL_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalEndAppealTemplate internalEndAppealTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalEndAppealTemplate = + new InternalEndAppealTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalEndAppealTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(END_APPEAL_DATE, String.class)).thenReturn(Optional.of(appealEndDate)); + when(asylumCase.read(END_APPEAL_APPROVER_TYPE, String.class)).thenReturn(Optional.of(approverType)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @ParameterizedTest + @MethodSource("getAdaAndNonAdaArguments") + void should_populate_template_correctly(String email, YesOrNo yesOrNo) { + dataSetup(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + fieldValuesMap = internalEndAppealTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(telephoneNumber, fieldValuesMap.get("customerServicesTelephone")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + assertEquals("1 Jul 2023", fieldValuesMap.get("endAppealDate")); + if (yesOrNo.equals(YesOrNo.YES)) { + assertEquals(adaEmail, fieldValuesMap.get("customerServicesEmail")); + assertEquals(adaFormName, fieldValuesMap.get("formName")); + } else { + assertEquals(nonAdaEmail, fieldValuesMap.get("customerServicesEmail")); + assertEquals(nonAdaFormName, fieldValuesMap.get("formName")); + } + } + + @Test + void should_throw_if_end_appeal_date_is_not_present() { + dataSetup(); + when(asylumCase.read(END_APPEAL_DATE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalEndAppealTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("End appeal date is missing"); + } + + private static Stream getAdaAndNonAdaArguments() { + + return Stream.of( + Arguments.of("IAC-ADA-HW@justice.gov.uk", YesOrNo.YES), + Arguments.of("contactia@justice.gov.uk", YesOrNo.NO) + ); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplateTest.java new file mode 100644 index 000000000..93f6467ae --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHearingAdjustmentsUpdatedLetterTemplateTest.java @@ -0,0 +1,84 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalHearingAdjustmentsUpdatedLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + @Mock private DateProvider dateProvider; + private InternalHearingAdjustmentsUpdatedLetterTemplate internalHearingAdjustmentsUpdatedLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00030.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalHearingAdjustmentsUpdatedLetterTemplate = + new InternalHearingAdjustmentsUpdatedLetterTemplate( + templateName, + dateProvider, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalHearingAdjustmentsUpdatedLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalHearingAdjustmentsUpdatedLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplateTest.java new file mode 100644 index 000000000..ce95f21c4 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoChangeDirectionDueDateLetterTemplateTest.java @@ -0,0 +1,103 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalHoChangeDirectionDueDateLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private String directionEditDueDate = "2023-07-01"; + private String directionEditExplanation = "Test Explanation"; + private final String templateName = "IA_INTERNAL_HO_CHANGE_DIRECTION_DUE_DATE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalHoChangeDirectionDueDateLetterTemplate internalHoChangeDirectionDueDateLetterTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalHoChangeDirectionDueDateLetterTemplate = + new InternalHoChangeDirectionDueDateLetterTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalHoChangeDirectionDueDateLetterTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(DIRECTION_EDIT_DATE_DUE, String.class)).thenReturn(Optional.of(directionEditDueDate)); + when(asylumCase.read(DIRECTION_EDIT_EXPLANATION, String.class)).thenReturn(Optional.of(directionEditExplanation)); + } + + @Test + void should_populate_template() { + dataSetup(); + fieldValuesMap = internalHoChangeDirectionDueDateLetterTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + assertEquals(directionEditExplanation, fieldValuesMap.get("directionExplaination")); + assertEquals("1 Jul 2023", fieldValuesMap.get("dueDate")); + } + + @Test + void should_throw_if_direction_edit_due_date_is_not_present() { + dataSetup(); + when(asylumCase.read(DIRECTION_EDIT_DATE_DUE, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Direction edit date due is not present"); + } + + @Test + void should_throw_if_direction_edit_explanation_is_not_present() { + dataSetup(); + when(asylumCase.read(DIRECTION_EDIT_EXPLANATION, String.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalHoChangeDirectionDueDateLetterTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Direction edit explanation is not present"); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplateTest.java new file mode 100644 index 000000000..c68e8f0cb --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedGrantedLetterTemplateTest.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalHoFtpaDecidedGrantedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private String appealSubmissionDate = "2023-07-01"; + private String remissionRejectedDate = "14 Jul 2023"; + private final String templateName = "INTERNAL_HO_FTPA_DECIDED_GRANTED_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalHoFtpaDecidedGrantedLetterTemplate internalHoFtpaDecidedGrantedLetterTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalHoFtpaDecidedGrantedLetterTemplate = + new InternalHoFtpaDecidedGrantedLetterTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalHoFtpaDecidedGrantedLetterTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + } + + @Test + void should_populate_template() { + dataSetup(); + fieldValuesMap = internalHoFtpaDecidedGrantedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplateTest.java new file mode 100644 index 000000000..ec7f3e418 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedPartiallyGrantedLetterTemplateTest.java @@ -0,0 +1,76 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalHoFtpaDecidedPartiallyGrantedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_HO_FTPA_DECIDED_PARTIALLY_GRANTED_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalHoFtpaDecidedPartiallyGrantedLetterTemplate internalHoFtpaDecidedPartiallyGrantedLetterTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalHoFtpaDecidedPartiallyGrantedLetterTemplate = + new InternalHoFtpaDecidedPartiallyGrantedLetterTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalHoFtpaDecidedPartiallyGrantedLetterTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + } + + @Test + void should_populate_template() { + dataSetup(); + fieldValuesMap = internalHoFtpaDecidedPartiallyGrantedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplateTest.java new file mode 100644 index 000000000..db73ddc38 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHoFtpaDecidedRefusedLetterTemplateTest.java @@ -0,0 +1,100 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.FtpaDecisionOutcomeType; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalHoFtpaDecidedRefusedLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_HO_FTPA_DECIDED_REFUSED_NOTICE_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private final String refused = "refused"; + private final String notAdmitted = "not admitted"; + private InternalHoFtpaDecidedRefusedLetterTemplate internalHoFtpaDecidedRefusedLetterTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalHoFtpaDecidedRefusedLetterTemplate = + new InternalHoFtpaDecidedRefusedLetterTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalHoFtpaDecidedRefusedLetterTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(FtpaDecisionOutcomeType.FTPA_REFUSED)); + } + + @ParameterizedTest + @EnumSource(value = FtpaDecisionOutcomeType.class, names = {"FTPA_REFUSED", "FTPA_NOT_ADMITTED"}) + void should_populate_template(FtpaDecisionOutcomeType ftpaDecisionOutcomeType) { + dataSetup(); + + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.of(ftpaDecisionOutcomeType)); + + fieldValuesMap = internalHoFtpaDecidedRefusedLetterTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + assertEquals(ftpaDecisionOutcomeType.equals(FtpaDecisionOutcomeType.FTPA_REFUSED) + ? refused + : notAdmitted, fieldValuesMap.get("refused")); + } + + @Test + void should_throw_if_refused_decision_is_not_present() { + dataSetup(); + when(asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalHoFtpaDecidedRefusedLetterTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Judge decision 'refused' or 'not admitted' must be present"); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplateTest.java new file mode 100644 index 000000000..d00adb57d --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeAmendAppealResponseTemplateTest.java @@ -0,0 +1,205 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalHomeOfficeAmendAppealResponseTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private DateProvider dateProvider; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DirectionFinder directionFinder; + private final String templateName = "TB-IAC-DEC-ENG-00029.docx"; + private final String customerServicesTelephoneNumber = "0300 123 1711"; + private final String customerServicesEmailAddress = "IAC-ADA-HW@justice.gov.uk"; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private String directionDueDate = "2024-01-01"; + private String formattedDirectionDueDate = formatDateForNotificationAttachmentDocument(LocalDate.parse(directionDueDate)); + private final IdValue requestResponseAmendDirectionOne = new IdValue<>( + "1", + new Direction( + "Some explanation", + Parties.RESPONDENT, + directionDueDate, + "2023-09-20", + DirectionTag.REQUEST_RESPONSE_AMEND, + Collections.emptyList(), + Collections.emptyList(), + "Some unique ID", + "Some direction type" + ) + ); + + private final IdValue requestResponseAmendDirectionTwo = new IdValue<>( + "2", + new Direction( + "Some explanation", + Parties.RESPONDENT, + directionDueDate, + "2023-09-20", + DirectionTag.REQUEST_RESPONSE_AMEND, + Collections.emptyList(), + Collections.emptyList(), + "Some unique ID", + "Some direction type" + ) + ); + + private final IdValue otherRandomDirection = new IdValue<>( + "3", + new Direction( + "Some explanation", + Parties.RESPONDENT, + directionDueDate, + "2023-09-20", + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + "Some unique ID", + "Some direction type" + ) + ); + + private InternalHomeOfficeAmendAppealResponseTemplate internalHomeOfficeAmendAppealResponseTemplate; + + @BeforeEach + void setUp() { + internalHomeOfficeAmendAppealResponseTemplate = + new InternalHomeOfficeAmendAppealResponseTemplate( + templateName, + dateProvider, + customerServicesProvider, + directionFinder + ); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + + List> directionList = new ArrayList<>(); + directionList.add(requestResponseAmendDirectionOne); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + when(directionFinder.findFirst(asylumCase, DirectionTag.REQUEST_RESPONSE_AMEND)).thenReturn(Optional.of(requestResponseAmendDirectionOne.getValue())); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)) + .thenReturn(customerServicesTelephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)) + .thenReturn(customerServicesEmailAddress); + + when(dateProvider.now()).thenReturn(LocalDate.now()); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalHomeOfficeAmendAppealResponseTemplate.getName()); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetup(); + + Map templateFieldValues = internalHomeOfficeAmendAppealResponseTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(formattedDirectionDueDate, templateFieldValues.get("directionDueDate")); + } + + @Test + void should_extract_correct_direction_and_map_case_data_to_template_field_values() { + dataSetup(); + + List> directionList = new ArrayList<>(); + directionList.add(requestResponseAmendDirectionOne); + directionList.add(otherRandomDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + when(directionFinder.findFirst(asylumCase, DirectionTag.REQUEST_RESPONSE_AMEND)).thenReturn(Optional.of(requestResponseAmendDirectionOne.getValue())); + + Map templateFieldValues = internalHomeOfficeAmendAppealResponseTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(formattedDirectionDueDate, templateFieldValues.get("directionDueDate")); + } + + @Test + void should_extract_latest_request_response_amend_direction_and_map_case_data_to_template_field_values() { + dataSetup(); + + List> directionList = new ArrayList<>(); + directionList.add(requestResponseAmendDirectionOne); + directionList.add(requestResponseAmendDirectionTwo); + directionList.add(otherRandomDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + when(directionFinder.findFirst(asylumCase, DirectionTag.REQUEST_RESPONSE_AMEND)).thenReturn(Optional.of(requestResponseAmendDirectionTwo.getValue())); + + Map templateFieldValues = internalHomeOfficeAmendAppealResponseTemplate.mapFieldValues(caseDetails); + + assertEquals(9, templateFieldValues.size()); + assertEquals("[userImage:hmcts.png]", templateFieldValues.get("hmcts")); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(customerServicesTelephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmailAddress, templateFieldValues.get("customerServicesEmail")); + assertEquals(formatDateForNotificationAttachmentDocument(dateProvider.now()), templateFieldValues.get("dateLetterSent")); + assertEquals(formattedDirectionDueDate, templateFieldValues.get("directionDueDate")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplateTest.java new file mode 100644 index 000000000..b625dfcbe --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplateTest.java @@ -0,0 +1,85 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + private InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate internalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate; + private final String templateName = "TB-IAC-LET-ENG-00035.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate = + new InternalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalHomeOfficeUploadAdditionalAndAddendumEvidenceTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplateTest.java new file mode 100644 index 000000000..2e72233c0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplateTest.java @@ -0,0 +1,86 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + private InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate internalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate; + private final String templateName = "TB-IAC-LET-ENG-00036.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate = + new InternalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalLegalOfficerUploadAdditionalAndAddendumEvidenceTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplateTest.java new file mode 100644 index 000000000..a7e59405c --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseLinkAppealTemplateTest.java @@ -0,0 +1,141 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.AbstractMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking.CaseLink; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.caselinking.ReasonForLink; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalMaintainCaseLinkAppealTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String adaEmail = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_DETAINED_MAINTAIN_CASE_LINK_APPEAL_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalMaintainCaseLinkAppealTemplate internalMaintainCaseLinkAppealTemplate; + private Map fieldValuesMap; + private final List> pairList = List.of( + new AbstractMap.SimpleEntry<>("reason", "Same Party"), + new AbstractMap.SimpleEntry<>("reason", "Same child/ren") + ); + + @BeforeEach + public void setUp() { + internalMaintainCaseLinkAppealTemplate = + new InternalMaintainCaseLinkAppealTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalMaintainCaseLinkAppealTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(adaEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(CASE_LINKS)).thenReturn(Optional.of(createCaseLinksFixtures())); + } + + @Test + void should_populate_template_correctly() { + dataSetup(); + fieldValuesMap = internalMaintainCaseLinkAppealTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(telephoneNumber, fieldValuesMap.get("customerServicesTelephone")); + assertEquals(pairList, fieldValuesMap.get("reason")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + } + + @Test + void should_throw_when_case_links_are_not_present() { + dataSetup(); + when(asylumCase.read(CASE_LINKS)).thenReturn(Optional.empty()); + + assertThatThrownBy(() -> internalMaintainCaseLinkAppealTemplate.mapFieldValues(caseDetails)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("caseLinks are not present"); + + } + + @Test + void should_resolve_reasons_from_latest_create_link_event() { + dataSetup(); + fieldValuesMap = internalMaintainCaseLinkAppealTemplate.mapFieldValues(caseDetails); + assertEquals(pairList, fieldValuesMap.get("reason")); + } + + private List> createCaseLinksFixtures() { + return List.of( + new IdValue<>("1", + new CaseLink( + "1", + "Asylum", + LocalDateTime.now().minusMinutes(10), + List.of( + new IdValue<>("1", + new ReasonForLink("CLRC001") + ), + new IdValue<>("2", + new ReasonForLink("CLRC002") + ) + ) + )), + new IdValue<>("2", + new CaseLink( + "2", + "Asylum", + LocalDateTime.now().minusMinutes(5), + List.of( + new IdValue<>("1", + new ReasonForLink("CLRC003") + ), + new IdValue<>("2", + new ReasonForLink("CLRC004") + ) + ) + ))); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplateTest.java new file mode 100644 index 000000000..90af53f11 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalMaintainCaseUnlinkAppealTemplateTest.java @@ -0,0 +1,79 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@MockitoSettings(strictness = Strictness.LENIENT) +@SuppressWarnings("unchecked") +@ExtendWith(MockitoExtension.class) +class InternalMaintainCaseUnlinkAppealTemplateTest { + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + private final String telephoneNumber = "0300 123 1711"; + private final String adaEmail = "IAC-ADA-HW@justice.gov.uk"; + private String appellantGivenNames = "John"; + private String appellantFamilyName = "Smith"; + private String homeOfficeReferenceNumber = "123654"; + private String appealReferenceNumber = "HU/11111/2022"; + private final String templateName = "INTERNAL_DETAINED_MAINTAIN_CASE_UNLINK_APPEAL_TEMPLATE.docx"; + private final String logo = "[userImage:hmcts.png]"; + private InternalMaintainCaseUnlinkAppealTemplate internalMaintainCaseUnlinkAppealTemplate; + private Map fieldValuesMap; + + @BeforeEach + public void setUp() { + internalMaintainCaseUnlinkAppealTemplate = + new InternalMaintainCaseUnlinkAppealTemplate(templateName, customerServicesProvider); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalMaintainCaseUnlinkAppealTemplate.getName()); + } + + void dataSetup() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(adaEmail); + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + } + + @Test + void should_populate_template_correctly() { + dataSetup(); + fieldValuesMap = internalMaintainCaseUnlinkAppealTemplate.mapFieldValues(caseDetails); + assertEquals(logo, fieldValuesMap.get("hmcts")); + assertEquals(appealReferenceNumber, fieldValuesMap.get("appealReferenceNumber")); + assertEquals(appellantGivenNames, fieldValuesMap.get("appellantGivenNames")); + assertEquals(appellantFamilyName, fieldValuesMap.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, fieldValuesMap.get("homeOfficeReferenceNumber")); + assertEquals(telephoneNumber, fieldValuesMap.get("customerServicesTelephone")); + assertEquals(LocalDate.now().format(DateTimeFormatter.ofPattern("d MMM yyyy")), fieldValuesMap.get("dateLetterSent")); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplateTest.java new file mode 100644 index 000000000..f840da018 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalNonStandardDirectionLetterTemplateTest.java @@ -0,0 +1,117 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_FAMILY_NAME; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.APPELLANT_GIVEN_NAMES; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HOME_OFFICE_REFERENCE_NUMBER; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) + +public class InternalNonStandardDirectionLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + @Mock + private CustomerServicesProvider customerServicesProvider; + @Mock + private DirectionFinder directionFinder; + private InternalNonStandardDirectionLetterTemplate internalNonStandardDirectionLetterTemplate; + private final String telephoneNumber = "0300 123 1711"; + private final String email = "IAC-ADA-HW@justice.gov.uk"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final LocalDate now = LocalDate.now(); + private final String templateName = "TB-IAC-LET-ENG-00028.docx"; + + private final String directionExplanation = "test reasons new direction sent"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + + private final Direction directionOne = new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.NONE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ); + + public InternalNonStandardDirectionLetterTemplateTest() { + } + + @BeforeEach + public void setUp() { + internalNonStandardDirectionLetterTemplate = + new InternalNonStandardDirectionLetterTemplate( + templateName, + customerServicesProvider, + directionFinder + ); + } + + @Test + void should_return_template_name() { + assertEquals(templateName, internalNonStandardDirectionLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(telephoneNumber); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(email);; + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + when(directionFinder.findFirst(asylumCase, DirectionTag.NONE)).thenReturn(Optional.of(directionOne)); + Map templateFieldValues = internalNonStandardDirectionLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(10, templateFieldValues.size()); + assertEquals(telephoneNumber, templateFieldValues.get("customerServicesTelephone")); + assertEquals(email, templateFieldValues.get("customerServicesEmail")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(directionExplanation, templateFieldValues.get("sendDirectionContent")); + + + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplateTest.java new file mode 100644 index 000000000..aa6173383 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalReinstateAppealLetterTemplateTest.java @@ -0,0 +1,110 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.entities.ccd.field.YesOrNo; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalReinstateAppealLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + private InternalReinstateAppealLetterTemplate internalReinstateAppealLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00050.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + private final String reinstatedDecisionMaker = "Admin Officer"; + private final String reinstateAppealDate = "2023-09-28"; + private final String formattedReinstateAppealDate = "28 September 2023"; + private final String reinstateAppealReason = "The reason why the appeal was reinstated."; + private final String adaFormName = "IAFT-ADA4: Make an application – Accelerated detained appeal (ADA)"; + private final String nonAdaFormName = "IAFT-DE4: Make an application – Detained appeal"; + + @BeforeEach + void setUp() { + internalReinstateAppealLetterTemplate = + new InternalReinstateAppealLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalReinstateAppealLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(REINSTATED_DECISION_MAKER, String.class)).thenReturn(Optional.of(reinstatedDecisionMaker)); + when(asylumCase.read(REINSTATE_APPEAL_DATE, String.class)).thenReturn(Optional.of(reinstateAppealDate)); + when(asylumCase.read(REINSTATE_APPEAL_REASON, String.class)).thenReturn(Optional.of(reinstateAppealReason)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalReinstateAppealLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(reinstatedDecisionMaker, templateFieldValues.get("reinstatedDecisionMaker")); + assertEquals(formattedReinstateAppealDate, templateFieldValues.get("reinstateAppealDate")); + assertEquals(reinstateAppealReason, templateFieldValues.get("reinstateAppealReason")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void should_return_correct_form_for_ada_and_non_ada_cases(YesOrNo yesOrNo) { + dataSetUp(); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + Map templateFieldValues = internalReinstateAppealLetterTemplate.mapFieldValues(caseDetails); + + if (yesOrNo.equals(YesOrNo.YES)) { + assertEquals(adaFormName, templateFieldValues.get("formName")); + } else { + assertEquals(nonAdaFormName, templateFieldValues.get("formName")); + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplateTest.java new file mode 100644 index 000000000..2f966e02e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/InternalUploadAdditionalEvidenceLetterTemplateTest.java @@ -0,0 +1,81 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.DateUtils.formatDateForNotificationAttachmentDocument; + +import java.time.LocalDate; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +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.infrastructure.CustomerServicesProvider; + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +class InternalUploadAdditionalEvidenceLetterTemplateTest { + + @Mock private CaseDetails caseDetails; + @Mock private AsylumCase asylumCase; + @Mock private CustomerServicesProvider customerServicesProvider; + private InternalUploadAdditionalEvidenceLetterTemplate internalUploadAdditionalEvidenceLetterTemplate; + private final String templateName = "TB-IAC-LET-ENG-00031.docx"; + private final String appealReferenceNumber = "HU/11111/2023"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + private final LocalDate now = LocalDate.now(); + private final String customerServicesTelephone = "0300 123 1711"; + private final String customerServicesEmail = "email@example.com"; + + @BeforeEach + void setUp() { + internalUploadAdditionalEvidenceLetterTemplate = + new InternalUploadAdditionalEvidenceLetterTemplate( + templateName, + customerServicesProvider + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, internalUploadAdditionalEvidenceLetterTemplate.getName()); + } + + void dataSetUp() { + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)).thenReturn(customerServicesTelephone); + when(customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)).thenReturn(customerServicesEmail); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = internalUploadAdditionalEvidenceLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(8, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent")); + assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone")); + assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail")); + } +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplateTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplateTest.java new file mode 100644 index 000000000..8bee8b32f --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/templates/letter/UploadAppealResponseMaintainedDecisionLetterTemplateTest.java @@ -0,0 +1,135 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates.letter; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; + +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.util.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.DateProvider; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Direction; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.DirectionTag; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.Parties; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.DueDateService; +import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider; + + +@ExtendWith(MockitoExtension.class) +@SuppressWarnings("unchecked") +@MockitoSettings(strictness = Strictness.LENIENT) +public class UploadAppealResponseMaintainedDecisionLetterTemplateTest { + + @Mock + private CaseDetails caseDetails; + @Mock + private AsylumCase asylumCase; + private final String templateName = "HO-Decision-Maintained.docx"; + @Mock private DateProvider dateProvider; + @Mock private CustomerServicesProvider customerServicesProvider; + @Mock private DueDateService dueDateService; + private final Parties directionParties = Parties.RESPONDENT; + private final IdValue hoReviewDirection = new IdValue<>( + "1", + new Direction( + "HO Review Request Direction", + directionParties, + "2023-08-16", + "2023-06-02", + DirectionTag.RESPONDENT_REVIEW, + Collections.emptyList(), + Collections.emptyList(), + "95e90870-2429-4660-b9c2-4111aff37304", + "someDirectionType" + ) + ); + + private final IdValue requestCaseBuildingDirection = new IdValue<>( + "1", + new Direction( + "Case Building Request Direction", + directionParties, + "2023-08-02", + "2023-06-05", + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + "95e90870-2429-4660-b9c2-4111aff45604", + "someDirectionType" + ) + ); + + private UploadAppealResponseMaintainedDecisionLetterTemplate uploadAppealResponseMaintainedDecisionLetterTemplate; + private final String appealReferenceNumber = "RP/11111/2020"; + private final String homeOfficeReferenceNumber = "A1234567/001"; + private final String appellantGivenNames = "John"; + private final String appellantFamilyName = "Doe"; + + + + @BeforeEach + void setUp() { + uploadAppealResponseMaintainedDecisionLetterTemplate = + new UploadAppealResponseMaintainedDecisionLetterTemplate( + templateName, + dateProvider, + customerServicesProvider, + dueDateService + ); + } + + @Test + void should_return_template_name() { + + assertEquals(templateName, uploadAppealResponseMaintainedDecisionLetterTemplate.getName()); + } + + void dataSetUp() { + List> directionList = new ArrayList<>(); + directionList.add(hoReviewDirection); + directionList.add(requestCaseBuildingDirection); + final String appealSubmissionDate = "2023-05-23"; + final String saHearingDate = "2023-06-13"; + final ZonedDateTime zonedDate = LocalDate.parse(appealSubmissionDate).atStartOfDay(ZoneOffset.UTC); + final ZonedDateTime zonedSaHEaringDate = LocalDate.parse(saHearingDate).atStartOfDay(ZoneOffset.UTC); + when(caseDetails.getCaseData()).thenReturn(asylumCase); + + when(asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(appealReferenceNumber)); + when(asylumCase.read(HOME_OFFICE_REFERENCE_NUMBER, String.class)).thenReturn(Optional.of(homeOfficeReferenceNumber)); + when(asylumCase.read(APPELLANT_GIVEN_NAMES, String.class)).thenReturn(Optional.of(appellantGivenNames)); + when(asylumCase.read(APPELLANT_FAMILY_NAME, String.class)).thenReturn(Optional.of(appellantFamilyName)); + when(asylumCase.read(APPEAL_SUBMISSION_DATE, String.class)).thenReturn(Optional.of(appealSubmissionDate)); + when(asylumCase.read(LIST_CASE_HEARING_DATE, String.class)).thenReturn(Optional.of("2023-08-22T09:00:00.000")); + when(dateProvider.now()).thenReturn(LocalDate.parse("2023-06-27")); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + when(dueDateService.calculateDueDate(zonedDate, 16)).thenReturn(zonedSaHEaringDate); + } + + @Test + void should_map_case_data_to_template_field_values() { + dataSetUp(); + + Map templateFieldValues = uploadAppealResponseMaintainedDecisionLetterTemplate.mapFieldValues(caseDetails); + + assertEquals(12, templateFieldValues.size()); + assertEquals(appealReferenceNumber, templateFieldValues.get("appealReferenceNumber")); + assertEquals(homeOfficeReferenceNumber, templateFieldValues.get("homeOfficeReferenceNumber")); + assertEquals(appellantGivenNames, templateFieldValues.get("appellantGivenNames")); + assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName")); + assertEquals("2 Aug 2023", templateFieldValues.get("caseBuildingDueDate")); + assertEquals("13062023", templateFieldValues.get("suitabilityAssessmentHearingDate")); + assertEquals("22082023", templateFieldValues.get("hearingDate")); + assertEquals("27 Jun 2023", templateFieldValues.get("dateLetterSent")); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtilsTest.java new file mode 100644 index 000000000..188652e0e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/AsylumCaseUtilsTest.java @@ -0,0 +1,316 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumAppealType.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionType.HO_WAIVER_REMISSION; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.RemissionType.NO_REMISSION; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.YES; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.hamcrest.MatcherAssert; +import org.hamcrest.collection.IsIterableContainingInOrder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.ValueSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.RequiredFieldMissingException; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.*; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; + + +@MockitoSettings(strictness = Strictness.LENIENT) +@ExtendWith(MockitoExtension.class) +public class AsylumCaseUtilsTest { + + @Mock + private AsylumCase asylumCase; + @Mock + private Document document; + private final String directionExplanation = "some explanation"; + private final Parties directionParties = Parties.APPELLANT; + private final String directionDateDue = "2023-06-16"; + private final String directionDateSent = "2023-06-02"; + private final String directionUniqueId = "95e90870-2429-4660-b9c2-4111aff37304"; + private final String directionType = "someDirectionType"; + private final IdValue requestCaseBuildingDirection = new IdValue<>( + "1", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.REQUEST_CASE_BUILDING, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private final IdValue caseEditDirection = new IdValue<>( + "2", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.CASE_EDIT, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private final IdValue adaListCaseDirection = new IdValue<>( + "3", + new Direction( + directionExplanation, + directionParties, + directionDateDue, + directionDateSent, + DirectionTag.ADA_LIST_CASE, + Collections.emptyList(), + Collections.emptyList(), + directionUniqueId, + directionType + ) + ); + + private final String legalOfficerAddendumUploadedByLabel = "TCW"; + private final String legalOfficerAddendumUploadSuppliedByLabel = "The respondent"; + private final IdValue addendumOne = new IdValue<>( + "1", + new DocumentWithMetadata( + document, + "Some description", + "2018-12-25", DocumentTag.ADDENDUM_EVIDENCE, + legalOfficerAddendumUploadSuppliedByLabel, + legalOfficerAddendumUploadedByLabel + ) + ); + + private final IdValue addendumTwo = new IdValue<>( + "2", + new DocumentWithMetadata( + document, + "Some description", + "2018-12-26", DocumentTag.ADDENDUM_EVIDENCE, + legalOfficerAddendumUploadSuppliedByLabel, + legalOfficerAddendumUploadedByLabel + ) + ); + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void should_return_correct_value_for_isAda(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + if (yesOrNo.equals(YES)) { + assertTrue(AsylumCaseUtils.isAcceleratedDetainedAppeal(asylumCase)); + } else { + assertFalse(AsylumCaseUtils.isAcceleratedDetainedAppeal(asylumCase)); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void should_return_correct_value_for_is_detained(YesOrNo yesOrNo) { + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + if (yesOrNo.equals(YES)) { + assertTrue(AsylumCaseUtils.isAppellantInDetention(asylumCase)); + } else { + assertFalse(AsylumCaseUtils.isAppellantInDetention(asylumCase)); + } + } + + @ParameterizedTest + @EnumSource(value = YesOrNo.class) + void should_return_correct_value_for_isAdmin(YesOrNo yesOrNo) { + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(yesOrNo)); + + if (yesOrNo.equals(YES)) { + assertTrue(AsylumCaseUtils.isInternalCase(asylumCase)); + } else { + assertFalse(AsylumCaseUtils.isInternalCase(asylumCase)); + } + } + + @Test + void should_return_empty_list_when_no_case_directions_present() { + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.empty()); + + assertEquals(Collections.emptyList(), AsylumCaseUtils.getCaseDirections(asylumCase)); + } + + @Test + void should_return_empty_list_when_no_directions_found_based_on_direction_tag() { + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.empty()); + + assertEquals(Collections.emptyList(), AsylumCaseUtils.getCaseDirectionsBasedOnTag(asylumCase, DirectionTag.REQUEST_CASE_BUILDING)); + } + + @Test + void should_return_direction_list() { + List> directionList = new ArrayList<>(); + directionList.add(requestCaseBuildingDirection); + directionList.add(caseEditDirection); + directionList.add(adaListCaseDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + List> returnedDirectionList = AsylumCaseUtils.getCaseDirections(asylumCase); + + MatcherAssert.assertThat(directionList, IsIterableContainingInOrder.contains(returnedDirectionList.toArray())); + + } + + @ParameterizedTest + @EnumSource(value = DirectionTag.class, names = {"REQUEST_CASE_BUILDING", "CASE_EDIT", "ADA_LIST_CASE"}) + void should_return_specific_direction_based_on_tag(DirectionTag directionTag) { + List> directionList = new ArrayList<>(); + directionList.add(requestCaseBuildingDirection); + directionList.add(caseEditDirection); + directionList.add(adaListCaseDirection); + when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList)); + + List returnedDirection = AsylumCaseUtils.getCaseDirectionsBasedOnTag(asylumCase, directionTag); + + assertEquals(1, returnedDirection.size()); + + assertEquals(directionTag, returnedDirection.get(0).getTag()); + + } + + @ParameterizedTest + @EnumSource(value = AsylumAppealType.class) + void should_return_true_if_ea_hu_eu_appeal_type(AsylumAppealType appealType) { + when(asylumCase.read(APPEAL_TYPE, AsylumAppealType.class)).thenReturn(Optional.of(appealType)); + if (List.of(HU, EA, EU).contains(appealType)) { + assertTrue(AsylumCaseUtils.isEaHuEuAppeal(asylumCase)); + } else { + assertFalse(AsylumCaseUtils.isEaHuEuAppeal(asylumCase)); + } + } + + @Test + void should_throw_for_fee_amount_not_present() { + assertThatThrownBy(() -> AsylumCaseUtils.getFeeBeforeRemission(asylumCase)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Fee amount not found"); + } + + @Test + void should_return_fee_amount() { + when(asylumCase.read(FEE_AMOUNT_GBP, String.class)).thenReturn(Optional.of("14000")); + assertEquals(140, AsylumCaseUtils.getFeeBeforeRemission(asylumCase)); + } + + @Test + void should_throw_for_remission_type_not_present() { + assertThatThrownBy(() -> AsylumCaseUtils.getFeeRemission(asylumCase)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Remission type not found"); + } + + @ParameterizedTest + @EnumSource(value = RemissionType.class) + void should_return_amount_remitted(RemissionType remissionType) { + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(remissionType)); + if (remissionType.equals(NO_REMISSION)) { + assertEquals(0, AsylumCaseUtils.getFeeRemission(asylumCase)); + } else { + when(asylumCase.read(AMOUNT_REMITTED, String.class)).thenReturn(Optional.of("8000")); + assertEquals(80, AsylumCaseUtils.getFeeRemission(asylumCase)); + } + } + + @Test + void should_return_no_amount_remitted_for_rejected_remission_decision() { + when(asylumCase.read(REMISSION_DECISION, RemissionDecision.class)).thenReturn(Optional.of(RemissionDecision.REJECTED)); + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(HO_WAIVER_REMISSION)); + + when(asylumCase.read(AMOUNT_REMITTED, String.class)).thenReturn(Optional.of("0")); + assertEquals(0, AsylumCaseUtils.getFeeRemission(asylumCase)); + } + + @Test + void should_throw_for_amount_remitted_not_present() { + when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(Optional.of(RemissionType.HO_WAIVER_REMISSION)); + assertThatThrownBy(() -> AsylumCaseUtils.getFeeRemission(asylumCase)) + .isExactlyInstanceOf(RequiredFieldMissingException.class) + .hasMessage("Amount remitted not found"); + } + + @Test + void should_get_addendum_document_when_present() { + List> addendumDocuments = new ArrayList<>(); + addendumDocuments.add(addendumOne); + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.of(addendumDocuments)); + + assertEquals(addendumDocuments, AsylumCaseUtils.getAddendumEvidenceDocuments(asylumCase)); + assertEquals(Optional.of(addendumOne), AsylumCaseUtils.getLatestAddendumEvidenceDocument(asylumCase)); + } + + @Test + void should_get_addendum_documents_when_more_than_one_exists() { + List> addendumDocuments = new ArrayList<>(); + addendumDocuments.add(addendumOne); + addendumDocuments.add(addendumTwo); + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.of(addendumDocuments)); + + assertEquals(addendumDocuments, AsylumCaseUtils.getAddendumEvidenceDocuments(asylumCase)); + assertEquals(2, AsylumCaseUtils.getAddendumEvidenceDocuments(asylumCase).size()); + } + + @Test + void should_return_empty_list_when_no_addendum_evidence_documents_present() { + when(asylumCase.read(ADDENDUM_EVIDENCE_DOCUMENTS)).thenReturn(Optional.empty()); + + assertEquals(Collections.emptyList(), AsylumCaseUtils.getAddendumEvidenceDocuments(asylumCase)); + assertEquals(Optional.empty(), AsylumCaseUtils.getLatestAddendumEvidenceDocument(asylumCase)); + } + + @ParameterizedTest + @ValueSource(strings = { "LEGAL_REPRESENTATIVE", "RESPONDENT", "APPELLANT", "BOTH", "APPELLANT_AND_RESPONDENT" }) + void should_return_correct_value_for_is_direction_party_respondent(String party) { + when(asylumCase.read(DIRECTION_EDIT_PARTIES, Parties.class)).thenReturn(Optional.of(Parties.valueOf(party))); + + if (party.equals("RESPONDENT")) { + assertTrue(AsylumCaseUtils.isDirectionPartyRespondent(asylumCase)); + } else { + assertFalse(AsylumCaseUtils.isDirectionPartyRespondent(asylumCase)); + } + } + + @Test + void should_throw_if_direction_edit_date_due_not_present() { + when(asylumCase.read(DIRECTION_EDIT_DATE_DUE, String.class)).thenReturn(Optional.empty()); + assertThatThrownBy(() -> AsylumCaseUtils.getDirectionDueDateAndExplanation(asylumCase)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Direction edit date due is not present"); + } + + @Test + void should_throw_if_direction_edit_explanation_not_present() { + when(asylumCase.read(DIRECTION_EDIT_DATE_DUE, String.class)).thenReturn(Optional.of("2020-12-25")); + when(asylumCase.read(DIRECTION_EDIT_EXPLANATION, String.class)).thenReturn(Optional.empty()); + assertThatThrownBy(() -> AsylumCaseUtils.getDirectionDueDateAndExplanation(asylumCase)) + .isExactlyInstanceOf(IllegalStateException.class) + .hasMessage("Direction edit explanation is not present"); + } + +} \ No newline at end of file diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtilsTest.java new file mode 100644 index 000000000..4880519f6 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/domain/utils/DateUtilsTest.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDate; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; + + + +@ExtendWith(MockitoExtension.class) +public class DateUtilsTest { + + private final LocalDate exampleDateToFormat = LocalDate.parse("2023-03-03"); + private final String formattedExampleDate = "3 Mar 2023"; + + @Test + void should_format_and_return_date_correctly_from_date() { + assertEquals(formattedExampleDate, DateUtils.formatDateForNotificationAttachmentDocument(exampleDateToFormat)); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/AsylumPreSubmitCallbackDispatcherTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/AsylumPreSubmitCallbackDispatcherTest.java index a1825c7f2..c464823c7 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/AsylumPreSubmitCallbackDispatcherTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/AsylumPreSubmitCallbackDispatcherTest.java @@ -256,12 +256,14 @@ public void should_not_allow_null_arguments() { @Test public void should_sort_handlers_by_name() { PreSubmitCallbackHandler h1 = new AppealSubmissionCreator( - mock(DocumentCreator.class), mock(DocumentHandler.class) + mock(DocumentCreator.class), mock(DocumentCreator.class), mock(DocumentHandler.class) ); PreSubmitCallbackHandler h3 = new HearingNoticeCreator( - mock(DocumentCreator.class), mock(DocumentCreator.class), mock(DocumentHandler.class) + mock(DocumentCreator.class), mock(DocumentCreator.class), mock(DocumentCreator.class), mock(DocumentHandler.class), + mock(FeatureToggler.class), mock(DocumentReceiver.class), + mock(DocumentsAppender.class), mock(Appender.class) ); PreSubmitCallbackDispatcher dispatcher = new AsylumPreSubmitCallbackDispatcher( diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProviderTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProviderTest.java index 711e34b96..1a2ae8b72 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProviderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/CustomerServicesProviderTest.java @@ -2,13 +2,19 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*; import java.util.Map; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo; @ExtendWith(MockitoExtension.class) @@ -16,12 +22,16 @@ public class CustomerServicesProviderTest { @Mock CustomerServicesProvider customerServicesProvider; + @Mock + private AsylumCase asylumCase; + private String customerServicesTelephone = "555 555"; private String customerServicesEmail = "some.email@example.com"; + private String internalAdaCustomerServicesTelephone = "111 111"; + private String internalAdaCustomerServicesEmail = "some.email@example.com"; @BeforeEach public void setUp() { - customerServicesProvider = new CustomerServicesProvider( customerServicesTelephone, customerServicesEmail @@ -55,4 +65,36 @@ public void should_return_customer_services_telephone_number_and_email() { assertEquals(customerServicesEmail, customerServicesProvider.getCustomerServicesEmail()); } + + @Test + public void should_return_internal_ada_customer_services_telephone_number_and_email() { + ReflectionTestUtils.setField(customerServicesProvider, "internalAdaCustomerServicesTelephone", internalAdaCustomerServicesTelephone); + ReflectionTestUtils.setField(customerServicesProvider, "internalAdaCustomerServicesEmail", internalAdaCustomerServicesEmail); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + + assertEquals(internalAdaCustomerServicesTelephone, + customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + + assertEquals(internalAdaCustomerServicesEmail, + customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + } + + @Test + public void should_return_internal_non_ada_customer_services_telephone_number_and_email() { + ReflectionTestUtils.setField(customerServicesProvider, "internalAdaCustomerServicesTelephone", internalAdaCustomerServicesTelephone); + ReflectionTestUtils.setField(customerServicesProvider, "internalAdaCustomerServicesEmail", internalAdaCustomerServicesEmail); + + when(asylumCase.read(IS_ADMIN, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); + when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + when(asylumCase.read(APPELLANT_IN_DETENTION, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.NO)); + + assertEquals(customerServicesTelephone, + customerServicesProvider.getInternalCustomerServicesTelephone(asylumCase)); + + assertEquals(customerServicesEmail, + customerServicesProvider.getInternalCustomerServicesEmail(asylumCase)); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/HearingDetailsFinderTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/HearingDetailsFinderTest.java index 7aa56cb81..3e973c9aa 100644 --- a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/HearingDetailsFinderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/HearingDetailsFinderTest.java @@ -13,11 +13,14 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre; import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider; @ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class HearingDetailsFinderTest { @Mock AsylumCase asylumCase; @@ -131,3 +134,4 @@ public void should_return_hearing_centres_urls() { assertEquals(northShieldsHearingCentreUrl, hearingDetailsFinder.getHearingCentreUrl(NORTH_SHIELDS)); } } + diff --git a/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationServiceTest.java b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationServiceTest.java new file mode 100644 index 000000000..3e9f8af3d --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/MakeAnApplicationServiceTest.java @@ -0,0 +1,174 @@ +package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure; + +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.DECIDE_AN_APPLICATION_ID; +import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.MAKE_AN_APPLICATIONS; +import static uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.MakeAnApplicationService.*; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplication; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.MakeAnApplicationTypes; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.State; +import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.IdValue; + +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class MakeAnApplicationServiceTest { + @Mock + private AsylumCase asylumCase; + @Mock + private List> applications; + @Mock + private MakeAnApplication makeAnApplication; + + private MakeAnApplicationService makeAnApplicationService; + private String decideAnApplicationId = "2"; + + @BeforeEach + public void setup() { + List> makeAnApplications = new ArrayList<>(); + MakeAnApplication makeAnApplication1 = new MakeAnApplication( + "", + "Expedite", + "", + new ArrayList<>(), + "", + "", + "", + ""); + makeAnApplications.add(new IdValue<>("1", makeAnApplication1)); + MakeAnApplication makeAnApplication2 = new MakeAnApplication( + "", + "Other", + "", + new ArrayList<>(), + "", + "", + "", + ""); + makeAnApplications.add(new IdValue<>("2", makeAnApplication2)); + MakeAnApplication makeAnApplication3 = new MakeAnApplication( + "", + "Withdraw", + "", + new ArrayList<>(), + "", + "", + "", + ""); + makeAnApplications.add(new IdValue<>("3", makeAnApplication3)); + when(asylumCase.read(MAKE_AN_APPLICATIONS)).thenReturn(Optional.of(makeAnApplications)); + makeAnApplicationService = new MakeAnApplicationService(); + } + + @Test + void should_return_application_when_not_decided() { + Optional makeAnApplicationOptional = makeAnApplicationService.getMakeAnApplication(asylumCase, false); + assertEquals("Withdraw", makeAnApplicationOptional.get().getType()); + } + + @Test + void should_return_application_when_decided() { + when(asylumCase.read(DECIDE_AN_APPLICATION_ID)).thenReturn(Optional.of(decideAnApplicationId)); + Optional makeAnApplicationOptional = makeAnApplicationService.getMakeAnApplication(asylumCase, true); + assertEquals("Other", makeAnApplicationOptional.get().getType()); + } + + @Test + void isAppealListed() { + State state = State.APPEAL_SUBMITTED; + assertFalse(makeAnApplicationService.isApplicationListed(state)); + + state = State.ADJOURNED; + assertTrue(makeAnApplicationService.isApplicationListed(state)); + } + + @ParameterizedTest + @EnumSource(value = MakeAnApplicationTypes.class) + void shouldMapApplicationTypeToPhrase(MakeAnApplicationTypes makeAnApplicationTypes) { + when(makeAnApplication.getType()).thenReturn(makeAnApplicationTypes.toString()); + + String expectedPhrase = makeAnApplicationService.mapApplicationTypeToPhrase(makeAnApplication); + + switch (makeAnApplicationTypes) { + case ADJOURN: + assertEquals(expectedPhrase, "change the hearing date"); + break; + case EXPEDITE: + assertEquals(expectedPhrase, "have the hearing sooner"); + break; + case JUDGE_REVIEW: + assertEquals(expectedPhrase, "ask a judge to review the decision"); + break; + case LINK_OR_UNLINK: + assertEquals(expectedPhrase, "link or unlink the appeal"); + break; + case TIME_EXTENSION: + assertEquals(expectedPhrase, "ask for more time"); + break; + case TRANSFER: + assertEquals(expectedPhrase, "move the hearing to a different location"); + break; + case WITHDRAW: + assertEquals(expectedPhrase, "withdraw from the appeal"); + break; + case UPDATE_HEARING_REQUIREMENTS: + assertEquals(expectedPhrase, "change some of the hearing requirements"); + break; + case UPDATE_APPEAL_DETAILS: + assertEquals(expectedPhrase, "change some of the appeal details"); + break; + case REINSTATE: + assertEquals(expectedPhrase, "reinstate the appeal"); + break; + case OTHER: + assertEquals(expectedPhrase, "change something about the appeal"); + break; + default: + break; + } + } + + @Test + void should_throw_exception_if_application_type_cannot_be_parsed() { + assertThatThrownBy(() -> makeAnApplicationService.getApplicationTypes("test")) + .hasMessage("Application type could not be parsed") + .isExactlyInstanceOf(IllegalStateException.class); + } + + @Test + void should_retrieve_correct_application_properties() { + final MakeAnApplication testApplication = new MakeAnApplication( + "Admin Officer", + "someRandomApplicationTypeThatShouldCauseAnException", + "someRandomDetails", + new ArrayList<>(), + LocalDate.now().toString(), + "Granted", + State.APPEAL_SUBMITTED.toString(), + "caseworker-ia-admofficer"); + testApplication.setDecisionReason("No reason"); + + Map applicationPropertiesMap = makeAnApplicationService.retrieveApplicationProperties(Optional.of(testApplication)); + assertEquals(applicationPropertiesMap.get(APPLICATION_TYPE), testApplication.getType()); + assertEquals(applicationPropertiesMap.get(APPLICATION_DECISION), testApplication.getDecision()); + assertEquals(applicationPropertiesMap.get(APPLICATION_DECISION_REASON), testApplication.getDecisionReason()); + } +} +