From f85c09a2f1e6b43dbe52eb6496cc80b151a264ea Mon Sep 17 00:00:00 2001 From: Aqib Date: Tue, 10 Mar 2026 14:21:17 +0000 Subject: [PATCH 01/22] initial commit of Summary page changes --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 + .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index 67aa7ba0af..e3aaad6bc2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -70,6 +70,7 @@ public void configure(final ConfigBuilder builder) { builder.tab("summary", "Summary") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) + .field(PCSCase::getTestLabel) .field(PCSCase::getPropertyAddress); builder.tab("CaseHistory", "History") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java index d9a4598fcf..e6c585d64f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java @@ -501,4 +501,23 @@ public class PCSCase { @SuppressWarnings("MemberName") // Field name is case-sensitive in CCD private SearchCriteria searchCriteria; + @CCD(label = """ +

Confirm the eviction date

+

+ The bailiff has given you an eviction date of Thursday, 25 June 2025 at 10am. + They need you to confirm if you are available on this date. +

+

+ You must confirm the eviction details before 1 May 2025. If you try to confirm the eviction after this + date, the bailiff will cancel your eviction. + They will also ask you to confirm if the defendants + (the person or people being evicted) pose any risk to the bailiff. + The bailiff needs this information to carry out the eviction safely. +

+

+ To confirm the eviction date, select ‘Confirm the eviction date’ from the dropdown menu. +

+ """,typeOverride = FieldType.Label + ) + private String testLabel; } From 5e5a643c32810f28bef4aed06351cbebe4b3f76f Mon Sep 17 00:00:00 2001 From: Aqib Date: Thu, 12 Mar 2026 12:44:30 +0000 Subject: [PATCH 02/22] Added Summary tab markup. Also Changed confirm eviction details page config --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 3 +- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 30 +++++++++- .../hmcts/reform/pcs/ccd/event/EventId.java | 3 +- .../ConfirmEvictionDetails.java | 58 +++++++++++++++++++ .../ConfirmEvictionDetailsPage.java | 49 ++++++++++++++++ .../ConfirmEvictionDetailsPageConfigurer.java | 18 ++++++ .../EvictionDatePage.java | 15 +++++ 7 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index e3aaad6bc2..5e2dd19a61 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -70,7 +70,8 @@ public void configure(final ConfigBuilder builder) { builder.tab("summary", "Summary") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) - .field(PCSCase::getTestLabel) + .field(PCSCase::getConfirmEvictionSummaryMarkup) + .field(PCSCase::getCannotEnforceOrderSummaryMarkup) .field(PCSCase::getPropertyAddress); builder.tab("CaseHistory", "History") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java index e6c585d64f..f86e9c941f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java @@ -504,11 +504,11 @@ public class PCSCase { @CCD(label = """

Confirm the eviction date

- The bailiff has given you an eviction date of Thursday, 25 June 2025 at 10am. + The bailiff has given you an eviction date of [day of the week], [date] [month] [year]. They need you to confirm if you are available on this date.

- You must confirm the eviction details before 1 May 2025. If you try to confirm the eviction after this + You must confirm the eviction details before [placeholder]. If you try to confirm the eviction after this date, the bailiff will cancel your eviction. They will also ask you to confirm if the defendants (the person or people being evicted) pose any risk to the bailiff. @@ -519,5 +519,29 @@ public class PCSCase {

""",typeOverride = FieldType.Label ) - private String testLabel; + private String confirmEvictionSummaryMarkup; + + @CCD(label = """ +

You cannot enforce the order at the moment

+

+ You cannot enforce the order at the moment (use a bailiff to evict someone). +

+

How to find out why you cannot + enforce the order +

+

To find out why you cannot enforce the order, you can:

+
    +
  • check the tab: ‘Case file view’ (you should see an order from the court, + explaining why you cannot enforce), or
  • +
  • + + contact your local court. You will need to tell them your case number + (you can find this at the top of this page). If you do not know the name of your local court, select the + ‘Money’ category and then the ‘Housing’ category to find it.
  • +
+ """,typeOverride = FieldType.Label + ) + private String cannotEnforceOrderSummaryMarkup; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java index 3a84e15878..181661529d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java @@ -7,5 +7,6 @@ public enum EventId { enforceTheOrder, respondPossessionClaim, submitDefendantResponse, - createTestCase + createTestCase, + confirmEvictionDetails } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java new file mode 100644 index 0000000000..78faeb3cb3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java @@ -0,0 +1,58 @@ +package uk.gov.hmcts.reform.pcs.ccd.event.confirmevictiondetails; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.api.CCDConfig; +import uk.gov.hmcts.ccd.sdk.api.DecentralisedConfigBuilder; +import uk.gov.hmcts.ccd.sdk.api.Event; +import uk.gov.hmcts.ccd.sdk.api.EventPayload; +import uk.gov.hmcts.ccd.sdk.api.Permission; +import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; +import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.State; +import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilderFactory; +import uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails.ConfirmEvictionDetailsPageConfigurer; +import uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter; + +import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEvictionDetails; +import static uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter.BR_DELIMITER; + +@Slf4j +@Component +@AllArgsConstructor +public class ConfirmEvictionDetails implements CCDConfig { + + private final AddressFormatter addressFormatter; + private final SavingPageBuilderFactory savingPageBuilderFactory; + private final ConfirmEvictionDetailsPageConfigurer confirmEvictionDetailsPageConfigurer; + + @Override + public void configureDecentralised(DecentralisedConfigBuilder configBuilder) { + Event.EventBuilder eventBuilder = + configBuilder + .decentralisedEvent(confirmEvictionDetails.name(), this::submit, this::start) + .forAllStates() + .name("Confirm the eviction details") + .grant(Permission.CRUD, UserRole.PCS_SOLICITOR) + .showSummary(); + SavingPageBuilder pageBuilder = savingPageBuilderFactory.create(eventBuilder, confirmEvictionDetails); + confirmEvictionDetailsPageConfigurer.configurePages(pageBuilder); + } + + private PCSCase start(EventPayload eventPayload) { + PCSCase pcsCase = eventPayload.caseData(); +// pcsCase.setFormattedPropertyAddress(addressFormatter +// .formatMediumAddress(pcsCase.getPropertyAddress(), BR_DELIMITER)); + + return pcsCase; + } + + private SubmitResponse submit(EventPayload eventPayload) { + return SubmitResponse.defaultResponse(); + } + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java new file mode 100644 index 0000000000..42a3179f7d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java @@ -0,0 +1,49 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; + +import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; + +public class ConfirmEvictionDetailsPage implements CcdPageConfiguration { + + public static final String CONFIRM_EVICTION_DETAILS_CONTENT = """ +

+ The bailiff has arranged a date for the eviction and they need you to confirm if you are + available. +

+

+ They will also ask you to confirm if the person being evicted poses any risk. +

+

+ The bailiff needs this information to carry out the eviction safely. If you do not provide it, + they may not be able to complete the eviction. +

+

What you’ll need +

+

You’ll need to know:

+
    +
  • who will attend the eviction (you, or someone else)
  • +
  • if you (or they) can attend the eviction on the date suggested + by the bailiff
  • +
+

We will also ask you to:

+
    +
  • describe the person who will be evicted
  • +
  • tell us how to access the property
  • +
  • book a locksmith (this is to make sure that the person being + evicted cannot return to the property)
  • +
+

+ Once you have confirmed the eviction date, we’ll send you an email reminding you to book a + locksmith. +

+ """; + + @Override + public void addTo(PageBuilder pageBuilder) { + pageBuilder + .page("confirmEvictionDetails") + .pageLabel("Confirm the eviction details") + .label("confirmEvictionDetails-line-separator", "---") + .label("confirmEvictionDetails-content", CONFIRM_EVICTION_DETAILS_CONTENT); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java new file mode 100644 index 0000000000..57cbf9b154 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java @@ -0,0 +1,18 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; + +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.common.PageConfigurer; + +@Component +@AllArgsConstructor +public class ConfirmEvictionDetailsPageConfigurer implements PageConfigurer { + + @Override + public void configurePages(PageBuilder pageBuilder) { + pageBuilder + .add(new ConfirmEvictionDetailsPage()) + .add(new EvictionDatePage()); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java new file mode 100644 index 0000000000..c2591fc0b6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java @@ -0,0 +1,15 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; + +import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; + +public class EvictionDatePage implements CcdPageConfiguration { + + @Override + public void addTo(PageBuilder pageBuilder) { + pageBuilder + .page("evictionDate") + .pageLabel("The eviction date") + .label("evictionDate-line-separator", "---"); + } +} From 2051b40c7870e5479554335e1f92afbe3bcf9327 Mon Sep 17 00:00:00 2001 From: Aqib Date: Mon, 16 Mar 2026 10:09:02 +0000 Subject: [PATCH 03/22] I've added date formatters. Also have a current issue where i cannot retreive an enforcement --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 5 +- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 105 +++++++++++++++++- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 64 ++++------- .../EnforcementOrderEntity.java | 4 + .../ConfirmEvictionDetails.java | 1 + .../EnforcementOrderRepository.java | 4 +- .../V063__add_bailiff_date_enf_case.sql | 2 + 7 files changed, 140 insertions(+), 45 deletions(-) create mode 100644 src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index 5e2dd19a61..8556d245b8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -70,10 +70,11 @@ public void configure(final ConfigBuilder builder) { builder.tab("summary", "Summary") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) - .field(PCSCase::getConfirmEvictionSummaryMarkup) - .field(PCSCase::getCannotEnforceOrderSummaryMarkup) + .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") + .field("confirmEvictionSummaryMarkup", NEVER_SHOW) .field(PCSCase::getPropertyAddress); + builder.tab("CaseHistory", "History") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .field("caseHistory"); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index e3b21c67e7..98e4e8d7c2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -1,8 +1,10 @@ package uk.gov.hmcts.reform.pcs.ccd; import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.CaseView; import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; @@ -12,13 +14,16 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; import uk.gov.hmcts.reform.pcs.ccd.domain.State; +import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.EnforcementOrder; import uk.gov.hmcts.reform.pcs.ccd.entity.AddressEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.ClaimPartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; +import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; import uk.gov.hmcts.reform.pcs.ccd.service.CaseTitleService; import uk.gov.hmcts.reform.pcs.ccd.service.DraftCaseDataService; import uk.gov.hmcts.reform.pcs.ccd.util.ListValueUtils; @@ -35,7 +40,10 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -49,6 +57,7 @@ */ @Component @AllArgsConstructor +@Slf4j public class PCSCaseView implements CaseView { private final PcsCaseRepository pcsCaseRepository; @@ -66,6 +75,7 @@ public class PCSCaseView implements CaseView { private final RentArrearsView rentArrearsView; private final NoticeOfPossessionView noticeOfPossessionView; private final StatementOfTruthView statementOfTruthView; + private final EnforcementOrderRepository enforcementOrderRepository; /** @@ -77,14 +87,107 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); + setBaillifDate(1, pcsCase); return pcsCase; } + private void setBaillifDate(long caseReference, PCSCase pcsCase){ + if(caseReference > 0) { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); + pcsCase.setConfirmEvictionSummaryMarkup(String.format(""" +

Confirm the + eviction date

+

+ The bailiff has given you an eviction date of %s. + They need you to confirm if you are available on this date. +

+

+ You must confirm the eviction details before %s. + If you try to confirm the eviction after this + date, the bailiff will cancel your eviction. + They will also ask you to confirm if the defendants + (the person or people being evicted) pose any risk to the + bailiff. + The bailiff needs this information to carry out the eviction + safely. +

+

+ To confirm the eviction date, select ‘Confirm the eviction + date’ from the dropdown menu. +

+ """,formatDate("2025-06-25 10:00:00+00"), + minusGivenHoursFormatted("2025-05-04 10:00:00+00",72))); + } + else { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); + pcsCase.setConfirmEvictionSummaryMarkup(""" +

You cannot enforce the order at the moment

+

+ You cannot enforce the order at the moment (use a bailiff to evict someone). +

+

How to find out why you cannot + enforce the order +

+

To find out why you cannot enforce the order, you can:

+
    +
  • check the tab: ‘Case file view’ (you should see an order from the court, + explaining why you cannot enforce), or
  • +
  • + + contact your local court. You will need to tell them your case number + (you can find this at the top of this page). If you do not know the name of your local court, select the + ‘Money’ category and then the ‘Housing’ category to find it.
  • +
+ """); + } + + // EnforcementOrder order = getEnforcementOrder(caseReference); + // System.out.println(order); + + } + + private EnforcementOrder getEnforcementOrder(long caseReference) { + + PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) + .orElseThrow(() -> new CaseNotFoundException(caseReference)); + + ClaimEntity claimEntity = pcsCaseEntity.getClaims().getFirst(); + + EnforcementOrderEntity entity = enforcementOrderRepository + .findByClaimId(claimEntity.getId()) + .orElseThrow(() -> new RuntimeException("Enforcement order not found")); + + return entity.getEnforcementOrder(); + } + + private String formatDate(String input) { + DateTimeFormatter inputFormatter = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"); + + DateTimeFormatter outputFormatter = + DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + + OffsetDateTime dateTime = OffsetDateTime.parse(input, inputFormatter); + + return dateTime.format(outputFormatter); + } + + private String minusGivenHoursFormatted(String input, int hours) { + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"); + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + + OffsetDateTime dateTime = OffsetDateTime.parse(input, inputFormatter) + .minusHours(hours); + + return dateTime.format(outputFormatter); + } + private boolean caseHasUnsubmittedData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java index f86e9c941f..72eef6b117 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java @@ -501,47 +501,29 @@ public class PCSCase { @SuppressWarnings("MemberName") // Field name is case-sensitive in CCD private SearchCriteria searchCriteria; - @CCD(label = """ -

Confirm the eviction date

-

- The bailiff has given you an eviction date of [day of the week], [date] [month] [year]. - They need you to confirm if you are available on this date. -

-

- You must confirm the eviction details before [placeholder]. If you try to confirm the eviction after this - date, the bailiff will cancel your eviction. - They will also ask you to confirm if the defendants - (the person or people being evicted) pose any risk to the bailiff. - The bailiff needs this information to carry out the eviction safely. -

-

- To confirm the eviction date, select ‘Confirm the eviction date’ from the dropdown menu. -

- """,typeOverride = FieldType.Label - ) +// @CCD(label = """ +//

Confirm the eviction date

+//

+// The bailiff has given you an eviction date of ${[CASE_REFERENCE]}. +// They need you to confirm if you are available on this date. +//

+//

+// You must confirm the eviction details before [placeholder]. If you try to confirm the eviction after this +// date, the bailiff will cancel your eviction. +// They will also ask you to confirm if the defendants +// (the person or people being evicted) pose any risk to the bailiff. +// The bailiff needs this information to carry out the eviction safely. +//

+//

+// To confirm the eviction date, select ‘Confirm the eviction date’ from the dropdown menu. +//

+// """,typeOverride = FieldType.Label +// ) +// private String confirmEvictionSummaryMarkup; + + @CCD(searchable = false ) private String confirmEvictionSummaryMarkup; - @CCD(label = """ -

You cannot enforce the order at the moment

-

- You cannot enforce the order at the moment (use a bailiff to evict someone). -

-

How to find out why you cannot - enforce the order -

-

To find out why you cannot enforce the order, you can:

-
    -
  • check the tab: ‘Case file view’ (you should see an order from the court, - explaining why you cannot enforce), or
  • -
  • - - contact your local court. You will need to tell them your case number - (you can find this at the top of this page). If you do not know the name of your local court, select the - ‘Money’ category and then the ‘Housing’ category to find it.
  • -
- """,typeOverride = FieldType.Label - ) - private String cannotEnforceOrderSummaryMarkup; + @CCD(searchable = false ) + private YesOrNo showConfirmEvictionJourney; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java index 3a90601007..17c2e940d4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java @@ -10,7 +10,9 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.type.SqlTypes; @@ -25,6 +27,8 @@ @Table(name = "enf_case") @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor public class EnforcementOrderEntity { @Id diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java index 78faeb3cb3..7c6f24c282 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java @@ -35,6 +35,7 @@ public void configureDecentralised(DecentralisedConfigBuilder { - + Optional findByClaimId(UUID claimId); } diff --git a/src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql new file mode 100644 index 0000000000..c377a15e31 --- /dev/null +++ b/src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql @@ -0,0 +1,2 @@ +ALTER TABLE enf_case + ADD COLUMN bailiff_date timestamp with time zone; From 464d2124584ac1ec9e1ee55c385771565f4a61f4 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Mon, 16 Mar 2026 11:34:12 +0000 Subject: [PATCH 04/22] [#4312] Update flyway version numbering. --- ...liff_date_enf_case.sql => V064__add_bailiff_date_enf_case.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V063__add_bailiff_date_enf_case.sql => V064__add_bailiff_date_enf_case.sql} (100%) diff --git a/src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V064__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V063__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V064__add_bailiff_date_enf_case.sql From 102f9d6c6080deb92826c8cc1d79e57386290e91 Mon Sep 17 00:00:00 2001 From: Aqib Date: Mon, 16 Mar 2026 14:25:05 +0000 Subject: [PATCH 05/22] We can now toggle on the summary page --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 18 ++++++++---------- .../EnforcementOrderEntity.java | 4 ++++ .../ConfirmEvictionDetails.java | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index 98e4e8d7c2..5dbce2d209 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -4,7 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; +import org.springframework.transaction.annotation.Transactional; import uk.gov.hmcts.ccd.sdk.CaseView; import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; @@ -14,7 +14,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; import uk.gov.hmcts.reform.pcs.ccd.domain.State; -import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.EnforcementOrder; import uk.gov.hmcts.reform.pcs.ccd.entity.AddressEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; @@ -90,13 +89,15 @@ public PCSCase getCase(CaseViewRequest request) { boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); - setBaillifDate(1, pcsCase); + setBaillifDate(caseReference, pcsCase); return pcsCase; } private void setBaillifDate(long caseReference, PCSCase pcsCase){ - if(caseReference > 0) { + EnforcementOrderEntity enforcementOrder = getEnforcementOrder(caseReference); + + if(enforcementOrder.getBailiffDate() != null) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); pcsCase.setConfirmEvictionSummaryMarkup(String.format("""

Confirm the @@ -146,13 +147,10 @@ You cannot enforce the order at the moment (use a bailiff to evict someone). """); } - - // EnforcementOrder order = getEnforcementOrder(caseReference); - // System.out.println(order); - } - private EnforcementOrder getEnforcementOrder(long caseReference) { + @Transactional + private EnforcementOrderEntity getEnforcementOrder(long caseReference) { PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) .orElseThrow(() -> new CaseNotFoundException(caseReference)); @@ -163,7 +161,7 @@ private EnforcementOrder getEnforcementOrder(long caseReference) { .findByClaimId(claimEntity.getId()) .orElseThrow(() -> new RuntimeException("Enforcement order not found")); - return entity.getEnforcementOrder(); + return entity; } private String formatDate(String input) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java index 17c2e940d4..fcd9f814f5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java @@ -19,6 +19,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.EnforcementOrder; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import java.time.Instant; import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -47,4 +48,7 @@ public class EnforcementOrderEntity { @OneToOne(mappedBy = "enforcementOrder", fetch = LAZY) private WarrantEntity warrantDetails; + @Column(name = "bailiff_date") + private Instant bailiffDate; + } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java index 7c6f24c282..8ffe392770 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java @@ -35,7 +35,7 @@ public void configureDecentralised(DecentralisedConfigBuilder Date: Tue, 17 Mar 2026 13:25:13 +0000 Subject: [PATCH 06/22] Added logs to see if we get pcs case objective for show condition --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 3 ++- .../java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 2 ++ .../java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java | 2 +- .../confirmevictiondetails/ConfirmEvictionDetails.java | 8 ++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index 0a3481e341..9e00a892e8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -86,7 +86,8 @@ public void configure(final ConfigBuilder builder) { builder.tab("hidden", "HiddenFields") .showCondition(NEVER_SHOW) - .field(PCSCase::getCaseTitleMarkdown); + .field(PCSCase::getCaseTitleMarkdown) + .field(PCSCase::getShowConfirmEvictionJourney); builder.tab("serviceRequest", "Service Request") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index f11319fd4f..c0e017335e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -151,6 +151,8 @@ You cannot enforce the order at the moment (use a bailiff to evict someone). """); } + log.warn("---------------------------"); + log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); } @Transactional diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java index 8e97e736b7..ce72eade2f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java @@ -526,6 +526,6 @@ public class PCSCase { @CCD(searchable = false ) private String confirmEvictionSummaryMarkup; - @CCD(searchable = false ) + @CCD(searchable = false, access = {ClaimantAccess.class}) private YesOrNo showConfirmEvictionJourney; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java index 8ffe392770..e2661d444d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java @@ -9,6 +9,7 @@ import uk.gov.hmcts.ccd.sdk.api.EventPayload; import uk.gov.hmcts.ccd.sdk.api.Permission; import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; +import uk.gov.hmcts.reform.pcs.ccd.ShowConditions; import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.State; @@ -17,6 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails.ConfirmEvictionDetailsPageConfigurer; import uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter; +import static uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo.YES; import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEvictionDetails; import static uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter.BR_DELIMITER; @@ -35,7 +37,8 @@ public void configureDecentralised(DecentralisedConfigBuilder eventPayload) { PCSCase pcsCase = eventPayload.caseData(); // pcsCase.setFormattedPropertyAddress(addressFormatter // .formatMediumAddress(pcsCase.getPropertyAddress(), BR_DELIMITER)); - + log.warn("---------------------------"); + log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); return pcsCase; } From 3d564079f6cb808ca4a33feb90a02662bc33b4da Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 20 Mar 2026 09:31:22 +0000 Subject: [PATCH 07/22] Refactor confirm eviction event and related logic: rename the event to `ConfirmEviction`, reorganise page configuration classes, update the event ID and imports, and adjust `PCSCaseView` to handle optional enforcement orders and bailiff dates with new date formatting helpers. Adjust repository import and update the test suite accordingly. --- build.gradle | 6 + .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 2 - .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 156 ++++++++++-------- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 22 +-- .../hmcts/reform/pcs/ccd/event/EventId.java | 2 +- .../ConfirmEviction.java} | 28 +--- ...er.java => ConfirmEvictionConfigurer.java} | 2 +- .../EnforcementOrderRepository.java | 1 - ...Create-Enforcement-Warrant-Basic-Case.json | 2 +- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 6 +- 10 files changed, 113 insertions(+), 114 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/{confirmevictiondetails/ConfirmEvictionDetails.java => confirmeviction/ConfirmEviction.java} (60%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/{ConfirmEvictionDetailsPageConfigurer.java => ConfirmEvictionConfigurer.java} (86%) diff --git a/build.gradle b/build.gradle index 60343fff68..b5f6daec13 100644 --- a/build.gradle +++ b/build.gradle @@ -299,6 +299,12 @@ jacocoTestReport { } } +configurations.cftlibTestRuntimeClasspath { + resolutionStrategy { + force 'org.junit.platform:junit-platform-console-standalone:1.12.2' + } +} + tasks.named('sonarqube') { dependsOn jacocoTestReport } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index 9e00a892e8..df0f98fc6a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -74,7 +74,6 @@ public void configure(final ConfigBuilder builder) { .field("nextStepsMarkdown", NEVER_SHOW); builder.tab("summary", "Summary") - .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") .field("confirmEvictionSummaryMarkup", NEVER_SHOW) .field(PCSCase::getPropertyAddress); @@ -85,7 +84,6 @@ public void configure(final ConfigBuilder builder) { .field("caseHistory"); builder.tab("hidden", "HiddenFields") - .showCondition(NEVER_SHOW) .field(PCSCase::getCaseTitleMarkdown) .field(PCSCase::getShowConfirmEvictionJourney); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index c0e017335e..4950cc177a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -4,7 +4,6 @@ import lombok.extern.slf4j.Slf4j; import org.modelmapper.ModelMapper; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import uk.gov.hmcts.ccd.sdk.CaseView; import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; @@ -40,6 +39,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.time.Instant; import java.time.OffsetDateTime; import java.time.format.DateTimeFormatter; import java.util.List; @@ -90,7 +90,7 @@ public PCSCase getCase(CaseViewRequest request) { boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); - setBaillifDate(caseReference, pcsCase); + handleEnforcementRequirements(caseReference, pcsCase); //allows indexing for Global Search pcsCase.setSearchCriteria(new SearchCriteria()); @@ -98,76 +98,30 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private void setBaillifDate(long caseReference, PCSCase pcsCase){ - EnforcementOrderEntity enforcementOrder = getEnforcementOrder(caseReference); - - if(enforcementOrder.getBailiffDate() != null) { - pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); - pcsCase.setConfirmEvictionSummaryMarkup(String.format(""" -

Confirm the - eviction date

-

- The bailiff has given you an eviction date of %s. - They need you to confirm if you are available on this date. -

-

- You must confirm the eviction details before %s. - If you try to confirm the eviction after this - date, the bailiff will cancel your eviction. - They will also ask you to confirm if the defendants - (the person or people being evicted) pose any risk to the - bailiff. - The bailiff needs this information to carry out the eviction - safely. -

-

- To confirm the eviction date, select ‘Confirm the eviction - date’ from the dropdown menu. -

- """,formatDate("2025-06-25 10:00:00+00"), - minusGivenHoursFormatted("2025-05-04 10:00:00+00",72))); + private void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { + if (caseReference > 0 && pcsCase != null) { + Optional optionalEnforcementOrder = getEnforcementOrder(caseReference); + if (optionalEnforcementOrder.isPresent()) { + EnforcementOrderEntity enforcementOrderEntity = optionalEnforcementOrder.get(); + if (enforcementOrderEntity.getBailiffDate() != null) { + hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); + } else { + noBailiffDate(pcsCase); + } + } + log.warn("---------------------------"); + log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); } - else { - pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); - pcsCase.setConfirmEvictionSummaryMarkup(""" -

You cannot enforce the order at the moment

-

- You cannot enforce the order at the moment (use a bailiff to evict someone). -

-

How to find out why you cannot - enforce the order -

-

To find out why you cannot enforce the order, you can:

-
    -
  • check the tab: ‘Case file view’ (you should see an order from the court, - explaining why you cannot enforce), or
  • -
  • - - contact your local court. You will need to tell them your case number - (you can find this at the top of this page). If you do not know the name of your local court, select the - ‘Money’ category and then the ‘Housing’ category to find it.
  • -
- """); - } - log.warn("---------------------------"); - log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); } - @Transactional - private EnforcementOrderEntity getEnforcementOrder(long caseReference) { - + private Optional getEnforcementOrder(long caseReference) { PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) .orElseThrow(() -> new CaseNotFoundException(caseReference)); - - ClaimEntity claimEntity = pcsCaseEntity.getClaims().getFirst(); - - EnforcementOrderEntity entity = enforcementOrderRepository - .findByClaimId(claimEntity.getId()) - .orElseThrow(() -> new RuntimeException("Enforcement order not found")); - - return entity; + List claims = pcsCaseEntity.getClaims(); + if (claims != null && !claims.isEmpty()) { + return enforcementOrderRepository.findByClaimId(claims.getFirst().getId()); + } + return Optional.empty(); } private String formatDate(String input) { @@ -182,6 +136,13 @@ private String formatDate(String input) { return dateTime.format(outputFormatter); } + private String formatDate(Instant instant) { + DateTimeFormatter outputFormatter = + DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + return instant.atZone(java.time.ZoneId.of("UTC")) + .format(outputFormatter); + } + private String minusGivenHoursFormatted(String input, int hours) { DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"); DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); @@ -192,6 +153,14 @@ private String minusGivenHoursFormatted(String input, int hours) { return dateTime.format(outputFormatter); } + private String minusGivenHoursFormatted(Instant instant, int hours) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + + return instant.atZone(java.time.ZoneId.of("UTC")) + .minusHours(hours) + .format(outputFormatter); + } + private boolean caseHasUnsubmittedData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); @@ -353,4 +322,57 @@ private List> mapAndWrapDocuments(PcsCaseEntity pcsCaseEntit .collect(Collectors.toList()); } + private void hasBailiffDate(PCSCase pcsCase, Instant instant) { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); + pcsCase.setConfirmEvictionSummaryMarkup(String.format( + """ +

Confirm the eviction date

+

+ The bailiff has given you an eviction date of %s. + They need you to confirm if you are available on this date. +

+

+ You must confirm the eviction details before %s. + If you try to confirm the eviction after this + date, the bailiff will cancel your eviction. + They will also ask you to confirm if the defendants + (the person or people being evicted) pose any risk to the + bailiff. + The bailiff needs this information to carry out the eviction + safely. +

+

+ To confirm the eviction date, select ‘Confirm the eviction + date’ from the dropdown menu. +

+ """, + formatDate(instant), + minusGivenHoursFormatted("2025-05-04 10:00:00+00",72))); + } + + private static void noBailiffDate(PCSCase pcsCase) { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); + pcsCase.setConfirmEvictionSummaryMarkup(""" +

You cannot enforce the order at the moment

+

+ You cannot enforce the order at the moment (use a bailiff to evict someone). +

+

How to find out why you cannot + enforce the order +

+

To find out why you cannot enforce the order, you can:

+
    +
  • check the tab: ‘Case file view’ (you should see an order from the court, + explaining why you cannot enforce), or
  • +
  • + + contact your local court. You will need to tell them your case number + (you can find this at the top of this page). If you do not know the name of your local court, select the + ‘Money’ category and then the ‘Housing’ category to find it.
  • +
+ """); + } + } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java index ce72eade2f..30cfab9dbd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java @@ -503,27 +503,7 @@ public class PCSCase { @JsonProperty("SearchCriteria") private SearchCriteria searchCriteria; -// @CCD(label = """ -//

Confirm the eviction date

-//

-// The bailiff has given you an eviction date of ${[CASE_REFERENCE]}. -// They need you to confirm if you are available on this date. -//

-//

-// You must confirm the eviction details before [placeholder]. If you try to confirm the eviction after this -// date, the bailiff will cancel your eviction. -// They will also ask you to confirm if the defendants -// (the person or people being evicted) pose any risk to the bailiff. -// The bailiff needs this information to carry out the eviction safely. -//

-//

-// To confirm the eviction date, select ‘Confirm the eviction date’ from the dropdown menu. -//

-// """,typeOverride = FieldType.Label -// ) -// private String confirmEvictionSummaryMarkup; - - @CCD(searchable = false ) + @CCD(searchable = false) private String confirmEvictionSummaryMarkup; @CCD(searchable = false, access = {ClaimantAccess.class}) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java index 181661529d..8e48fabc23 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/EventId.java @@ -8,5 +8,5 @@ public enum EventId { respondPossessionClaim, submitDefendantResponse, createTestCase, - confirmEvictionDetails + confirmEviction } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java similarity index 60% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java index e2661d444d..63cfe768b5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmevictiondetails/ConfirmEvictionDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.event.confirmevictiondetails; +package uk.gov.hmcts.reform.pcs.ccd.event.confirmeviction; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -9,55 +9,45 @@ import uk.gov.hmcts.ccd.sdk.api.EventPayload; import uk.gov.hmcts.ccd.sdk.api.Permission; import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; -import uk.gov.hmcts.reform.pcs.ccd.ShowConditions; import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.State; import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilder; import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilderFactory; -import uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails.ConfirmEvictionDetailsPageConfigurer; -import uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter; +import uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails.ConfirmEvictionConfigurer; -import static uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo.YES; -import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEvictionDetails; -import static uk.gov.hmcts.reform.pcs.ccd.util.AddressFormatter.BR_DELIMITER; +import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEviction; @Slf4j @Component @AllArgsConstructor -public class ConfirmEvictionDetails implements CCDConfig { +public class ConfirmEviction implements CCDConfig { - private final AddressFormatter addressFormatter; private final SavingPageBuilderFactory savingPageBuilderFactory; - private final ConfirmEvictionDetailsPageConfigurer confirmEvictionDetailsPageConfigurer; + private final ConfirmEvictionConfigurer confirmEvictionConfigurer; @Override public void configureDecentralised(DecentralisedConfigBuilder configBuilder) { Event.EventBuilder eventBuilder = configBuilder - .decentralisedEvent(confirmEvictionDetails.name(), this::submit, this::start) + .decentralisedEvent(confirmEviction.name(), this::submit, this::start) .forAllStates() -// .showCondition(ShowConditions.fieldEquals("showConfirmEvictionJourney", YES)) - .showCondition("showConfirmEvictionJourney=\"YES\"") .name("Confirm the eviction details") .grant(Permission.CRUD, UserRole.PCS_SOLICITOR) .showSummary(); - SavingPageBuilder pageBuilder = savingPageBuilderFactory.create(eventBuilder, confirmEvictionDetails); - confirmEvictionDetailsPageConfigurer.configurePages(pageBuilder); + SavingPageBuilder pageBuilder = savingPageBuilderFactory.create(eventBuilder, confirmEviction); + confirmEvictionConfigurer.configurePages(pageBuilder); } private PCSCase start(EventPayload eventPayload) { PCSCase pcsCase = eventPayload.caseData(); -// pcsCase.setFormattedPropertyAddress(addressFormatter -// .formatMediumAddress(pcsCase.getPropertyAddress(), BR_DELIMITER)); log.warn("---------------------------"); log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); return pcsCase; } private SubmitResponse submit(EventPayload eventPayload) { - return SubmitResponse.defaultResponse(); + return SubmitResponse.defaultResponse(); } - } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java similarity index 86% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java index 57cbf9b154..bd0fab6488 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPageConfigurer.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java @@ -7,7 +7,7 @@ @Component @AllArgsConstructor -public class ConfirmEvictionDetailsPageConfigurer implements PageConfigurer { +public class ConfirmEvictionConfigurer implements PageConfigurer { @Override public void configurePages(PageBuilder pageBuilder) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java index 8f4e0b963a..11e43d1ee4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java @@ -1,7 +1,6 @@ package uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder; import org.springframework.data.jpa.repository.JpaRepository; -import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import java.util.Optional; diff --git a/src/main/resources/test-case-generation/Create-Enforcement-Warrant-Basic-Case.json b/src/main/resources/test-case-generation/Create-Enforcement-Warrant-Basic-Case.json index 0b21e07c3a..2f89989562 100644 --- a/src/main/resources/test-case-generation/Create-Enforcement-Warrant-Basic-Case.json +++ b/src/main/resources/test-case-generation/Create-Enforcement-Warrant-Basic-Case.json @@ -1 +1 @@ -{"writFeeAmount": "£999999.99", "warrantFeeAmount": "£999999.99", "warrantAmountOwed": "123300", "selectedDefendants": {"value": [{"code": "feb27cee-c4be-4a89-820e-d7bbce32f3a9", "label": "Test1 Testing1"}], "list_items": [{"code": "9abf3261-70f6-4a6a-a47b-d6c6ededf472", "label": "TVR HN"}, {"code": "feb27cee-c4be-4a89-820e-d7bbce32f3a9", "label": "Test1 Testing1"}]}, "warrantCompletedBy": "CLAIMANT", "warrantCertification": ["CERTIFY"], "warrantEvictEveryone": "NO", "selectEnforcementType": "WARRANT", "warrantRepaymentChoice": "ALL", "vulnerablePeoplePresent": "NO", "warrantAnyRiskToBailiff": "YES", "warrantFullNameClaimant": "fsfdsdf", "warrantIsSuspendedOrder": "YES", "warrantPositionClaimant": "sdfasfasdfaasdfasfdasdfsadf", "warrantAgreementClaimant": ["BELIEVE_TRUE"], "warrantDefendantsDOBKnown": "NO", "warrantCorrectNameAndAddress": "YES", "warrantEnforcementLanguageUsed": "ENGLISH", "warrantAreLegalCostsToBeClaimed": "NO", "warrantRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Total amount that can be repaid
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£0
Land Registry fees£0
\n Warrant of possession fee\n £999999.99
Total£1,001,232.99
", "warrantEnforcementRiskCategories": ["VERBAL_OR_WRITTEN_THREATS"], "warrantAdditionalInformationSelect": "NO", "warrantIsDifficultToAccessProperty": "NO", "warrantHaveLandRegistryFeesBeenPaid": "NO", "warrantShowPeopleYouWantToEvictPage": "Yes", "warrantShowPeopleWhoWillBeEvictedPage": "Yes", "warrantEnforcementVerbalOrWrittenThreatsDetails": "sxdfgsdefg", "warrantStatementOfTruthRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
The payments due
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£0
Land Registry fees£0
\n Warrant of possession fee\n £999999.99
Total£1,001,232.99
"} +{"parties": [{"value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}, {"value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}, {"value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}], "allClaimants": [{"id": "99816c04-7aa5-4e0b-b509-5fda878403c2", "value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}], "allDocuments": [], "claimantType": {"value": {"code": "PROVIDER_OF_SOCIAL_HOUSING", "label": "Registered provider of social housing"}, "valueCode": "PROVIDER_OF_SOCIAL_HOUSING"}, "languageUsed": "ENGLISH", "noticeServed": "No", "userPcqIdSet": "No", "allDefendants": [{"id": "7abd474a-6e4e-48e4-b2bc-a1a3afb14bb4", "value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}, {"id": "758e4317-31ee-4e3b-b3e6-928cc48b0a73", "value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}], "writFeeAmount": "£999999.99", "SearchCriteria": {}, "propertyAddress": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "statementOfTruth": {"completedBy": "CLAIMANT", "fullNameClaimant": "wert", "positionClaimant": "ewrt", "agreementClaimant": ["BELIEVE_TRUE"]}, "warrantFeeAmount": "£999999.99", "warrantAmountOwed": "123300", "legislativeCountry": "England", "mediationAttempted": "NO", "selectedDefendants": {"value": [{"code": "7abd474a-6e4e-48e4-b2bc-a1a3afb14bb4", "label": "TVR HN"}], "list_items": [{"code": "7abd474a-6e4e-48e4-b2bc-a1a3afb14bb4", "label": "TVR HN"}, {"code": "758e4317-31ee-4e3b-b3e6-928cc48b0a73", "label": "Test1 Testing1"}]}, "warrantCompletedBy": "CLAIMANT", "addAnotherDefendant": "YES", "claimingCostsWanted": "NO", "settlementAttempted": "NO", "applicationWithClaim": "NO", "claimGroundSummaries": [{"id": "1483147f-6c07-4d40-811a-5c09fa8e5ee8", "value": {"code": "NUISANCE_OR_IMMORAL_USE", "label": "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", "reason": "sfgsdfgsdfg", "category": "SECURE_OR_FLEXIBLE_DISCRETIONARY", "isRentArrears": "No"}}], "warrantCertification": ["CERTIFY"], "warrantEvictEveryone": "NO", "chooseEnforcementType": {"value": {"code": "WARRANT", "label": "Warrant of possession"}, "valueCode": "WARRANT", "list_items": [{"code": "WARRANT", "label": "Warrant of possession"}, {"code": "WRIT", "label": "Writ of possession"}]}, "wantToUploadDocuments": "NO", "suspensionOfRTB_Reason": "asdfasdf", "warrantRepaymentChoice": "ALL", "claimAgainstTrespassers": "NO", "formattedDefendantNames": "TVR HN
\nTest1 Testing1
", "vulnerablePeoplePresent": "NO", "warrantAnyRiskToBailiff": "NO", "warrantFullNameClaimant": "fgsdfg", "warrantIsSuspendedOrder": "NO", "warrantPositionClaimant": "sdfgsdfgsdfg", "formattedPropertyAddress": "1 Rse Way
London
SW11 1PD", "warrantAgreementClaimant": ["BELIEVE_TRUE"], "hasUnderlesseeOrMortgagee": "NO", "warrantDefendantsDOBKnown": "NO", "preActionProtocolCompleted": "NO", "suspensionOfRTB_HousingAct": "SECTION_6A_2", "claimantCircumstancesSelect": "NO", "tenancy_TypeOfTenancyLicence": "SECURE_TENANCY", "warrantCorrectNameAndAddress": "YES", "warrantOfRestitutionInfoText": "", "hasDefendantCircumstancesInfo": "NO", "additionalReasonsForPossession": {"hasReasons": "NO"}, "warrantEnforcementLanguageUsed": "ENGLISH", "warrantAreLegalCostsToBeClaimed": "NO", "warrantRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Total amount that can be repaid
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£0
Land Registry fees£0
Warrant of possession fee£999999.99
Total£1,001,232.99
", "warrantShowChangeNameAddressPage": "No", "warrantAdditionalInformationSelect": "NO", "warrantIsDifficultToAccessProperty": "NO", "warrantHaveLandRegistryFeesBeenPaid": "NO", "warrantShowPeopleYouWantToEvictPage": "Yes", "warrantShowPeopleWhoWillBeEvictedPage": "Yes", "warrantStatementOfTruthRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
The payments due
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£0
Land Registry fees£0
Warrant of possession fee£999999.99
Total£1,001,232.99
"} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java index 2565b0b6f3..5808118b1a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java @@ -22,6 +22,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; +import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; import uk.gov.hmcts.reform.pcs.ccd.service.CaseTitleService; import uk.gov.hmcts.reform.pcs.ccd.service.DraftCaseDataService; import uk.gov.hmcts.reform.pcs.ccd.view.AlternativesToPossessionView; @@ -92,6 +93,8 @@ class PCSCaseViewTest { private PcsCaseEntity pcsCaseEntity; @Mock private ClaimEntity claimEntity; + @Mock + private EnforcementOrderRepository enforcementOrderRepository; private PCSCaseView underTest; @@ -103,7 +106,8 @@ void setUp() { underTest = new PCSCaseView(pcsCaseRepository, securityContextService, modelMapper, draftCaseDataService, caseTitleService, claimView, tenancyLicenceView, claimGroundsView, rentDetailsView, alternativesToPossessionView, housingActWalesView, asbProhibitedConductView, - rentArrearsView, noticeOfPossessionView, statementOfTruthView + rentArrearsView, noticeOfPossessionView, statementOfTruthView, + enforcementOrderRepository ); } From 5eb187a81d39981e712c4e2f6efe4f56fc3602df Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 20 Mar 2026 09:32:48 +0000 Subject: [PATCH 08/22] Reverting local change --- build.gradle | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.gradle b/build.gradle index b5f6daec13..60343fff68 100644 --- a/build.gradle +++ b/build.gradle @@ -299,12 +299,6 @@ jacocoTestReport { } } -configurations.cftlibTestRuntimeClasspath { - resolutionStrategy { - force 'org.junit.platform:junit-platform-console-standalone:1.12.2' - } -} - tasks.named('sonarqube') { dependsOn jacocoTestReport } From 1d105e2c78ee4aceb87743fe5d9ca012be01d118 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 20 Mar 2026 16:35:38 +0000 Subject: [PATCH 09/22] =?UTF-8?q?Move=20enforcement=E2=80=91order=20handli?= =?UTF-8?q?ng=20into=20a=20dedicated=20mediator,=20removing=20the=20old=20?= =?UTF-8?q?`EvictionDatePage`=20and=20`EnforcementOrderRepository`=20from?= =?UTF-8?q?=20`PCSCaseView`.=20Update=20page=20configuration=20tests,=20he?= =?UTF-8?q?lper=20imports,=20and=20add=20comprehensive=20tests=20for=20the?= =?UTF-8?q?=20new=20`EnforcementOrderMediator`.=20This=20refactor=20centra?= =?UTF-8?q?lises=20date=20formatting,=20bailiff=E2=80=91date=20checks,=20a?= =?UTF-8?q?nd=20UI=20markup=20generation.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pcs/ccd/EnforcementOrderMediator.java | 119 +++++++ .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 127 +------ .../confirmeviction/ConfirmEviction.java | 9 +- .../EvictionDatePage.java | 15 - .../ConfirmEvictionConfigurer.java | 2 +- .../ConfirmEvictionDetailsPage.java | 17 +- .../confirmeviction/EvictionDatePage.java | 23 ++ ...ql => V070__add_bailiff_date_enf_case.sql} | 0 .../Create-Enforcement-Writ-Basic-Case.json | 2 +- .../pcs/ccd/EnforcementOrderMediatorTest.java | 326 ++++++++++++++++++ .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 14 +- .../enforcetheorder/PageConfigurerHelper.java | 6 +- .../ConfirmEvictionPageConfigurerTest.java | 55 +++ 13 files changed, 556 insertions(+), 159 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/{confirmevictiondetails => enforcetheorder/confirmeviction}/ConfirmEvictionConfigurer.java (86%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/{confirmevictiondetails => enforcetheorder/confirmeviction}/ConfirmEvictionDetailsPage.java (84%) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/EvictionDatePage.java rename src/main/resources/db/migration/{V064__add_bailiff_date_enf_case.sql => V070__add_bailiff_date_enf_case.sql} (100%) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionPageConfigurerTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java new file mode 100644 index 0000000000..f0c3479b9a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -0,0 +1,119 @@ +package uk.gov.hmcts.reform.pcs.ccd; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; +import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; +import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; +import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Locale; +import java.util.Optional; + +@Component +@Slf4j +@AllArgsConstructor +public class EnforcementOrderMediator { + + private final PcsCaseRepository pcsCaseRepository; + private final EnforcementOrderRepository enforcementOrderRepository; + + public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { + if (caseReference > 0 && pcsCase != null) { + Optional optionalEnforcementOrder = getEnforcementOrder(caseReference); + if (optionalEnforcementOrder.isPresent()) { + EnforcementOrderEntity enforcementOrderEntity = optionalEnforcementOrder.get(); + if (enforcementOrderEntity.getBailiffDate() != null) { + hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); + } else { + noBailiffDate(pcsCase); + } + } + log.warn("---------------------------"); + log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); + } + } + + Optional getEnforcementOrder(long caseReference) { + PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) + .orElseThrow(() -> new CaseNotFoundException(caseReference)); + List claims = pcsCaseEntity.getClaims(); + if (claims != null && !claims.isEmpty()) { + return enforcementOrderRepository.findByClaimId(claims.getFirst().getId()); + } + return Optional.empty(); + } + + private void hasBailiffDate(PCSCase pcsCase, Instant instant) { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); + pcsCase.setConfirmEvictionSummaryMarkup(String.format( + """ +

Confirm the eviction date

+

+ The bailiff has given you an eviction date of %s. + They need you to confirm if you are available on this date. +

+

+ You must confirm the eviction details before %s. + If you try to confirm the eviction after this + date, the bailiff will cancel your eviction. + They will also ask you to confirm if the defendants + (the person or people being evicted) pose any risk to the + bailiff. + The bailiff needs this information to carry out the eviction + safely. +

+

+ To confirm the eviction date, select ‘Confirm the eviction + date’ from the dropdown menu. +

+ """, + formatDate(instant), + minus72HoursFormatted(instant))); + } + + private static void noBailiffDate(PCSCase pcsCase) { + pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); + pcsCase.setConfirmEvictionSummaryMarkup(""" +

You cannot enforce the order at the moment

+

+ You cannot enforce the order at the moment (use a bailiff to evict someone). +

+

How to find out why you cannot + enforce the order +

+

To find out why you cannot enforce the order, you can:

+
    +
  • check the tab: ‘Case file view’ (you should see an order from the court, + explaining why you cannot enforce), or
  • +
  • + + contact your local court. You will need to tell them your case number + (you can find this at the top of this page). If you do not know the name of your local court, select the + ‘Money’ category and then the ‘Housing’ category to find it.
  • +
+ """); + } + + private String formatDate(Instant instant) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + return instant.atZone(ZoneId.of("UTC")).format(outputFormatter); + } + + private String minus72HoursFormatted(Instant instant) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + return instant.atZone(ZoneId.of("UTC")).minusHours(72).format(outputFormatter); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index 4950cc177a..b47f1b9a69 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -17,12 +17,10 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.AddressEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; -import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.ClaimPartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; -import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; import uk.gov.hmcts.reform.pcs.ccd.service.CaseTitleService; import uk.gov.hmcts.reform.pcs.ccd.service.DraftCaseDataService; import uk.gov.hmcts.reform.pcs.ccd.util.ListValueUtils; @@ -39,11 +37,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; -import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -75,8 +69,7 @@ public class PCSCaseView implements CaseView { private final RentArrearsView rentArrearsView; private final NoticeOfPossessionView noticeOfPossessionView; private final StatementOfTruthView statementOfTruthView; - private final EnforcementOrderRepository enforcementOrderRepository; - + private final EnforcementOrderMediator enforcementOrderMediator; /** * Invoked by CCD to load PCS cases by reference. @@ -90,7 +83,7 @@ public PCSCase getCase(CaseViewRequest request) { boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); - handleEnforcementRequirements(caseReference, pcsCase); + enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); //allows indexing for Global Search pcsCase.setSearchCriteria(new SearchCriteria()); @@ -98,69 +91,6 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { - if (caseReference > 0 && pcsCase != null) { - Optional optionalEnforcementOrder = getEnforcementOrder(caseReference); - if (optionalEnforcementOrder.isPresent()) { - EnforcementOrderEntity enforcementOrderEntity = optionalEnforcementOrder.get(); - if (enforcementOrderEntity.getBailiffDate() != null) { - hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); - } else { - noBailiffDate(pcsCase); - } - } - log.warn("---------------------------"); - log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); - } - } - - private Optional getEnforcementOrder(long caseReference) { - PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) - .orElseThrow(() -> new CaseNotFoundException(caseReference)); - List claims = pcsCaseEntity.getClaims(); - if (claims != null && !claims.isEmpty()) { - return enforcementOrderRepository.findByClaimId(claims.getFirst().getId()); - } - return Optional.empty(); - } - - private String formatDate(String input) { - DateTimeFormatter inputFormatter = - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"); - - DateTimeFormatter outputFormatter = - DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); - - OffsetDateTime dateTime = OffsetDateTime.parse(input, inputFormatter); - - return dateTime.format(outputFormatter); - } - - private String formatDate(Instant instant) { - DateTimeFormatter outputFormatter = - DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); - return instant.atZone(java.time.ZoneId.of("UTC")) - .format(outputFormatter); - } - - private String minusGivenHoursFormatted(String input, int hours) { - DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssX"); - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); - - OffsetDateTime dateTime = OffsetDateTime.parse(input, inputFormatter) - .minusHours(hours); - - return dateTime.format(outputFormatter); - } - - private String minusGivenHoursFormatted(Instant instant, int hours) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); - - return instant.atZone(java.time.ZoneId.of("UTC")) - .minusHours(hours) - .format(outputFormatter); - } - private boolean caseHasUnsubmittedData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); @@ -322,57 +252,4 @@ private List> mapAndWrapDocuments(PcsCaseEntity pcsCaseEntit .collect(Collectors.toList()); } - private void hasBailiffDate(PCSCase pcsCase, Instant instant) { - pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); - pcsCase.setConfirmEvictionSummaryMarkup(String.format( - """ -

Confirm the eviction date

-

- The bailiff has given you an eviction date of %s. - They need you to confirm if you are available on this date. -

-

- You must confirm the eviction details before %s. - If you try to confirm the eviction after this - date, the bailiff will cancel your eviction. - They will also ask you to confirm if the defendants - (the person or people being evicted) pose any risk to the - bailiff. - The bailiff needs this information to carry out the eviction - safely. -

-

- To confirm the eviction date, select ‘Confirm the eviction - date’ from the dropdown menu. -

- """, - formatDate(instant), - minusGivenHoursFormatted("2025-05-04 10:00:00+00",72))); - } - - private static void noBailiffDate(PCSCase pcsCase) { - pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); - pcsCase.setConfirmEvictionSummaryMarkup(""" -

You cannot enforce the order at the moment

-

- You cannot enforce the order at the moment (use a bailiff to evict someone). -

-

How to find out why you cannot - enforce the order -

-

To find out why you cannot enforce the order, you can:

-
    -
  • check the tab: ‘Case file view’ (you should see an order from the court, - explaining why you cannot enforce), or
  • -
  • - - contact your local court. You will need to tell them your case number - (you can find this at the top of this page). If you do not know the name of your local court, select the - ‘Money’ category and then the ‘Housing’ category to find it.
  • -
- """); - } - } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java index 63cfe768b5..fad1be0e82 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java @@ -10,11 +10,10 @@ import uk.gov.hmcts.ccd.sdk.api.Permission; import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.State; -import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilder; -import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilderFactory; -import uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails.ConfirmEvictionConfigurer; +import uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.ConfirmEvictionConfigurer; import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEviction; @@ -23,7 +22,6 @@ @AllArgsConstructor public class ConfirmEviction implements CCDConfig { - private final SavingPageBuilderFactory savingPageBuilderFactory; private final ConfirmEvictionConfigurer confirmEvictionConfigurer; @Override @@ -35,8 +33,7 @@ public void configureDecentralised(DecentralisedConfigBuilder eventPayload) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java deleted file mode 100644 index c2591fc0b6..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/EvictionDatePage.java +++ /dev/null @@ -1,15 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; - -import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; -import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; - -public class EvictionDatePage implements CcdPageConfiguration { - - @Override - public void addTo(PageBuilder pageBuilder) { - pageBuilder - .page("evictionDate") - .pageLabel("The eviction date") - .label("evictionDate-line-separator", "---"); - } -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionConfigurer.java similarity index 86% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionConfigurer.java index bd0fab6488..393290c726 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionConfigurer.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionConfigurer.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; +package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionDetailsPage.java similarity index 84% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionDetailsPage.java index 42a3179f7d..252ac449c1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/confirmevictiondetails/ConfirmEvictionDetailsPage.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionDetailsPage.java @@ -1,9 +1,10 @@ -package uk.gov.hmcts.reform.pcs.ccd.page.confirmevictiondetails; +package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.page.CcdPage; -public class ConfirmEvictionDetailsPage implements CcdPageConfiguration { +public class ConfirmEvictionDetailsPage implements CcdPageConfiguration, CcdPage { public static final String CONFIRM_EVICTION_DETAILS_CONTENT = """

@@ -40,10 +41,16 @@ public class ConfirmEvictionDetailsPage implements CcdPageConfiguration { @Override public void addTo(PageBuilder pageBuilder) { + String pageKey = getPageKey(); pageBuilder - .page("confirmEvictionDetails") + .page(pageKey) .pageLabel("Confirm the eviction details") - .label("confirmEvictionDetails-line-separator", "---") - .label("confirmEvictionDetails-content", CONFIRM_EVICTION_DETAILS_CONTENT); + .label(pageKey + "-line-separator", "---") + .label(pageKey + "-content", CONFIRM_EVICTION_DETAILS_CONTENT); + } + + @Override + public String getPageKey() { + return CcdPage.derivePageKey(this.getClass()); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/EvictionDatePage.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/EvictionDatePage.java new file mode 100644 index 0000000000..beebe71a6e --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/EvictionDatePage.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; + +import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.page.CcdPage; + +public class EvictionDatePage implements CcdPageConfiguration, CcdPage { + + @Override + public void addTo(PageBuilder pageBuilder) { + String pageKey = getPageKey(); + pageBuilder + .page(pageKey) + .pageLabel("The eviction date") + .label(pageKey + "-line-separator", "---"); + } + + @Override + public String getPageKey() { + return CcdPage.derivePageKey(this.getClass()); + } + +} diff --git a/src/main/resources/db/migration/V064__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V070__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V064__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V070__add_bailiff_date_enf_case.sql diff --git a/src/main/resources/test-case-generation/Create-Enforcement-Writ-Basic-Case.json b/src/main/resources/test-case-generation/Create-Enforcement-Writ-Basic-Case.json index 4059acd0b3..7eb9c13364 100644 --- a/src/main/resources/test-case-generation/Create-Enforcement-Writ-Basic-Case.json +++ b/src/main/resources/test-case-generation/Create-Enforcement-Writ-Basic-Case.json @@ -1 +1 @@ -{"parties": [{"value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}, {"value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}, {"value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}], "allClaimants": [{"id": "ea700fdb-b710-4326-8b37-24df0f4d2f92", "value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}], "allDocuments": [], "claimantType": {"value": {"code": "PROVIDER_OF_SOCIAL_HOUSING", "label": "Registered provider of social housing"}, "valueCode": "PROVIDER_OF_SOCIAL_HOUSING"}, "languageUsed": "ENGLISH", "noticeServed": "No", "userPcqIdSet": "No", "allDefendants": [{"id": "39d575e6-fed3-4747-a5bb-c85e3931c16e", "value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}, {"id": "0ee3acb7-5c81-47dc-b09f-211064f91037", "value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}], "writFeeAmount": "£999999.99", "writAmountOwed": "123300", "propertyAddress": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "statementOfTruth": {"completedBy": "CLAIMANT", "fullNameClaimant": "wert", "positionClaimant": "ewrt", "agreementClaimant": ["BELIEVE_TRUE"]}, "warrantFeeAmount": "£999999.99", "legislativeCountry": "England", "mediationAttempted": "NO", "addAnotherDefendant": "YES", "claimingCostsWanted": "NO", "settlementAttempted": "NO", "writRepaymentChoice": "ALL", "applicationWithClaim": "NO", "claimGroundSummaries": [{"id": "9df0dd7e-8ee2-49d9-9135-2dc33a5a2ff2", "value": {"code": "NUISANCE_OR_IMMORAL_USE", "label": "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", "reason": "sfgsdfgsdfg", "category": "SECURE_OR_FLEXIBLE_DISCRETIONARY", "isRentArrears": "No"}}], "selectEnforcementType": "WRIT", "wantToUploadDocuments": "NO", "suspensionOfRTB_Reason": "asdfasdf", "writAmountOfLegalCosts": "12300", "claimAgainstTrespassers": "NO", "formattedDefendantNames": "TVR HN
\nTest1 Testing1
", "formattedPropertyAddress": "1 Rse Way
London
SW11 1PD", "hasUnderlesseeOrMortgagee": "NO", "writCorrectNameAndAddress": "YES", "preActionProtocolCompleted": "NO", "suspensionOfRTB_HousingAct": "SECTION_6A_2", "claimantCircumstancesSelect": "NO", "writEnforcementLanguageUsed": "ENGLISH", "tenancy_TypeOfTenancyLicence": "SECURE_TENANCY", "writAmountOfLandRegistryFees": "234500", "writAreLegalCostsToBeClaimed": "YES", "writRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Total amount that can be repaid
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£123
Land Registry fees£2,345
Writ of possession fee£999999.99
Total£1,003,700.99
", "hasDefendantCircumstancesInfo": "NO", "writShowChangeNameAddressPage": "No", "additionalReasonsForPossession": {"hasReasons": "NO"}, "writHaveLandRegistryFeesBeenPaid": "YES", "writHasClaimTransferredToHighCourt": "Yes", "writShowPeopleWhoWillBeEvictedPage": "Yes", "writHasHiredHighCourtEnforcementOfficer": "NO", "writStatementOfTruthRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
The payments due
Repayment forAmount
Arrears and other costs\n £1,233
Legal costs£123
Land Registry fees£2,345
Writ of possession fee£999999.99
Total£1,003,700.99
\n"} +{"parties": [{"value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}, {"value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}, {"value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}], "allClaimants": [{"id": "8d731f23-de9b-476e-b5df-1038864aede9", "value": {"address": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "orgName": "pcs-solicitor1@test.com", "emailAddress": "pcs-solicitor1@test.com", "phoneNumberProvided": "NO"}}], "allDocuments": [], "claimantType": {"value": {"code": "PROVIDER_OF_SOCIAL_HOUSING", "label": "Registered provider of social housing"}, "valueCode": "PROVIDER_OF_SOCIAL_HOUSING"}, "languageUsed": "ENGLISH", "noticeServed": "No", "userPcqIdSet": "No", "allDefendants": [{"id": "8abcc4f8-931d-4132-858c-17811da06ffa", "value": {"lastName": "HN", "firstName": "TVR", "nameKnown": "YES", "addressKnown": "NO"}}, {"id": "d27588bb-8854-4124-96e3-f9ed9cf51a30", "value": {"lastName": "Testing1", "firstName": "Test1", "nameKnown": "YES", "addressKnown": "NO"}}], "writFeeAmount": "£999999.99", "SearchCriteria": {}, "writAmountOwed": "124300", "propertyAddress": {"County": "", "Country": "United Kingdom", "PostCode": "SW11 1PD", "PostTown": "London", "AddressLine1": "1 Rse Way", "AddressLine2": "", "AddressLine3": ""}, "writCompletedBy": "CLAIMANT", "statementOfTruth": {"completedBy": "CLAIMANT", "fullNameClaimant": "wert", "positionClaimant": "ewrt", "agreementClaimant": ["BELIEVE_TRUE"]}, "warrantFeeAmount": "£999999.99", "legislativeCountry": "England", "mediationAttempted": "NO", "addAnotherDefendant": "YES", "claimingCostsWanted": "NO", "settlementAttempted": "NO", "writRepaymentChoice": "ALL", "applicationWithClaim": "NO", "claimGroundSummaries": [{"id": "5a00be37-cd6a-484f-b198-f969670a38f8", "value": {"code": "NUISANCE_OR_IMMORAL_USE", "label": "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", "reason": "sfgsdfgsdfg", "category": "SECURE_OR_FLEXIBLE_DISCRETIONARY", "isRentArrears": "No"}}], "writFullNameClaimant": "dsftsdfg", "writPositionClaimant": "dsfgsdfgsdf", "chooseEnforcementType": {"value": {"code": "WRIT", "label": "Writ of possession"}, "valueCode": "WRIT", "list_items": [{"code": "WARRANT", "label": "Warrant of possession"}, {"code": "WRIT", "label": "Writ of possession"}]}, "wantToUploadDocuments": "NO", "writAgreementClaimant": ["BELIEVE_TRUE"], "suspensionOfRTB_Reason": "asdfasdf", "claimAgainstTrespassers": "NO", "formattedDefendantNames": "TVR HN
\nTest1 Testing1
", "formattedPropertyAddress": "1 Rse Way
London
SW11 1PD", "hasUnderlesseeOrMortgagee": "NO", "writCorrectNameAndAddress": "YES", "preActionProtocolCompleted": "NO", "suspensionOfRTB_HousingAct": "SECTION_6A_2", "claimantCircumstancesSelect": "NO", "writEnforcementLanguageUsed": "ENGLISH", "tenancy_TypeOfTenancyLicence": "SECURE_TENANCY", "warrantOfRestitutionInfoText": "", "writAreLegalCostsToBeClaimed": "NO", "writRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Total amount that can be repaid
Repayment forAmount
Arrears and other costs\n £1,243
Legal costs£0
Land Registry fees£0
Writ of possession fee£999999.99
Total£1,001,242.99
", "hasDefendantCircumstancesInfo": "NO", "writShowChangeNameAddressPage": "No", "additionalReasonsForPossession": {"hasReasons": "NO"}, "writHaveLandRegistryFeesBeenPaid": "NO", "writHasClaimTransferredToHighCourt": "Yes", "writShowPeopleWhoWillBeEvictedPage": "Yes", "writHasHiredHighCourtEnforcementOfficer": "NO", "writStatementOfTruthRepaymentSummaryMarkdown": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
The payments due
Repayment forAmount
Arrears and other costs\n £1,243
Legal costs£0
Land Registry fees£0
Writ of possession fee£999999.99
Total£1,001,242.99
", "writWasGeneralApplicationToTransferToHighCourtSuccessful": "Yes"} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java new file mode 100644 index 0000000000..15ba3d28c5 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java @@ -0,0 +1,326 @@ +package uk.gov.hmcts.reform.pcs.ccd; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.EnforcementOrder; +import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; +import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; +import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; +import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.UUID; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +class EnforcementOrderMediatorTest { + + public static final long CASE_REFERENCE = 1234567890L; + + @Mock + private PcsCaseRepository pcsCaseRepository; + @Mock + private EnforcementOrderRepository enforcementOrderRepository; + + @InjectMocks + private EnforcementOrderMediator underTest; + + private PCSCase pcsCase; + + @BeforeEach + void beforeEach() { + pcsCase = PCSCase.builder() + .enforcementOrder(EnforcementOrder.builder().build()) + .build(); + } + + @Test + void shouldSetShowConfirmEvictionJourneyToYesWhenBailiffDateExists() { + // Given + long caseReference = 1234567890L; + Instant bailiffDate = Instant.parse("2026-04-15T10:00:00Z"); + + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.of(enforcementOrderEntity)); + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + assertEquals(YesOrNo.YES, pcsCase.getShowConfirmEvictionJourney()); + assertNotNull(pcsCase.getConfirmEvictionSummaryMarkup()); + assertTrue(pcsCase.getConfirmEvictionSummaryMarkup().contains("Confirm the eviction date")); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); + } + + @Test + void shouldSetShowConfirmEvictionJourneyToNoWhenBailiffDateIsNull() { + // Given + long caseReference = 1234567890L; + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(null); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.of(enforcementOrderEntity)); + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + assertEquals(YesOrNo.NO, pcsCase.getShowConfirmEvictionJourney()); + assertNotNull(pcsCase.getConfirmEvictionSummaryMarkup()); + assertTrue(pcsCase.getConfirmEvictionSummaryMarkup().contains("You cannot enforce the order at the moment")); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); + } + + @Test + void shouldFormatBailiffDateCorrectlyInMarkup() { + // Given + long caseReference = 1234567890L; + Instant bailiffDate = Instant.parse("2026-05-20T14:30:00Z"); + + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.of(enforcementOrderEntity)); + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + String expectedDate = bailiffDate.atZone(ZoneId.of("UTC")).format(outputFormatter); + assertTrue(pcsCase.getConfirmEvictionSummaryMarkup().contains(expectedDate)); + } + + @Test + void shouldCalculateDeadlineDateAsMinus72HoursFromBailiffDate() { + // Given + long caseReference = 1234567890L; + Instant bailiffDate = Instant.parse("2026-05-20T14:30:00Z"); + + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.of(enforcementOrderEntity)); + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + String expectedDeadline = bailiffDate.atZone(ZoneId.of("UTC")).minusHours(72).format(outputFormatter); + assertTrue(pcsCase.getConfirmEvictionSummaryMarkup().contains(expectedDeadline)); + } + + @Test + void shouldNotProcessWhenCaseReferenceIsZero() { + // Given + long caseReference = 0L; + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + assertNull(pcsCase.getShowConfirmEvictionJourney()); + assertNull(pcsCase.getConfirmEvictionSummaryMarkup()); + verify(pcsCaseRepository, never()).findByCaseReference(anyLong()); + } + + @Test + void shouldNotProcessWhenCaseReferenceIsNegative() { + // Given + long caseReference = -1L; + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + assertNull(pcsCase.getShowConfirmEvictionJourney()); + assertNull(pcsCase.getConfirmEvictionSummaryMarkup()); + verify(pcsCaseRepository, never()).findByCaseReference(anyLong()); + } + + @Test + void shouldNotProcessWhenPcsCaseIsNull() { + // Given + long caseReference = 1234567890L; + + // When + underTest.handleEnforcementRequirements(caseReference, null); + + // Then + verify(pcsCaseRepository, never()).findByCaseReference(anyLong()); + } + + @Test + void shouldThrowCaseNotFoundExceptionWhenCaseDoesNotExist() { + // Given + long caseReference = 1234567890L; + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.empty()); + + // When & Then + assertThrows(CaseNotFoundException.class, () -> + underTest.handleEnforcementRequirements(caseReference, pcsCase) + ); + verify(pcsCaseRepository).findByCaseReference(caseReference); + } + + @Test + void shouldReturnEmptyWhenClaimsListIsNull() { + // Given + long caseReference = 1234567890L; + PcsCaseEntity pcsCaseEntity = new PcsCaseEntity(); + pcsCaseEntity.setClaims(null); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + + // When + Optional result = underTest.getEnforcementOrder(caseReference); + + // Then + assertTrue(result.isEmpty()); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository, never()).findByClaimId(any()); + } + + @Test + void shouldReturnEmptyWhenClaimsListIsEmpty() { + // Given + long caseReference = 1234567890L; + PcsCaseEntity pcsCaseEntity = new PcsCaseEntity(); + pcsCaseEntity.setClaims(new ArrayList<>()); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + + // When + Optional result = underTest.getEnforcementOrder(caseReference); + + // Then + assertTrue(result.isEmpty()); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository, never()).findByClaimId(any()); + } + + @Test + void shouldReturnEnforcementOrderWhenFound() { + // Given + long caseReference = 1234567890L; + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(Instant.now()); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.of(enforcementOrderEntity)); + + // When + Optional result = underTest.getEnforcementOrder(caseReference); + + // Then + assertTrue(result.isPresent()); + assertEquals(enforcementOrderEntity, result.get()); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); + } + + @Test + void shouldReturnEmptyWhenEnforcementOrderNotFound() { + // Given + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + + when(pcsCaseRepository.findByCaseReference(CASE_REFERENCE)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.empty()); + + // When + Optional result = underTest.getEnforcementOrder(CASE_REFERENCE); + + // Then + assertTrue(result.isEmpty()); + verify(pcsCaseRepository).findByCaseReference(CASE_REFERENCE); + verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); + } + + @Test + void shouldNotSetMarkupWhenEnforcementOrderNotPresent() { + // Given + long caseReference = 1234567890L; + PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); + + when(pcsCaseRepository.findByCaseReference(caseReference)) + .thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))) + .thenReturn(Optional.empty()); + + // When + underTest.handleEnforcementRequirements(caseReference, pcsCase); + + // Then + assertNull(pcsCase.getShowConfirmEvictionJourney()); + assertNull(pcsCase.getConfirmEvictionSummaryMarkup()); + verify(pcsCaseRepository).findByCaseReference(caseReference); + verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); + } + + // Helper methods + private PcsCaseEntity createPcsCaseEntity() { + PcsCaseEntity entity = new PcsCaseEntity(); + ClaimEntity claimEntity = new ClaimEntity(); + claimEntity.setId(UUID.randomUUID()); + entity.setClaims(List.of(claimEntity)); + return entity; + } + + private EnforcementOrderEntity createEnforcementOrderEntity(Instant bailiffDate) { + EnforcementOrderEntity entity = new EnforcementOrderEntity(); + entity.setId(UUID.randomUUID()); + entity.setBailiffDate(bailiffDate); + return entity; + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java index 5808118b1a..e7cb2a8052 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java @@ -22,7 +22,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; -import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; import uk.gov.hmcts.reform.pcs.ccd.service.CaseTitleService; import uk.gov.hmcts.reform.pcs.ccd.service.DraftCaseDataService; import uk.gov.hmcts.reform.pcs.ccd.view.AlternativesToPossessionView; @@ -94,7 +93,7 @@ class PCSCaseViewTest { @Mock private ClaimEntity claimEntity; @Mock - private EnforcementOrderRepository enforcementOrderRepository; + private EnforcementOrderMediator enforcementOrderMediator; private PCSCaseView underTest; @@ -107,7 +106,7 @@ void setUp() { caseTitleService, claimView, tenancyLicenceView, claimGroundsView, rentDetailsView, alternativesToPossessionView, housingActWalesView, asbProhibitedConductView, rentArrearsView, noticeOfPossessionView, statementOfTruthView, - enforcementOrderRepository + enforcementOrderMediator ); } @@ -333,6 +332,15 @@ void shouldSetCaseFieldsInViewHelpers() { verify(statementOfTruthView).setCaseFields(pcsCase, pcsCaseEntity); } + @Test + void shouldCallEnforcementOrderMediator() { + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); + + // Then + verify(enforcementOrderMediator).handleEnforcementRequirements(CASE_REFERENCE, pcsCase); + } + private AddressUK stubAddressEntityModelMapper(AddressEntity addressEntity) { AddressUK addressUK = mock(AddressUK.class); when(modelMapper.map(addressEntity, AddressUK.class)).thenReturn(addressUK); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java index 1298af5944..e3ce4311f5 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java @@ -2,7 +2,7 @@ import org.mockito.InOrder; import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; -import uk.gov.hmcts.reform.pcs.ccd.page.builder.SavingPageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; import java.util.concurrent.atomic.AtomicInteger; @@ -10,13 +10,13 @@ public class PageConfigurerHelper { - public static void verifyAndCount(InOrder inOrder, SavingPageBuilder pageBuilder, + public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, Class pageClass, AtomicInteger counter) { inOrder.verify(pageBuilder).add(isA(pageClass)); counter.incrementAndGet(); } - public static void verifyAndCount(InOrder inOrder, SavingPageBuilder pageBuilder, + public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, CcdPageConfiguration specificInstance, AtomicInteger counter) { inOrder.verify(pageBuilder).add(specificInstance); counter.incrementAndGet(); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionPageConfigurerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionPageConfigurerTest.java new file mode 100644 index 0000000000..78d642dc88 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/ConfirmEvictionPageConfigurerTest.java @@ -0,0 +1,55 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.InOrder; +import org.mockito.InjectMocks; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; +import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; +import uk.gov.hmcts.reform.pcs.ccd.page.BasePageTest; + +import java.util.concurrent.atomic.AtomicInteger; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.PageConfigurerHelper.verifyAndCount; + +@ExtendWith(MockitoExtension.class) +class ConfirmEvictionPageConfigurerTest extends BasePageTest { + + @InjectMocks + private ConfirmEvictionConfigurer underTest; + + @Test + @SuppressWarnings("squid:S5961") + void shouldConfigurePagesInCorrectOrder() { + // Given + PageBuilder pageBuilder = mock(PageBuilder.class); + when(pageBuilder.add(any())).thenReturn(pageBuilder); + + // When + underTest.configurePages(pageBuilder); + + // Then + ArgumentCaptor pageCaptor = ArgumentCaptor.forClass(CcdPageConfiguration.class); + InOrder inOrder = inOrder(pageBuilder); + Mockito.verify(pageBuilder, Mockito.atLeastOnce()).add(pageCaptor.capture()); + AtomicInteger verificationCount = new AtomicInteger(0); + + verifyAndCount(inOrder, pageBuilder, ConfirmEvictionDetailsPage.class, verificationCount); + verifyAndCount(inOrder, pageBuilder, EvictionDatePage.class, verificationCount); + + int numberOfPages = pageCaptor.getAllValues().size(); + assertThat(verificationCount.get()).isEqualTo(numberOfPages); + + verifyNoMoreInteractions(pageBuilder); + } +} From 3e6165b15809882a43527bd1d62099eab00d94f6 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 20 Mar 2026 17:03:45 +0000 Subject: [PATCH 10/22] Cleanup ConfirmEviction event and helpers: drop unused start method and logger, make PageConfigurerHelper final with a private constructor, remove debug logs from the mediator, and hide the showConfirmEvictionJourney field in CaseType. --- .../java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 5 ++--- .../reform/pcs/ccd/EnforcementOrderMediator.java | 2 -- .../ccd/event/confirmeviction/ConfirmEviction.java | 11 +---------- .../page/enforcetheorder/PageConfigurerHelper.java | 6 +++++- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java index df0f98fc6a..fb9814c309 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java @@ -78,14 +78,13 @@ public void configure(final ConfigBuilder builder) { .field("confirmEvictionSummaryMarkup", NEVER_SHOW) .field(PCSCase::getPropertyAddress); - builder.tab("CaseHistory", "History") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .field("caseHistory"); builder.tab("hidden", "HiddenFields") - .field(PCSCase::getCaseTitleMarkdown) - .field(PCSCase::getShowConfirmEvictionJourney); + .showCondition(NEVER_SHOW) + .field(PCSCase::getCaseTitleMarkdown); builder.tab("serviceRequest", "Service Request") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index f0c3479b9a..02e4351d09 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -38,8 +38,6 @@ public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { noBailiffDate(pcsCase); } } - log.warn("---------------------------"); - log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java index fad1be0e82..7357d5fcfd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/confirmeviction/ConfirmEviction.java @@ -1,7 +1,6 @@ package uk.gov.hmcts.reform.pcs.ccd.event.confirmeviction; import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import uk.gov.hmcts.ccd.sdk.api.CCDConfig; import uk.gov.hmcts.ccd.sdk.api.DecentralisedConfigBuilder; @@ -17,7 +16,6 @@ import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEviction; -@Slf4j @Component @AllArgsConstructor public class ConfirmEviction implements CCDConfig { @@ -28,7 +26,7 @@ public class ConfirmEviction implements CCDConfig { public void configureDecentralised(DecentralisedConfigBuilder configBuilder) { Event.EventBuilder eventBuilder = configBuilder - .decentralisedEvent(confirmEviction.name(), this::submit, this::start) + .decentralisedEvent(confirmEviction.name(), this::submit) .forAllStates() .name("Confirm the eviction details") .grant(Permission.CRUD, UserRole.PCS_SOLICITOR) @@ -36,13 +34,6 @@ public void configureDecentralised(DecentralisedConfigBuilder eventPayload) { - PCSCase pcsCase = eventPayload.caseData(); - log.warn("---------------------------"); - log.warn(String.valueOf(pcsCase.getShowConfirmEvictionJourney())); - return pcsCase; - } - private SubmitResponse submit(EventPayload eventPayload) { return SubmitResponse.defaultResponse(); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java index e3ce4311f5..675e7a7c82 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java @@ -8,7 +8,7 @@ import static org.mockito.ArgumentMatchers.isA; -public class PageConfigurerHelper { +public final class PageConfigurerHelper { public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, Class pageClass, AtomicInteger counter) { @@ -22,4 +22,8 @@ public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, counter.incrementAndGet(); } + private PageConfigurerHelper() { + + } + } From a5e7fb65438f56c48007427808d96a3d654e42c2 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Thu, 26 Mar 2026 10:16:22 +0000 Subject: [PATCH 11/22] Flyway version update. --- ...model_updates.sql => V071__enforcement_data_model_updates.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V070__enforcement_data_model_updates.sql => V071__enforcement_data_model_updates.sql} (100%) diff --git a/src/main/resources/db/migration/V070__enforcement_data_model_updates.sql b/src/main/resources/db/migration/V071__enforcement_data_model_updates.sql similarity index 100% rename from src/main/resources/db/migration/V070__enforcement_data_model_updates.sql rename to src/main/resources/db/migration/V071__enforcement_data_model_updates.sql From 85954990d87398d64077b7eb514323f99c2978f6 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Thu, 26 Mar 2026 10:27:51 +0000 Subject: [PATCH 12/22] Change of version in the flyway to the correct script this time :) --- ...model_updates.sql => V070__enforcement_data_model_updates.sql} | 0 ...liff_date_enf_case.sql => V071__add_bailiff_date_enf_case.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V071__enforcement_data_model_updates.sql => V070__enforcement_data_model_updates.sql} (100%) rename src/main/resources/db/migration/{V070__add_bailiff_date_enf_case.sql => V071__add_bailiff_date_enf_case.sql} (100%) diff --git a/src/main/resources/db/migration/V071__enforcement_data_model_updates.sql b/src/main/resources/db/migration/V070__enforcement_data_model_updates.sql similarity index 100% rename from src/main/resources/db/migration/V071__enforcement_data_model_updates.sql rename to src/main/resources/db/migration/V070__enforcement_data_model_updates.sql diff --git a/src/main/resources/db/migration/V070__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V071__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V070__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V071__add_bailiff_date_enf_case.sql From d68f6e1b2a90ec656f60d09073b686ae6d68111e Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Thu, 26 Mar 2026 12:09:36 +0000 Subject: [PATCH 13/22] flyway version update. --- ...liff_date_enf_case.sql => V072__add_bailiff_date_enf_case.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V071__add_bailiff_date_enf_case.sql => V072__add_bailiff_date_enf_case.sql} (100%) diff --git a/src/main/resources/db/migration/V071__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V072__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V071__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V072__add_bailiff_date_enf_case.sql From 21df5f844fee7779a7d56800cb625f875efc803f Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 27 Mar 2026 16:34:33 +0000 Subject: [PATCH 14/22] Refactor eviction summary formatting: extract date formatting to DateUtil and summary markup to MarkupContent constants. Remove inline formatter logic and private constructor in PageConfigurerHelper. Update mediator to use new utilities and constants. --- .../pcs/ccd/EnforcementOrderMediator.java | 66 +++---------------- .../confirmeviction/MarkupContent.java | 55 ++++++++++++++++ .../hmcts/reform/pcs/ccd/util/DateUtil.java | 23 +++++++ .../enforcetheorder/PageConfigurerHelper.java | 6 +- 4 files changed, 90 insertions(+), 60 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index 02e4351d09..9d80b75ffb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -10,15 +10,16 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; +import uk.gov.hmcts.reform.pcs.ccd.util.DateUtil; import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import java.time.Instant; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; import java.util.List; -import java.util.Locale; import java.util.Optional; +import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.MarkupContent.CONFIRM_EVICTION_SUMMARY_NO_DATES; +import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.MarkupContent.CONFIRM_EVICTION_SUMMARY_WITH_DATES; + @Component @Slf4j @AllArgsConstructor @@ -26,6 +27,7 @@ public class EnforcementOrderMediator { private final PcsCaseRepository pcsCaseRepository; private final EnforcementOrderRepository enforcementOrderRepository; + private final DateUtil dateUtil; public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { if (caseReference > 0 && pcsCase != null) { @@ -54,64 +56,14 @@ Optional getEnforcementOrder(long caseReference) { private void hasBailiffDate(PCSCase pcsCase, Instant instant) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); pcsCase.setConfirmEvictionSummaryMarkup(String.format( - """ -

Confirm the eviction date

-

- The bailiff has given you an eviction date of %s. - They need you to confirm if you are available on this date. -

-

- You must confirm the eviction details before %s. - If you try to confirm the eviction after this - date, the bailiff will cancel your eviction. - They will also ask you to confirm if the defendants - (the person or people being evicted) pose any risk to the - bailiff. - The bailiff needs this information to carry out the eviction - safely. -

-

- To confirm the eviction date, select ‘Confirm the eviction - date’ from the dropdown menu. -

- """, - formatDate(instant), - minus72HoursFormatted(instant))); + CONFIRM_EVICTION_SUMMARY_WITH_DATES, + dateUtil.formatDate(instant), + dateUtil.minusHoursFormatted(instant, 72))); } private static void noBailiffDate(PCSCase pcsCase) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); - pcsCase.setConfirmEvictionSummaryMarkup(""" -

You cannot enforce the order at the moment

-

- You cannot enforce the order at the moment (use a bailiff to evict someone). -

-

How to find out why you cannot - enforce the order -

-

To find out why you cannot enforce the order, you can:

-
    -
  • check the tab: ‘Case file view’ (you should see an order from the court, - explaining why you cannot enforce), or
  • -
  • - - contact your local court. You will need to tell them your case number - (you can find this at the top of this page). If you do not know the name of your local court, select the - ‘Money’ category and then the ‘Housing’ category to find it.
  • -
- """); - } - - private String formatDate(Instant instant) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); - return instant.atZone(ZoneId.of("UTC")).format(outputFormatter); - } - - private String minus72HoursFormatted(Instant instant) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); - return instant.atZone(ZoneId.of("UTC")).minusHours(72).format(outputFormatter); + pcsCase.setConfirmEvictionSummaryMarkup(CONFIRM_EVICTION_SUMMARY_NO_DATES); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java new file mode 100644 index 0000000000..1eed86129f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java @@ -0,0 +1,55 @@ +package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class MarkupContent { + + public static String CONFIRM_EVICTION_SUMMARY_WITH_DATES = + """ +

Confirm the eviction date

+

+ The bailiff has given you an eviction date of %s. + They need you to confirm if you are available on this date. +

+

+ You must confirm the eviction details before %s. + If you try to confirm the eviction after this + date, the bailiff will cancel your eviction. + They will also ask you to confirm if the defendants + (the person or people being evicted) pose any risk to the + bailiff. + The bailiff needs this information to carry out the eviction + safely. +

+

+ To confirm the eviction date, select ‘Confirm the eviction + date’ from the dropdown menu. +

+ """; + + public static String CONFIRM_EVICTION_SUMMARY_NO_DATES = + """ +

You cannot enforce the order at the moment

+

+ You cannot enforce the order at the moment (use a bailiff to evict someone). +

+

How to find out why you cannot + enforce the order +

+

To find out why you cannot enforce the order, you can:

+
    +
  • check the tab: ‘Case file view’ (you should see an order from the court, + explaining why you cannot enforce), or
  • +
  • + + contact your local court. You will need to tell them your case number + (you can find this at the top of this page). If you do not know the name of your local court, select the + ‘Money’ category and then the ‘Housing’ category to find it.
  • +
+ """; + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java new file mode 100644 index 0000000000..48e5d27952 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.pcs.ccd.util; + +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + +@Component +public class DateUtil { + + public String formatDate(Instant instant) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + return instant.atZone(ZoneId.of("UTC")).format(outputFormatter); + } + + public String minusHoursFormatted(Instant instant, int hours) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + return instant.atZone(ZoneId.of("UTC")).minusHours(hours).format(outputFormatter); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java index 675e7a7c82..6722df7042 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java @@ -1,5 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.mockito.InOrder; import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; @@ -8,6 +10,7 @@ import static org.mockito.ArgumentMatchers.isA; +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class PageConfigurerHelper { public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, @@ -22,8 +25,5 @@ public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, counter.incrementAndGet(); } - private PageConfigurerHelper() { - - } } From 4541fd4f6eba986468e108cc19111640649b5aec Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Fri, 27 Mar 2026 17:06:07 +0000 Subject: [PATCH 15/22] Flyway version update and fix of test --- ...te_enf_case.sql => V073__add_bailiff_date_enf_case.sql} | 0 .../hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java | 7 +++++++ 2 files changed, 7 insertions(+) rename src/main/resources/db/migration/{V072__add_bailiff_date_enf_case.sql => V073__add_bailiff_date_enf_case.sql} (100%) diff --git a/src/main/resources/db/migration/V072__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V073__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V072__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V073__add_bailiff_date_enf_case.sql diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java index 15ba3d28c5..89f6589244 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java @@ -14,6 +14,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; +import uk.gov.hmcts.reform.pcs.ccd.util.DateUtil; import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import java.time.Instant; @@ -31,7 +32,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -45,6 +48,8 @@ class EnforcementOrderMediatorTest { private PcsCaseRepository pcsCaseRepository; @Mock private EnforcementOrderRepository enforcementOrderRepository; + @Mock + private DateUtil dateUtil; @InjectMocks private EnforcementOrderMediator underTest; @@ -56,6 +61,8 @@ void beforeEach() { pcsCase = PCSCase.builder() .enforcementOrder(EnforcementOrder.builder().build()) .build(); + lenient().when(dateUtil.formatDate(any(Instant.class))).thenCallRealMethod(); + lenient().when(dateUtil.minusHoursFormatted(any(Instant.class), anyInt())).thenCallRealMethod(); } @Test From 31691aeb03336f18e1bbcd0efdfe2b51d1d2ffbb Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Tue, 31 Mar 2026 09:39:37 +0100 Subject: [PATCH 16/22] Version number update for flyway. --- ...liff_date_enf_case.sql => V075__add_bailiff_date_enf_case.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V073__add_bailiff_date_enf_case.sql => V075__add_bailiff_date_enf_case.sql} (100%) diff --git a/src/main/resources/db/migration/V073__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql similarity index 100% rename from src/main/resources/db/migration/V073__add_bailiff_date_enf_case.sql rename to src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql From 311bf85555323c4956df6c2dd48aa2af5378359e Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Tue, 31 Mar 2026 11:57:25 +0100 Subject: [PATCH 17/22] Remove DateUtil and inline date formatting in EnforcementOrderMediator; migrate to LocalDateTime, update DB migration to plain timestamp, and simplify PageConfigurerHelper. This consolidates date logic directly in the mediator and aligns tests with the new date handling. --- .../pcs/ccd/EnforcementOrderMediator.java | 26 ++++++++++++------- .../EnforcementOrderEntity.java | 4 +-- .../hmcts/reform/pcs/ccd/util/DateUtil.java | 23 ---------------- .../V075__add_bailiff_date_enf_case.sql | 2 +- .../pcs/ccd/EnforcementOrderMediatorTest.java | 21 +++++---------- .../enforcetheorder/PageConfigurerHelper.java | 1 - 6 files changed, 27 insertions(+), 50 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index 9d80b75ffb..4f463dff81 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -10,11 +10,12 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; -import uk.gov.hmcts.reform.pcs.ccd.util.DateUtil; import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; -import java.time.Instant; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Locale; import java.util.Optional; import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.MarkupContent.CONFIRM_EVICTION_SUMMARY_NO_DATES; @@ -27,19 +28,17 @@ public class EnforcementOrderMediator { private final PcsCaseRepository pcsCaseRepository; private final EnforcementOrderRepository enforcementOrderRepository; - private final DateUtil dateUtil; public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { if (caseReference > 0 && pcsCase != null) { Optional optionalEnforcementOrder = getEnforcementOrder(caseReference); - if (optionalEnforcementOrder.isPresent()) { - EnforcementOrderEntity enforcementOrderEntity = optionalEnforcementOrder.get(); + optionalEnforcementOrder.ifPresent(enforcementOrderEntity -> { if (enforcementOrderEntity.getBailiffDate() != null) { hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); } else { noBailiffDate(pcsCase); } - } + }); } } @@ -53,12 +52,12 @@ Optional getEnforcementOrder(long caseReference) { return Optional.empty(); } - private void hasBailiffDate(PCSCase pcsCase, Instant instant) { + private void hasBailiffDate(PCSCase pcsCase, LocalDateTime localDateTime) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); pcsCase.setConfirmEvictionSummaryMarkup(String.format( CONFIRM_EVICTION_SUMMARY_WITH_DATES, - dateUtil.formatDate(instant), - dateUtil.minusHoursFormatted(instant, 72))); + formatDate(localDateTime), + getEvictionCancellationDeadline(localDateTime))); } private static void noBailiffDate(PCSCase pcsCase) { @@ -66,4 +65,13 @@ private static void noBailiffDate(PCSCase pcsCase) { pcsCase.setConfirmEvictionSummaryMarkup(CONFIRM_EVICTION_SUMMARY_NO_DATES); } + public String formatDate(LocalDateTime localDateTime) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + return localDateTime.format(outputFormatter); + } + + public String getEvictionCancellationDeadline(LocalDateTime localDateTime) { + DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + return localDateTime.minusHours(72).format(outputFormatter); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java index fcd9f814f5..a08612a90a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/enforcetheorder/EnforcementOrderEntity.java @@ -19,7 +19,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.enforcetheorder.EnforcementOrder; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; -import java.time.Instant; +import java.time.LocalDateTime; import java.util.UUID; import static jakarta.persistence.FetchType.LAZY; @@ -49,6 +49,6 @@ public class EnforcementOrderEntity { private WarrantEntity warrantDetails; @Column(name = "bailiff_date") - private Instant bailiffDate; + private LocalDateTime bailiffDate; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java deleted file mode 100644 index 48e5d27952..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/util/DateUtil.java +++ /dev/null @@ -1,23 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.util; - -import org.springframework.stereotype.Component; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - -@Component -public class DateUtil { - - public String formatDate(Instant instant) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); - return instant.atZone(ZoneId.of("UTC")).format(outputFormatter); - } - - public String minusHoursFormatted(Instant instant, int hours) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); - return instant.atZone(ZoneId.of("UTC")).minusHours(hours).format(outputFormatter); - } - -} diff --git a/src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql b/src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql index c377a15e31..75e441cc17 100644 --- a/src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql +++ b/src/main/resources/db/migration/V075__add_bailiff_date_enf_case.sql @@ -1,2 +1,2 @@ ALTER TABLE enf_case - ADD COLUMN bailiff_date timestamp with time zone; + ADD COLUMN bailiff_date timestamp; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java index 89f6589244..da55b73bf7 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java @@ -14,10 +14,9 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; -import uk.gov.hmcts.reform.pcs.ccd.util.DateUtil; import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; -import java.time.Instant; +import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -32,9 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -42,14 +39,12 @@ @ExtendWith(MockitoExtension.class) class EnforcementOrderMediatorTest { - public static final long CASE_REFERENCE = 1234567890L; + private static final long CASE_REFERENCE = 1234567890L; @Mock private PcsCaseRepository pcsCaseRepository; @Mock private EnforcementOrderRepository enforcementOrderRepository; - @Mock - private DateUtil dateUtil; @InjectMocks private EnforcementOrderMediator underTest; @@ -61,15 +56,13 @@ void beforeEach() { pcsCase = PCSCase.builder() .enforcementOrder(EnforcementOrder.builder().build()) .build(); - lenient().when(dateUtil.formatDate(any(Instant.class))).thenCallRealMethod(); - lenient().when(dateUtil.minusHoursFormatted(any(Instant.class), anyInt())).thenCallRealMethod(); } @Test void shouldSetShowConfirmEvictionJourneyToYesWhenBailiffDateExists() { // Given long caseReference = 1234567890L; - Instant bailiffDate = Instant.parse("2026-04-15T10:00:00Z"); + LocalDateTime bailiffDate = LocalDateTime.parse("2026-04-15T10:00:00"); PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); @@ -117,7 +110,7 @@ void shouldSetShowConfirmEvictionJourneyToNoWhenBailiffDateIsNull() { void shouldFormatBailiffDateCorrectlyInMarkup() { // Given long caseReference = 1234567890L; - Instant bailiffDate = Instant.parse("2026-05-20T14:30:00Z"); + LocalDateTime bailiffDate = LocalDateTime.parse("2026-05-20T14:30:00"); PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); @@ -140,7 +133,7 @@ void shouldFormatBailiffDateCorrectlyInMarkup() { void shouldCalculateDeadlineDateAsMinus72HoursFromBailiffDate() { // Given long caseReference = 1234567890L; - Instant bailiffDate = Instant.parse("2026-05-20T14:30:00Z"); + LocalDateTime bailiffDate = LocalDateTime.parse("2026-05-20T14:30:00"); PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); @@ -257,7 +250,7 @@ void shouldReturnEnforcementOrderWhenFound() { // Given long caseReference = 1234567890L; PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); - EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(Instant.now()); + EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(LocalDateTime.now()); when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); @@ -323,7 +316,7 @@ private PcsCaseEntity createPcsCaseEntity() { return entity; } - private EnforcementOrderEntity createEnforcementOrderEntity(Instant bailiffDate) { + private EnforcementOrderEntity createEnforcementOrderEntity(LocalDateTime bailiffDate) { EnforcementOrderEntity entity = new EnforcementOrderEntity(); entity.setId(UUID.randomUUID()); entity.setBailiffDate(bailiffDate); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java index 6722df7042..d07d45e5fd 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/PageConfigurerHelper.java @@ -25,5 +25,4 @@ public static void verifyAndCount(InOrder inOrder, PageBuilder pageBuilder, counter.incrementAndGet(); } - } From 51fd8011e107638df49e44cee77fb3db4a4607c2 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Tue, 31 Mar 2026 17:49:12 +0100 Subject: [PATCH 18/22] Change EnforcementOrderRepository to return list; update mediator to use first element if present. --- .../pcs/ccd/EnforcementOrderMediator.java | 8 ++++++- .../EnforcementOrderRepository.java | 4 ++-- .../pcs/ccd/EnforcementOrderMediatorTest.java | 23 ++++++++----------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index 4f463dff81..63ae42835c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -47,7 +47,13 @@ Optional getEnforcementOrder(long caseReference) { .orElseThrow(() -> new CaseNotFoundException(caseReference)); List claims = pcsCaseEntity.getClaims(); if (claims != null && !claims.isEmpty()) { - return enforcementOrderRepository.findByClaimId(claims.getFirst().getId()); + // At this point we do not know which Enforcement Order the Confirm Eviction is placed against. + // To be confirmed. + List byClaimId = enforcementOrderRepository + .findByClaimId(claims.getFirst().getId()); + if (!byClaimId.isEmpty()) { + return Optional.of(byClaimId.getFirst()); + } } return Optional.empty(); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java index 11e43d1ee4..357e38d522 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/repository/enforcetheorder/EnforcementOrderRepository.java @@ -3,9 +3,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; -import java.util.Optional; +import java.util.List; import java.util.UUID; public interface EnforcementOrderRepository extends JpaRepository { - Optional findByClaimId(UUID claimId); + List findByClaimId(UUID claimId); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java index da55b73bf7..95ed532016 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java @@ -70,7 +70,7 @@ void shouldSetShowConfirmEvictionJourneyToYesWhenBailiffDateExists() { when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.of(enforcementOrderEntity)); + .thenReturn(List.of(enforcementOrderEntity)); // When underTest.handleEnforcementRequirements(caseReference, pcsCase); @@ -93,7 +93,7 @@ void shouldSetShowConfirmEvictionJourneyToNoWhenBailiffDateIsNull() { when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.of(enforcementOrderEntity)); + .thenReturn(List.of(enforcementOrderEntity)); // When underTest.handleEnforcementRequirements(caseReference, pcsCase); @@ -115,10 +115,8 @@ void shouldFormatBailiffDateCorrectlyInMarkup() { PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); EnforcementOrderEntity enforcementOrderEntity = createEnforcementOrderEntity(bailiffDate); - when(pcsCaseRepository.findByCaseReference(caseReference)) - .thenReturn(Optional.of(pcsCaseEntity)); - when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.of(enforcementOrderEntity)); + when(pcsCaseRepository.findByCaseReference(caseReference)).thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))).thenReturn(List.of(enforcementOrderEntity)); // When underTest.handleEnforcementRequirements(caseReference, pcsCase); @@ -141,7 +139,7 @@ void shouldCalculateDeadlineDateAsMinus72HoursFromBailiffDate() { when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.of(enforcementOrderEntity)); + .thenReturn(List.of(enforcementOrderEntity)); // When underTest.handleEnforcementRequirements(caseReference, pcsCase); @@ -255,7 +253,7 @@ void shouldReturnEnforcementOrderWhenFound() { when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.of(enforcementOrderEntity)); + .thenReturn(List.of(enforcementOrderEntity)); // When Optional result = underTest.getEnforcementOrder(caseReference); @@ -272,10 +270,8 @@ void shouldReturnEmptyWhenEnforcementOrderNotFound() { // Given PcsCaseEntity pcsCaseEntity = createPcsCaseEntity(); - when(pcsCaseRepository.findByCaseReference(CASE_REFERENCE)) - .thenReturn(Optional.of(pcsCaseEntity)); - when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.empty()); + when(pcsCaseRepository.findByCaseReference(CASE_REFERENCE)).thenReturn(Optional.of(pcsCaseEntity)); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))).thenReturn(List.of()); // When Optional result = underTest.getEnforcementOrder(CASE_REFERENCE); @@ -294,8 +290,7 @@ void shouldNotSetMarkupWhenEnforcementOrderNotPresent() { when(pcsCaseRepository.findByCaseReference(caseReference)) .thenReturn(Optional.of(pcsCaseEntity)); - when(enforcementOrderRepository.findByClaimId(any(UUID.class))) - .thenReturn(Optional.empty()); + when(enforcementOrderRepository.findByClaimId(any(UUID.class))).thenReturn(List.of()); // When underTest.handleEnforcementRequirements(caseReference, pcsCase); From 84d71867a2aca61b8b85680ac4e0ee54915f3479 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Wed, 1 Apr 2026 09:45:20 +0100 Subject: [PATCH 19/22] [#4312] Alteration based on PR comment of method hasBailiffDate which is not changed to prepareConfirmEvictionWithDates --- .../pcs/ccd/EnforcementOrderMediator.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index 63ae42835c..2711ba3c6f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -31,14 +31,12 @@ public class EnforcementOrderMediator { public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { if (caseReference > 0 && pcsCase != null) { - Optional optionalEnforcementOrder = getEnforcementOrder(caseReference); - optionalEnforcementOrder.ifPresent(enforcementOrderEntity -> { - if (enforcementOrderEntity.getBailiffDate() != null) { - hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); - } else { - noBailiffDate(pcsCase); - } - }); + getEnforcementOrder(caseReference).ifPresent(enforcementOrderEntity -> + Optional.ofNullable(enforcementOrderEntity.getBailiffDate()) + .ifPresentOrElse( + date -> prepareConfirmEvictionWithDates(pcsCase, date), + () -> prepareConfirmEvictionWithNoDates(pcsCase) + )); } } @@ -48,7 +46,7 @@ Optional getEnforcementOrder(long caseReference) { List claims = pcsCaseEntity.getClaims(); if (claims != null && !claims.isEmpty()) { // At this point we do not know which Enforcement Order the Confirm Eviction is placed against. - // To be confirmed. + // this to be confirmed beyond this ticket scope (HDPI-4312) List byClaimId = enforcementOrderRepository .findByClaimId(claims.getFirst().getId()); if (!byClaimId.isEmpty()) { @@ -58,7 +56,7 @@ Optional getEnforcementOrder(long caseReference) { return Optional.empty(); } - private void hasBailiffDate(PCSCase pcsCase, LocalDateTime localDateTime) { + private void prepareConfirmEvictionWithDates(PCSCase pcsCase, LocalDateTime localDateTime) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); pcsCase.setConfirmEvictionSummaryMarkup(String.format( CONFIRM_EVICTION_SUMMARY_WITH_DATES, @@ -66,7 +64,7 @@ private void hasBailiffDate(PCSCase pcsCase, LocalDateTime localDateTime) { getEvictionCancellationDeadline(localDateTime))); } - private static void noBailiffDate(PCSCase pcsCase) { + private static void prepareConfirmEvictionWithNoDates(PCSCase pcsCase) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); pcsCase.setConfirmEvictionSummaryMarkup(CONFIRM_EVICTION_SUMMARY_NO_DATES); } From f94dea1cfbe9c2eac0ba3d91f0abcc5bacc8ff9d Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Wed, 1 Apr 2026 10:03:53 +0100 Subject: [PATCH 20/22] [#4312] Method and local field rename --- .../reform/pcs/ccd/EnforcementOrderMediator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java index 2711ba3c6f..1660f0692e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java @@ -34,8 +34,8 @@ public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { getEnforcementOrder(caseReference).ifPresent(enforcementOrderEntity -> Optional.ofNullable(enforcementOrderEntity.getBailiffDate()) .ifPresentOrElse( - date -> prepareConfirmEvictionWithDates(pcsCase, date), - () -> prepareConfirmEvictionWithNoDates(pcsCase) + date -> prepareEvictionWithDates(pcsCase, date), + () -> prepareEvictionWithNoDates(pcsCase) )); } } @@ -47,16 +47,16 @@ Optional getEnforcementOrder(long caseReference) { if (claims != null && !claims.isEmpty()) { // At this point we do not know which Enforcement Order the Confirm Eviction is placed against. // this to be confirmed beyond this ticket scope (HDPI-4312) - List byClaimId = enforcementOrderRepository + List enforcementOrderEntities = enforcementOrderRepository .findByClaimId(claims.getFirst().getId()); - if (!byClaimId.isEmpty()) { - return Optional.of(byClaimId.getFirst()); + if (!enforcementOrderEntities.isEmpty()) { + return Optional.of(enforcementOrderEntities.getFirst()); } } return Optional.empty(); } - private void prepareConfirmEvictionWithDates(PCSCase pcsCase, LocalDateTime localDateTime) { + private void prepareEvictionWithDates(PCSCase pcsCase, LocalDateTime localDateTime) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); pcsCase.setConfirmEvictionSummaryMarkup(String.format( CONFIRM_EVICTION_SUMMARY_WITH_DATES, @@ -64,7 +64,7 @@ private void prepareConfirmEvictionWithDates(PCSCase pcsCase, LocalDateTime loca getEvictionCancellationDeadline(localDateTime))); } - private static void prepareConfirmEvictionWithNoDates(PCSCase pcsCase) { + private static void prepareEvictionWithNoDates(PCSCase pcsCase) { pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); pcsCase.setConfirmEvictionSummaryMarkup(CONFIRM_EVICTION_SUMMARY_NO_DATES); } From 70162e4fbd7c4036243d2c7c5da1e39cfa03cc79 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Wed, 1 Apr 2026 10:17:16 +0100 Subject: [PATCH 21/22] [#4312] Repackaging. --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 1 + .../ccd/{ => enforcementorder}/EnforcementOrderMediator.java | 2 +- src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 1 + .../{ => enforcementorder}/EnforcementOrderMediatorTest.java | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/{ => enforcementorder}/EnforcementOrderMediator.java (98%) rename src/test/java/uk/gov/hmcts/reform/pcs/ccd/{ => enforcementorder}/EnforcementOrderMediatorTest.java (99%) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java index c7196e5145..fe2ee2fd1d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; import uk.gov.hmcts.reform.pcs.ccd.domain.State; +import uk.gov.hmcts.reform.pcs.ccd.enforcementorder.EnforcementOrderMediator; import uk.gov.hmcts.reform.pcs.ccd.entity.AddressEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java similarity index 98% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java index 1660f0692e..5b996a8604 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd; +package uk.gov.hmcts.reform.pcs.ccd.enforcementorder; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java index e57dc7b9ab..3b28ed7be9 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseViewTest.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; import uk.gov.hmcts.reform.pcs.ccd.domain.State; +import uk.gov.hmcts.reform.pcs.ccd.enforcementorder.EnforcementOrderMediator; import uk.gov.hmcts.reform.pcs.ccd.entity.AddressEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java similarity index 99% rename from src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java rename to src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java index 95ed532016..d18933da8a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/EnforcementOrderMediatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd; +package uk.gov.hmcts.reform.pcs.ccd.enforcementorder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; From 6661d9995a60870435cea1b032756cd6e5bc1235 Mon Sep 17 00:00:00 2001 From: tvr-solirius Date: Thu, 2 Apr 2026 17:36:14 +0100 Subject: [PATCH 22/22] Update of the date displayed to align with the Figma design. Plus some additional line breaks. --- .../EnforcementOrderMediator.java | 3 +- .../confirmeviction/MarkupContent.java | 6 ++++ .../EnforcementOrderMediatorTest.java | 31 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java index 5b996a8604..7b4d89f3a8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediator.java @@ -70,7 +70,8 @@ private static void prepareEvictionWithNoDates(PCSCase pcsCase) { } public String formatDate(LocalDateTime localDateTime) { - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); + DateTimeFormatter outputFormatter = DateTimeFormatter + .ofPattern("EEEE, d MMMM yyyy 'at' h:mm a", Locale.UK); return localDateTime.format(outputFormatter); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java index 1eed86129f..7eae698f3e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/enforcetheorder/confirmeviction/MarkupContent.java @@ -11,15 +11,21 @@ public class MarkupContent {

Confirm the eviction date

The bailiff has given you an eviction date of %s. +

+

They need you to confirm if you are available on this date.

You must confirm the eviction details before %s. If you try to confirm the eviction after this date, the bailiff will cancel your eviction. +

+

They will also ask you to confirm if the defendants (the person or people being evicted) pose any risk to the bailiff. +

+

The bailiff needs this information to carry out the eviction safely.

diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java index d18933da8a..f75542a0ce 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/enforcementorder/EnforcementOrderMediatorTest.java @@ -3,6 +3,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; @@ -24,7 +27,9 @@ import java.util.Locale; import java.util.Optional; import java.util.UUID; +import java.util.stream.Stream; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -302,6 +307,32 @@ void shouldNotSetMarkupWhenEnforcementOrderNotPresent() { verify(enforcementOrderRepository).findByClaimId(any(UUID.class)); } + @ParameterizedTest(name = "{0}") + @MethodSource("formatDateArguments") + void formatDate(String testName, LocalDateTime input, String expected) { + assertThat(underTest.formatDate(input)).isEqualTo(expected); + } + + private static Stream formatDateArguments() { + return Stream.of( + Arguments.of("morning time", + LocalDateTime.of(2025, 6, 9, 9, 30), + "Monday, 9 June 2025 at 9:30 am"), + Arguments.of("afternoon time", + LocalDateTime.of(2025, 6, 9, 14, 0), + "Monday, 9 June 2025 at 2:00 pm"), + Arguments.of("midnight", + LocalDateTime.of(2025, 6, 9, 0, 0), + "Monday, 9 June 2025 at 12:00 am"), + Arguments.of("noon", + LocalDateTime.of(2025, 6, 9, 12, 0), + "Monday, 9 June 2025 at 12:00 pm"), + Arguments.of("single digit day", + LocalDateTime.of(2025, 1, 3, 8, 15), + "Friday, 3 January 2025 at 8:15 am") + ); + } + // Helper methods private PcsCaseEntity createPcsCaseEntity() { PcsCaseEntity entity = new PcsCaseEntity();