From 6a41366eb4f2c7be2e1505b35feeddae5d13b306 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 18 Oct 2023 16:02:57 +0100 Subject: [PATCH 01/18] CIV-10820 update Cos Notify Claim Details screen with deemed served date --- .../NotifyClaimDetailsCallbackHandler.java | 38 +++- .../civil/model/CertificateOfService.java | 2 + ...NotifyClaimDetailsCallbackHandlerTest.java | 162 +++++++++++++++--- .../civil/sampledata/CaseDataBuilder.java | 8 +- 4 files changed, 184 insertions(+), 26 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 9dd8d9fe63b..6c52f173240 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -6,13 +6,13 @@ import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; +import uk.gov.hmcts.reform.civil.bankholidays.WorkingDayIndicator; import uk.gov.hmcts.reform.civil.callback.Callback; import uk.gov.hmcts.reform.civil.callback.CallbackHandler; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; -import uk.gov.hmcts.reform.civil.model.common.Element; -import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.CertificateOfService; @@ -20,9 +20,10 @@ import uk.gov.hmcts.reform.civil.model.ServedDocumentFiles; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; -import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; +import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator; import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import uk.gov.hmcts.reform.civil.utils.ElementUtils; @@ -86,6 +87,15 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement public static final String DOC_SERVED_DATE_OLDER_THAN_14DAYS = "Date of Service should not be more than 14 days old"; + public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS = + "Date of service must be no greater than 2 working days in the future"; + + public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = + "On what day did you serve should not be more than 14 days old"; + + public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = + "For the date of service please enter a working day"; + public static final String DOC_SERVED_MANDATORY = "Supporting evidence is required"; @@ -96,6 +106,7 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement private final ObjectMapper objectMapper; private final Time time; private final DeadlinesCalculator deadlinesCalculator; + private final WorkingDayIndicator workingDayIndicator; private final FeatureToggleService featureToggleService; private final AssignCategoryId assignCategoryId; @@ -434,6 +445,12 @@ private String getServiceOfDateValidationMessage(CertificateOfService certificat return DOC_SERVED_DATE_IN_FUTURE; } else if (isCosDefendantNotifyDateOlderThan14Days(certificateOfService.getCosDateOfServiceForDefendant())) { return DOC_SERVED_DATE_OLDER_THAN_14DAYS; + } else if (isDeemedServedWithinMaxWorkingDays(certificateOfService.getCosDateDeemedServedForDefendant())) { + return DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS; + } else if (isDeemedServedDateIsNotWorkingDay(certificateOfService.getCosDateDeemedServedForDefendant())) { + return DATE_OF_SERVICE_DATE_IS_WORKING_DAY; + } else if (isDeemedServedDateOlderThan14Days(certificateOfService.getCosDateDeemedServedForDefendant())) { + return DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS; } } return errorMessage; @@ -446,7 +463,22 @@ private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceFor private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { return time.now().isAfter(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant .atTime(time.now().toLocalTime()))); + } + + private boolean isDeemedServedDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { + return time.now().isAfter(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant + .atTime(time.now().toLocalTime()))); + } + + public boolean isDeemedServedWithinMaxWorkingDays(LocalDate cosDateOfServiceForDefendant) { + LocalDate currentDate = LocalDate.now(); + LocalDate maxWorkingDaysDate = deadlinesCalculator.plusWorkingDays(currentDate, 2); + + return cosDateOfServiceForDefendant.isAfter(maxWorkingDaysDate); + } + private boolean isDeemedServedDateIsNotWorkingDay(LocalDate cosDateOfServiceForDefendant) { + return !workingDayIndicator.isWorkingDay(cosDateOfServiceForDefendant); } private boolean isBothDefendantLip(CaseData caseData) { diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CertificateOfService.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CertificateOfService.java index a0f83c9cd6b..df1a5830ff0 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CertificateOfService.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CertificateOfService.java @@ -27,6 +27,8 @@ public class CertificateOfService { @JsonProperty("cosDateOfServiceForDefendant") private LocalDate cosDateOfServiceForDefendant; + @JsonProperty("cosDateDeemedServedForDefendant") + private LocalDate cosDateDeemedServedForDefendant; @JsonProperty("cosServedDocumentFiles") private String cosServedDocumentFiles; @JsonProperty("cosEvidenceDocument") diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index b9ac78d66d1..8ffb340827e 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -13,25 +13,27 @@ import org.springframework.boot.test.mock.mockito.MockBean; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; +import uk.gov.hmcts.reform.civil.bankholidays.WorkingDayIndicator; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.config.ExitSurveyConfiguration; import uk.gov.hmcts.reform.civil.documentmanagement.model.Document; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; -import uk.gov.hmcts.reform.civil.model.DocumentWithRegex; -import uk.gov.hmcts.reform.civil.model.common.Element; -import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.DocumentWithRegex; import uk.gov.hmcts.reform.civil.model.ServedDocumentFiles; +import uk.gov.hmcts.reform.civil.model.common.Element; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.sampledata.PartyBuilder; import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator; import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService; +import uk.gov.hmcts.reform.civil.service.FeatureToggleService; import uk.gov.hmcts.reform.civil.service.Time; import uk.gov.hmcts.reform.civil.utils.AssignCategoryId; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -69,6 +71,9 @@ class NotifyClaimDetailsCallbackHandlerTest extends BaseCallbackHandlerTest { @MockBean private Time time; + @MockBean + private WorkingDayIndicator workingDayIndicator; + @MockBean private DeadlinesCalculator deadlinesCalculator; @@ -256,13 +261,14 @@ void shouldUpdateBusinessProcess_whenInvoked1v2DifferentSolicitor() { void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); + LocalDate deemedDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, false, cosDate, null, true, false) + .setCoSClaimDetailsWithDate(true, false, cosDate, deemedDate, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -280,13 +286,14 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); + LocalDate deemedDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(false, true, null, cosDate, false, true) + .setCoSClaimDetailsWithDate(false, true, null, null, cosDate, deemedDate, false, true) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -305,6 +312,8 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cos1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate cos2Date = localDateTime.minusDays(3).toLocalDate(); + LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); + LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); @@ -313,7 +322,7 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, cos1Date, cos2Date, true, true) + .setCoSClaimDetailsWithDate(true, true, cos1Date, deemed1Date, cos2Date, deemed2Date, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -331,6 +340,8 @@ void shouldUpdate_to_earliest_day_cos1_is_earliest_whenSubmitted() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); LocalDate cos1Date = localDateTime.minusDays(3).toLocalDate(); LocalDate cos2Date = localDateTime.minusDays(2).toLocalDate(); + LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); + LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); @@ -339,7 +350,7 @@ void shouldUpdate_to_earliest_day_cos1_is_earliest_whenSubmitted() { CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, cos1Date, cos2Date, true, true) + .setCoSClaimDetailsWithDate(true, true, cos1Date, deemed1Date, cos2Date, deemed2Date, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -505,7 +516,7 @@ void shouldReturnCoSConfirmation_whenCosNotifyDetailsSuccess() { .thenReturn(past.plusDays(14).atTime(16, 0)); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, past, true, true) + .setCoSClaimDetailsWithDate(true, true, past, past, past, past, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -521,7 +532,7 @@ void shouldReturnCoSConfirmation_1Lip1Lr_whenCosNotifyDetailsSuccess() { .thenReturn(past.plusDays(14).atTime(16, 0)); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lip_1Lr() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, SUBMITTED); SubmittedCallbackResponse response = (SubmittedCallbackResponse) handler.handle(params); @@ -531,18 +542,30 @@ void shouldReturnCoSConfirmation_1Lip1Lr_whenCosNotifyDetailsSuccess() { @Nested class MidEventValidateCos { + public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS = + "Date of service must be no greater than 2 working days in the future"; + + public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = + "On what day did you serve should not be more than 14 days old"; + + public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = + "For the date of service please enter a working day"; + @Test void shouldPassValidateCertificateOfService_whenDateIsPast() { LocalDate past = LocalDate.now().minusDays(1); when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, past, true, true) + .setCoSClaimDetailsWithDate(true, true, past, past, past, past, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -558,12 +581,15 @@ void shouldPassValidateCertificateOfService_1Lip1Lr_whenDateIsPast() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(16, 05)); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lip_1Lr() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -579,12 +605,15 @@ void shouldPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_notOld when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lr_1Lip() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -604,7 +633,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lr_1Lip() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -624,7 +653,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_dea CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lr_1Lip() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -641,7 +670,7 @@ void shouldIgnoreValidateCertificateOfService_whenDisabled() { LocalDate future = LocalDate.now().plusDays(1); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, future, true, true) + .setCoSClaimDetailsWithDate(true, true, past, past, future, future, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -658,7 +687,7 @@ void shouldFailValidateCertificateOfService_whenDateIsFuture() { LocalDate future = LocalDate.now().plusDays(1); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, past, future, true, true) + .setCoSClaimDetailsWithDate(true, true, past, past, future, future, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -673,12 +702,15 @@ void shouldFailValidateCertificateOfService_When1v2LIP_BothDefendant_DifferentDa when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(def2pastDate.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, def1pastDate, def2pastDate, true, true) + .setCoSClaimDetailsWithDate(true, true, def1pastDate, def1pastDate, def2pastDate, def2pastDate, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -689,6 +721,9 @@ void shouldFailValidateCertificateOfService_When1v2LIP_BothDefendant_DifferentDa @Test void shouldNotFailValidateCertificateOfService_When1v2LIP_BothDefendant_SameDateOfService() { when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); LocalDate def1pastDate = LocalDate.now().minusDays(1); @@ -699,7 +734,7 @@ void shouldNotFailValidateCertificateOfService_When1v2LIP_BothDefendant_SameDate CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, true, def1pastDate, def2pastDate, true, true) + .setCoSClaimDetailsWithDate(true, true, def1pastDate, def1pastDate, def2pastDate, def2pastDate, true, true) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails2"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -712,12 +747,15 @@ void shouldPassValidateCertificateOfService_whenHasFile() { LocalDate past = LocalDate.now().minusDays(1); when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, false, past, null, true, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, true, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = @@ -730,17 +768,101 @@ void shouldFailValidateCertificateOfService_whenHasNoFile() { LocalDate past = LocalDate.now().minusDays(1); when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); when(time.now()).thenReturn(LocalDateTime.now()); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() - .setCoSClaimDetailsWithDate(true, false, past, null, false, false) + .setCoSClaimDetailsWithDate(true, false, past, past, null, null, false, false) .build(); CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); assertThat(successResponse.getErrors().size()).isEqualTo(1); } + + @Test + void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateIsPast_deadline() { + LocalDate currentDate = LocalDate.now(); + LocalDate deemedServedDate = currentDate.minusDays(15); + + when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); + when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); + when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) + .thenReturn(LocalDate.of(2023, 10, 16)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) + .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) + .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDetailsNotified_1v2_1Lip_1Lr() + .setCoSClaimDetailsWithDate(true, false, currentDate, deemedServedDate, null, null, true, false) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); + AboutToStartOrSubmitCallbackResponse successResponse = + (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(successResponse.getErrors().size()).isEqualTo(1); + assertThat(successResponse.getErrors()).contains(DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS); + assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); + } + + @Test + void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateNotInWorkingDay() { + LocalDate currentDate = LocalDate.now(); + LocalDate deemedServedDate = currentDate; + + when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); + when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); + when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) + .thenReturn(LocalDate.now().plusDays(2)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) // assuming 4 pm deadline + .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) // assuming 4 pm deadline + .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(false); + + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDetailsNotified_1v2_1Lip_1Lr() + .setCoSClaimDetailsWithDate(true, false, currentDate, deemedServedDate, null, null, true, false) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); + AboutToStartOrSubmitCallbackResponse successResponse = + (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(successResponse.getErrors().size()).isEqualTo(1); + assertThat(successResponse.getErrors()).contains(DATE_OF_SERVICE_DATE_IS_WORKING_DAY); + assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); + } + + @Test + void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateExceeds2WorkingDays() { + LocalDate currentDate = LocalDate.now(); + LocalDate deemedServedDate = currentDate.plusDays(5); + + when(featureToggleService.isCertificateOfServiceEnabled()).thenReturn(true); + when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); + when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) + .thenReturn(LocalDate.of(2023, 10, 16)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) + .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) + .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); + + CaseData caseData = CaseDataBuilder.builder() + .atStateClaimDetailsNotified_1v2_1Lip_1Lr() + .setCoSClaimDetailsWithDate(true, false, currentDate, deemedServedDate, null, null, true, false) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); + AboutToStartOrSubmitCallbackResponse successResponse = + (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(successResponse.getErrors().size()).isEqualTo(1); + assertThat(successResponse.getErrors()).contains(DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS); + assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java index 2e378f46262..5e73f362f64 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java @@ -5497,7 +5497,7 @@ public CaseDataBuilder setCaseListDisplayDefendantSolicitorReferences(boolean is } public CaseDataBuilder setCoSClaimDetailsWithDate(boolean setCos1, boolean setCos2, - LocalDate cos1Date, LocalDate cos2Date, + LocalDate cos1Date, LocalDate deemed1Date, LocalDate cos2Date, LocalDate deemed2Date, boolean file1, boolean file2) { List> files = wrapElements(Document.builder() .documentUrl("fake-url") @@ -5513,7 +5513,8 @@ public CaseDataBuilder setCoSClaimDetailsWithDate(boolean setCos1, boolean setCo cosUIStatement.add("CERTIFIED"); if (setCos1) { CertificateOfService.CertificateOfServiceBuilder cos1Builder = CertificateOfService.builder() - .cosDateOfServiceForDefendant(cos1Date); + .cosDateOfServiceForDefendant(cos1Date) + .cosDateDeemedServedForDefendant(deemed1Date); if (file1) { cos1Builder.cosEvidenceDocument(files); } @@ -5521,7 +5522,8 @@ public CaseDataBuilder setCoSClaimDetailsWithDate(boolean setCos1, boolean setCo } if (setCos2) { CertificateOfService.CertificateOfServiceBuilder cos2Builder = CertificateOfService.builder() - .cosDateOfServiceForDefendant(cos2Date); + .cosDateOfServiceForDefendant(cos2Date) + .cosDateDeemedServedForDefendant(deemed2Date); if (file2) { cos2Builder.cosEvidenceDocument(files2); } From a84e01dbf84354bb379d0c2b4c8629a9465714b4 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 18 Oct 2023 16:09:25 +0100 Subject: [PATCH 02/18] Update Jenkinsfile_CNP --- Jenkinsfile_CNP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 54a1d7d1008..ccdaf5d8cab 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -8,7 +8,7 @@ import uk.gov.hmcts.contino.GithubAPI def type = "java" def product = "civil" def component = "service" -def ccdBranch = "master" +def ccdBranch = "CIV-10820-CoS-Notify-Claim-Details-Screen-add-date-deemed-served" def camundaBranch = "master" def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this) From f55d3a95e17c514732b86870e7858db0cae68de0 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Thu, 19 Oct 2023 09:16:36 +0100 Subject: [PATCH 03/18] Update Jenkinsfile_CNP --- Jenkinsfile_CNP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index ccdaf5d8cab..54a1d7d1008 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -8,7 +8,7 @@ import uk.gov.hmcts.contino.GithubAPI def type = "java" def product = "civil" def component = "service" -def ccdBranch = "CIV-10820-CoS-Notify-Claim-Details-Screen-add-date-deemed-served" +def ccdBranch = "master" def camundaBranch = "master" def yarnBuilder = new uk.gov.hmcts.contino.YarnBuilder(this) From 64b889d7572eb87d86c22b45f6691cc337e7b9c3 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Fri, 3 Nov 2023 16:42:07 +0000 Subject: [PATCH 04/18] CIV-10820 fix errorMessage and respondentDedline --- .../user/NotifyClaimDetailsCallbackHandler.java | 12 ++++++------ .../user/NotifyClaimDetailsCallbackHandlerTest.java | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 6c52f173240..908da6c1e47 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -85,13 +85,13 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement "Date you served the documents must be today or in the past"; public static final String DOC_SERVED_DATE_OLDER_THAN_14DAYS = - "Date of Service should not be more than 14 days old"; + "On what day did you serve should not be more than 14 days old"; public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS = "Date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = - "On what day did you serve should not be more than 14 days old"; + "The date of service should not be more than 14 days old"; public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = "For the date of service please enter a working day"; @@ -209,17 +209,17 @@ private LocalDateTime getEarliestDateOfService(CaseData caseData) { if (featureToggleService.isCertificateOfServiceEnabled()) { if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant())) { + && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) { LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); if (cosDate1.isBefore(date)) { date = cosDate1; } } if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) { + && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); if (cosDate2.isBefore(date)) { date = cosDate2; } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index 8ffb340827e..5eb896fc9c7 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -546,7 +546,7 @@ class MidEventValidateCos { "Date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = - "On what day did you serve should not be more than 14 days old"; + "Date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = "For the date of service please enter a working day"; @@ -793,10 +793,10 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateIsPast_dead when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.of(2023, 10, 16)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) - .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) + .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() From ac3c0d8b5f54a4a669adde2b5f30b5a69141323a Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 15 Nov 2023 15:36:38 +0000 Subject: [PATCH 05/18] CIV-18020 - update error message according to change in AC --- .../callback/user/NotifyClaimDetailsCallbackHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 908da6c1e47..d4cbef3a4c5 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -82,7 +82,7 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement "Your claim will progress offline if you only notify one Defendant of the claim details."; public static final String DOC_SERVED_DATE_IN_FUTURE = - "Date you served the documents must be today or in the past"; + "On what day did you serve must be today or in the past"; public static final String DOC_SERVED_DATE_OLDER_THAN_14DAYS = "On what day did you serve should not be more than 14 days old"; From 47b00c85bcc3587fa6dfeb22a0663e577a0719ad Mon Sep 17 00:00:00 2001 From: MMNycz Date: Tue, 21 Nov 2023 10:28:52 +0000 Subject: [PATCH 06/18] Update suppressions.xml --- config/owasp/suppressions.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml index 8effe28d3c5..97eb8c27875 100644 --- a/config/owasp/suppressions.xml +++ b/config/owasp/suppressions.xml @@ -34,6 +34,7 @@ CVE-2023-4586 CVE-2023-5072 CVE-2023-44487 + CVE-2023-36052 From 3f2944d7e50aca27200abebafc460e693b968b27 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 6 Dec 2023 16:47:08 +0000 Subject: [PATCH 07/18] Update suppressions.xml --- config/owasp/suppressions.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/owasp/suppressions.xml b/config/owasp/suppressions.xml index 07a90a161f6..be178ea20b7 100644 --- a/config/owasp/suppressions.xml +++ b/config/owasp/suppressions.xml @@ -40,6 +40,7 @@ CVE-2023-36052 CVE-2023-34055 CVE-2023-46589 + CVE-2023-6378 From 4434e43da576baab54e9b048105668b09413d221 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 13 Dec 2023 10:14:25 +0000 Subject: [PATCH 08/18] Update NotifyClaimDetailsCallbackHandler.java --- .../user/NotifyClaimDetailsCallbackHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index cb791ca8548..610fa62d260 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -206,17 +206,17 @@ private LocalDateTime getEarliestDateOfService(CaseData caseData) { LocalDateTime date = time.now(); if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant())) { + && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) { LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); if (cosDate1.isBefore(date)) { date = cosDate1; } } if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) - && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) { + && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() - .getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime()); + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); if (cosDate2.isBefore(date)) { date = cosDate2; } @@ -475,8 +475,8 @@ private boolean isBothDefendantLip(CaseData caseData) { private boolean isBothDefendantWithSameDateOfService(CaseData caseData) { if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) && Objects.nonNull(caseData.getCosNotifyClaimDetails2())) { - if (caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant() - .equals(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) { + if (caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant() + .equals(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { return true; } } From 5db3a103867f6657240a7ba8b6cac0cee57c2bc4 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Thu, 14 Dec 2023 09:55:09 +0000 Subject: [PATCH 09/18] CIV-10820 add log info to check multipartyScenario --- .../callback/user/NotifyClaimDetailsCallbackHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 610fa62d260..80497dd71a9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; @@ -53,6 +54,7 @@ import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE_TIME_AT; import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.formatLocalDateTime; +@Slf4j @Service @RequiredArgsConstructor public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implements ParticularsOfClaimValidator { @@ -135,6 +137,8 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { LocalDate notificationDate = notificationDateTime.toLocalDate(); MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); + log.info("MultipartyScenario: {}", multiPartyScenario); + caseData = saveCoSDetailsDoc(caseData, 1); caseData = saveCoSDetailsDoc(caseData, 2); From e654c7693e68111d4a0d322c212742d4f07e7f7d Mon Sep 17 00:00:00 2001 From: MMNycz Date: Fri, 15 Dec 2023 14:05:38 +0000 Subject: [PATCH 10/18] CIV-10820 --- .../NotifyClaimDetailsCallbackHandler.java | 59 +++++++++++++------ 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 80497dd71a9..032f9c8de2a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -90,7 +90,7 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement "On what day did you serve should not be more than 14 days old"; public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS = - "Date of service must be no greater than 2 working days in the future"; + "The date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = "The date of service should not be more than 14 days old"; @@ -207,25 +207,32 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { } private LocalDateTime getEarliestDateOfService(CaseData caseData) { - LocalDateTime date = time.now(); + LocalDateTime date1 = null; + LocalDateTime date2 = null; if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) { - LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() - .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); - if (cosDate1.isBefore(date)) { - date = cosDate1; - } + date1 = caseData.getCosNotifyClaimDetails1() + .getCosDateDeemedServedForDefendant().atTime(LocalDateTime.now().toLocalTime()); } + if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { - LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() - .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); - if (cosDate2.isBefore(date)) { - date = cosDate2; - } + date2 = caseData.getCosNotifyClaimDetails2() + .getCosDateDeemedServedForDefendant().atTime(LocalDateTime.now().toLocalTime()); + } + + return getEarliestDate(date1, date2); + } + + private LocalDateTime getEarliestDate(LocalDateTime date1, LocalDateTime date2) { + if (date1 == null) { + return date2; + } else if (date2 == null) { + return date1; + } else { + return date1.isBefore(date2) ? date1 : date2; } - return date; } private CaseData saveCoSDetailsDoc(CaseData caseData, int lipNumber) { @@ -449,13 +456,31 @@ private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceFor } private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { - return time.now().isAfter(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant - .atTime(time.now().toLocalTime()))); + LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant + .atTime(time.now().toLocalTime())); + LocalDateTime currentDateTime = time.now(); + LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); + + boolean isAfter4pmToday = currentDateTime.isAfter(today4pm) + && currentDateTime.toLocalDate().equals(notificationDeadline.toLocalDate()); + + boolean isAfter14DaysAt4pmDeadline = currentDateTime.isAfter(notificationDeadline); + + return isAfter14DaysAt4pmDeadline || isAfter4pmToday; } private boolean isDeemedServedDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { - return time.now().isAfter(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant - .atTime(time.now().toLocalTime()))); + LocalDateTime deemedServedDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant + .atTime(time.now().toLocalTime())); + LocalDateTime currentDateTime = time.now(); + LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); + + boolean isAfter4pmToday = currentDateTime.isAfter(today4pm) + && currentDateTime.toLocalDate().equals(deemedServedDeadline.toLocalDate()); + + boolean isAfter14DaysAt4pmDeadline = currentDateTime.isAfter(deemedServedDeadline); + + return isAfter14DaysAt4pmDeadline || isAfter4pmToday; } public boolean isDeemedServedWithinMaxWorkingDays(LocalDate cosDateOfServiceForDefendant) { From 701d3fca1efa8a3642a9481d62c033dd46bc2ec8 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Mon, 18 Dec 2023 11:14:45 +0000 Subject: [PATCH 11/18] Update NotifyClaimDetailsCallbackHandlerTest.java --- .../NotifyClaimDetailsCallbackHandlerTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index 6b2164eac4e..b72ff6ec721 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -216,6 +216,9 @@ void setup() { when(deadlinesCalculator.plus14DaysAt4pmDeadline(localDateTime)).thenReturn(newDate); when(deadlinesCalculator.addMonthsToDateToNextWorkingDayAtMidnight(6, localDateTime.toLocalDate())) .thenReturn(sixMonthDate); + when(workingDayIndicator.isWeekend(any(LocalDate.class))).thenReturn(true); + when(deadlinesCalculator.plusWorkingDays(localDateTime.toLocalDate(), 2)) + .thenReturn(LocalDate.of(2023, 10, 16)); } @Test @@ -285,9 +288,16 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); LocalDate deemedDate = localDateTime.minusDays(2).toLocalDate(); + LocalDate currentDate = LocalDate.now(); + + when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedDate.atTime(15, 05))) + .thenReturn(newDate.minusDays(2)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(false); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() @@ -536,10 +546,10 @@ void shouldReturnCoSConfirmation_1Lip1Lr_whenCosNotifyDetailsSuccess() { @Nested class MidEventValidateCos { public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS = - "Date of service must be no greater than 2 working days in the future"; + "The date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = - "Date of service must be no greater than 2 working days in the future"; + "The date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = "For the date of service please enter a working day"; From 37ba6156adbe7bd1d6fadcb84eebfa86f26136c7 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Mon, 18 Dec 2023 14:49:47 +0000 Subject: [PATCH 12/18] CIV-10820 fix unit test --- .../user/NotifyClaimDetailsCallbackHandler.java | 17 ++++++++--------- .../NotifyClaimDetailsCallbackHandlerTest.java | 3 +++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 032f9c8de2a..2ba41ec93da 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -137,8 +137,6 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { LocalDate notificationDate = notificationDateTime.toLocalDate(); MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData); - log.info("MultipartyScenario: {}", multiPartyScenario); - caseData = saveCoSDetailsDoc(caseData, 1); caseData = saveCoSDetailsDoc(caseData, 2); @@ -207,22 +205,23 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { } private LocalDateTime getEarliestDateOfService(CaseData caseData) { - LocalDateTime date1 = null; - LocalDateTime date2 = null; + LocalDateTime date = time.now(); if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) { - date1 = caseData.getCosNotifyClaimDetails1() - .getCosDateDeemedServedForDefendant().atTime(LocalDateTime.now().toLocalTime()); + LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); + date = getEarliestDate(date, cosDate1); } if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { - date2 = caseData.getCosNotifyClaimDetails2() - .getCosDateDeemedServedForDefendant().atTime(LocalDateTime.now().toLocalTime()); + LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() + .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); + date = getEarliestDate(date, cosDate2); } - return getEarliestDate(date1, date2); + return date; } private LocalDateTime getEarliestDate(LocalDateTime date1, LocalDateTime date2) { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index b72ff6ec721..85a0b83f7e6 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -267,11 +267,14 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedDate.atTime(15, 05))) + .thenReturn(newDate.minusDays(2)); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_andNotifyBothCoS() .setCoSClaimDetailsWithDate(true, false, cosDate, deemedDate, null, null, true, false) .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); From fc395362b82fd6391a1fcc39fb36a915d7c1c643 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Tue, 19 Dec 2023 14:57:25 +0000 Subject: [PATCH 13/18] CIV-10820 fix single error message --- .../NotifyClaimDetailsCallbackHandler.java | 51 ++++++++++--------- ...NotifyClaimDetailsCallbackHandlerTest.java | 18 ++++--- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 2ba41ec93da..2e71b8995be 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -102,7 +102,7 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement "Supporting evidence is required"; public static final String BOTH_CERTIFICATE_SERVED_SAME_DATE = - "Date of Service for both certificate must be the same"; + "The date of Service for defendant 1 and defendant 2 must be the same"; private final ExitSurveyContentService exitSurveyContentService; private final ObjectMapper objectMapper; @@ -375,12 +375,9 @@ private CallbackResponse validateCoSDetailsDefendant1(final CallbackParams callb caseData.getCosNotifyClaimDetails1().setCosDocSaved(NO); } - final String dateValidationErrorMessage = getServiceOfDateValidationMessage( - caseData.getCosNotifyClaimDetails1()); + List dateValidationErrorMessages = getServiceOfDateValidationMessages(caseData.getCosNotifyClaimDetails1()); + errors.addAll(dateValidationErrorMessages); - if (!dateValidationErrorMessage.isEmpty()) { - errors.add(dateValidationErrorMessage); - } if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) && isMandatoryDocMissing(caseData.getCosNotifyClaimDetails1())) { errors.add(DOC_SERVED_MANDATORY); @@ -402,12 +399,8 @@ private CallbackResponse validateCoSDetailsDefendant2(final CallbackParams callb if (Objects.nonNull(caseData.getCosNotifyClaimDetails2())) { caseData.getCosNotifyClaimDetails2().setCosDocSaved(NO); } - final String dateValidationErrorMessage = getServiceOfDateValidationMessage( - caseData.getCosNotifyClaimDetails2()); - - if (!dateValidationErrorMessage.isEmpty()) { - errors.add(dateValidationErrorMessage); - } + List dateValidationErrorMessages = getServiceOfDateValidationMessages(caseData.getCosNotifyClaimDetails2()); + errors.addAll(dateValidationErrorMessages); if (isBothDefendantLip(caseData) && !isBothDefendantWithSameDateOfService(caseData)) { errors.add(BOTH_CERTIFICATE_SERVED_SAME_DATE); @@ -432,22 +425,32 @@ private boolean isMandatoryDocMissing(CertificateOfService certificateOfService) return Objects.isNull(certificateOfService.getCosEvidenceDocument()); } - private String getServiceOfDateValidationMessage(CertificateOfService certificateOfService) { - final String errorMessage = ""; + private List getServiceOfDateValidationMessages(CertificateOfService certificateOfService) { + List errorMessages = new ArrayList<>(); + if (Objects.nonNull(certificateOfService)) { if (isCosDefendantNotifyDateFutureDate(certificateOfService.getCosDateOfServiceForDefendant())) { - return DOC_SERVED_DATE_IN_FUTURE; - } else if (isCosDefendantNotifyDateOlderThan14Days(certificateOfService.getCosDateOfServiceForDefendant())) { - return DOC_SERVED_DATE_OLDER_THAN_14DAYS; - } else if (isDeemedServedWithinMaxWorkingDays(certificateOfService.getCosDateDeemedServedForDefendant())) { - return DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS; - } else if (isDeemedServedDateIsNotWorkingDay(certificateOfService.getCosDateDeemedServedForDefendant())) { - return DATE_OF_SERVICE_DATE_IS_WORKING_DAY; - } else if (isDeemedServedDateOlderThan14Days(certificateOfService.getCosDateDeemedServedForDefendant())) { - return DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS; + errorMessages.add(DOC_SERVED_DATE_IN_FUTURE); + } + + if (isCosDefendantNotifyDateOlderThan14Days(certificateOfService.getCosDateOfServiceForDefendant())) { + errorMessages.add(DOC_SERVED_DATE_OLDER_THAN_14DAYS); + } + + if (isDeemedServedWithinMaxWorkingDays(certificateOfService.getCosDateDeemedServedForDefendant())) { + errorMessages.add(DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS); + } + + if (isDeemedServedDateIsNotWorkingDay(certificateOfService.getCosDateDeemedServedForDefendant())) { + errorMessages.add(DATE_OF_SERVICE_DATE_IS_WORKING_DAY); + } + + if (isDeemedServedDateOlderThan14Days(certificateOfService.getCosDateDeemedServedForDefendant())) { + errorMessages.add(DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS); } } - return errorMessage; + + return errorMessages; } private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceForDefendant) { diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index 85a0b83f7e6..1a3b0e82df0 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -552,7 +552,7 @@ class MidEventValidateCos { "The date of service must be no greater than 2 working days in the future"; public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS = - "The date of service must be no greater than 2 working days in the future"; + "The date of service should not be more than 14 days old"; public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY = "For the date of service please enter a working day"; @@ -630,8 +630,11 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old LocalDate past = LocalDate.now().minusDays(15); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lr_1Lip() @@ -640,7 +643,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - assertThat(successResponse.getErrors().size()).isEqualTo(1); + assertThat(successResponse.getErrors().size()).isEqualTo(2); assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); } @@ -648,9 +651,12 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_deadlineTodayDate_After16hrs() { LocalDate past = LocalDate.now().minusDays(14); - when(time.now()).thenReturn(LocalDate.now().atTime(16, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(time.now()).thenReturn(LocalDate.now().atTime(17, 05)); + when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) + .thenReturn(LocalDate.now().plusDays(2)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(17, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); + when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); CaseData caseData = CaseDataBuilder.builder() .atStateClaimDetailsNotified_1v2_1Lr_1Lip() @@ -659,7 +665,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_dea CallbackParams params = callbackParamsOf(caseData, MID, "validateCosNotifyClaimDetails1"); AboutToStartOrSubmitCallbackResponse successResponse = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); - assertThat(successResponse.getErrors().size()).isEqualTo(1); + assertThat(successResponse.getErrors().size()).isEqualTo(2); assertThat(params.getCaseData().getCosNotifyClaimDetails1().getCosDocSaved()).isEqualTo(NO); } @@ -755,7 +761,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateIsPast_dead when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) - .thenReturn(LocalDate.of(2023, 10, 16)); + .thenReturn(LocalDate.now().plusDays(2)); when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) From 4d1b23ffb5ca2e5231c062faf35d3397428f0fc3 Mon Sep 17 00:00:00 2001 From: kdaHMCTS Date: Wed, 20 Dec 2023 14:14:01 +0000 Subject: [PATCH 14/18] uodate branch with master --- .../callback/user/NotifyClaimDetailsCallbackHandler.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 2e71b8995be..1ed444f4369 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -32,6 +32,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -458,9 +459,13 @@ private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceFor } private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { + LocalDateTime fakeDateTime = time.now().toLocalDate().atTime(16, 10); LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant - .atTime(time.now().toLocalTime())); - LocalDateTime currentDateTime = time.now(); + .atTime(LocalTime.from(fakeDateTime + ))); + + LocalDateTime currentDateTime = fakeDateTime; + LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); boolean isAfter4pmToday = currentDateTime.isAfter(today4pm) From 0395c504e8b7f03919f0231c8ed6dcc468b6e34d Mon Sep 17 00:00:00 2001 From: kdaHMCTS Date: Wed, 20 Dec 2023 14:22:36 +0000 Subject: [PATCH 15/18] uodate branch with master --- .../callback/user/NotifyClaimDetailsCallbackHandler.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 1ed444f4369..2e71b8995be 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -32,7 +32,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -459,13 +458,9 @@ private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceFor } private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { - LocalDateTime fakeDateTime = time.now().toLocalDate().atTime(16, 10); LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant - .atTime(LocalTime.from(fakeDateTime - ))); - - LocalDateTime currentDateTime = fakeDateTime; - + .atTime(time.now().toLocalTime())); + LocalDateTime currentDateTime = time.now(); LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); boolean isAfter4pmToday = currentDateTime.isAfter(today4pm) From ec0b273f4225a10d917516520c582083209634b2 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 20 Dec 2023 14:25:25 +0000 Subject: [PATCH 16/18] CIC-10820 update validate date to plus14Days --- .../NotifyClaimDetailsCallbackHandler.java | 4 +- ...NotifyClaimDetailsCallbackHandlerTest.java | 48 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index ebcfc5cef69..54ee89d1603 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -473,7 +473,7 @@ private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceFor } private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { - LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant + LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysDeadline(cosDateOfServiceForDefendant .atTime(time.now().toLocalTime())); LocalDateTime currentDateTime = time.now(); LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); @@ -487,7 +487,7 @@ private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServi } private boolean isDeemedServedDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) { - LocalDateTime deemedServedDeadline = deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant + LocalDateTime deemedServedDeadline = deadlinesCalculator.plus14DaysDeadline(cosDateOfServiceForDefendant .atTime(time.now().toLocalTime())); LocalDateTime currentDateTime = time.now(); LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0); diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index 1a3b0e82df0..d9a83b8d486 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -213,7 +213,7 @@ void setup() { newDate = LocalDateTime.of(2020, 1, 15, 16, 0, 0); sixMonthDate = LocalDateTime.of(2020, 7, 1, 0, 0, 0); when(time.now()).thenReturn(localDateTime); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(localDateTime)).thenReturn(newDate); + when(deadlinesCalculator.plus14DaysDeadline(localDateTime)).thenReturn(newDate); when(deadlinesCalculator.addMonthsToDateToNextWorkingDayAtMidnight(6, localDateTime.toLocalDate())) .thenReturn(sixMonthDate); when(workingDayIndicator.isWeekend(any(LocalDate.class))).thenReturn(true); @@ -265,9 +265,9 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); LocalDate deemedDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(deemedDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); CaseData caseData = CaseDataBuilder.builder() @@ -296,9 +296,9 @@ void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.now().plusDays(2)); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(deemedDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(false); @@ -325,9 +325,9 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos2Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cos2Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); CaseData caseData = CaseDataBuilder.builder() @@ -352,9 +352,9 @@ void shouldUpdate_to_earliest_day_cos1_is_earliest_whenSubmitted() { LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos2Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(cos2Date.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); CaseData caseData = CaseDataBuilder.builder() @@ -564,7 +564,7 @@ void shouldPassValidateCertificateOfService_whenDateIsPast() { when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -587,7 +587,7 @@ void shouldPassValidateCertificateOfService_1Lip1Lr_whenDateIsPast() { when(time.now()).thenReturn(LocalDate.now().atTime(16, 05)); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -610,7 +610,7 @@ void shouldPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_notOld when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -632,7 +632,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_Old when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysDeadline(past.atTime(15, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -654,7 +654,7 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenServiceDateIsPast_dea when(time.now()).thenReturn(LocalDate.now().atTime(17, 05)); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(past.atTime(17, 05))) + when(deadlinesCalculator.plus14DaysDeadline(past.atTime(17, 05))) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -677,7 +677,7 @@ void shouldFailValidateCertificateOfService_When1v2LIP_BothDefendant_DifferentDa when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(def2pastDate.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -701,7 +701,7 @@ void shouldNotFailValidateCertificateOfService_When1v2LIP_BothDefendant_SameDate LocalDate def1pastDate = LocalDate.now().minusDays(1); LocalDate def2pastDate = LocalDate.now().minusDays(1); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(def1pastDate.plusDays(14).atTime(16, 0)); CaseData caseData = CaseDataBuilder.builder() @@ -720,7 +720,7 @@ void shouldPassValidateCertificateOfService_whenHasFile() { when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -740,7 +740,7 @@ void shouldFailValidateCertificateOfService_whenHasNoFile() { when(time.now()).thenReturn(LocalDateTime.now()); when(deadlinesCalculator.plusWorkingDays(LocalDate.now(), 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(any())) + when(deadlinesCalculator.plus14DaysDeadline(any())) .thenReturn(past.plusDays(14).atTime(16, 0)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -762,9 +762,9 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateIsPast_dead when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) + when(deadlinesCalculator.plus14DaysDeadline(currentDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) + when(deadlinesCalculator.plus14DaysDeadline(deemedServedDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); @@ -788,9 +788,9 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateNotInWorkin when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.now().plusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) // assuming 4 pm deadline + when(deadlinesCalculator.plus14DaysDeadline(deemedServedDate.atTime(16, 0))) // assuming 4 pm deadline .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) // assuming 4 pm deadline + when(deadlinesCalculator.plus14DaysDeadline(currentDate.atTime(16, 0))) // assuming 4 pm deadline .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(false); @@ -814,9 +814,9 @@ void shouldNotPassValidateCertificateOfService_1Lr1Lip_whenDeemedDateExceeds2Wor when(time.now()).thenReturn(LocalDate.now().atTime(16, 00)); when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.of(2023, 10, 16)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedServedDate.atTime(16, 0))) + when(deadlinesCalculator.plus14DaysDeadline(deemedServedDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(deemedServedDate, LocalTime.of(16, 0))); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(currentDate.atTime(16, 0))) + when(deadlinesCalculator.plus14DaysDeadline(currentDate.atTime(16, 0))) .thenReturn(LocalDateTime.of(currentDate, LocalTime.of(16, 0))); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(true); From 44440f969f16c16e26a7e8025adebdde319552a8 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Wed, 20 Dec 2023 15:53:39 +0000 Subject: [PATCH 17/18] Update NotifyClaimDetailsCallbackHandlerTest.java --- .../NotifyClaimDetailsCallbackHandlerTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index d9a83b8d486..498ce64f27f 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -214,6 +214,7 @@ void setup() { sixMonthDate = LocalDateTime.of(2020, 7, 1, 0, 0, 0); when(time.now()).thenReturn(localDateTime); when(deadlinesCalculator.plus14DaysDeadline(localDateTime)).thenReturn(newDate); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(localDateTime)).thenReturn(newDate); when(deadlinesCalculator.addMonthsToDateToNextWorkingDayAtMidnight(6, localDateTime.toLocalDate())) .thenReturn(sixMonthDate); when(workingDayIndicator.isWeekend(any(LocalDate.class))).thenReturn(true); @@ -265,6 +266,8 @@ void shouldUpdateCertificateOfService_and_documents_cos1_whenSubmitted() { LocalDate cosDate = localDateTime.minusDays(2).toLocalDate(); LocalDate deemedDate = localDateTime.minusDays(2).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) + .thenReturn(newDate.minusDays(2)); when(deadlinesCalculator.plus14DaysDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); when(deadlinesCalculator.plus14DaysDeadline(deemedDate.atTime(15, 05))) @@ -296,9 +299,9 @@ void shouldUpdateCertificateOfService_and_documents_cos2_whenSubmitted() { when(deadlinesCalculator.plusWorkingDays(currentDate, 2)) .thenReturn(LocalDate.now().plusDays(2)); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysDeadline(cosDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysDeadline(deemedDate.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemedDate.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); when(workingDayIndicator.isWorkingDay(any(LocalDate.class))).thenReturn(false); @@ -325,9 +328,9 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysDeadline(cos1Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysDeadline(cos2Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos2Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); CaseData caseData = CaseDataBuilder.builder() @@ -352,6 +355,10 @@ void shouldUpdate_to_earliest_day_cos1_is_earliest_whenSubmitted() { LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) + .thenReturn(newDate.minusDays(3)); + when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos2Date.atTime(15, 05))) + .thenReturn(newDate.minusDays(2)); when(deadlinesCalculator.plus14DaysDeadline(cos1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); when(deadlinesCalculator.plus14DaysDeadline(cos2Date.atTime(15, 05))) From 023c26c8fe1fe98af5a44ac31208e916c606ff69 Mon Sep 17 00:00:00 2001 From: MMNycz Date: Thu, 21 Dec 2023 13:20:45 +0000 Subject: [PATCH 18/18] CIV-10820 fix issue with incorrect deadline display on confimration screen --- .../NotifyClaimDetailsCallbackHandler.java | 25 +++++++++---------- ...NotifyClaimDetailsCallbackHandlerTest.java | 12 +++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java index 54ee89d1603..752eabdfa28 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandler.java @@ -221,31 +221,30 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) { private LocalDateTime getEarliestDateOfService(CaseData caseData) { LocalDateTime date = time.now(); + LocalDateTime deemedDate1 = null; + LocalDateTime deemedDate2 = null; if (Objects.nonNull(caseData.getCosNotifyClaimDetails1()) && Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) { - LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1() + deemedDate1 = caseData.getCosNotifyClaimDetails1() .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); - date = getEarliestDate(date, cosDate1); } if (Objects.nonNull(caseData.getCosNotifyClaimDetails2()) && Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) { - LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2() + deemedDate2 = caseData.getCosNotifyClaimDetails2() .getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime()); - date = getEarliestDate(date, cosDate2); } - return date; - } - - private LocalDateTime getEarliestDate(LocalDateTime date1, LocalDateTime date2) { - if (date1 == null) { - return date2; - } else if (date2 == null) { - return date1; + if (deemedDate1 != null && deemedDate2 != null) { + return deemedDate1.isBefore(deemedDate2) ? deemedDate1 : deemedDate2; + } else if (deemedDate1 != null) { + return deemedDate1; + } else if (deemedDate2 != null) { + return deemedDate2; } else { - return date1.isBefore(date2) ? date1 : date2; + // If both deemedDate1 and deemedDate2 are null, use the current date and time + return date; } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java index 498ce64f27f..e8969ee3e43 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/NotifyClaimDetailsCallbackHandlerTest.java @@ -224,7 +224,9 @@ void setup() { @Test void shouldUpdateBusinessProcess_whenInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimNotified_1v1().build(); + CaseData caseData = CaseDataBuilder.builder().atStateClaimNotified_1v1() + .setCoSClaimDetailsWithDate(true, false, localDateTime.toLocalDate(), localDateTime.toLocalDate(), null, null, true, false) + .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); @@ -328,9 +330,9 @@ void shouldUpdate_to_earliest_day_cos2_is_earliest_whenSubmitted() { LocalDate deemed1Date = localDateTime.minusDays(2).toLocalDate(); LocalDate deemed2Date = localDateTime.minusDays(3).toLocalDate(); when(time.now()).thenReturn(LocalDate.now().atTime(15, 05)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos1Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemed1Date.atTime(15, 05))) .thenReturn(newDate.minusDays(2)); - when(deadlinesCalculator.plus14DaysAt4pmDeadline(cos2Date.atTime(15, 05))) + when(deadlinesCalculator.plus14DaysAt4pmDeadline(deemed2Date.atTime(15, 05))) .thenReturn(newDate.minusDays(3)); CaseData caseData = CaseDataBuilder.builder() @@ -402,7 +404,8 @@ static Stream caseDataStream() { .other(documentList).build(); return Stream.of( - arguments(CaseDataBuilder.builder().atStateClaimDraft().build().toBuilder() + arguments(CaseDataBuilder.builder().atStateClaimDraft() + .build().toBuilder() .uploadParticularsOfClaim(YES) .servedDocumentFiles(documentToUpload) .build()) @@ -413,7 +416,6 @@ static Stream caseDataStream() { @MethodSource("caseDataStream") void shouldAssignCategoryIds_whenDocumentExist(CaseData caseData) { when(featureToggleService.isCaseFileViewEnabled()).thenReturn(true); - var response = (AboutToStartOrSubmitCallbackResponse) handler.handle( callbackParamsOf(caseData, ABOUT_TO_SUBMIT)); // When