Skip to content

Commit

Permalink
RIA-7561: Fix the deadline date in the 'Request Hearing Requirements'…
Browse files Browse the repository at this point in the history
… letter (#687)

Co-authored-by: colmlynch60 <113999496+colmlynch60@users.noreply.github.com>
  • Loading branch information
neha-aggarw and colmlynch60 authored Sep 12, 2023
1 parent 7a1bc06 commit b1add88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
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.service.DueDateService;
import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.CustomerServicesProvider;

import java.time.LocalDate;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -21,15 +19,12 @@ public class InternalDetainedRequestHearingRequirementsTemplate implements Docum

private final String templateName;
private final CustomerServicesProvider customerServicesProvider;
private final DueDateService dueDateService;

public InternalDetainedRequestHearingRequirementsTemplate(
@Value("${internalDetainedRequestHearingRequirements.templateName}") String templateName,
CustomerServicesProvider customerServicesProvider,
DueDateService dueDateService) {
CustomerServicesProvider customerServicesProvider) {
this.templateName = templateName;
this.customerServicesProvider = customerServicesProvider;
this.dueDateService = dueDateService;
}

public String getName() {
Expand All @@ -55,7 +50,7 @@ public Map<String, Object> mapFieldValues(

private String getHearingRequirementsSubmissionDeadline(AsylumCase asylumCase) {
LocalDate directionDueDate = LocalDate.parse(getDirectionDueDate(asylumCase, DirectionTag.REQUEST_RESPONSE_REVIEW));
return formatDateForNotificationAttachmentDocument(dueDateService.calculateDueDate(directionDueDate.atStartOfDay(ZoneOffset.UTC), 5).toLocalDate());
return formatDateForNotificationAttachmentDocument(directionDueDate.plusDays(5));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
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;

import java.time.LocalDate;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.*;

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;
Expand All @@ -38,8 +33,6 @@ class InternalDetainedRequestHearingRequirementsTemplateTest {
private AsylumCase asylumCase;
@Mock
private CustomerServicesProvider customerServicesProvider;
@Mock
private DueDateService mockDueDateService;
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";
Expand All @@ -56,7 +49,6 @@ class InternalDetainedRequestHearingRequirementsTemplateTest {
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-08-17").atStartOfDay(ZoneOffset.UTC);

private final IdValue<Direction> requestResponseReviewDirection = new IdValue<>(
"1",
Expand All @@ -78,8 +70,7 @@ void setUp() {
internalDetainedRequestHearingRequirementsTemplate =
new InternalDetainedRequestHearingRequirementsTemplate(
templateName,
customerServicesProvider,
mockDueDateService
customerServicesProvider
);
}

Expand All @@ -102,7 +93,6 @@ void dataSetUp() {
List<IdValue<Direction>> directionList = new ArrayList<>();
directionList.add(requestResponseReviewDirection);
when(asylumCase.read(DIRECTIONS)).thenReturn(Optional.of(directionList));
when(mockDueDateService.calculateDueDate(any(), eq(5))).thenReturn(zonedDueDateTime);
}

@Test
Expand All @@ -119,7 +109,7 @@ void should_map_case_data_to_template_field_values() {
assertEquals(appellantFamilyName, templateFieldValues.get("appellantFamilyName"));
assertEquals(customerServicesTelephone, templateFieldValues.get("customerServicesTelephone"));
assertEquals(customerServicesEmail, templateFieldValues.get("customerServicesEmail"));
assertEquals("17 Aug 2023", templateFieldValues.get("hearingReqSubmissionDeadline"));
assertEquals("15 Aug 2023", templateFieldValues.get("hearingReqSubmissionDeadline"));

assertEquals(formatDateForNotificationAttachmentDocument(now), templateFieldValues.get("dateLetterSent"));
}
Expand Down

0 comments on commit b1add88

Please sign in to comment.