-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RIA-7331 Internal appellant ftpa decided - partially granted document (…
…#676) * RIA-7331 Internal appellant ftpa decided - partially granted document * RIA-7331 Corrected deadline date values for ada and non-ada
- Loading branch information
1 parent
961915c
commit c6f3893
Showing
7 changed files
with
287 additions
and
9 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...lTest/resources/scenarios/RIA-7331-internal-appellant-ftpa-decided-partially-granted.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"description": "RIA-7331 Internal appellant ftpa decided - partially granted letter", | ||
"request": { | ||
"uri": "/asylum/ccdAboutToSubmit", | ||
"credentials": "Judge", | ||
"input": { | ||
"id": 7331, | ||
"eventId": "residentJudgeFtpaDecision", | ||
"state": "ftpaSubmitted", | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "Yes", | ||
"ftpaAppellantRjDecisionOutcomeType": "partiallyGranted", | ||
"ftpaApplicantType": "appellant" | ||
} | ||
} | ||
} | ||
}, | ||
"expectation": { | ||
"status": 200, | ||
"errors": [], | ||
"caseData": { | ||
"template": "minimal-internal-appeal-submitted.json", | ||
"replacements": { | ||
"appellantInDetention": "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}" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...entsapi/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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.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 InternalAppellantFtpaDecidedPartiallyGrantedTemplate implements DocumentTemplate<AsylumCase> { | ||
|
||
private final String templateName; | ||
private final DateProvider dateProvider; | ||
private final CustomerServicesProvider customerServicesProvider; | ||
private final int adaDueInCalendarDays; | ||
private final int nonAdaDueInCalendarDays; | ||
|
||
public InternalAppellantFtpaDecidedPartiallyGrantedTemplate( | ||
@Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.templateName}") String templateName, | ||
DateProvider dateProvider, | ||
CustomerServicesProvider customerServicesProvider, | ||
@Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaAdaDueCalendarDays}") int adaDueInCalendarDays, | ||
@Value("${internalAppellantFtpaDecidedPartiallyGrantedLetter.ftpaNonAdaDueCalendarDays}") int nonAdaDueInCalendarDays) { | ||
this.templateName = templateName; | ||
this.dateProvider = dateProvider; | ||
this.customerServicesProvider = customerServicesProvider; | ||
this.adaDueInCalendarDays = adaDueInCalendarDays; | ||
this.nonAdaDueInCalendarDays = nonAdaDueInCalendarDays; | ||
} | ||
|
||
public String getName() { | ||
return templateName; | ||
} | ||
|
||
public Map<String, Object> mapFieldValues( | ||
CaseDetails<AsylumCase> caseDetails | ||
) { | ||
final AsylumCase asylumCase = caseDetails.getCaseData(); | ||
final Map<String, Object> fieldValues = new HashMap<>(); | ||
|
||
LocalDate dueDate = isAcceleratedDetainedAppeal(asylumCase) | ||
? LocalDate.now().plusDays(adaDueInCalendarDays) | ||
: 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
...api/domain/templates/letter/InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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.*; | ||
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.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.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.infrastructure.CustomerServicesProvider; | ||
|
||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
@SuppressWarnings("unchecked") | ||
@ExtendWith(MockitoExtension.class) | ||
class InternalAppellantFtpaDecidedPartiallyGrantedTemplateTest { | ||
|
||
@Mock | ||
private CaseDetails<AsylumCase> caseDetails; | ||
@Mock | ||
private AsylumCase asylumCase; | ||
@Mock | ||
private DateProvider dateProvider; | ||
@Mock | ||
private CustomerServicesProvider customerServicesProvider; | ||
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 adaDueInCalendarDays = 7; | ||
private final int nonAdaDueInCalendarDays = 14; | ||
private final LocalDate now = LocalDate.now(); | ||
private InternalAppellantFtpaDecidedPartiallyGrantedTemplate internalAppellantFtpaDecidedPartiallyGrantedTemplate; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
internalAppellantFtpaDecidedPartiallyGrantedTemplate = | ||
new InternalAppellantFtpaDecidedPartiallyGrantedTemplate( | ||
templateName, | ||
dateProvider, | ||
customerServicesProvider, | ||
adaDueInCalendarDays, | ||
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()); | ||
} | ||
|
||
@Test | ||
void should_return_template_name() { | ||
Assertions.assertEquals(templateName, internalAppellantFtpaDecidedPartiallyGrantedTemplate.getName()); | ||
} | ||
|
||
@Test | ||
void should_map_case_data_to_template_field_values() { | ||
dataSetup(); | ||
|
||
Map<String, Object> 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_calendar_days_for_ada() { | ||
dataSetup(); | ||
when(asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class)).thenReturn(Optional.of(YesOrNo.YES)); | ||
Map<String, Object> templateFieldValues = internalAppellantFtpaDecidedPartiallyGrantedTemplate.mapFieldValues(caseDetails); | ||
Assertions.assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(adaDueInCalendarDays)), 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<String, Object> templateFieldValues = internalAppellantFtpaDecidedPartiallyGrantedTemplate.mapFieldValues(caseDetails); | ||
Assertions.assertEquals(formatDateForNotificationAttachmentDocument(now.plusDays(nonAdaDueInCalendarDays)), templateFieldValues.get("utApplicationDeadline")); | ||
} | ||
} |