From 4724e1e95e18f1261136a42ebaa29a09285c0299 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 11 May 2026 11:46:15 +0100 Subject: [PATCH 001/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 44 ++- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 7 + .../GroundsForPossessionTabDetails.java | 19 ++ .../domain/tabs/summary/NoticeTabDetails.java | 19 ++ .../ReasonsForPossessionTabDetails.java | 24 ++ .../tabs/summary/RentArrearsTabDetails.java | 39 +++ .../SummaryAdditionalDefendantTabDetails.java | 30 ++ .../summary/SummaryClaimantTabDetails.java | 19 ++ .../summary/SummaryDefendantTabDetails.java | 30 ++ .../ccd/domain/tabs/summary/SummaryTab.java | 78 ++++++ .../tabs/summary/TenancyTabDetails.java | 25 ++ .../reform/pcs/ccd/entity/ClaimEntity.java | 3 + .../reform/pcs/ccd/service/ClaimService.java | 2 + .../reform/pcs/ccd/view/CaseTabView.java | 265 +++++++++++++++++- .../hmcts/reform/pcs/ccd/view/ClaimView.java | 8 + .../V093__add_claim_submitted_date.sql | 1 + 16 files changed, 603 insertions(+), 10 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java create mode 100644 src/main/resources/db/migration/V093__add_claim_submitted_date.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 9fa96bc2dd..215551af09 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,10 +74,7 @@ public void configure(final ConfigBuilder builder) { .label("nextStepsMarkdownLabel", null, "${nextStepsMarkdown}") .field("nextStepsMarkdown", NEVER_SHOW); - builder.tab("summary", "Summary") - .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") - .field("confirmEvictionSummaryMarkup", NEVER_SHOW) - .field(PCSCase::getPropertyAddress); + buildSummaryTab(builder); builder.tab("CaseHistory", "History") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) @@ -123,4 +120,43 @@ private void buildCasePartiesTab(ConfigBuilder builder .field("casePartiesTab_DefendantOneDetails") .field("casePartiesTab_DefendantsDetails"); } + + private void buildSummaryTab(ConfigBuilder builder) { + builder.tab("summary", "Summary") + .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") + .field("confirmEvictionSummaryMarkup", NEVER_SHOW) + .label("Summary", null, "## Summary") + .field("summaryTab_RepossessedPropertyAddress") + .field("summaryTab_GroundsForPossession") + .field("summaryTab_ClaimSubmittedDate") + .field("summaryTab_ReasonsForPossession", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_PossessionReasonsSubmittedDate", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_ClaimSubmittedDate") + .label("Claimant details", + "summaryTab_ClaimantDetails!=\"\"", + "## Claimant details") + .field("summaryTab_ClaimantDetails") + .label("Defendant details", + "summaryTab_DefendantDetails!=\"\"", + "## Defendant details") + .field("summaryTab_DefendantDetails", + "summaryTab_DefendantDetails!=\"\"") + .field("summaryTab_AdditionalDefendants", + "summaryTab_AdditionalDefendants!=\"\"") + .label("Rent arrears", + "summaryTab_RentArrearsDetails!=\"\"", + "## Rent arrears") + .field("summaryTab_RentArrearsDetails") + .label("Tenancy or occupation contract or licence", + "summaryTab_TenancyDetails!=\"\"", + "## Tenancy or occupation contract or licence") + .field("summaryTab_TenancyDetails") + .label("Notice", + "summaryTab_NoticeDetails!=\"\"", + "## Notice") + .field("summaryTab_NoticeDetails", + "summaryTab_NoticeDetails!=\"\""); + } } 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 8639d60046..45e82d65f3 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 @@ -38,6 +38,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; @@ -536,6 +537,8 @@ public class PCSCase { @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) private List> claimGroundSummaries; + private String dateSubmitted; + @CCD( access = DefendantAccess.class, searchable = false @@ -589,4 +592,8 @@ public class PCSCase { @JsonUnwrapped(prefix = "casePartiesTab_") @CCD private CasePartiesTab casePartiesTab; + + @JsonUnwrapped(prefix = "summaryTab_") + @CCD + private SummaryTab summaryTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java new file mode 100644 index 0000000000..0fb214c9e7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroundsForPossessionTabDetails { + + @CCD( + label = "Grounds" + ) + private String grounds; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java new file mode 100644 index 0000000000..e66f4960e0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class NoticeTabDetails { + + @CCD( + label = "Date notice was served" + ) + private String noticeServedDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java new file mode 100644 index 0000000000..90aaac2db4 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ReasonsForPossessionTabDetails { + + @CCD( + label = "Reasons for claiming possession under ground X" + ) + private String groundReasons; + + @CCD( + label = "Additional reasons for possession" + ) + private String additionalReasonsForPossession; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java new file mode 100644 index 0000000000..428462386b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java @@ -0,0 +1,39 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RentArrearsTabDetails { + + @CCD( + label = "Rent amount" + ) + private String rentAmount; + + @CCD( + label = "How rent is calculated" + ) + private String calculationFrequency; + + @CCD( + label = "Daily rate" + ) + private String dailyRate; + + @CCD( + label = "Rent arrears total at the time of claim issue" + ) + private String arrearsTotal; + + @CCD( + label = "Judgment requested for the outstanding arrears?" + ) + private String judgmentRequested; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java new file mode 100644 index 0000000000..8ecfbc2c1f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryAdditionalDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Additional defendant address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java new file mode 100644 index 0000000000..a9731b1739 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryClaimantTabDetails { + + @CCD( + label = "Claimant name" + ) + private String claimantName; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java new file mode 100644 index 0000000000..20647d131f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Defendant 1 address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java new file mode 100644 index 0000000000..27fb48eee8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) +public class SummaryTab { + + @CCD( + label = "Address of property to be repossessed" + ) + private AddressUK repossessedPropertyAddress; + + @CCD( + label = "Grounds for possession" + ) + private GroundsForPossessionTabDetails groundsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String claimSubmittedDate; + + @CCD( + label = "Reasons for possession" + ) + private ReasonsForPossessionTabDetails reasonsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String possessionReasonsSubmittedDate; + + @CCD( + label = "Claimant" + ) + private SummaryClaimantTabDetails claimantDetails; + + @CCD( + label = "Defendant 1" + ) + private SummaryDefendantTabDetails defendantDetails; + + @CCD( + label = "Additional defendant" + ) + private List> additionalDefendants; + + @CCD( + label = "Details of rent arrears" + ) + private RentArrearsTabDetails rentArrearsDetails; + + @CCD( + label = "Tenancy or occupation contract or licence details" + ) + private TenancyTabDetails tenancyDetails; + + @CCD( + label = "Notice details" + ) + private NoticeTabDetails noticeDetails; + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java new file mode 100644 index 0000000000..f140e76b89 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TenancyTabDetails { + + @CCD( + label = "Tenancy, occupation contract or licence agreement type" + ) + private String agreementType; + + @CCD( + label = "Tenancy, occupation contract or licence agreement start date", + showCondition = "agreementStartDate!=\"\"" + ) + private String agreementStartDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index 62ddea3395..f51371228a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,6 +34,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -136,6 +137,8 @@ public class ClaimEntity { @Enumerated(EnumType.STRING) private LanguageUsed languageUsed; + private LocalDateTime claimSubmittedDate; + @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "claim") @Builder.Default @JsonManagedReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java index 503271ab82..9e0ec7618e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.ClaimRepository; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.List; @Service @@ -65,6 +66,7 @@ public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { .additionalDocsProvided(pcsCase.getWantToUploadDocuments()) .genAppExpected(pcsCase.getApplicationWithClaim()) .languageUsed(pcsCase.getLanguageUsed()) + .claimSubmittedDate(LocalDateTime.now()) .build(); claimEntity.addClaimGrounds(claimGrounds); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index a8abad4594..fef3cec681 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,24 +4,29 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import java.math.BigDecimal; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + @Component public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; + private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); + SummaryTab summaryTab = buildSummaryTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); + pcsCase.setSummaryTab(summaryTab); } private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { @@ -81,4 +86,252 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p .lastName(defendantLastName) .build(); } + + private SummaryTab buildSummaryTab(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + + return SummaryTab.builder() + .repossessedPropertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossession(GroundsForPossessionTabDetails.builder() + .grounds(getGrounds(pcsCase)) + .build()) + .claimSubmittedDate(pcsCase.getDateSubmitted()) + .reasonsForPossession(reasonsForPossession) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : pcsCase.getDateSubmitted()) + .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) + .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .tenancyDetails(buildTenancyTabDetails(pcsCase)) + .noticeDetails(buildNoticeTabDetails(pcsCase)) + .build(); + } + + private SummaryClaimantTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return SummaryClaimantTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } + + private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryAdditionalDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private SummaryDefendantTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return null; + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + return null; + } + + return ReasonsForPossessionTabDetails.builder() + .groundReasons(additionalReasons.getHasReasons().getLabel()) + .additionalReasonsForPossession(additionalReasons.getReasons()) + .build(); + } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + + if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + return null; + } + + String agreementType = getAgreementType(tenancyLicenceDetails); + String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null + ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + + return TenancyTabDetails.builder() + .agreementType(agreementType) + .agreementStartDate(agreementStartDate) + .build(); + } + + private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { + if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { + return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); + } + + return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); + } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + + if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + return null; + } + + return NoticeTabDetails.builder() + .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .build(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + return pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .orElse(null); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java index 0efb99bd8b..8c478fe9f6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java @@ -10,9 +10,15 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + @Component public class ClaimView { + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { if (!pcsCaseEntity.getClaims().isEmpty()) { ClaimEntity mainClaim = pcsCaseEntity.getClaims().getFirst(); @@ -36,6 +42,8 @@ private void mapBasicClaimFields(PCSCase pcsCase, ClaimEntity claim) { pcsCase.setApplicationWithClaim(claim.getGenAppExpected()); pcsCase.setLanguageUsed(claim.getLanguageUsed()); pcsCase.setWantToUploadDocuments(claim.getAdditionalDocsProvided()); + pcsCase.setDateSubmitted(claim.getClaimSubmittedDate() == null ? null : claim.getClaimSubmittedDate() + .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); } private void mapComplexClaimFields(PCSCase pcsCase, ClaimEntity claim) { diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql new file mode 100644 index 0000000000..63b1fa3595 --- /dev/null +++ b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql @@ -0,0 +1 @@ +ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; From 05d6c29390e02479b8d533764959031321ad2078 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Mon, 11 May 2026 21:10:41 +0100 Subject: [PATCH 002/138] HDPI-2983: build case details tab classes --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 21 +++- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 5 + .../domain/tabs/ActionsTakenTabDetails.java | 34 +++++ ...itionalDefendantInformationTabDetails.java | 24 ++++ .../domain/tabs/ApplicationsTabDetails.java | 19 +++ .../pcs/ccd/domain/tabs/CaseDetailsTab.java | 116 ++++++++++++++++++ .../pcs/ccd/domain/tabs/ClaimTabDetails.java | 23 ++++ .../tabs/ClaimantCircumstancesTabDetails.java | 24 ++++ .../tabs/ClaimantInformationTabDetails.java | 18 +++ .../tabs/DefendantCircumstanceTabDetails.java | 25 ++++ .../tabs/DefendantInformationTabDetails.java | 13 ++ .../tabs/DemotionOfTenancyTabDetails.java | 35 ++++++ .../tabs/GroundsForPossessionTabDetails.java | 26 ++++ .../pcs/ccd/domain/tabs/NoticeTabDetails.java | 63 ++++++++++ .../tabs/ReasonsForPossessionTabDetails.java | 4 + .../domain/tabs/RentArrearsTabDetails.java | 58 +++++++++ .../SuspensionOfRightToBuyTabDetails.java | 24 ++++ .../domain/tabs/TenancyLicenceTabDetails.java | 43 +++++++ ...lesseeOrMortgageInformationTabDetails.java | 24 ++++ 19 files changed, 597 insertions(+), 2 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.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 9fa96bc2dd..b9498f68c8 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 @@ -96,13 +96,15 @@ public void configure(final ConfigBuilder builder) { .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .field(PCSCase::getCaseFileView, null, "#ARGUMENT(CaseFileView)"); + buildCaseDetailsTab(builder); + + buildCasePartiesTab(builder); + builder.tab("caseLinks", "Linked Cases") .forRoles(UserRole.PCS_SOLICITOR) .field(PCSCase::getLinkedCasesComponentLauncher, null, "#ARGUMENT(LinkedCases)") .field(PCSCase::getCaseLinks, "LinkedCasesComponentLauncher!=\"\"", "#ARGUMENT(LinkedCases)"); - buildCasePartiesTab(builder); - configureCaseFileCategories(builder); } @@ -123,4 +125,19 @@ private void buildCasePartiesTab(ConfigBuilder builder .field("casePartiesTab_DefendantOneDetails") .field("casePartiesTab_DefendantsDetails"); } + + private void buildCaseDetailsTab(ConfigBuilder builder) { + builder.tab("caseDetails", "Case Details") + .label("Case details", null, "### Case details") + .field(PCSCase::getPropertyAddress) + .label("Claimant Details", null, "### Claimant Details") + .label("Defendant Details", null, "### Defendant Details") + .label( + "Underlessee or mortgagee", + null, + "### Underlessee or mortgagee entitled to claim relief against forfeiture" + ) + .label("Demotion of tenancy", null, "### Demotion of tenancy") + .label("Suspension of right to buy", null, "### Suspension of right to buy"); + } } 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 8639d60046..11d4a57bb1 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 @@ -37,6 +37,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.model.NoRentArrearsReasonForGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; @@ -589,4 +590,8 @@ public class PCSCase { @JsonUnwrapped(prefix = "casePartiesTab_") @CCD private CasePartiesTab casePartiesTab; + + @JsonUnwrapped(prefix = "caseDetailsTab_") + @CCD + private CaseDetailsTab caseDetailsTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java new file mode 100644 index 0000000000..ffa6148265 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java @@ -0,0 +1,34 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ActionsTakenTabDetails { + + @CCD( + label = "Pre-action protocol followed?" + ) + private String preactionProtocolFollowed; + + @CCD( + label = "Explain why you have not followed the pre-action protocol" + ) + private String preActionProtocolIncompleteExplanation; + + @CCD( + label = "Mediation attempted?" + ) + private String mediationAttempted; + + @CCD( + label = "Settlement attempted?" + ) + private String settlementAttempted; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java new file mode 100644 index 0000000000..c62b6aaba9 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class AdditionalDefendantInformationTabDetails { + @CCD( + label = "Additional defendant" + ) + private DefendantInformationTabDetails defendantInformationDetails; + + @CCD( + label = "Additional defendant address for service" + ) + private AddressUK defendantOneAddress; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java new file mode 100644 index 0000000000..9dbdd2e05d --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ApplicationsTabDetails { + + @CCD( + label = "Are you planning to make an application at the same time as your claim?" + ) + private String planToMakeGeneralApplication; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java new file mode 100644 index 0000000000..a41ce30ed3 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java @@ -0,0 +1,116 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) +public class CaseDetailsTab { + + @CCD( + label = "Claim details" + ) + private ClaimTabDetails claimDetails; + + @CCD( + label = "Address of property to be repossessed" + ) + private AddressUK propertyAddress; + + @CCD( + label = "Grounds for possession" + ) + private GroundsForPossessionTabDetails groundsForPossessionDetails; + + @CCD( + label = "Tenancy, occupation contract or licence details" + ) + private TenancyLicenceTabDetails tenancyLicenceDetails; + + @CCD( + label = "Notice details" + ) + private NoticeTabDetails noticeDetails; + + @CCD( + label = "Actions already taken" + ) + private ActionsTakenTabDetails actionsTakenDetails; + + @CCD( + label = "Details of rent arrears" + ) + private RentArrearsTabDetails rentArrearsDetails; + + @CCD( + label = "Reasons for possession" + ) + private ReasonsForPossessionTabDetails reasonsForPossessionDetails; + + @CCD( + label = "Applications" + ) + private ApplicationsTabDetails applicationsDetails; + + @CCD( + label = "Claimant" + ) + private ClaimantInformationTabDetails claimantInformation; + + @CCD( + label = "Claimant address for service" + ) + private AddressUK claimantAddress; + + @CCD( + label = "Claimant contact details" + ) + private ClaimantTabDetails claimantContactDetails; + + @CCD( + label = "Claimant circumstances" + ) + private ClaimantCircumstancesTabDetails claimantCircumstances; + + @CCD( + label = "Defendant 1" + ) + private DefendantInformationTabDetails defendantInformationDetails; + + @CCD( + label = "Defendant 1 address for service" + ) + private AddressUK defendantOneAddress; + + @CCD( + label = "Defendant’ circumstances" + ) + private DefendantCircumstanceTabDetails defendantCircumstanceDetails; + + @CCD( + label = "Underlessee or mortgagee" + ) + private List> underlesseeMortgageDetails; + + @CCD( + label = "Demotion of tenancy claim" + ) + private DemotionOfTenancyTabDetails demotionOfTenancyDetails; + + @CCD( + label = "SuspensionOfRightToBuyTabDetails" + ) + private SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyDetails; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java new file mode 100644 index 0000000000..bd629f06df --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java @@ -0,0 +1,23 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClaimTabDetails { + @CCD( + label = "Claimant type" + ) + private String claimantType; + + @CCD( + label = "Claim against trespassers?" + ) + private String trespassClaim; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java new file mode 100644 index 0000000000..0e404d61a2 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClaimantCircumstancesTabDetails { + + @CCD( + label = "Is there any information you’d like to provide about ${claimantNamePossessiveForm} circumstances?" + ) + private String claimantCircumstancesGiven; + + @CCD( + label = "Claimant circumstances" + ) + private String claimantCircumstancesDetails; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java new file mode 100644 index 0000000000..fc5cc436b6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java @@ -0,0 +1,18 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClaimantInformationTabDetails { + @CCD( + label = "Claimant name" + ) + private String name; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java new file mode 100644 index 0000000000..29e265752c --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DefendantCircumstanceTabDetails { + + @CCD( + label = "Is there any information you're required to provide, or you want to provide, " + + "about the defendants’ circumstances?" + ) + private String defendantCircumstancesGiven; + + @CCD( + label = "Defendants’ circumstances" + ) + private String defendantCircumstances; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java new file mode 100644 index 0000000000..bbb6386cd6 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java @@ -0,0 +1,13 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DefendantInformationTabDetails { +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java new file mode 100644 index 0000000000..ac2f47f92f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java @@ -0,0 +1,35 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class DemotionOfTenancyTabDetails { + + @CCD( + label = "Section of the Housing Act demotion of tenancy claim made under" + ) + private String housingAct; + + @CCD( + label = "Have you served the defendants with a statement of the express terms which will " + + "apply to the demoted tenancy?" + ) + private String statementOfExpressTermsServed; + + @CCD( + label = "Details of terms" + ) + private String terms; + + @CCD( + label = "Reasons for requesting a demotion of tenancy order" + ) + private String reasons; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java new file mode 100644 index 0000000000..4935a9b178 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroundsForPossessionTabDetails { + + @CCD( + label = "Grounds" + ) + private List grounds; + + @CCD( + label = "Description of other grounds" + ) + private String otherGroundsDescription; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java new file mode 100644 index 0000000000..19e3fcd54a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java @@ -0,0 +1,63 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class NoticeTabDetails { + + @CCD( + label = "Has notice been served?" + ) + private String noticeServed; + + @CCD( + label = "Date and time notice served (if applicable)" + ) + private String noticeDate; + + @CCD( + label = "Method of service" + ) + private String noticeMethod; + + @CCD( + label = "Name of person document was left with" + ) + private String noticePersonName; + + @CCD( + label = "Email address the document sent to" + ) + private String noticeEmailAddress; + + @CCD( + label = "Explain what the other means were" + ) + private String noticeOtherExplanation; + + @CCD( + label = "Are you able to upload a copy of the notice you served?" + ) + private String noticeUploaded; + + @CCD( + label = "Notice or certificate of service" + ) + private List> noticeDocuments; + + @CCD( + label = "Details of why you cannot upload a copy" + ) + private String reasonsForNoNoticeDocument; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java new file mode 100644 index 0000000000..a6e786fe68 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +public class ReasonsForPossessionTabDetails { +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java new file mode 100644 index 0000000000..d93dea250f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java @@ -0,0 +1,58 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RentArrearsTabDetails { + + @CCD( + label = "Rent amount" + ) + private String rentAmount; + + @CCD( + label = "How rent is calculated" + ) + private String rentCalculation; + + @CCD( + label = "Frequency" + ) + private String frequency; + + @CCD( + label = "Daily rate" + ) + private String dailyRate; + + @CCD( + label = "Previous steps taken to recover rent arrears?" + ) + private String stepsToRecoverArrears; + + @CCD( + label = "Rent statement" + ) + private List> rentStatement; + + @CCD( + label = "Rent arrears total at the time of claim issue" + ) + private String totalRentArrears; + + @CCD( + label = "Judgment requested for the outstanding arrears?" + ) + private String judgementRequested; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java new file mode 100644 index 0000000000..8c4d5ed3d5 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SuspensionOfRightToBuyTabDetails { + + @CCD( + label = "Section of the Housing Act suspension of right to buy claim made under" + ) + private String section; + + @CCD( + label = "Reasons for requesting suspension of right to buy order" + ) + private String reasons; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java new file mode 100644 index 0000000000..31a005e76a --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java @@ -0,0 +1,43 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TenancyLicenceTabDetails { + + @CCD( + label = "Tenancy, occupation contract or licence agreement type" + ) + private String typeOfTenancyLicence; + + @CCD( + label = "Tenancy, occupation contract or licence start date" + ) + private String tenancyLicenceDate; + + @CCD( + label = "Do you have a copy of the tenancy or licence agreement?" + ) + private String hasCopyOfTenancyLicence; + + @CCD( + label = "Details of why you do not have a copy" + ) + private String reasonsForNoTenancyLicenceDocuments; + + @CCD( + label = "Tenancy, occupation contract or licence agreement" + ) + private List> tenancyLicenceDocuments; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java new file mode 100644 index 0000000000..d1f8af86bb --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UnderlesseeOrMortgageInformationTabDetails { + + @CCD( + label = "Underlessee or mortgagee’s address for service known?" + ) + private String nameKnown; + + @CCD( + label = "Name" + ) + private String name; +} From 9d0f9a6d732cbaf0f4fa167db07b6dcf1fbd2478 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Mon, 11 May 2026 23:28:45 +0100 Subject: [PATCH 003/138] HDPI-2983: create CaseDetailsTabView and allow draft data to be viewed in tabs --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 4 +- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 6 ++ .../pcs/ccd/domain/tabs/CaseDetailsTab.java | 10 +-- .../pcs/ccd/domain/tabs/ClaimTabDetails.java | 6 +- .../tabs/DefendantInformationTabDetails.java | 4 ++ .../tabs/GroundsForPossessionTabDetails.java | 8 +-- .../domain/tabs/TenancyLicenceTabDetails.java | 6 +- .../pcs/ccd/view/CaseDetailsTabView.java | 68 +++++++++++++++++++ .../reform/pcs/ccd/view/CaseTabView.java | 12 ++++ .../reform/pcs/ccd/view/CaseTabViewTest.java | 25 +++++-- 10 files changed, 129 insertions(+), 20 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.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 b9498f68c8..a00179bde2 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 @@ -129,7 +129,9 @@ private void buildCasePartiesTab(ConfigBuilder builder private void buildCaseDetailsTab(ConfigBuilder builder) { builder.tab("caseDetails", "Case Details") .label("Case details", null, "### Case details") - .field(PCSCase::getPropertyAddress) + .field("caseDetailsTab_ClaimDetails") + .field("caseDetailsTab_PropertyAddress") + .field("caseDetailsTab_TenancyLicenceDetails") .label("Claimant Details", null, "### Claimant Details") .label("Defendant Details", null, "### Defendant Details") .label( 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 310e8d4ed6..a3f4804808 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 @@ -87,6 +87,12 @@ public PCSCase getCase(CaseViewRequest request) { PCSCase pcsCase = getSubmittedCase(caseReference); boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); + if (hasUnsubmittedCaseData) { + draftCaseDataService + .getUnsubmittedCaseData(caseReference, resumePossessionClaim) + .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + } + setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java index a41ce30ed3..cfb2eca714 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java @@ -54,10 +54,10 @@ public class CaseDetailsTab { ) private RentArrearsTabDetails rentArrearsDetails; - @CCD( - label = "Reasons for possession" - ) - private ReasonsForPossessionTabDetails reasonsForPossessionDetails; +// @CCD( +// label = "Reasons for possession" +// ) +// private ReasonsForPossessionTabDetails reasonsForPossessionDetails; @CCD( label = "Applications" @@ -102,7 +102,7 @@ public class CaseDetailsTab { @CCD( label = "Underlessee or mortgagee" ) - private List> underlesseeMortgageDetails; + private List> mortgageDetails; @CCD( label = "Demotion of tenancy claim" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java index bd629f06df..74d40ed032 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java @@ -5,6 +5,8 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @Builder @Data @@ -14,10 +16,10 @@ public class ClaimTabDetails { @CCD( label = "Claimant type" ) - private String claimantType; + private ClaimantType claimantType; @CCD( label = "Claim against trespassers?" ) - private String trespassClaim; + private VerticalYesNo trespassClaim; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java index bbb6386cd6..dbadb32ada 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java @@ -4,10 +4,14 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; @Builder @Data @NoArgsConstructor @AllArgsConstructor public class DefendantInformationTabDetails { + + @CCD + private String firstName; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java index 4935a9b178..02e3e48760 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java @@ -14,10 +14,10 @@ @AllArgsConstructor public class GroundsForPossessionTabDetails { - @CCD( - label = "Grounds" - ) - private List grounds; +// @CCD( +// label = "Grounds" +// ) +// private List grounds; @CCD( label = "Description of other grounds" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java index 31a005e76a..ab7db1621a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java @@ -7,6 +7,8 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.Document; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import java.util.List; @@ -19,7 +21,7 @@ public class TenancyLicenceTabDetails { @CCD( label = "Tenancy, occupation contract or licence agreement type" ) - private String typeOfTenancyLicence; + private TenancyLicenceType typeOfTenancyLicence; @CCD( label = "Tenancy, occupation contract or licence start date" @@ -29,7 +31,7 @@ public class TenancyLicenceTabDetails { @CCD( label = "Do you have a copy of the tenancy or licence agreement?" ) - private String hasCopyOfTenancyLicence; + private VerticalYesNo hasCopyOfTenancyLicence; @CCD( label = "Details of why you do not have a copy" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java new file mode 100644 index 0000000000..5a76100c06 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -0,0 +1,68 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.TenancyLicenceTabDetails; + +import java.time.format.DateTimeFormatter; + +@Component +public class CaseDetailsTabView { + + private static final String NO_ANSWER = " "; + private static final DateTimeFormatter pattern = DateTimeFormatter.ofPattern("d MMM yyyy"); + + public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { + ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); + GroundsForPossessionTabDetails groundsForPossessionTabDetails = buildGroundsForPossessionTabDetails(pcsCase); + TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase); + + return CaseDetailsTab.builder() + .claimDetails(claimTabDetails) + .propertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossessionDetails(groundsForPossessionTabDetails) + .tenancyLicenceDetails(tenancyLicenceTabDetails) + .build(); + } + + private ClaimTabDetails buildClaimTabDetails(PCSCase pcsCase) { + ClaimantType claimantType = pcsCase.getClaimantType() != null + ? ClaimantType.fromName(pcsCase.getClaimantType().getValueCode()) : null; + + return ClaimTabDetails.builder() + .claimantType(claimantType) + .trespassClaim(pcsCase.getClaimAgainstTrespassers()) + .build(); + } + + private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCase pcsCase) { + return GroundsForPossessionTabDetails + .builder() + .build(); + } + + private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + if (tenancyLicenceDetails == null) { + return null; + } + + //1 Jan 2026 not 2026-2-1 + + String tenancyDate = tenancyLicenceDetails.getTenancyLicenceDate() != null ? + tenancyLicenceDetails.getTenancyLicenceDate().format(pattern): NO_ANSWER; + + return TenancyLicenceTabDetails.builder() + .typeOfTenancyLicence(tenancyLicenceDetails.getTypeOfTenancyLicence()) + .tenancyLicenceDate(tenancyDate) + .hasCopyOfTenancyLicence(tenancyLicenceDetails.getHasCopyOfTenancyLicence()) + .tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments()) + .reasonsForNoTenancyLicenceDocuments(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments()) + .build(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index a8abad4594..850f1726fa 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.pcs.ccd.view; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; @@ -7,6 +8,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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; @@ -14,14 +16,24 @@ import java.util.ArrayList; import java.util.List; +@AllArgsConstructor @Component public class CaseTabView { + private final CaseDetailsTabView caseDetailsTabView; + private static final String NAME_UNKNOWN = "Person unknown"; public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); + pcsCase.setCaseDetailsTab(caseDetailsTab); + } + + public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draft) { + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(draft); + pcsCase.setCaseDetailsTab(caseDetailsTab); } private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c1afe68a2a..f062eec3a9 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -1,14 +1,16 @@ package uk.gov.hmcts.reform.pcs.ccd.view; -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.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; @@ -16,16 +18,16 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class CaseTabViewTest { - private CaseTabView underTest; + @Mock + private CaseDetailsTabView caseDetailsTabView; - @BeforeEach - void setUp() { - underTest = new CaseTabView(); - } + @InjectMocks + private CaseTabView underTest; @Test void shouldSetClaimantDetailsInCasePartiesTab() { @@ -50,6 +52,8 @@ void shouldSetClaimantDetailsInCasePartiesTab() { .allClaimants(claimants) .build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); + // When underTest.setCaseTabFields(pcsCase); @@ -87,6 +91,8 @@ void shouldSetDefendantOneDetailsInCasePartiesTab() { .allDefendants(defendants) .build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); + // When underTest.setCaseTabFields(pcsCase); @@ -141,6 +147,8 @@ void shouldSetMultipleDefendantDetailsInCasePartiesTab() { .allDefendants(defendants) .build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); + // When underTest.setCaseTabFields(pcsCase); @@ -186,6 +194,8 @@ void shouldSetDefaultDefendantNameInCasePartiesTabIfNameNotKnown() { .allDefendants(defendants) .build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); + // When underTest.setCaseTabFields(pcsCase); @@ -226,6 +236,8 @@ void shouldSetDefaultDefendantAddressToPropertyAddressIfNotKnown() { .propertyAddress(address) .build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); + // When underTest.setCaseTabFields(pcsCase); @@ -245,6 +257,7 @@ void shouldSetDefaultDefendantAddressToPropertyAddressIfNotKnown() { void shouldNotSetCasePartiesTabWithNoData() { // Given PCSCase pcsCase = PCSCase.builder().build(); + when(caseDetailsTabView.buildCaseDetailsTab(pcsCase)).thenReturn(CaseDetailsTab.builder().build()); // When underTest.setCaseTabFields(pcsCase); From 02d4bf6846daf1b3da3f656a2a65f112b20b082a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:35:23 +0100 Subject: [PATCH 004/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 69 +++- .../reform/pcs/ccd/view/CaseTabView.java | 62 +++- .../reform/pcs/ccd/view/ClaimGroundsView.java | 86 ++++- .../hmcts/reform/pcs/ccd/view/ClaimView.java | 2 +- ...sql => V095__add_claim_submitted_date.sql} | 0 .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 109 +++++++ .../ccd/service/DraftCaseJsonMergerTest.java | 1 + .../reform/pcs/ccd/view/CaseTabViewTest.java | 294 +++++++++++++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 124 ++++++++ .../reform/pcs/ccd/view/ClaimViewTest.java | 22 ++ 10 files changed, 752 insertions(+), 17 deletions(-) rename src/main/resources/db/migration/{V093__add_claim_submitted_date.sql => V095__add_claim_submitted_date.sql} (100%) 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 310e8d4ed6..f934d1a9b1 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 @@ -3,6 +3,7 @@ import lombok.AllArgsConstructor; 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; @@ -10,9 +11,12 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.SearchCriteria; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; 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; @@ -40,6 +44,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -85,7 +90,10 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); + Optional draftCaseData = getUnsubmittedCaseData(caseReference, state); + boolean hasUnsubmittedCaseData = draftCaseData.isPresent(); + + draftCaseData.ifPresent(draft -> setSummaryTabFromDraftData(pcsCase, draft)); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); @@ -98,12 +106,63 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private boolean caseHasUnsubmittedData(long caseReference, State state) { + private Optional getUnsubmittedCaseData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { - return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); - } else { - return false; + return draftCaseDataService.getUnsubmittedCaseData(caseReference, resumePossessionClaim); + } + + return Optional.empty(); + } + + private void setSummaryTabFromDraftData(PCSCase pcsCase, PCSCase draftCaseData) { + draftCaseData.setPropertyAddress(Optional.ofNullable(draftCaseData.getPropertyAddress()) + .orElse(pcsCase.getPropertyAddress())); + + if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { + draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); + } + + if (draftCaseData.getDefendant1() != null) { + draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); + } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { + draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + } + + List> draftGrounds = + claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) + ? pcsCase.getClaimGroundSummaries() + : draftGrounds); + + caseTabView.setCaseTabFields(draftCaseData); + pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + } + + private List> buildDefendants(PCSCase draftCaseData) { + List> defendants = new ArrayList<>(); + defendants.add(buildDefendant(draftCaseData.getDefendant1())); + + if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES + && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { + draftCaseData.getAdditionalDefendants().stream() + .map(ListValue::getValue) + .map(this::buildDefendant) + .forEach(defendants::add); } + + return defendants; + } + + private ListValue buildDefendant(DefendantDetails defendant) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(defendant.getNameKnown()) + .firstName(defendant.getFirstName()) + .lastName(defendant.getLastName()) + .addressKnown(defendant.getAddressKnown()) + .address(defendant.getCorrespondenceAddress()) + .build()) + .build(); } private PCSCase getSubmittedCase(long caseReference) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index fef3cec681..9b0b67b438 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,10 +4,32 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryAdditionalDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; import java.time.format.DateTimeFormatter; @@ -149,7 +171,8 @@ private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsC return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + private List> createAdditionalSummaryDefendantsDetails( + PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; } @@ -244,14 +267,21 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); - if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) + && (occupationLicenceDetailsWales == null + || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { return null; } - String agreementType = getAgreementType(tenancyLicenceDetails); - String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null - ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null + ? getAgreementType(tenancyLicenceDetails) + : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); + String agreementStartDate = tenancyLicenceDetails != null + && tenancyLicenceDetails.getTenancyLicenceDate() != null + ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) + : getOccupationLicenceStartDate(occupationLicenceDetailsWales); return TenancyTabDetails.builder() .agreementType(agreementType) @@ -267,6 +297,22 @@ private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); } + private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { + return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); + } + + return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); + } + + private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { + return null; + } + + return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); + } + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index 2a34d1a2d1..00137d4e13 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -1,14 +1,17 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; -import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; @@ -25,6 +28,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.util.YesOrNoConverter; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; @@ -40,6 +44,84 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { .ifPresent(mainClaim -> setClaimGroundFields(pcsCase, mainClaim)); } + public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { + List> summaries = new ArrayList<>(); + + Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { + if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { + addGrounds(summaries, selected.getRentArrearsGrounds().stream() + .map(this::mapAssuredRentArrearsGround) + .toList()); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { + addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() + .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) + .toList()); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { + addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() + .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) + .toList()); + } + }); + + Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + }); + + Optional.ofNullable(draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession()) + .map(IntroductoryDemotedOtherGroundsForPossession::getIntroductoryDemotedOrOtherGrounds) + .ifPresent(selected -> addGrounds(summaries, selected)); + + Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds()); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt()); + }); + + Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } + + private void addGrounds(List> summaries, + Set grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds)); + } + } + + private void addGrounds(List> summaries, + List grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder().label(ground.getLabel()).build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { + if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { + return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; + } + + return AssuredDiscretionaryGround.valueOf(ground.name()); + } + private void setClaimGroundFields(PCSCase pcsCase, ClaimEntity mainClaim) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java index 8c478fe9f6..3ca905669c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java @@ -43,7 +43,7 @@ private void mapBasicClaimFields(PCSCase pcsCase, ClaimEntity claim) { pcsCase.setLanguageUsed(claim.getLanguageUsed()); pcsCase.setWantToUploadDocuments(claim.getAdditionalDocsProvided()); pcsCase.setDateSubmitted(claim.getClaimSubmittedDate() == null ? null : claim.getClaimSubmittedDate() - .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); + .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); } private void mapComplexClaimFields(PCSCase pcsCase, ClaimEntity claim) { diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V095__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V093__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V095__add_claim_submitted_date.sql 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 8c5add37e2..66ec74b3a6 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 @@ -10,9 +10,13 @@ import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; 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; @@ -51,10 +55,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mock.Strictness.LENIENT; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.resumePossessionClaim; @ExtendWith(MockitoExtension.class) class PCSCaseViewTest { @@ -311,6 +318,10 @@ private static ListValue asListValue(UUID id, Party party) { return ListValue.builder().id(id.toString()).value(party).build(); } + private static ListValue listValue(T value) { + return ListValue.builder().value(value).build(); + } + private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { PartyEntity partyEntity = mock(PartyEntity.class); @@ -356,6 +367,104 @@ void shouldSetCaseFields() { verify(caseFieldsView).setCaseFields(pcsCase); } + @Test + void shouldSetSummaryTabFromDraftDataWhenUnsubmittedCaseDataExists() { + // Given + AddressEntity addressEntity = mock(AddressEntity.class); + when(pcsCaseEntity.getPropertyAddress()).thenReturn(addressEntity); + AddressUK propertyAddress = stubAddressEntityModelMapper(addressEntity); + + Party claimant = mock(Party.class); + UUID claimantId = UUID.randomUUID(); + ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(claimantClaimParty)); + + AddressUK defendantOneAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK defendantTwoAddress = AddressUK.builder().postCode("E2 2AA").build(); + PCSCase draftCaseData = PCSCase.builder() + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantOneAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of(listValue(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantTwoAddress) + .build()))) + .summaryTab(SummaryTab.builder().build()) + .build(); + List> draftGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Draft ground").build())); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(caseTabView).setCaseTabFields(draftCaseData); + assertThat(draftCaseData.getPropertyAddress()).isEqualTo(propertyAddress); + assertThat(draftCaseData.getAllClaimants()).containsExactly(asListValue(claimantId, claimant)); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getLastName()).isEqualTo("One"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getAddress()).isEqualTo(defendantOneAddress); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getLastName()).isEqualTo("Two"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getAddress()).isEqualTo(defendantTwoAddress); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(draftGrounds); + assertThat(pcsCase.getSummaryTab()).isSameAs(draftCaseData.getSummaryTab()); + assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); + } + + @Test + void shouldFallbackToSubmittedSummaryDataWhenDraftDataIsPartial() { + // Given + Party defendant = mock(Party.class); + UUID defendantId = UUID.randomUUID(); + ClaimPartyEntity defendantClaimParty = createClaimPartyEntity(defendant, defendantId, PartyRole.DEFENDANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(defendantClaimParty)); + + List> submittedGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Submitted ground").build())); + doAnswer(invocation -> { + PCSCase pcsCase = invocation.getArgument(0); + pcsCase.setClaimGroundSummaries(submittedGrounds); + return null; + }).when(claimGroundsView).setCaseFields(any(PCSCase.class), any(PcsCaseEntity.class)); + + PCSCase draftCaseData = PCSCase.builder() + .summaryTab(SummaryTab.builder().build()) + .build(); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + assertThat(draftCaseData.getAllDefendants()).containsExactly(asListValue(defendantId, defendant)); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(submittedGrounds); + } + + @Test + void shouldNotLoadUnsubmittedCaseDataWhenCaseIsNotAwaitingSubmission() { + // When + underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); + + // Then + verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); + } + @Test void shouldCallEnforcementOrderMediator() { // When diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java index 884a498aeb..d04a2d7749 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java @@ -92,6 +92,7 @@ void shouldKeepExistingFieldsWhenMerging() throws JsonProcessingException { "enforcementOrder.rawWarrantDetails.selectedDefendants", "enforcementOrder.rawWarrantDetails.vulnerablePeoplePresent", "enforcementOrder.rawWarrantDetails.vulnerableAdultsChildren", + "summaryTab", "casePartiesTab.claimantDetails.emailAddress", "casePartiesTab.claimantDetails.name", "casePartiesTab.claimantDetails.serviceAddress", diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c1afe68a2a..fd78e16c57 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -6,12 +6,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; - +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -255,4 +272,279 @@ void shouldNotSetCasePartiesTabWithNoData() { assertThat(pcsCase.getCasePartiesTab().getDefendantOneDetails()).isNull(); assertThat(pcsCase.getCasePartiesTab().getDefendantsDetails()).isNull(); } + + @Test + void shouldSetSummaryTabFields() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .dateSubmitted("11 May 2026, 5:02:31PM") + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Ground 1").build()), + listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("Licence details") + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .build()) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()) + .isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldNotSetEmptySummarySections() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + assertThat(summaryTab.getReasonsForPossession()).isNull(); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getAdditionalDefendants()).isNull(); + assertThat(summaryTab.getRentArrearsDetails()).isNull(); + assertThat(summaryTab.getTenancyDetails()).isNull(); + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + RentArrearsTabDetails rentArrearsDetails = pcsCase.getSummaryTab().getRentArrearsDetails(); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); + } + + @Test + void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + @Test + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .licenceStartDate(LocalDate.of(2025, 5, 12)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); + } + + @Test + void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .otherLicenceTypeDetails("Other Welsh licence") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 2d50a056f1..2662d53560 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,19 +12,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -203,6 +213,112 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { ); } + @Test + void shouldBuildClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 + )) + .build()) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + "Serious rent arrears (ground 8)", + "Rent arrears (ground 10)", + "Owner occupier (ground 1)", + "Breach of tenancy conditions (ground 12)", + "Holiday let (ground 3)", + "Deterioration in the condition of the property (ground 13)", + "Antisocial behaviour", + "Rent arrears or breach of the tenancy (ground 1)", + "Condition 1 of Section 84A of the Housing Act 1985", + "Property sold for redevelopment (ground 10A)", + "Adapted accommodation (ground 13)", + "Antisocial behaviour", + "Notice given under a landlord’s break clause (section 199)", + "Rent arrears (breach of contract) (section 157)", + "Redevelopment schemes (ground B)", + "Landlord’s notice in connection with end of fixed term given (section 186)", + "Antisocial behaviour (breach of contract) (section 157)", + "Reserve successors (ground G)" + ); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); + + // Then + assertThat(summaries).isEmpty(); + } + private static Stream claimGroundScenarios() { return Stream.of( argumentSet( @@ -237,6 +353,14 @@ private static Stream claimGroundScenarios() { "Antisocial behaviour", // Expected label false // Is rent arrears ground ), + argumentSet( + "Secure or flexible tenancy antisocial ground", + ClaimGroundCategory.SECURE_OR_FLEXIBLE_ANTISOCIAL, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.name(), + "Reason for antisocial ground", // Reason + "Condition 1 of Section 84A of the Housing Act 1985", // Expected label + false // Is rent arrears ground + ), argumentSet( "Secure or flexible tenancy discretionary ground", ClaimGroundCategory.SECURE_OR_FLEXIBLE_DISCRETIONARY, diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index b7932a75dc..5d596424c1 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -16,6 +16,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -80,6 +81,20 @@ void shouldMapBasicClaimFields() { assertThat(pcsCase.getWantToUploadDocuments()).isEqualTo(VerticalYesNo.YES); } + @ParameterizedTest + @MethodSource("claimSubmittedDateScenarios") + void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { + // Given + when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); + when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); + } + @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( @@ -139,6 +154,13 @@ void shouldNotPopulateAnyClaimFieldsWhenNoClaimsExist() { assertThat(pcsCase.getClaimantType()).isNull(); } + private static Stream claimSubmittedDateScenarios() { + return Stream.of( + Arguments.of(null, null), + Arguments.of(LocalDateTime.of(2026, 5, 11, 17, 2, 31), "11 May 2026, 5:02:31PM") + ); + } + private static Stream complexClaimFieldsScenarios() { return Stream.of( Arguments.of( From a3efdd6d249b931be846f63bdc781e3f74fcbc87 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:48:32 +0100 Subject: [PATCH 005/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 2 +- .../hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 2 +- 2 files changed, 2 insertions(+), 2 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 215551af09..6895d7927d 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 @@ -151,7 +151,7 @@ private void buildSummaryTab(ConfigBuilder builder) { .field("summaryTab_RentArrearsDetails") .label("Tenancy or occupation contract or licence", "summaryTab_TenancyDetails!=\"\"", - "## Tenancy or occupation contract or licence") + "## Tenancy, occupation contract or licence") .field("summaryTab_TenancyDetails") .label("Notice", "summaryTab_NoticeDetails!=\"\"", diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 27fb48eee8..baa5e6046f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -65,7 +65,7 @@ public class SummaryTab { private RentArrearsTabDetails rentArrearsDetails; @CCD( - label = "Tenancy or occupation contract or licence details" + label = "Tenancy, occupation contract or licence details" ) private TenancyTabDetails tenancyDetails; From ee09dce36c1300eb067ad1f1ca776f61e658b764 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 14:38:19 +0100 Subject: [PATCH 006/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V096__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V095__add_claim_submitted_date.sql => V096__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V095__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V095__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V096__add_claim_submitted_date.sql From 5859b05bcfd77274fd08a75287ed3d4ad2a428d2 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 11 May 2026 11:46:15 +0100 Subject: [PATCH 007/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 44 ++- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 7 + .../GroundsForPossessionTabDetails.java | 19 ++ .../domain/tabs/summary/NoticeTabDetails.java | 19 ++ .../ReasonsForPossessionTabDetails.java | 24 ++ .../tabs/summary/RentArrearsTabDetails.java | 39 +++ .../SummaryAdditionalDefendantTabDetails.java | 30 ++ .../summary/SummaryClaimantTabDetails.java | 19 ++ .../summary/SummaryDefendantTabDetails.java | 30 ++ .../ccd/domain/tabs/summary/SummaryTab.java | 78 ++++++ .../tabs/summary/TenancyTabDetails.java | 25 ++ .../reform/pcs/ccd/entity/ClaimEntity.java | 3 + .../reform/pcs/ccd/service/ClaimService.java | 2 + .../reform/pcs/ccd/view/CaseTabView.java | 265 +++++++++++++++++- .../hmcts/reform/pcs/ccd/view/ClaimView.java | 8 + .../V093__add_claim_submitted_date.sql | 1 + 16 files changed, 603 insertions(+), 10 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java create mode 100644 src/main/resources/db/migration/V093__add_claim_submitted_date.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 9fa96bc2dd..215551af09 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,10 +74,7 @@ public void configure(final ConfigBuilder builder) { .label("nextStepsMarkdownLabel", null, "${nextStepsMarkdown}") .field("nextStepsMarkdown", NEVER_SHOW); - builder.tab("summary", "Summary") - .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") - .field("confirmEvictionSummaryMarkup", NEVER_SHOW) - .field(PCSCase::getPropertyAddress); + buildSummaryTab(builder); builder.tab("CaseHistory", "History") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) @@ -123,4 +120,43 @@ private void buildCasePartiesTab(ConfigBuilder builder .field("casePartiesTab_DefendantOneDetails") .field("casePartiesTab_DefendantsDetails"); } + + private void buildSummaryTab(ConfigBuilder builder) { + builder.tab("summary", "Summary") + .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") + .field("confirmEvictionSummaryMarkup", NEVER_SHOW) + .label("Summary", null, "## Summary") + .field("summaryTab_RepossessedPropertyAddress") + .field("summaryTab_GroundsForPossession") + .field("summaryTab_ClaimSubmittedDate") + .field("summaryTab_ReasonsForPossession", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_PossessionReasonsSubmittedDate", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_ClaimSubmittedDate") + .label("Claimant details", + "summaryTab_ClaimantDetails!=\"\"", + "## Claimant details") + .field("summaryTab_ClaimantDetails") + .label("Defendant details", + "summaryTab_DefendantDetails!=\"\"", + "## Defendant details") + .field("summaryTab_DefendantDetails", + "summaryTab_DefendantDetails!=\"\"") + .field("summaryTab_AdditionalDefendants", + "summaryTab_AdditionalDefendants!=\"\"") + .label("Rent arrears", + "summaryTab_RentArrearsDetails!=\"\"", + "## Rent arrears") + .field("summaryTab_RentArrearsDetails") + .label("Tenancy or occupation contract or licence", + "summaryTab_TenancyDetails!=\"\"", + "## Tenancy or occupation contract or licence") + .field("summaryTab_TenancyDetails") + .label("Notice", + "summaryTab_NoticeDetails!=\"\"", + "## Notice") + .field("summaryTab_NoticeDetails", + "summaryTab_NoticeDetails!=\"\""); + } } 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 a3c0ba88da..72537e983e 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 @@ -39,6 +39,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; @@ -537,6 +538,8 @@ public class PCSCase { @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) private List> claimGroundSummaries; + private String dateSubmitted; + @CCD( access = DefendantAccess.class, searchable = false @@ -590,4 +593,8 @@ public class PCSCase { @JsonUnwrapped(prefix = "casePartiesTab_") @CCD private CasePartiesTab casePartiesTab; + + @JsonUnwrapped(prefix = "summaryTab_") + @CCD + private SummaryTab summaryTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java new file mode 100644 index 0000000000..0fb214c9e7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroundsForPossessionTabDetails { + + @CCD( + label = "Grounds" + ) + private String grounds; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java new file mode 100644 index 0000000000..e66f4960e0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class NoticeTabDetails { + + @CCD( + label = "Date notice was served" + ) + private String noticeServedDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java new file mode 100644 index 0000000000..90aaac2db4 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ReasonsForPossessionTabDetails { + + @CCD( + label = "Reasons for claiming possession under ground X" + ) + private String groundReasons; + + @CCD( + label = "Additional reasons for possession" + ) + private String additionalReasonsForPossession; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java new file mode 100644 index 0000000000..428462386b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java @@ -0,0 +1,39 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RentArrearsTabDetails { + + @CCD( + label = "Rent amount" + ) + private String rentAmount; + + @CCD( + label = "How rent is calculated" + ) + private String calculationFrequency; + + @CCD( + label = "Daily rate" + ) + private String dailyRate; + + @CCD( + label = "Rent arrears total at the time of claim issue" + ) + private String arrearsTotal; + + @CCD( + label = "Judgment requested for the outstanding arrears?" + ) + private String judgmentRequested; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java new file mode 100644 index 0000000000..8ecfbc2c1f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryAdditionalDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Additional defendant address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java new file mode 100644 index 0000000000..a9731b1739 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryClaimantTabDetails { + + @CCD( + label = "Claimant name" + ) + private String claimantName; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java new file mode 100644 index 0000000000..20647d131f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Defendant 1 address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java new file mode 100644 index 0000000000..27fb48eee8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) +public class SummaryTab { + + @CCD( + label = "Address of property to be repossessed" + ) + private AddressUK repossessedPropertyAddress; + + @CCD( + label = "Grounds for possession" + ) + private GroundsForPossessionTabDetails groundsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String claimSubmittedDate; + + @CCD( + label = "Reasons for possession" + ) + private ReasonsForPossessionTabDetails reasonsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String possessionReasonsSubmittedDate; + + @CCD( + label = "Claimant" + ) + private SummaryClaimantTabDetails claimantDetails; + + @CCD( + label = "Defendant 1" + ) + private SummaryDefendantTabDetails defendantDetails; + + @CCD( + label = "Additional defendant" + ) + private List> additionalDefendants; + + @CCD( + label = "Details of rent arrears" + ) + private RentArrearsTabDetails rentArrearsDetails; + + @CCD( + label = "Tenancy or occupation contract or licence details" + ) + private TenancyTabDetails tenancyDetails; + + @CCD( + label = "Notice details" + ) + private NoticeTabDetails noticeDetails; + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java new file mode 100644 index 0000000000..f140e76b89 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TenancyTabDetails { + + @CCD( + label = "Tenancy, occupation contract or licence agreement type" + ) + private String agreementType; + + @CCD( + label = "Tenancy, occupation contract or licence agreement start date", + showCondition = "agreementStartDate!=\"\"" + ) + private String agreementStartDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index 62ddea3395..f51371228a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,6 +34,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -136,6 +137,8 @@ public class ClaimEntity { @Enumerated(EnumType.STRING) private LanguageUsed languageUsed; + private LocalDateTime claimSubmittedDate; + @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "claim") @Builder.Default @JsonManagedReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java index 503271ab82..9e0ec7618e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.ClaimRepository; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.List; @Service @@ -65,6 +66,7 @@ public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { .additionalDocsProvided(pcsCase.getWantToUploadDocuments()) .genAppExpected(pcsCase.getApplicationWithClaim()) .languageUsed(pcsCase.getLanguageUsed()) + .claimSubmittedDate(LocalDateTime.now()) .build(); claimEntity.addClaimGrounds(claimGrounds); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index a8abad4594..fef3cec681 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,24 +4,29 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import java.math.BigDecimal; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + @Component public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; + private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); + SummaryTab summaryTab = buildSummaryTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); + pcsCase.setSummaryTab(summaryTab); } private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { @@ -81,4 +86,252 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p .lastName(defendantLastName) .build(); } + + private SummaryTab buildSummaryTab(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + + return SummaryTab.builder() + .repossessedPropertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossession(GroundsForPossessionTabDetails.builder() + .grounds(getGrounds(pcsCase)) + .build()) + .claimSubmittedDate(pcsCase.getDateSubmitted()) + .reasonsForPossession(reasonsForPossession) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : pcsCase.getDateSubmitted()) + .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) + .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .tenancyDetails(buildTenancyTabDetails(pcsCase)) + .noticeDetails(buildNoticeTabDetails(pcsCase)) + .build(); + } + + private SummaryClaimantTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return SummaryClaimantTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } + + private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryAdditionalDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private SummaryDefendantTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return null; + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + return null; + } + + return ReasonsForPossessionTabDetails.builder() + .groundReasons(additionalReasons.getHasReasons().getLabel()) + .additionalReasonsForPossession(additionalReasons.getReasons()) + .build(); + } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + + if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + return null; + } + + String agreementType = getAgreementType(tenancyLicenceDetails); + String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null + ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + + return TenancyTabDetails.builder() + .agreementType(agreementType) + .agreementStartDate(agreementStartDate) + .build(); + } + + private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { + if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { + return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); + } + + return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); + } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + + if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + return null; + } + + return NoticeTabDetails.builder() + .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .build(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + return pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .orElse(null); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java index 0efb99bd8b..8c478fe9f6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java @@ -10,9 +10,15 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; +import java.time.format.DateTimeFormatter; +import java.util.Locale; + @Component public class ClaimView { + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { if (!pcsCaseEntity.getClaims().isEmpty()) { ClaimEntity mainClaim = pcsCaseEntity.getClaims().getFirst(); @@ -36,6 +42,8 @@ private void mapBasicClaimFields(PCSCase pcsCase, ClaimEntity claim) { pcsCase.setApplicationWithClaim(claim.getGenAppExpected()); pcsCase.setLanguageUsed(claim.getLanguageUsed()); pcsCase.setWantToUploadDocuments(claim.getAdditionalDocsProvided()); + pcsCase.setDateSubmitted(claim.getClaimSubmittedDate() == null ? null : claim.getClaimSubmittedDate() + .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); } private void mapComplexClaimFields(PCSCase pcsCase, ClaimEntity claim) { diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql new file mode 100644 index 0000000000..63b1fa3595 --- /dev/null +++ b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql @@ -0,0 +1 @@ +ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; From 1372eb48b12c2147288b3188148400af8e04aab1 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:35:23 +0100 Subject: [PATCH 008/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 69 +++- .../reform/pcs/ccd/view/CaseTabView.java | 62 +++- .../reform/pcs/ccd/view/ClaimGroundsView.java | 86 ++++- .../hmcts/reform/pcs/ccd/view/ClaimView.java | 2 +- ...sql => V095__add_claim_submitted_date.sql} | 0 .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 109 +++++++ .../ccd/service/DraftCaseJsonMergerTest.java | 1 + .../reform/pcs/ccd/view/CaseTabViewTest.java | 294 +++++++++++++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 124 ++++++++ .../reform/pcs/ccd/view/ClaimViewTest.java | 22 ++ 10 files changed, 752 insertions(+), 17 deletions(-) rename src/main/resources/db/migration/{V093__add_claim_submitted_date.sql => V095__add_claim_submitted_date.sql} (100%) 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 310e8d4ed6..f934d1a9b1 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 @@ -3,6 +3,7 @@ import lombok.AllArgsConstructor; 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; @@ -10,9 +11,12 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.SearchCriteria; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; 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; @@ -40,6 +44,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -85,7 +90,10 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); + Optional draftCaseData = getUnsubmittedCaseData(caseReference, state); + boolean hasUnsubmittedCaseData = draftCaseData.isPresent(); + + draftCaseData.ifPresent(draft -> setSummaryTabFromDraftData(pcsCase, draft)); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); @@ -98,12 +106,63 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private boolean caseHasUnsubmittedData(long caseReference, State state) { + private Optional getUnsubmittedCaseData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { - return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); - } else { - return false; + return draftCaseDataService.getUnsubmittedCaseData(caseReference, resumePossessionClaim); + } + + return Optional.empty(); + } + + private void setSummaryTabFromDraftData(PCSCase pcsCase, PCSCase draftCaseData) { + draftCaseData.setPropertyAddress(Optional.ofNullable(draftCaseData.getPropertyAddress()) + .orElse(pcsCase.getPropertyAddress())); + + if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { + draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); + } + + if (draftCaseData.getDefendant1() != null) { + draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); + } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { + draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + } + + List> draftGrounds = + claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) + ? pcsCase.getClaimGroundSummaries() + : draftGrounds); + + caseTabView.setCaseTabFields(draftCaseData); + pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + } + + private List> buildDefendants(PCSCase draftCaseData) { + List> defendants = new ArrayList<>(); + defendants.add(buildDefendant(draftCaseData.getDefendant1())); + + if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES + && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { + draftCaseData.getAdditionalDefendants().stream() + .map(ListValue::getValue) + .map(this::buildDefendant) + .forEach(defendants::add); } + + return defendants; + } + + private ListValue buildDefendant(DefendantDetails defendant) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(defendant.getNameKnown()) + .firstName(defendant.getFirstName()) + .lastName(defendant.getLastName()) + .addressKnown(defendant.getAddressKnown()) + .address(defendant.getCorrespondenceAddress()) + .build()) + .build(); } private PCSCase getSubmittedCase(long caseReference) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index fef3cec681..9b0b67b438 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,10 +4,32 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryAdditionalDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; import java.time.format.DateTimeFormatter; @@ -149,7 +171,8 @@ private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsC return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + private List> createAdditionalSummaryDefendantsDetails( + PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; } @@ -244,14 +267,21 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); - if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) + && (occupationLicenceDetailsWales == null + || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { return null; } - String agreementType = getAgreementType(tenancyLicenceDetails); - String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null - ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null + ? getAgreementType(tenancyLicenceDetails) + : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); + String agreementStartDate = tenancyLicenceDetails != null + && tenancyLicenceDetails.getTenancyLicenceDate() != null + ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) + : getOccupationLicenceStartDate(occupationLicenceDetailsWales); return TenancyTabDetails.builder() .agreementType(agreementType) @@ -267,6 +297,22 @@ private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); } + private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { + return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); + } + + return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); + } + + private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { + return null; + } + + return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); + } + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index 2a34d1a2d1..00137d4e13 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -1,14 +1,17 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; -import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; @@ -25,6 +28,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.util.YesOrNoConverter; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; @@ -40,6 +44,84 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { .ifPresent(mainClaim -> setClaimGroundFields(pcsCase, mainClaim)); } + public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { + List> summaries = new ArrayList<>(); + + Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { + if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { + addGrounds(summaries, selected.getRentArrearsGrounds().stream() + .map(this::mapAssuredRentArrearsGround) + .toList()); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { + addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() + .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) + .toList()); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { + addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() + .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) + .toList()); + } + }); + + Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + }); + + Optional.ofNullable(draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession()) + .map(IntroductoryDemotedOtherGroundsForPossession::getIntroductoryDemotedOrOtherGrounds) + .ifPresent(selected -> addGrounds(summaries, selected)); + + Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds()); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt()); + }); + + Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } + + private void addGrounds(List> summaries, + Set grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds)); + } + } + + private void addGrounds(List> summaries, + List grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder().label(ground.getLabel()).build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { + if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { + return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; + } + + return AssuredDiscretionaryGround.valueOf(ground.name()); + } + private void setClaimGroundFields(PCSCase pcsCase, ClaimEntity mainClaim) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java index 8c478fe9f6..3ca905669c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java @@ -43,7 +43,7 @@ private void mapBasicClaimFields(PCSCase pcsCase, ClaimEntity claim) { pcsCase.setLanguageUsed(claim.getLanguageUsed()); pcsCase.setWantToUploadDocuments(claim.getAdditionalDocsProvided()); pcsCase.setDateSubmitted(claim.getClaimSubmittedDate() == null ? null : claim.getClaimSubmittedDate() - .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); + .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); } private void mapComplexClaimFields(PCSCase pcsCase, ClaimEntity claim) { diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V095__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V093__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V095__add_claim_submitted_date.sql 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 8c5add37e2..66ec74b3a6 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 @@ -10,9 +10,13 @@ import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; 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; @@ -51,10 +55,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mock.Strictness.LENIENT; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.resumePossessionClaim; @ExtendWith(MockitoExtension.class) class PCSCaseViewTest { @@ -311,6 +318,10 @@ private static ListValue asListValue(UUID id, Party party) { return ListValue.builder().id(id.toString()).value(party).build(); } + private static ListValue listValue(T value) { + return ListValue.builder().value(value).build(); + } + private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { PartyEntity partyEntity = mock(PartyEntity.class); @@ -356,6 +367,104 @@ void shouldSetCaseFields() { verify(caseFieldsView).setCaseFields(pcsCase); } + @Test + void shouldSetSummaryTabFromDraftDataWhenUnsubmittedCaseDataExists() { + // Given + AddressEntity addressEntity = mock(AddressEntity.class); + when(pcsCaseEntity.getPropertyAddress()).thenReturn(addressEntity); + AddressUK propertyAddress = stubAddressEntityModelMapper(addressEntity); + + Party claimant = mock(Party.class); + UUID claimantId = UUID.randomUUID(); + ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(claimantClaimParty)); + + AddressUK defendantOneAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK defendantTwoAddress = AddressUK.builder().postCode("E2 2AA").build(); + PCSCase draftCaseData = PCSCase.builder() + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantOneAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of(listValue(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantTwoAddress) + .build()))) + .summaryTab(SummaryTab.builder().build()) + .build(); + List> draftGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Draft ground").build())); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(caseTabView).setCaseTabFields(draftCaseData); + assertThat(draftCaseData.getPropertyAddress()).isEqualTo(propertyAddress); + assertThat(draftCaseData.getAllClaimants()).containsExactly(asListValue(claimantId, claimant)); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getLastName()).isEqualTo("One"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getAddress()).isEqualTo(defendantOneAddress); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getLastName()).isEqualTo("Two"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getAddress()).isEqualTo(defendantTwoAddress); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(draftGrounds); + assertThat(pcsCase.getSummaryTab()).isSameAs(draftCaseData.getSummaryTab()); + assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); + } + + @Test + void shouldFallbackToSubmittedSummaryDataWhenDraftDataIsPartial() { + // Given + Party defendant = mock(Party.class); + UUID defendantId = UUID.randomUUID(); + ClaimPartyEntity defendantClaimParty = createClaimPartyEntity(defendant, defendantId, PartyRole.DEFENDANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(defendantClaimParty)); + + List> submittedGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Submitted ground").build())); + doAnswer(invocation -> { + PCSCase pcsCase = invocation.getArgument(0); + pcsCase.setClaimGroundSummaries(submittedGrounds); + return null; + }).when(claimGroundsView).setCaseFields(any(PCSCase.class), any(PcsCaseEntity.class)); + + PCSCase draftCaseData = PCSCase.builder() + .summaryTab(SummaryTab.builder().build()) + .build(); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + assertThat(draftCaseData.getAllDefendants()).containsExactly(asListValue(defendantId, defendant)); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(submittedGrounds); + } + + @Test + void shouldNotLoadUnsubmittedCaseDataWhenCaseIsNotAwaitingSubmission() { + // When + underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); + + // Then + verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); + } + @Test void shouldCallEnforcementOrderMediator() { // When diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java index 884a498aeb..d04a2d7749 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java @@ -92,6 +92,7 @@ void shouldKeepExistingFieldsWhenMerging() throws JsonProcessingException { "enforcementOrder.rawWarrantDetails.selectedDefendants", "enforcementOrder.rawWarrantDetails.vulnerablePeoplePresent", "enforcementOrder.rawWarrantDetails.vulnerableAdultsChildren", + "summaryTab", "casePartiesTab.claimantDetails.emailAddress", "casePartiesTab.claimantDetails.name", "casePartiesTab.claimantDetails.serviceAddress", diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c1afe68a2a..fd78e16c57 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -6,12 +6,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; - +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -255,4 +272,279 @@ void shouldNotSetCasePartiesTabWithNoData() { assertThat(pcsCase.getCasePartiesTab().getDefendantOneDetails()).isNull(); assertThat(pcsCase.getCasePartiesTab().getDefendantsDetails()).isNull(); } + + @Test + void shouldSetSummaryTabFields() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .dateSubmitted("11 May 2026, 5:02:31PM") + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Ground 1").build()), + listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("Licence details") + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .build()) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()) + .isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldNotSetEmptySummarySections() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + assertThat(summaryTab.getReasonsForPossession()).isNull(); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getAdditionalDefendants()).isNull(); + assertThat(summaryTab.getRentArrearsDetails()).isNull(); + assertThat(summaryTab.getTenancyDetails()).isNull(); + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + RentArrearsTabDetails rentArrearsDetails = pcsCase.getSummaryTab().getRentArrearsDetails(); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); + } + + @Test + void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + @Test + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .licenceStartDate(LocalDate.of(2025, 5, 12)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); + } + + @Test + void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .otherLicenceTypeDetails("Other Welsh licence") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 2d50a056f1..2662d53560 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,19 +12,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -203,6 +213,112 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { ); } + @Test + void shouldBuildClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 + )) + .build()) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + "Serious rent arrears (ground 8)", + "Rent arrears (ground 10)", + "Owner occupier (ground 1)", + "Breach of tenancy conditions (ground 12)", + "Holiday let (ground 3)", + "Deterioration in the condition of the property (ground 13)", + "Antisocial behaviour", + "Rent arrears or breach of the tenancy (ground 1)", + "Condition 1 of Section 84A of the Housing Act 1985", + "Property sold for redevelopment (ground 10A)", + "Adapted accommodation (ground 13)", + "Antisocial behaviour", + "Notice given under a landlord’s break clause (section 199)", + "Rent arrears (breach of contract) (section 157)", + "Redevelopment schemes (ground B)", + "Landlord’s notice in connection with end of fixed term given (section 186)", + "Antisocial behaviour (breach of contract) (section 157)", + "Reserve successors (ground G)" + ); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); + + // Then + assertThat(summaries).isEmpty(); + } + private static Stream claimGroundScenarios() { return Stream.of( argumentSet( @@ -237,6 +353,14 @@ private static Stream claimGroundScenarios() { "Antisocial behaviour", // Expected label false // Is rent arrears ground ), + argumentSet( + "Secure or flexible tenancy antisocial ground", + ClaimGroundCategory.SECURE_OR_FLEXIBLE_ANTISOCIAL, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.name(), + "Reason for antisocial ground", // Reason + "Condition 1 of Section 84A of the Housing Act 1985", // Expected label + false // Is rent arrears ground + ), argumentSet( "Secure or flexible tenancy discretionary ground", ClaimGroundCategory.SECURE_OR_FLEXIBLE_DISCRETIONARY, diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index b7932a75dc..5d596424c1 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -16,6 +16,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -80,6 +81,20 @@ void shouldMapBasicClaimFields() { assertThat(pcsCase.getWantToUploadDocuments()).isEqualTo(VerticalYesNo.YES); } + @ParameterizedTest + @MethodSource("claimSubmittedDateScenarios") + void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { + // Given + when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); + when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); + } + @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( @@ -139,6 +154,13 @@ void shouldNotPopulateAnyClaimFieldsWhenNoClaimsExist() { assertThat(pcsCase.getClaimantType()).isNull(); } + private static Stream claimSubmittedDateScenarios() { + return Stream.of( + Arguments.of(null, null), + Arguments.of(LocalDateTime.of(2026, 5, 11, 17, 2, 31), "11 May 2026, 5:02:31PM") + ); + } + private static Stream complexClaimFieldsScenarios() { return Stream.of( Arguments.of( From a483a0e1fc23bd450c075de8ad9abf5a8bb3da29 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:48:32 +0100 Subject: [PATCH 009/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 2 +- .../hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 2 +- 2 files changed, 2 insertions(+), 2 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 215551af09..6895d7927d 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 @@ -151,7 +151,7 @@ private void buildSummaryTab(ConfigBuilder builder) { .field("summaryTab_RentArrearsDetails") .label("Tenancy or occupation contract or licence", "summaryTab_TenancyDetails!=\"\"", - "## Tenancy or occupation contract or licence") + "## Tenancy, occupation contract or licence") .field("summaryTab_TenancyDetails") .label("Notice", "summaryTab_NoticeDetails!=\"\"", diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 27fb48eee8..baa5e6046f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -65,7 +65,7 @@ public class SummaryTab { private RentArrearsTabDetails rentArrearsDetails; @CCD( - label = "Tenancy or occupation contract or licence details" + label = "Tenancy, occupation contract or licence details" ) private TenancyTabDetails tenancyDetails; From 2bd1c11f9a69f48668a946ccbf9d9de5f41f8566 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 14:38:19 +0100 Subject: [PATCH 010/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V096__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V095__add_claim_submitted_date.sql => V096__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V095__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V095__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V096__add_claim_submitted_date.sql From 4c0e1e555c7002adfd13325f57cf651c2f5879c7 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 12 May 2026 15:21:42 +0100 Subject: [PATCH 011/138] HDPI-2983: add more claim details to CaseDetailsTabView --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 3 + .../domain/tabs/ActionsTakenTabDetails.java | 1 + .../pcs/ccd/domain/tabs/ClaimTabDetails.java | 4 +- .../pcs/ccd/domain/tabs/NoticeTabDetails.java | 2 + .../domain/tabs/TenancyLicenceTabDetails.java | 4 +- .../pcs/ccd/view/CaseDetailsTabView.java | 111 ++++++++++++++++-- 6 files changed, 110 insertions(+), 15 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 a00179bde2..a251c0aa92 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 @@ -132,6 +132,9 @@ private void buildCaseDetailsTab(ConfigBuilder builder .field("caseDetailsTab_ClaimDetails") .field("caseDetailsTab_PropertyAddress") .field("caseDetailsTab_TenancyLicenceDetails") + .field("caseDetailsTab_NoticeDetails") + .field("caseDetailsTab_ActionsTakenDetails") + .field("caseDetailsTab_RentArrearsDetails") .label("Claimant Details", null, "### Claimant Details") .label("Defendant Details", null, "### Defendant Details") .label( diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java index ffa6148265..c38b21fdad 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @Builder @Data diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java index 74d40ed032..574285b669 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java @@ -16,10 +16,10 @@ public class ClaimTabDetails { @CCD( label = "Claimant type" ) - private ClaimantType claimantType; + private String claimantType; @CCD( label = "Claim against trespassers?" ) - private VerticalYesNo trespassClaim; + private String trespassClaim; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java index 19e3fcd54a..b125c94512 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java @@ -7,6 +7,8 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.Document; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java index ab7db1621a..55cbb25f00 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java @@ -21,7 +21,7 @@ public class TenancyLicenceTabDetails { @CCD( label = "Tenancy, occupation contract or licence agreement type" ) - private TenancyLicenceType typeOfTenancyLicence; + private String typeOfTenancyLicence; @CCD( label = "Tenancy, occupation contract or licence start date" @@ -31,7 +31,7 @@ public class TenancyLicenceTabDetails { @CCD( label = "Do you have a copy of the tenancy or licence agreement?" ) - private VerticalYesNo hasCopyOfTenancyLicence; + private String hasCopyOfTenancyLicence; @CCD( label = "Details of why you do not have a copy" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 5a76100c06..d10b2fdad3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -2,13 +2,21 @@ import org.springframework.stereotype.Component; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ActionsTakenTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.TenancyLicenceTabDetails; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @Component @@ -21,22 +29,27 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); GroundsForPossessionTabDetails groundsForPossessionTabDetails = buildGroundsForPossessionTabDetails(pcsCase); TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase); + NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); + ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); return CaseDetailsTab.builder() .claimDetails(claimTabDetails) .propertyAddress(pcsCase.getPropertyAddress()) .groundsForPossessionDetails(groundsForPossessionTabDetails) .tenancyLicenceDetails(tenancyLicenceTabDetails) + .noticeDetails(noticeTabDetails) + .actionsTakenDetails(actionsTakenTabDetails) .build(); } private ClaimTabDetails buildClaimTabDetails(PCSCase pcsCase) { - ClaimantType claimantType = pcsCase.getClaimantType() != null - ? ClaimantType.fromName(pcsCase.getClaimantType().getValueCode()) : null; + String claimantType = pcsCase.getClaimantType() != null + ? ClaimantType.fromName(pcsCase.getClaimantType().getValueCode()).getLabel() : NO_ANSWER; + VerticalYesNo trespassClaim = pcsCase.getClaimAgainstTrespassers(); return ClaimTabDetails.builder() .claimantType(claimantType) - .trespassClaim(pcsCase.getClaimAgainstTrespassers()) + .trespassClaim(trespassClaim != null ? trespassClaim.getLabel() : NO_ANSWER) .build(); } @@ -49,20 +62,96 @@ private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCa private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); if (tenancyLicenceDetails == null) { - return null; + return TenancyLicenceTabDetails.builder() + .typeOfTenancyLicence(NO_ANSWER) + .tenancyLicenceDate(NO_ANSWER) + .hasCopyOfTenancyLicence(NO_ANSWER) + .build(); } - //1 Jan 2026 not 2026-2-1 - - String tenancyDate = tenancyLicenceDetails.getTenancyLicenceDate() != null ? - tenancyLicenceDetails.getTenancyLicenceDate().format(pattern): NO_ANSWER; + TenancyLicenceType tenancyType = tenancyLicenceDetails.getTypeOfTenancyLicence(); + LocalDate tenancyDate = tenancyLicenceDetails.getTenancyLicenceDate(); + VerticalYesNo hasTenancyLicence = tenancyLicenceDetails.getHasCopyOfTenancyLicence(); return TenancyLicenceTabDetails.builder() - .typeOfTenancyLicence(tenancyLicenceDetails.getTypeOfTenancyLicence()) - .tenancyLicenceDate(tenancyDate) - .hasCopyOfTenancyLicence(tenancyLicenceDetails.getHasCopyOfTenancyLicence()) + .typeOfTenancyLicence(tenancyType != null ? tenancyType.getLabel() : NO_ANSWER) + .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(pattern) : NO_ANSWER) + .hasCopyOfTenancyLicence(hasTenancyLicence != null ? hasTenancyLicence.getLabel() : NO_ANSWER) .tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments()) .reasonsForNoTenancyLicenceDocuments(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments()) .build(); } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + if (pcsCase.getNoticeServed() == null) { + return NoticeTabDetails.builder() + .noticeServed(NO_ANSWER) + .noticeMethod(NO_ANSWER) + .noticeDate(NO_ANSWER) + .build(); + } + + NoticeTabDetails noticeTabDetails = NoticeTabDetails.builder() + .noticeServed(pcsCase.getNoticeServed().getValue()) + .noticeMethod(NO_ANSWER) + .noticeDate(NO_ANSWER) + .build(); + + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + if (noticeTabDetails != null) { + NoticeServiceMethod method = noticeServedDetails.getNoticeServiceMethod(); + noticeTabDetails.setNoticeDocuments(noticeServedDetails.getNoticeDocuments()); + + if (method != null) { + noticeTabDetails.setNoticeMethod(method.getLabel()); + switch (method) { + case FIRST_CLASS_POST -> { + LocalDate date = noticeServedDetails.getNoticePostedDate(); + noticeTabDetails.setNoticeDate(date != null ? date.format(pattern) : NO_ANSWER); + } + case DELIVERED_PERMITTED_PLACE -> { + LocalDate date = noticeServedDetails.getNoticeDeliveredDate(); + noticeTabDetails.setNoticeDate(date != null ? date.format(pattern) : NO_ANSWER); + } + case PERSONALLY_HANDED -> { + LocalDateTime dateTime = noticeServedDetails.getNoticeHandedOverDateTime(); + String name = noticeTabDetails.getNoticePersonName(); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticePersonName(name != null ? name : NO_ANSWER); + } + case EMAIL -> { + LocalDateTime dateTime = noticeServedDetails.getNoticeEmailSentDateTime(); + String emailAddress = noticeServedDetails.getNoticeEmailAddress(); + noticeTabDetails.setNoticeDate( dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeEmailAddress(emailAddress != null ? emailAddress : NO_ANSWER); + } + case OTHER_ELECTRONIC -> { + LocalDateTime dateTime = noticeServedDetails.getNoticeOtherElectronicDateTime(); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + } + case OTHER -> { + LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); + String explanation = noticeTabDetails.getNoticeOtherExplanation(); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeOtherExplanation(explanation != null ? explanation : NO_ANSWER); + } + }; + } + } + + return noticeTabDetails; + } + + private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { + VerticalYesNo preactionProtocol = pcsCase.getPreActionProtocolCompleted(); + + VerticalYesNo mediationAttempted = pcsCase.getMediationAttempted(); + VerticalYesNo settlementAttempted = pcsCase.getSettlementAttempted(); + + return ActionsTakenTabDetails.builder() + .preactionProtocolFollowed(preactionProtocol != null ? preactionProtocol.getLabel() :NO_ANSWER) + .mediationAttempted(mediationAttempted != null ? mediationAttempted.getLabel() : NO_ANSWER) + .settlementAttempted(settlementAttempted != null ? settlementAttempted.getLabel() : NO_ANSWER) + .build(); + } } From 62808321ed37ab1e1fb1953cfbcedf5a738e0a9a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 15:31:03 +0100 Subject: [PATCH 012/138] HDPI-2978: Build Case Summary tab --- .../hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index baa5e6046f..b7a5dc47f8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -73,6 +73,4 @@ public class SummaryTab { label = "Notice details" ) private NoticeTabDetails noticeDetails; - - } From 694c7fe95dece9f7c25b5410bb07296b0090e6ef Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 15:36:36 +0100 Subject: [PATCH 013/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index b7a5dc47f8..d3ec0e4af5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -73,4 +73,5 @@ public class SummaryTab { label = "Notice details" ) private NoticeTabDetails noticeDetails; + } From 35238c1b352deab71b885d005fdfbd2d7d70f825 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 12 May 2026 22:12:15 +0100 Subject: [PATCH 014/138] HDPI-2983: move details tab classes into separate directory and build view for grounds of possession --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 + .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 2 +- ...AssuredAdditionalDiscretionaryGrounds.java | 24 +- .../AssuredAdditionalMandatoryGrounds.java | 24 +- .../grounds/AssuredRentArrearsGround.java | 12 +- .../tabs/ReasonsForPossessionTabDetails.java | 4 - .../{ => details}/ActionsTakenTabDetails.java | 3 +- ...itionalDefendantInformationTabDetails.java | 2 +- .../{ => details}/ApplicationsTabDetails.java | 2 +- .../tabs/{ => details}/CaseDetailsTab.java | 3 +- .../tabs/{ => details}/ClaimTabDetails.java | 4 +- .../ClaimantCircumstancesTabDetails.java | 2 +- .../ClaimantInformationTabDetails.java | 2 +- .../DefendantCircumstanceTabDetails.java | 2 +- .../DefendantInformationTabDetails.java | 2 +- .../DemotionOfTenancyTabDetails.java | 2 +- .../GroundsForPossessionTabDetails.java | 11 +- .../tabs/{ => details}/NoticeTabDetails.java | 4 +- .../ReasonsForPossessionTabDetails.java | 4 + .../{ => details}/RentArrearsTabDetails.java | 2 +- .../SuspensionOfRightToBuyTabDetails.java | 2 +- .../TenancyLicenceTabDetails.java | 4 +- ...lesseeOrMortgageInformationTabDetails.java | 2 +- .../pcs/ccd/view/CaseDetailsTabView.java | 222 ++++++++++++++++-- .../reform/pcs/ccd/view/CaseTabView.java | 2 +- .../reform/pcs/ccd/view/CaseTabViewTest.java | 2 +- 26 files changed, 275 insertions(+), 71 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/ActionsTakenTabDetails.java (86%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/AdditionalDefendantInformationTabDetails.java (90%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/ApplicationsTabDetails.java (87%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/CaseDetailsTab.java (95%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/ClaimTabDetails.java (71%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/ClaimantCircumstancesTabDetails.java (90%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/ClaimantInformationTabDetails.java (85%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/DefendantCircumstanceTabDetails.java (90%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/DefendantInformationTabDetails.java (83%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/DemotionOfTenancyTabDetails.java (93%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/GroundsForPossessionTabDetails.java (69%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/NoticeTabDetails.java (89%) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/RentArrearsTabDetails.java (95%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/SuspensionOfRightToBuyTabDetails.java (89%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/TenancyLicenceTabDetails.java (85%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{ => details}/UnderlesseeOrMortgageInformationTabDetails.java (88%) 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 a251c0aa92..22291d8b46 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 @@ -131,6 +131,7 @@ private void buildCaseDetailsTab(ConfigBuilder builder .label("Case details", null, "### Case details") .field("caseDetailsTab_ClaimDetails") .field("caseDetailsTab_PropertyAddress") + .field("caseDetailsTab_GroundsForPossessionDetails") .field("caseDetailsTab_TenancyLicenceDetails") .field("caseDetailsTab_NoticeDetails") .field("caseDetailsTab_ActionsTakenDetails") 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 11d4a57bb1..d3b282f895 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 @@ -37,7 +37,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.model.NoRentArrearsReasonForGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java index a93e7bdb0f..4a15b4f35e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java @@ -1,38 +1,44 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; +import lombok.AllArgsConstructor; +import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Additional-only discretionary grounds for Assured tenancy (excludes grounds 10 and 11). */ +@AllArgsConstructor +@Getter public enum AssuredAdditionalDiscretionaryGrounds { @CCD(label = "Suitable alternative accommodation (ground 9)") - ALTERNATIVE_ACCOMMODATION_GROUND9, + ALTERNATIVE_ACCOMMODATION_GROUND9("Suitable alternative accommodation (ground 9)"), @CCD(label = "Breach of tenancy conditions (ground 12)") - BREACH_TENANCY_GROUND12, + BREACH_TENANCY_GROUND12("Breach of tenancy conditions (ground 12)"), @CCD(label = "Deterioration in the condition of the property (ground 13)") - DETERIORATION_PROPERTY_GROUND13, + DETERIORATION_PROPERTY_GROUND13("Deterioration in the condition of the property (ground 13)"), @CCD(label = "Nuisance, annoyance, illegal, or immoral use of the property (ground 14)") - NUISANCE_ANNOYANCE_GROUND14, + NUISANCE_ANNOYANCE_GROUND14("Nuisance, annoyance, illegal, or immoral use of the property (ground 14)"), @CCD(label = "Domestic violence (ground 14A)") - DOMESTIC_VIOLENCE_GROUND14A, + DOMESTIC_VIOLENCE_GROUND14A("Domestic violence (ground 14A)"), @CCD(label = "Offence during a riot (ground 14ZA)") - OFFENCE_RIOT_GROUND14ZA, + OFFENCE_RIOT_GROUND14ZA("Offence during a riot (ground 14ZA)"), @CCD(label = "Deterioration of furniture (ground 15)") - DETERIORATION_FURNITURE_GROUND15, + DETERIORATION_FURNITURE_GROUND15("Deterioration of furniture (ground 15)"), @CCD(label = "Employee of the landlord (ground 16)") - EMPLOYEE_LANDLORD_GROUND16, + EMPLOYEE_LANDLORD_GROUND16("Employee of the landlord (ground 16)"), @CCD(label = "Tenancy obtained by false statement (ground 17)") - FALSE_STATEMENT_GROUND17; + FALSE_STATEMENT_GROUND17("Tenancy obtained by false statement (ground 17)"); + + private final String label; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java index f6c0b904e5..52a57fd9db 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java @@ -1,38 +1,44 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; +import lombok.AllArgsConstructor; +import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Additional-only mandatory grounds for Assured tenancy (excludes ground 8). */ +@AllArgsConstructor +@Getter public enum AssuredAdditionalMandatoryGrounds { @CCD(label = "Owner occupier (ground 1)") - OWNER_OCCUPIER_GROUND1, + OWNER_OCCUPIER_GROUND1("Owner occupier (ground 1)"), @CCD(label = "Repossession by the landlord’s mortgage lender (ground 2)") - REPOSSESSION_GROUND2, + REPOSSESSION_GROUND2("Repossession by the landlord’s mortgage lender (ground 2)"), @CCD(label = "Holiday let (ground 3)") - HOLIDAY_LET_GROUND3, + HOLIDAY_LET_GROUND3("Holiday let (ground 3)"), @CCD(label = "Student let (ground 4)") - STUDENT_LET_GROUND4, + STUDENT_LET_GROUND4("Student let (ground 4)"), @CCD(label = "Property required for minister of religion (ground 5)") - MINISTER_RELIGION_GROUND5, + MINISTER_RELIGION_GROUND5("Property required for minister of religion (ground 5)"), @CCD(label = "Property required for redevelopment (ground 6)") - REDEVELOPMENT_GROUND6, + REDEVELOPMENT_GROUND6("Property required for redevelopment (ground 6)"), @CCD(label = "Death of the tenant (ground 7)") - DEATH_OF_TENANT_GROUND7, + DEATH_OF_TENANT_GROUND7("Death of the tenant (ground 7)"), @CCD(label = "Antisocial behaviour (ground 7A)") - ANTISOCIAL_BEHAVIOUR_GROUND7A, + ANTISOCIAL_BEHAVIOUR_GROUND7A("Antisocial behaviour (ground 7A)"), @CCD(label = "Tenant does not have a right to rent (ground 7B)") - NO_RIGHT_TO_RENT_GROUND7B; + NO_RIGHT_TO_RENT_GROUND7B("Tenant does not have a right to rent (ground 7B)"); + + private final String label; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java index da948fa506..2857e186ae 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java @@ -1,18 +1,24 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; +import lombok.AllArgsConstructor; +import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Enum representing rent arrears grounds for possession claims. */ +@AllArgsConstructor +@Getter public enum AssuredRentArrearsGround { @CCD(label = "Serious rent arrears (ground 8)") - SERIOUS_RENT_ARREARS_GROUND8, + SERIOUS_RENT_ARREARS_GROUND8("Serious rent arrears (ground 8)"), @CCD(label = "Rent arrears (ground 10)") - RENT_ARREARS_GROUND10, + RENT_ARREARS_GROUND10("Rent arrears (ground 10)"), @CCD(label = "Persistent delay in paying rent (ground 11)") - PERSISTENT_DELAY_GROUND11; + PERSISTENT_DELAY_GROUND11("Persistent delay in paying rent (ground 11)"); + + private final String label; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java deleted file mode 100644 index a6e786fe68..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ReasonsForPossessionTabDetails.java +++ /dev/null @@ -1,4 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; - -public class ReasonsForPossessionTabDetails { -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java similarity index 86% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java index c38b21fdad..7f2d7d9359 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ActionsTakenTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java @@ -1,11 +1,10 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @Builder @Data diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java similarity index 90% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java index c62b6aaba9..287858aef2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/AdditionalDefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java similarity index 87% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java index 9dbdd2e05d..60a04e070b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ApplicationsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java similarity index 95% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index cfb2eca714..b9c2d066ed 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -9,6 +9,7 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java similarity index 71% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java index 574285b669..e9a34c7775 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java @@ -1,12 +1,10 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @Builder @Data diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java similarity index 90% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java index 0e404d61a2..96e382fc01 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantCircumstancesTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java similarity index 85% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java index fc5cc436b6..3b8094d854 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/ClaimantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java similarity index 90% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java index 29e265752c..5c172d44dc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantCircumstanceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java similarity index 83% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java index dbadb32ada..055f028909 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java similarity index 93% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java index ac2f47f92f..761692f837 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/DemotionOfTenancyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java similarity index 69% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java index 02e3e48760..8633d5e344 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; @@ -6,7 +6,6 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; -import java.util.List; @Builder @Data @@ -14,10 +13,10 @@ @AllArgsConstructor public class GroundsForPossessionTabDetails { -// @CCD( -// label = "Grounds" -// ) -// private List grounds; + @CCD( + label = "Grounds" + ) + private String grounds; @CCD( label = "Description of other grounds" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java similarity index 89% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java index b125c94512..77f665dff1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/NoticeTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +7,6 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.Document; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java new file mode 100644 index 0000000000..3f084cba0b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java @@ -0,0 +1,4 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; + +public class ReasonsForPossessionTabDetails { +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java similarity index 95% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java index d93dea250f..c6ba204b20 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java similarity index 89% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java index 8c4d5ed3d5..1a80819f5c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/SuspensionOfRightToBuyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java similarity index 85% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java index 55cbb25f00..f16ec9b525 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/TenancyLicenceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; @@ -7,8 +7,6 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.Document; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java similarity index 88% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index d1f8af86bb..82482e1daf 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index d10b2fdad3..7d71ccad87 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; @@ -8,22 +9,46 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ActionsTakenTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.GroundsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.NoticeTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.TenancyLicenceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ActionsTakenTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.Set; + +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.ASSURED_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.DEMOTED_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.FLEXIBLE_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.INTRODUCTORY_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.OTHER; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.SECURE_TENANCY; @Component public class CaseDetailsTabView { private static final String NO_ANSWER = " "; - private static final DateTimeFormatter pattern = DateTimeFormatter.ofPattern("d MMM yyyy"); + private static final DateTimeFormatter PATTERN = DateTimeFormatter.ofPattern("d MMMM yyyy"); + private static final String SEPARATE = ", "; public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); @@ -54,11 +79,179 @@ private ClaimTabDetails buildClaimTabDetails(PCSCase pcsCase) { } private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCase pcsCase) { + AssuredRentArrearsPossessionGrounds assuredRentArrearsPossessionGrounds = + pcsCase.getAssuredRentArrearsPossessionGrounds(); + AssuredNoArrearsPossessionGrounds noRentArrearsPossessionGrounds = pcsCase.getNoRentArrearsGroundsOptions(); + SecureOrFlexiblePossessionGrounds secureOrFlexiblePossessionGrounds = + pcsCase.getSecureOrFlexiblePossessionGrounds(); + IntroductoryDemotedOtherGroundsForPossession introductoryDemotedOrOtherGroundsForPossession = + pcsCase.getIntroductoryDemotedOrOtherGroundsForPossession(); + + if( + assuredRentArrearsPossessionGrounds == null && + noRentArrearsPossessionGrounds == null && + secureOrFlexiblePossessionGrounds == null + ) { + return GroundsForPossessionTabDetails.builder() + .grounds(NO_ANSWER) + .build(); + } + + String grounds = NO_ANSWER; + String otherGroundsDescription = ""; + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + TenancyLicenceType tenancyType = tenancyLicenceDetails != null ? + tenancyLicenceDetails.getTypeOfTenancyLicence() : null; + + if ( + assuredRentArrearsPossessionGrounds != null && + pcsCase.getClaimDueToRentArrears() == YesOrNo.YES && + tenancyType == ASSURED_TENANCY + ) { + grounds = getAssuredRentArrearsPossessionGrounds(assuredRentArrearsPossessionGrounds); + } else if ( + noRentArrearsPossessionGrounds != null && + pcsCase.getClaimDueToRentArrears() == YesOrNo.NO && + tenancyType == ASSURED_TENANCY + ) { + grounds = getAssuredNoArrearsPossessionGrounds(noRentArrearsPossessionGrounds); + } else if ( + secureOrFlexiblePossessionGrounds != null && + (tenancyType == SECURE_TENANCY || tenancyType == FLEXIBLE_TENANCY) + ) { + grounds = getSecureOrFlexiblePossessionGrounds(secureOrFlexiblePossessionGrounds); + } else if ( + introductoryDemotedOrOtherGroundsForPossession != null && + (tenancyType == INTRODUCTORY_TENANCY || tenancyType == DEMOTED_TENANCY || tenancyType == OTHER) + ) { + grounds = getIntroductoryDemotedOrOtherGrounds(introductoryDemotedOrOtherGroundsForPossession); + otherGroundsDescription = introductoryDemotedOrOtherGroundsForPossession.getOtherGroundDescription(); + } + return GroundsForPossessionTabDetails .builder() + .grounds(grounds) + .otherGroundsDescription(otherGroundsDescription) .build(); } + private String getAssuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds grounds) { + StringBuilder allGrounds = new StringBuilder(); + Set rentArrearsGrounds = + grounds.getRentArrearsGrounds(); + Set additionalMandatoryGrounds = + grounds.getAdditionalMandatoryGrounds(); + Set additionalDiscretionaryGrounds = + grounds.getAdditionalDiscretionaryGrounds(); + + if (rentArrearsGrounds != null) { + for (AssuredRentArrearsGround rentArrearsGround : rentArrearsGrounds) { + allGrounds.append(rentArrearsGround.getLabel()).append(SEPARATE); + } + } + + if (additionalMandatoryGrounds != null) { + for(AssuredAdditionalMandatoryGrounds mandatoryGround : additionalMandatoryGrounds) { + allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); + } + } + + if (additionalDiscretionaryGrounds != null) { + for(AssuredAdditionalDiscretionaryGrounds discretionaryGround : additionalDiscretionaryGrounds) { + allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); + } + } + + return allGrounds.toString(); + } + + private String getAssuredNoArrearsPossessionGrounds(AssuredNoArrearsPossessionGrounds grounds) { + StringBuilder allGrounds = new StringBuilder(); + Set mandatoryGrounds = grounds.getMandatoryGrounds(); + Set discretionaryGrounds = + grounds.getDiscretionaryGrounds(); + + for(AssuredMandatoryGround mandatoryGround : mandatoryGrounds) { + allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); + } + + for(AssuredDiscretionaryGround discretionaryGround : discretionaryGrounds) { + allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); + } + + return allGrounds.toString(); + } + + private String getSecureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds grounds) { + StringBuilder allGrounds = new StringBuilder(); + + Set secureOrFlexibleDiscretionaryGrounds = + grounds.getSecureOrFlexibleDiscretionaryGrounds(); + Set secureOrFlexibleMandatoryGrounds = + grounds.getSecureOrFlexibleMandatoryGrounds(); + Set secureOrFlexibleDiscretionaryGroundsAlt + = grounds.getSecureOrFlexibleDiscretionaryGroundsAlt(); + Set secureOrFlexibleMandatoryGroundsAlt + = grounds.getSecureOrFlexibleMandatoryGroundsAlt(); + Set secureAntisocialAdditionalGrounds + = grounds.getSecureAntisocialAdditionalGrounds(); + + if (secureOrFlexibleDiscretionaryGrounds != null) { + for (SecureOrFlexibleDiscretionaryGrounds discretionaryGround : secureOrFlexibleDiscretionaryGrounds) { + allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); + } + } + + if (secureOrFlexibleMandatoryGrounds != null) { + for (SecureOrFlexibleMandatoryGrounds mandatoryGround : secureOrFlexibleMandatoryGrounds) { + allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); + } + } + + if (secureOrFlexibleDiscretionaryGroundsAlt != null) { + for ( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm altDiscretionaryGround : + secureOrFlexibleDiscretionaryGroundsAlt + ) { + allGrounds.append(altDiscretionaryGround.getLabel()).append(SEPARATE); + } + } + + if (secureOrFlexibleMandatoryGroundsAlt != null) { + for ( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm altMandatoryGround : + secureOrFlexibleMandatoryGroundsAlt + ) { + allGrounds.append(altMandatoryGround).append(SEPARATE); + } + } + + if (secureAntisocialAdditionalGrounds != null) { + for (SecureAntisocialAdditionalGrounds antisocialGround : secureAntisocialAdditionalGrounds) { + allGrounds.append(antisocialGround.getLabel()).append(SEPARATE); + } + } + + return allGrounds.toString(); + } + + private String getIntroductoryDemotedOrOtherGrounds( + IntroductoryDemotedOtherGroundsForPossession grounds + ) { + StringBuilder allGrounds = new StringBuilder(); + + Set introductoryDemotedOrOtherGrounds = + grounds.getIntroductoryDemotedOrOtherGrounds(); + + if (introductoryDemotedOrOtherGrounds != null) { + for (IntroductoryDemotedOrOtherGrounds otherGrounds : introductoryDemotedOrOtherGrounds) { + allGrounds.append(otherGrounds.getLabel()).append(SEPARATE); + } + } + + return allGrounds.toString(); + } + private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); if (tenancyLicenceDetails == null) { @@ -75,7 +268,7 @@ private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) return TenancyLicenceTabDetails.builder() .typeOfTenancyLicence(tenancyType != null ? tenancyType.getLabel() : NO_ANSWER) - .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(pattern) : NO_ANSWER) + .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(PATTERN) : NO_ANSWER) .hasCopyOfTenancyLicence(hasTenancyLicence != null ? hasTenancyLicence.getLabel() : NO_ANSWER) .tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments()) .reasonsForNoTenancyLicenceDocuments(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments()) @@ -107,32 +300,32 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { switch (method) { case FIRST_CLASS_POST -> { LocalDate date = noticeServedDetails.getNoticePostedDate(); - noticeTabDetails.setNoticeDate(date != null ? date.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate(date != null ? date.format(PATTERN) : NO_ANSWER); } case DELIVERED_PERMITTED_PLACE -> { LocalDate date = noticeServedDetails.getNoticeDeliveredDate(); - noticeTabDetails.setNoticeDate(date != null ? date.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate(date != null ? date.format(PATTERN) : NO_ANSWER); } case PERSONALLY_HANDED -> { LocalDateTime dateTime = noticeServedDetails.getNoticeHandedOverDateTime(); String name = noticeTabDetails.getNoticePersonName(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); noticeTabDetails.setNoticePersonName(name != null ? name : NO_ANSWER); } case EMAIL -> { LocalDateTime dateTime = noticeServedDetails.getNoticeEmailSentDateTime(); String emailAddress = noticeServedDetails.getNoticeEmailAddress(); - noticeTabDetails.setNoticeDate( dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate( dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); noticeTabDetails.setNoticeEmailAddress(emailAddress != null ? emailAddress : NO_ANSWER); } case OTHER_ELECTRONIC -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherElectronicDateTime(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); } case OTHER -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); String explanation = noticeTabDetails.getNoticeOtherExplanation(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(pattern) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); noticeTabDetails.setNoticeOtherExplanation(explanation != null ? explanation : NO_ANSWER); } }; @@ -144,7 +337,6 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { VerticalYesNo preactionProtocol = pcsCase.getPreActionProtocolCompleted(); - VerticalYesNo mediationAttempted = pcsCase.getMediationAttempted(); VerticalYesNo settlementAttempted = pcsCase.getSettlementAttempted(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 850f1726fa..c41f6fc353 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -8,7 +8,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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index f062eec3a9..36d19e2262 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -10,7 +10,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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; From 7e7bbe29625e6a37c3f0f66d97abf2cd97e8d5ec Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 12 May 2026 22:15:42 +0100 Subject: [PATCH 015/138] HDPI-2983: get label for secureOrFlexibleMandatoryGroundsAlt --- .../uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 7d71ccad87..69245c78fe 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -222,7 +222,7 @@ private String getSecureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGr SecureOrFlexibleMandatoryGroundsAlternativeAccomm altMandatoryGround : secureOrFlexibleMandatoryGroundsAlt ) { - allGrounds.append(altMandatoryGround).append(SEPARATE); + allGrounds.append(altMandatoryGround.getLabel()).append(SEPARATE); } } From 70f607b209a2242e5bfaa1ea5dfa1fead9c84f4f Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 23:35:41 +0100 Subject: [PATCH 016/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 1 + .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 4 +- ...tionalDefendantInformationTabDetails.java} | 4 +- .../ClaimantInformationTabDetails.java} | 4 +- .../DefendantInfomationTabDetails.java} | 4 +- .../RentArrearsTabDetails.java | 2 +- .../ccd/domain/tabs/summary/SummaryTab.java | 12 ++++-- .../reform/pcs/ccd/entity/ClaimEntity.java | 3 -- .../reform/pcs/ccd/entity/PcsCaseEntity.java | 3 ++ .../reform/pcs/ccd/service/ClaimService.java | 2 - .../pcs/ccd/service/PcsCaseService.java | 2 + .../reform/pcs/ccd/view/CaseTabView.java | 43 ++++++++++++------- .../hmcts/reform/pcs/ccd/view/ClaimView.java | 8 ---- .../V096__add_claim_submitted_date.sql | 2 +- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 14 ++++++ .../reform/pcs/ccd/view/CaseTabViewTest.java | 4 +- .../reform/pcs/ccd/view/ClaimViewTest.java | 22 ---------- 17 files changed, 69 insertions(+), 65 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryAdditionalDefendantTabDetails.java => shared/AdditionalDefendantInformationTabDetails.java} (82%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryClaimantTabDetails.java => shared/ClaimantInformationTabDetails.java} (73%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryDefendantTabDetails.java => shared/DefendantInfomationTabDetails.java} (83%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/RentArrearsTabDetails.java (92%) 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 f934d1a9b1..b0fd6e197c 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 @@ -178,6 +178,7 @@ private PCSCase getSubmittedCase(long caseReference) { .allDefendants(partyMap.get(PartyRole.DEFENDANT)) .allUnderlesseeOrMortgagees(partyMap.get(PartyRole.UNDERLESSEE_OR_MORTGAGEE)) .allDocuments(mapAndWrapDocuments(pcsCaseEntity)) + .dateSubmitted(pcsCaseEntity.getCreatedAt()) .build(); setDerivedProperties(pcsCase, pcsCaseEntity); 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 72537e983e..a612195cd9 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 @@ -50,6 +50,7 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -538,7 +539,8 @@ public class PCSCase { @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) private List> claimGroundSummaries; - private String dateSubmitted; + @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) + private LocalDateTime dateSubmitted; @CCD( access = DefendantAccess.class, diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java similarity index 82% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index 8ecfbc2c1f..22e1a5b870 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryAdditionalDefendantTabDetails { +public class AdditionalDefendantInformationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java similarity index 73% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java index a9731b1739..dc008a923d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,7 +10,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryClaimantTabDetails { +public class ClaimantInformationTabDetails { @CCD( label = "Claimant name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java similarity index 83% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java index 20647d131f..9f1320f897 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryDefendantTabDetails { +public class DefendantInfomationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java similarity index 92% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 428462386b..78ba11160e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index d3ec0e4af5..6c703fdb62 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -9,6 +9,10 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; @@ -37,7 +41,7 @@ public class SummaryTab { @CCD( label = "Reasons for possession" ) - private ReasonsForPossessionTabDetails reasonsForPossession; + private ReasonsForPossessionTabDetails reasonsForPossession; @CCD( label = "Date claim Submitted" @@ -47,17 +51,17 @@ public class SummaryTab { @CCD( label = "Claimant" ) - private SummaryClaimantTabDetails claimantDetails; + private ClaimantInformationTabDetails claimantDetails; @CCD( label = "Defendant 1" ) - private SummaryDefendantTabDetails defendantDetails; + private DefendantInfomationTabDetails defendantDetails; @CCD( label = "Additional defendant" ) - private List> additionalDefendants; + private List> additionalDefendants; @CCD( label = "Details of rent arrears" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index f51371228a..62ddea3395 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,7 +34,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -137,8 +136,6 @@ public class ClaimEntity { @Enumerated(EnumType.STRING) private LanguageUsed languageUsed; - private LocalDateTime claimSubmittedDate; - @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "claim") @Builder.Default @JsonManagedReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java index 712cf10dc9..65cf8eb820 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java @@ -22,6 +22,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.respondpossessionclaim.DefendantResponseEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -60,6 +61,8 @@ public class PcsCaseEntity { private Boolean preActionProtocolCompleted; + private LocalDateTime createdAt; + @OneToOne(mappedBy = "pcsCase", cascade = ALL, orphanRemoval = true) @JsonManagedReference private TenancyLicenceEntity tenancyLicence; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java index 9e0ec7618e..503271ab82 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java @@ -13,7 +13,6 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.ClaimRepository; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; -import java.time.LocalDateTime; import java.util.List; @Service @@ -66,7 +65,6 @@ public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { .additionalDocsProvided(pcsCase.getWantToUploadDocuments()) .genAppExpected(pcsCase.getApplicationWithClaim()) .languageUsed(pcsCase.getLanguageUsed()) - .claimSubmittedDate(LocalDateTime.now()) .build(); claimEntity.addClaimGrounds(claimGrounds); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index d2c67f6929..6c7c939a99 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -14,6 +14,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @@ -47,6 +48,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); + pcsCaseEntity.setCreatedAt(LocalDateTime.now()); ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); List documentEntities = documentService.createAllDocuments(pcsCase); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 9b0b67b438..2b7a75b0b6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -22,19 +22,21 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryAdditionalDefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryClaimantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @@ -43,6 +45,8 @@ public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); @@ -111,15 +115,16 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p private SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); return SummaryTab.builder() .repossessedPropertyAddress(pcsCase.getPropertyAddress()) .groundsForPossession(GroundsForPossessionTabDetails.builder() .grounds(getGrounds(pcsCase)) .build()) - .claimSubmittedDate(pcsCase.getDateSubmitted()) + .claimSubmittedDate(dateSubmitted) .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : pcsCase.getDateSubmitted()) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) @@ -129,13 +134,21 @@ private SummaryTab buildSummaryTab(PCSCase pcsCase) { .build(); } - private SummaryClaimantTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + private String formatSubmittedDate(LocalDateTime dateSubmitted) { + if (dateSubmitted == null) { + return null; + } + + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } + + private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { String claimantName = getSummaryClaimantName(pcsCase); if (claimantName == null) { return null; } - return SummaryClaimantTabDetails.builder() + return ClaimantInformationTabDetails.builder() .claimantName(claimantName) .build(); } @@ -163,7 +176,7 @@ private String getSummaryClaimantName(PCSCase pcsCase) { return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); } - private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } @@ -171,7 +184,7 @@ private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsC return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - private List> createAdditionalSummaryDefendantsDetails( + private List> createAdditionalSummaryDefendantsDetails( PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; @@ -182,13 +195,13 @@ private List> createAdditionalSu .map(ListValue::getValue) .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) .filter(defendantDetails -> defendantDetails != null) - .map(defendantDetails -> ListValue.builder() + .map(defendantDetails -> ListValue.builder() .value(defendantDetails) .build()) .toList(); } - private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); @@ -196,21 +209,21 @@ private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDet return null; } - return SummaryAdditionalDefendantTabDetails.builder() + return AdditionalDefendantInformationTabDetails.builder() .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) .addressForService(addressForService) .build(); } - private SummaryDefendantTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; } - return SummaryDefendantTabDetails.builder() + return DefendantInfomationTabDetails.builder() .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) .addressForService(addressForService) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java index 3ca905669c..0efb99bd8b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java @@ -10,15 +10,9 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; -import java.time.format.DateTimeFormatter; -import java.util.Locale; - @Component public class ClaimView { - private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = - DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); - public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { if (!pcsCaseEntity.getClaims().isEmpty()) { ClaimEntity mainClaim = pcsCaseEntity.getClaims().getFirst(); @@ -42,8 +36,6 @@ private void mapBasicClaimFields(PCSCase pcsCase, ClaimEntity claim) { pcsCase.setApplicationWithClaim(claim.getGenAppExpected()); pcsCase.setLanguageUsed(claim.getLanguageUsed()); pcsCase.setWantToUploadDocuments(claim.getAdditionalDocsProvided()); - pcsCase.setDateSubmitted(claim.getClaimSubmittedDate() == null ? null : claim.getClaimSubmittedDate() - .format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM")); } private void mapComplexClaimFields(PCSCase pcsCase, ClaimEntity claim) { diff --git a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql index 63b1fa3595..d6c27708e8 100644 --- a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql +++ b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql @@ -1 +1 @@ -ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; +ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP; 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 66ec74b3a6..499a781e76 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 @@ -46,6 +46,7 @@ import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.Set; @@ -219,6 +220,19 @@ void shouldMapLegislativeCountry() { assertThat(pcsCase.getLegislativeCountry()).isEqualTo(expectedLegislativeCountry); } + @Test + void shouldMapDateSubmittedFromCaseCreatedAt() { + // Given + LocalDateTime createdAt = LocalDateTime.of(2026, 5, 12, 14, 30); + when(pcsCaseEntity.getCreatedAt()).thenReturn(createdAt); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); + + // Then + assertThat(pcsCase.getDateSubmitted()).isEqualTo(createdAt); + } + @Test void shouldMapAllParties() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index fd78e16c57..a70a4c3094 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -21,7 +21,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -280,7 +280,7 @@ void shouldSetSummaryTabFields() { AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); PCSCase pcsCase = PCSCase.builder() .propertyAddress(propertyAddress) - .dateSubmitted("11 May 2026, 5:02:31PM") + .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) .claimGroundSummaries(List.of( listValue(ClaimGroundSummary.builder().label("Ground 1").build()), listValue(ClaimGroundSummary.builder().label("Ground 2").build()) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index 5d596424c1..b7932a75dc 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -16,7 +16,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -81,20 +80,6 @@ void shouldMapBasicClaimFields() { assertThat(pcsCase.getWantToUploadDocuments()).isEqualTo(VerticalYesNo.YES); } - @ParameterizedTest - @MethodSource("claimSubmittedDateScenarios") - void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { - // Given - when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); - when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); - - // When - underTest.setCaseFields(pcsCase, pcsCaseEntity); - - // Then - assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); - } - @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( @@ -154,13 +139,6 @@ void shouldNotPopulateAnyClaimFieldsWhenNoClaimsExist() { assertThat(pcsCase.getClaimantType()).isNull(); } - private static Stream claimSubmittedDateScenarios() { - return Stream.of( - Arguments.of(null, null), - Arguments.of(LocalDateTime.of(2026, 5, 11, 17, 2, 31), "11 May 2026, 5:02:31PM") - ); - } - private static Stream complexClaimFieldsScenarios() { return Stream.of( Arguments.of( From 7ab69c13fd879d047194279811e36b598971416d Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 12:57:42 +0100 Subject: [PATCH 017/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 71 +----- .../reform/pcs/ccd/view/CaseTabView.java | 56 +++++ .../reform/pcs/ccd/view/ClaimGroundsView.java | 102 ++++++-- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 88 +------ .../reform/pcs/ccd/view/CaseTabViewTest.java | 110 +++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 235 ++++++++++++++++-- 6 files changed, 479 insertions(+), 183 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 b0fd6e197c..e0cbca9e34 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 @@ -3,7 +3,6 @@ import lombok.AllArgsConstructor; 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; @@ -11,12 +10,9 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.SearchCriteria; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; 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; @@ -44,7 +40,6 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Optional; @@ -90,10 +85,13 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - Optional draftCaseData = getUnsubmittedCaseData(caseReference, state); - boolean hasUnsubmittedCaseData = draftCaseData.isPresent(); + boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); - draftCaseData.ifPresent(draft -> setSummaryTabFromDraftData(pcsCase, draft)); + if (hasUnsubmittedCaseData) { + draftCaseDataService + .getUnsubmittedCaseData(caseReference, resumePossessionClaim) + .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + } setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); @@ -106,63 +104,12 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private Optional getUnsubmittedCaseData(long caseReference, State state) { + private boolean caseHasUnsubmittedData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { - return draftCaseDataService.getUnsubmittedCaseData(caseReference, resumePossessionClaim); - } - - return Optional.empty(); - } - - private void setSummaryTabFromDraftData(PCSCase pcsCase, PCSCase draftCaseData) { - draftCaseData.setPropertyAddress(Optional.ofNullable(draftCaseData.getPropertyAddress()) - .orElse(pcsCase.getPropertyAddress())); - - if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { - draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); + return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); } - if (draftCaseData.getDefendant1() != null) { - draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); - } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { - draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); - } - - List> draftGrounds = - claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); - draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) - ? pcsCase.getClaimGroundSummaries() - : draftGrounds); - - caseTabView.setCaseTabFields(draftCaseData); - pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); - } - - private List> buildDefendants(PCSCase draftCaseData) { - List> defendants = new ArrayList<>(); - defendants.add(buildDefendant(draftCaseData.getDefendant1())); - - if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES - && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { - draftCaseData.getAdditionalDefendants().stream() - .map(ListValue::getValue) - .map(this::buildDefendant) - .forEach(defendants::add); - } - - return defendants; - } - - private ListValue buildDefendant(DefendantDetails defendant) { - return ListValue.builder() - .value(Party.builder() - .nameKnown(defendant.getNameKnown()) - .firstName(defendant.getFirstName()) - .lastName(defendant.getLastName()) - .addressKnown(defendant.getAddressKnown()) - .address(defendant.getCorrespondenceAddress()) - .build()) - .build(); + return false; } private PCSCase getSubmittedCase(long caseReference) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 2b7a75b0b6..86bffaa0d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -1,11 +1,13 @@ package uk.gov.hmcts.reform.pcs.ccd.view; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; @@ -41,6 +43,7 @@ import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @Component +@AllArgsConstructor public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; @@ -48,6 +51,8 @@ public class CaseTabView { private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + private final ClaimGroundsView claimGroundsView; + public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); SummaryTab summaryTab = buildSummaryTab(pcsCase); @@ -55,6 +60,57 @@ public void setCaseTabFields(PCSCase pcsCase) { pcsCase.setSummaryTab(summaryTab); } + public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { + draftCaseData.setPropertyAddress(java.util.Optional.ofNullable(draftCaseData.getPropertyAddress()) + .orElse(pcsCase.getPropertyAddress())); + + if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { + draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); + } + + if (draftCaseData.getDefendant1() != null) { + draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); + } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { + draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + } + + List> draftGrounds = + claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) + ? pcsCase.getClaimGroundSummaries() + : draftGrounds); + + setCaseTabFields(draftCaseData); + pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + } + + private List> buildDefendants(PCSCase draftCaseData) { + List> defendants = new ArrayList<>(); + defendants.add(buildDefendant(draftCaseData.getDefendant1())); + + if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES + && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { + draftCaseData.getAdditionalDefendants().stream() + .map(ListValue::getValue) + .map(this::buildDefendant) + .forEach(defendants::add); + } + + return defendants; + } + + private ListValue buildDefendant(DefendantDetails defendant) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(defendant.getNameKnown()) + .firstName(defendant.getFirstName()) + .lastName(defendant.getLastName()) + .addressKnown(defendant.getAddressKnown()) + .address(defendant.getCorrespondenceAddress()) + .build()) + .build(); + } + private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { CasePartiesTab tab = CasePartiesTab.builder().build(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index 00137d4e13..b3bca4b4c5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -3,8 +3,12 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.PossessionGroundEnum; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; @@ -20,6 +24,8 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -47,6 +53,62 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { List> summaries = new ArrayList<>(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = draftCaseData.getOccupationLicenceDetailsWales(); + OccupationLicenceTypeWales occupationLicenceType = occupationLicenceDetailsWales == null + ? null : occupationLicenceDetailsWales.getOccupationLicenceTypeWales(); + + if (occupationLicenceType == OccupationLicenceTypeWales.SECURE_CONTRACT) { + Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } else if (occupationLicenceType == OccupationLicenceTypeWales.STANDARD_CONTRACT + || occupationLicenceType == OccupationLicenceTypeWales.OTHER) { + Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } + + TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); + TenancyLicenceType tenancyType = tenancyLicenceDetails == null + ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); + + if (tenancyType == TenancyLicenceType.ASSURED_TENANCY) { + if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { + addAssuredRentArrearsGrounds(summaries, draftCaseData); + } else if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.NO) { + Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + }); + } + } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY + || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { + Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds()); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds()); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt()); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt()); + }); + } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY + || tenancyType == TenancyLicenceType.DEMOTED_TENANCY + || tenancyType == TenancyLicenceType.OTHER) { + addIntroductoryDemotedOrOtherGrounds(summaries, draftCaseData); + } + + return summaries; + } + + private void addAssuredRentArrearsGrounds(List> summaries, + PCSCase draftCaseData) { Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { addGrounds(summaries, selected.getRentArrearsGrounds().stream() @@ -64,37 +126,23 @@ public List> buildClaimGroundSummariesFromDraft(PC .toList()); } }); + } - Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); - }); - - Optional.ofNullable(draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession()) - .map(IntroductoryDemotedOtherGroundsForPossession::getIntroductoryDemotedOrOtherGrounds) - .ifPresent(selected -> addGrounds(summaries, selected)); + private void addIntroductoryDemotedOrOtherGrounds(List> summaries, + PCSCase draftCaseData) { + IntroductoryDemotedOtherGroundsForPossession selected = + draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); - Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds()); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds()); - addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds()); - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt()); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt()); - }); - - Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); - addGrounds(summaries, selected.getEstateManagementGrounds()); - }); + if (selected == null) { + return; + } - Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); - addGrounds(summaries, selected.getEstateManagementGrounds()); - }); + if (selected.getHasIntroductoryDemotedOtherGroundsForPossession() == VerticalYesNo.NO) { + addGrounds(summaries, Set.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS)); + return; + } - return summaries; + addGrounds(summaries, selected.getIntroductoryDemotedOrOtherGrounds()); } private void addGrounds(List> summaries, 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 499a781e76..c1130537dc 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 @@ -10,13 +10,9 @@ import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; 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; @@ -56,7 +52,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mock.Strictness.LENIENT; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -332,10 +327,6 @@ private static ListValue asListValue(UUID id, Party party) { return ListValue.builder().id(id.toString()).value(party).build(); } - private static ListValue listValue(T value) { - return ListValue.builder().value(value).build(); - } - private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { PartyEntity partyEntity = mock(PartyEntity.class); @@ -382,92 +373,33 @@ void shouldSetCaseFields() { } @Test - void shouldSetSummaryTabFromDraftDataWhenUnsubmittedCaseDataExists() { + void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { // Given - AddressEntity addressEntity = mock(AddressEntity.class); - when(pcsCaseEntity.getPropertyAddress()).thenReturn(addressEntity); - AddressUK propertyAddress = stubAddressEntityModelMapper(addressEntity); - - Party claimant = mock(Party.class); - UUID claimantId = UUID.randomUUID(); - ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); - when(claimEntity.getClaimParties()).thenReturn(List.of(claimantClaimParty)); - - AddressUK defendantOneAddress = AddressUK.builder().postCode("E1 1AA").build(); - AddressUK defendantTwoAddress = AddressUK.builder().postCode("E2 2AA").build(); - PCSCase draftCaseData = PCSCase.builder() - .defendant1(DefendantDetails.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .addressKnown(VerticalYesNo.YES) - .correspondenceAddress(defendantOneAddress) - .build()) - .addAnotherDefendant(VerticalYesNo.YES) - .additionalDefendants(List.of(listValue(DefendantDetails.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("Two") - .addressKnown(VerticalYesNo.YES) - .correspondenceAddress(defendantTwoAddress) - .build()))) - .summaryTab(SummaryTab.builder().build()) - .build(); - List> draftGrounds = - List.of(listValue(ClaimGroundSummary.builder().label("Draft ground").build())); + PCSCase draftCaseData = PCSCase.builder().build(); + when(draftCaseDataService.hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(true); when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) .thenReturn(Optional.of(draftCaseData)); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); // When PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); // Then + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); - verify(caseTabView).setCaseTabFields(draftCaseData); - assertThat(draftCaseData.getPropertyAddress()).isEqualTo(propertyAddress); - assertThat(draftCaseData.getAllClaimants()).containsExactly(asListValue(claimantId, claimant)); - assertThat(draftCaseData.getAllDefendants()).hasSize(2); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getLastName()).isEqualTo("One"); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getAddress()).isEqualTo(defendantOneAddress); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getLastName()).isEqualTo("Two"); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getAddress()).isEqualTo(defendantTwoAddress); - assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(draftGrounds); - assertThat(pcsCase.getSummaryTab()).isSameAs(draftCaseData.getSummaryTab()); + verify(caseTabView).setDraftCaseTabFields(pcsCase, draftCaseData); assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } @Test - void shouldFallbackToSubmittedSummaryDataWhenDraftDataIsPartial() { - // Given - Party defendant = mock(Party.class); - UUID defendantId = UUID.randomUUID(); - ClaimPartyEntity defendantClaimParty = createClaimPartyEntity(defendant, defendantId, PartyRole.DEFENDANT); - when(claimEntity.getClaimParties()).thenReturn(List.of(defendantClaimParty)); - - List> submittedGrounds = - List.of(listValue(ClaimGroundSummary.builder().label("Submitted ground").build())); - doAnswer(invocation -> { - PCSCase pcsCase = invocation.getArgument(0); - pcsCase.setClaimGroundSummaries(submittedGrounds); - return null; - }).when(claimGroundsView).setCaseFields(any(PCSCase.class), any(PcsCaseEntity.class)); - - PCSCase draftCaseData = PCSCase.builder() - .summaryTab(SummaryTab.builder().build()) - .build(); - when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) - .thenReturn(Optional.of(draftCaseData)); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); - + void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { // When underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); // Then - assertThat(draftCaseData.getAllDefendants()).containsExactly(asListValue(defendantId, defendant)); - assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(submittedGrounds); + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); + verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index a70a4c3094..f4fc8c445f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -4,11 +4,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; @@ -33,15 +35,19 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class CaseTabViewTest { private CaseTabView underTest; + @Mock + private ClaimGroundsView claimGroundsView; + @BeforeEach void setUp() { - underTest = new CaseTabView(); + underTest = new CaseTabView(claimGroundsView); } @Test @@ -542,6 +548,108 @@ void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); } + @Test + void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + List> submittedClaimants = List.of( + listValue(Party.builder().orgName("Submitted claimant").build()) + ); + List> submittedDefendants = List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Submitted") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .address(propertyAddress) + .build()) + ); + List> submittedGrounds = List.of( + listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) + ); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allClaimants(submittedClaimants) + .allDefendants(submittedDefendants) + .claimGroundSummaries(submittedGrounds) + .build(); + PCSCase draftCaseData = PCSCase.builder().build(); + + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Submitted claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Submitted"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Submitted ground"); + } + + @Test + void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { + // Given + AddressUK submittedPropertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK draftPropertyAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK defendantOneAddress = AddressUK.builder().postCode("M1 1AA").build(); + AddressUK additionalDefendantAddress = AddressUK.builder().postCode("B1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(submittedPropertyAddress) + .allClaimants(List.of(listValue(Party.builder().orgName("Submitted claimant").build()))) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) + )) + .build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(draftPropertyAddress) + .allClaimants(List.of(listValue(Party.builder().orgName("Draft claimant").build()))) + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Draft") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantOneAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of( + listValue(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Additional") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(additionalDefendantAddress) + .build()) + )) + .build(); + List> draftGrounds = List.of( + listValue(ClaimGroundSummary.builder().label("Draft ground").build()) + ); + + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(draftPropertyAddress); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Draft claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Draft"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(defendantOneAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Additional"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(additionalDefendantAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Draft ground"); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 2662d53560..18680825c4 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,6 +12,9 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; @@ -34,6 +37,8 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; @@ -217,6 +222,10 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { void shouldBuildClaimGroundSummariesFromDraft() { // Given PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() .rentArrearsGrounds(Set.of( AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, @@ -291,21 +300,7 @@ void shouldBuildClaimGroundSummariesFromDraft() { "Serious rent arrears (ground 8)", "Rent arrears (ground 10)", "Owner occupier (ground 1)", - "Breach of tenancy conditions (ground 12)", - "Holiday let (ground 3)", - "Deterioration in the condition of the property (ground 13)", - "Antisocial behaviour", - "Rent arrears or breach of the tenancy (ground 1)", - "Condition 1 of Section 84A of the Housing Act 1985", - "Property sold for redevelopment (ground 10A)", - "Adapted accommodation (ground 13)", - "Antisocial behaviour", - "Notice given under a landlord’s break clause (section 199)", - "Rent arrears (breach of contract) (section 157)", - "Redevelopment schemes (ground B)", - "Landlord’s notice in connection with end of fixed term given (section 186)", - "Antisocial behaviour (breach of contract) (section 157)", - "Reserve successors (ground G)" + "Breach of tenancy conditions (ground 12)" ); } @@ -319,6 +314,216 @@ void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { assertThat(summaries).isEmpty(); } + @Test + void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), + SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), + EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() + ); + } + + @Test + void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), + DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() + ); + } + + @Test + void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.NO) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() + ); + } + + @Test + void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel() + ); + } + + @Test + void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel()); + } + + @Test + void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) + .build() + ) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries).isEmpty(); + } + private static Stream claimGroundScenarios() { return Stream.of( argumentSet( From 478615048d72ff65dbf4dab8e5f099a4229d68c6 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 13:53:29 +0100 Subject: [PATCH 018/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabView.java | 334 ++++++++++++++++ .../reform/pcs/ccd/view/CaseTabView.java | 313 +-------------- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 364 ++++++++++++++++++ .../reform/pcs/ccd/view/CaseTabViewTest.java | 286 +------------- 4 files changed, 702 insertions(+), 595 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java new file mode 100644 index 0000000000..49f9365076 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -0,0 +1,334 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Locale; + +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + +@Component +public class CaseSummaryTabView { + + private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + + public SummaryTab buildSummaryTab(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); + + return SummaryTab.builder() + .repossessedPropertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossession(GroundsForPossessionTabDetails.builder() + .grounds(getGrounds(pcsCase)) + .build()) + .claimSubmittedDate(dateSubmitted) + .reasonsForPossession(reasonsForPossession) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) + .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) + .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .tenancyDetails(buildTenancyTabDetails(pcsCase)) + .noticeDetails(buildNoticeTabDetails(pcsCase)) + .build(); + } + + private String formatSubmittedDate(LocalDateTime dateSubmitted) { + if (dateSubmitted == null) { + return null; + } + + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } + + private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return ClaimantInformationTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } + + private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private List> createAdditionalSummaryDefendantsDetails( + PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return AdditionalDefendantInformationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } + + private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return DefendantInfomationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } + + private String getDefendantFirstName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : CaseTabView.NAME_UNKNOWN; + } + + private String getDefendantLastName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : CaseTabView.NAME_UNKNOWN; + } + + private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return null; + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + return null; + } + + return ReasonsForPossessionTabDetails.builder() + .groundReasons(additionalReasons.getHasReasons().getLabel()) + .additionalReasonsForPossession(additionalReasons.getReasons()) + .build(); + } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); + + if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) + && (occupationLicenceDetailsWales == null + || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { + return null; + } + + String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null + ? getAgreementType(tenancyLicenceDetails) + : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); + String agreementStartDate = tenancyLicenceDetails != null + && tenancyLicenceDetails.getTenancyLicenceDate() != null + ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) + : getOccupationLicenceStartDate(occupationLicenceDetailsWales); + + return TenancyTabDetails.builder() + .agreementType(agreementType) + .agreementStartDate(agreementStartDate) + .build(); + } + + private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { + if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { + return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); + } + + return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); + } + + private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { + return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); + } + + return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); + } + + private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { + return null; + } + + return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); + } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + + if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + return null; + } + + return NoticeTabDetails.builder() + .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .build(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + return pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .orElse(null); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 86bffaa0d7..d5b9d51cfe 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -5,57 +5,31 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; -import java.util.Locale; - -import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @Component @AllArgsConstructor public class CaseTabView { - private static final String NAME_UNKNOWN = "Person unknown"; - private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = - DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + static final String NAME_UNKNOWN = "Person unknown"; private final ClaimGroundsView claimGroundsView; + private final CaseSummaryTabView caseSummaryTabView; public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); - SummaryTab summaryTab = buildSummaryTab(pcsCase); + SummaryTab summaryTab = caseSummaryTabView.buildSummaryTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); pcsCase.setSummaryTab(summaryTab); } @@ -168,285 +142,4 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p .lastName(defendantLastName) .build(); } - - private SummaryTab buildSummaryTab(PCSCase pcsCase) { - ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); - String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); - - return SummaryTab.builder() - .repossessedPropertyAddress(pcsCase.getPropertyAddress()) - .groundsForPossession(GroundsForPossessionTabDetails.builder() - .grounds(getGrounds(pcsCase)) - .build()) - .claimSubmittedDate(dateSubmitted) - .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) - .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) - .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) - .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) - .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) - .tenancyDetails(buildTenancyTabDetails(pcsCase)) - .noticeDetails(buildNoticeTabDetails(pcsCase)) - .build(); - } - - private String formatSubmittedDate(LocalDateTime dateSubmitted) { - if (dateSubmitted == null) { - return null; - } - - return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); - } - - private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { - String claimantName = getSummaryClaimantName(pcsCase); - if (claimantName == null) { - return null; - } - - return ClaimantInformationTabDetails.builder() - .claimantName(claimantName) - .build(); - } - - private String getSummaryClaimantName(PCSCase pcsCase) { - ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); - if (claimantInformation != null) { - if (claimantInformation.getOrgNameFound() == NO) { - return claimantInformation.getFallbackClaimantName(); - } - - if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { - return claimantInformation.getOverriddenClaimantName(); - } - - if (claimantInformation.getClaimantName() != null) { - return claimantInformation.getClaimantName(); - } - } - - if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { - return null; - } - - return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); - } - - private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { - return null; - } - - return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); - } - - private List> createAdditionalSummaryDefendantsDetails( - PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { - return null; - } - - return pcsCase.getAllDefendants().stream() - .skip(1) - .map(ListValue::getValue) - .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) - .filter(defendantDetails -> defendantDetails != null) - .map(defendantDetails -> ListValue.builder() - .value(defendantDetails) - .build()) - .toList(); - } - - private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, - PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return AdditionalDefendantInformationTabDetails.builder() - .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) - .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) - .addressForService(addressForService) - .build(); - } - - private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return DefendantInfomationTabDetails.builder() - .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) - .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) - .addressForService(addressForService) - .build(); - } - - private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { - if (defendant.getAddressKnown() != VerticalYesNo.YES) { - return null; - } - - return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); - } - - private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { - AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); - if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { - return null; - } - - return ReasonsForPossessionTabDetails.builder() - .groundReasons(additionalReasons.getHasReasons().getLabel()) - .additionalReasonsForPossession(additionalReasons.getReasons()) - .build(); - } - - private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { - RentDetails rentDetails = pcsCase.getRentDetails(); - RentArrearsSection rentArrears = pcsCase.getRentArrears(); - - String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); - String calculationFrequency = getRentCalculationFrequency(rentDetails); - String dailyRate = getDailyRate(rentDetails); - String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); - String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null - ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); - - if (rentAmount == null - && calculationFrequency == null - && dailyRate == null - && arrearsTotal == null - && judgmentRequested == null) { - return null; - } - - return RentArrearsTabDetails.builder() - .rentAmount(rentAmount) - .calculationFrequency(calculationFrequency) - .dailyRate(dailyRate) - .arrearsTotal(arrearsTotal) - .judgmentRequested(judgmentRequested) - .build(); - } - - private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { - TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); - OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); - - if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) - && (occupationLicenceDetailsWales == null - || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { - return null; - } - - String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null - ? getAgreementType(tenancyLicenceDetails) - : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); - String agreementStartDate = tenancyLicenceDetails != null - && tenancyLicenceDetails.getTenancyLicenceDate() != null - ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) - : getOccupationLicenceStartDate(occupationLicenceDetailsWales); - - return TenancyTabDetails.builder() - .agreementType(agreementType) - .agreementStartDate(agreementStartDate) - .build(); - } - - private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { - if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { - return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); - } - - return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); - } - - private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { - if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { - return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); - } - - return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); - } - - private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { - if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { - return null; - } - - return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); - } - - private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { - NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); - - if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { - return null; - } - - return NoticeTabDetails.builder() - .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) - .build(); - } - - private String getRentCalculationFrequency(RentDetails rentDetails) { - if (rentDetails == null || rentDetails.getFrequency() == null) { - return null; - } - - if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { - return rentDetails.getOtherFrequency(); - } - - return rentDetails.getFrequency().getLabel(); - } - - private String getDailyRate(RentDetails rentDetails) { - if (rentDetails == null) { - return null; - } - - if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { - return formatMoney(rentDetails.getAmendedDailyCharge()); - } - - if (rentDetails.getDailyCharge() != null) { - return formatMoney(rentDetails.getDailyCharge()); - } - - if (rentDetails.getFormattedCalculatedDailyCharge() != null) { - return rentDetails.getFormattedCalculatedDailyCharge(); - } - - return formatMoney(rentDetails.getCalculatedDailyCharge()); - } - - private String formatMoney(BigDecimal amount) { - if (amount == null) { - return null; - } - - if (amount.stripTrailingZeros().scale() <= 0) { - amount = amount.stripTrailingZeros(); - } - - return "£" + amount.toPlainString(); - } - - private String getGrounds(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { - return null; - } - - return pcsCase.getClaimGroundSummaries().stream() - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) - .orElse(null); - } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java new file mode 100644 index 0000000000..d95fe478ac --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -0,0 +1,364 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CaseSummaryTabViewTest { + + private CaseSummaryTabView underTest; + + @BeforeEach + void setUp() { + underTest = new CaseSummaryTabView(); + } + + @Test + void shouldSetSummaryTabFields() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Ground 1").build()), + listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("Licence details") + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .build()) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldNotSetEmptySummarySections() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + assertThat(summaryTab.getReasonsForPossession()).isNull(); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getAdditionalDefendants()).isNull(); + assertThat(summaryTab.getRentArrearsDetails()).isNull(); + assertThat(summaryTab.getTenancyDetails()).isNull(); + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + + @Test + void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(address); + } + + @Test + void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(address); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = underTest.buildSummaryTab(pcsCase).getRentArrearsDetails(); + + // Then + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); + } + + @Test + void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); + } + + @Test + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .licenceStartDate(LocalDate.of(2025, 5, 12)) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); + } + + @Test + void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .otherLicenceTypeDetails("Other Welsh licence") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index f4fc8c445f..5b63229196 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -7,30 +7,15 @@ import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -47,7 +32,7 @@ public class CaseTabViewTest { @BeforeEach void setUp() { - underTest = new CaseTabView(claimGroundsView); + underTest = new CaseTabView(claimGroundsView, new CaseSummaryTabView()); } @Test @@ -279,275 +264,6 @@ void shouldNotSetCasePartiesTabWithNoData() { assertThat(pcsCase.getCasePartiesTab().getDefendantsDetails()).isNull(); } - @Test - void shouldSetSummaryTabFields() { - // Given - AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) - .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder().label("Ground 1").build()), - listValue(ClaimGroundSummary.builder().label("Ground 2").build()) - )) - .additionalReasonsForPossession(AdditionalReasons.builder() - .hasReasons(VerticalYesNo.YES) - .reasons("Additional reasons") - .build()) - .claimantInformation(ClaimantInformation.builder() - .orgNameFound(YesOrNo.NO) - .fallbackClaimantName("Fallback claimant") - .build()) - .allDefendants(List.of( - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .addressKnown(VerticalYesNo.YES) - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("Two") - .addressKnown(VerticalYesNo.YES) - .address(defendantAddress) - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()) - )) - .rentDetails(RentDetails.builder() - .currentRent(new BigDecimal("100.00")) - .frequency(RentPaymentFrequency.OTHER) - .otherFrequency("Every 4 weeks") - .perDayCorrect(VerticalYesNo.NO) - .amendedDailyCharge(new BigDecimal("12.30")) - .build()) - .rentArrears(RentArrearsSection.builder() - .total(new BigDecimal("450.75")) - .build()) - .arrearsJudgmentWanted(VerticalYesNo.YES) - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .detailsOfOtherTypeOfTenancyLicence("Licence details") - .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) - .build()) - .noticeServedDetails(NoticeServedDetails.builder() - .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); - assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); - assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) - .isEqualTo("Additional reasons"); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) - .isEqualTo(defendantAddress); - assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); - assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); - assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); - assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); - assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); - assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); - assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); - assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); - } - - @Test - void shouldSetSummaryClaimantNameFromOverriddenName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .isClaimantNameCorrect(VerticalYesNo.NO) - .overriddenClaimantName("Overridden claimant") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); - } - - @Test - void shouldSetSummaryClaimantNameFromClaimantInformationName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .claimantName("Claimant information name") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()) - .isEqualTo("Claimant information name"); - } - - @Test - void shouldSetSummaryClaimantNameFromAllClaimants() { - // Given - PCSCase pcsCase = PCSCase.builder() - .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); - } - - @Test - void shouldNotSetEmptySummarySections() { - // Given - PCSCase pcsCase = PCSCase.builder() - .allDefendants(List.of(listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()))) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); - assertThat(summaryTab.getReasonsForPossession()).isNull(); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); - assertThat(summaryTab.getClaimantDetails()).isNull(); - assertThat(summaryTab.getDefendantDetails()).isNull(); - assertThat(summaryTab.getAdditionalDefendants()).isNull(); - assertThat(summaryTab.getRentArrearsDetails()).isNull(); - assertThat(summaryTab.getTenancyDetails()).isNull(); - assertThat(summaryTab.getNoticeDetails()).isNull(); - } - - @Test - void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .frequency(RentPaymentFrequency.WEEKLY) - .dailyCharge(new BigDecimal("1.50")) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - RentArrearsTabDetails rentArrearsDetails = pcsCase.getSummaryTab().getRentArrearsDetails(); - assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); - assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); - } - - @Test - void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .formattedCalculatedDailyCharge("£2.34") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); - } - - @Test - void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .calculatedDailyCharge(new BigDecimal("3.40")) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); - } - - @Test - void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { - // Given - PCSCase pcsCase = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); - } - - @Test - void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { - // Given - PCSCase pcsCase = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) - .licenceStartDate(LocalDate.of(2025, 5, 12)) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); - } - - @Test - void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { - // Given - PCSCase pcsCase = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) - .otherLicenceTypeDetails("Other Welsh licence") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); - } - @Test void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { // Given From 355e4ec441f396c189d71d2db708dd2bfd83acf7 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 16:41:37 +0100 Subject: [PATCH 019/138] HDPI-2978: Build Case Summary tab --- .../ReasonsForPossessionTabDetails.java | 162 +++++++- .../pcs/ccd/view/CaseSummaryTabView.java | 145 ++++++- .../reform/pcs/ccd/view/ClaimGroundsView.java | 178 ++++++++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 221 ++++++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 375 +++++++++++++++++- 5 files changed, 1046 insertions(+), 35 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java index 90aaac2db4..c8647b148d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java @@ -12,10 +12,164 @@ @AllArgsConstructor public class ReasonsForPossessionTabDetails { - @CCD( - label = "Reasons for claiming possession under ground X" - ) - private String groundReasons; + @CCD(label = "Reasons for claiming possession under ground 1") + private String ground1; + + @CCD(label = "Reasons for claiming possession under ground 2") + private String ground2; + + @CCD(label = "Reasons for claiming possession under ground 2A") + private String ground2A; + + @CCD(label = "Reasons for claiming possession under ground 2ZA") + private String ground2ZA; + + @CCD(label = "Reasons for claiming possession under ground 3") + private String ground3; + + @CCD(label = "Reasons for claiming possession under ground 4") + private String ground4; + + @CCD(label = "Reasons for claiming possession under ground 5") + private String ground5; + + @CCD(label = "Reasons for claiming possession under ground 6") + private String ground6; + + @CCD(label = "Reasons for claiming possession under ground 7") + private String ground7; + + @CCD(label = "Reasons for claiming possession under ground 7A") + private String ground7A; + + @CCD(label = "Reasons for claiming possession under ground 7B") + private String ground7B; + + @CCD(label = "Reasons for claiming possession under ground 8") + private String ground8; + + @CCD(label = "Reasons for claiming possession under ground 9") + private String ground9; + + @CCD(label = "Reasons for claiming possession under ground 10") + private String ground10; + + @CCD(label = "Reasons for claiming possession under ground 10A") + private String ground10A; + + @CCD(label = "Reasons for claiming possession under ground 11") + private String ground11; + + @CCD(label = "Reasons for claiming possession under ground 12") + private String ground12; + + @CCD(label = "Reasons for claiming possession under ground 13") + private String ground13; + + @CCD(label = "Reasons for claiming possession under ground 14") + private String ground14; + + @CCD(label = "Reasons for claiming possession under ground 14A") + private String ground14A; + + @CCD(label = "Reasons for claiming possession under ground 14ZA") + private String ground14ZA; + + @CCD(label = "Reasons for claiming possession under ground 15") + private String ground15; + + @CCD(label = "Reasons for claiming possession under ground 15A") + private String ground15A; + + @CCD(label = "Reasons for claiming possession under ground 16") + private String ground16; + + @CCD(label = "Reasons for claiming possession under ground 17") + private String ground17; + + @CCD(label = "Reasons for claiming possession under ground A") + private String groundA; + + @CCD(label = "Reasons for claiming possession under ground B") + private String groundB; + + @CCD(label = "Reasons for claiming possession under ground C") + private String groundC; + + @CCD(label = "Reasons for claiming possession under ground D") + private String groundD; + + @CCD(label = "Reasons for claiming possession under ground E") + private String groundE; + + @CCD(label = "Reasons for claiming possession under ground F") + private String groundF; + + @CCD(label = "Reasons for claiming possession under ground G") + private String groundG; + + @CCD(label = "Reasons for claiming possession under ground H") + private String groundH; + + @CCD(label = "Reasons for claiming possession under ground I") + private String groundI; + + @CCD(label = "Reasons for claiming possession under Condition 1 of Section 84A of the Housing Act 1985") + private String condition1OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 2 of Section 84A of the Housing Act 1985") + private String condition2OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 3 of Section 84A of the Housing Act 1985") + private String condition3OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 4 of Section 84A of the Housing Act 1985") + private String condition4OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 5 of Section 84A of the Housing Act 1985") + private String condition5OfSection84A; + + @CCD(label = "Reasons for claiming possession under section 157") + private String section157; + + @CCD(label = "Reasons for claiming possession under section 170") + private String section170; + + @CCD(label = "Reasons for claiming possession under section 178") + private String section178; + + @CCD(label = "Reasons for claiming possession under section 181") + private String section181; + + @CCD(label = "Reasons for claiming possession under section 186") + private String section186; + + @CCD(label = "Reasons for claiming possession under section 187") + private String section187; + + @CCD(label = "Reasons for claiming possession under section 191") + private String section191; + + @CCD(label = "Reasons for claiming possession under section 199") + private String section199; + + @CCD(label = "Reasons for claiming possession under paragraph 25B(2) of Schedule 12") + private String paragraph25B2Schedule12; + + @CCD(label = "Reasons for claiming possession under Antisocial behaviour") + private String antisocialBehaviour; + + @CCD(label = "Reasons for claiming possession under Breach of the tenancy") + private String breachOfTheTenancy; + + @CCD(label = "Reasons for claiming possession under Absolute grounds") + private String absoluteGrounds; + + @CCD(label = "Reasons for claiming possession under Other grounds") + private String otherGrounds; + + @CCD(label = "Reasons for claiming possession under No grounds") + private String noGrounds; @CCD( label = "Additional reasons for possession" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 49f9365076..ced75a04ad 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -2,6 +2,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; @@ -33,6 +34,8 @@ import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @@ -42,6 +45,10 @@ public class CaseSummaryTabView { private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + private static final Pattern GROUND_REFERENCE_PATTERN = + Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_REFERENCE_PATTERN = + Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -178,14 +185,142 @@ private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); - if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + ReasonsForPossessionTabDetails reasonsForPossession = + buildReasonsForPossessionFromGroundSummaries(pcsCase); + String additionalReasonsText = additionalReasons == null + || additionalReasons.getHasReasons() != VerticalYesNo.YES ? null : additionalReasons.getReasons(); + + if (reasonsForPossession == null && additionalReasonsText == null) { return null; } - return ReasonsForPossessionTabDetails.builder() - .groundReasons(additionalReasons.getHasReasons().getLabel()) - .additionalReasonsForPossession(additionalReasons.getReasons()) - .build(); + if (reasonsForPossession == null) { + reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + } + + reasonsForPossession.setAdditionalReasonsForPossession(additionalReasonsText); + return reasonsForPossession; + } + + private ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + ReasonsForPossessionTabDetails reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + boolean hasReason = false; + + for (ListValue listValue : pcsCase.getClaimGroundSummaries()) { + ClaimGroundSummary summary = listValue.getValue(); + if (summary == null || !StringUtils.hasText(summary.getReason())) { + continue; + } + + setGroundReason(reasonsForPossession, summary.getLabel(), summary.getReason()); + hasReason = true; + } + + return hasReason ? reasonsForPossession : null; + } + + private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession, + String groundLabel, + String reason) { + Matcher groundMatcher = GROUND_REFERENCE_PATTERN.matcher(groundLabel); + if (groundMatcher.find()) { + setGroundNumberReason(reasonsForPossession, groundMatcher.group(1), reason); + return; + } + + Matcher sectionMatcher = SECTION_REFERENCE_PATTERN.matcher(groundLabel); + if (sectionMatcher.find()) { + setSectionReason(reasonsForPossession, sectionMatcher.group(1), reason); + return; + } + + if (groundLabel.startsWith("Condition 1")) { + reasonsForPossession.setCondition1OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 2")) { + reasonsForPossession.setCondition2OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 3")) { + reasonsForPossession.setCondition3OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 4")) { + reasonsForPossession.setCondition4OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 5")) { + reasonsForPossession.setCondition5OfSection84A(reason); + } else if ("Antisocial behaviour".equals(groundLabel)) { + reasonsForPossession.setAntisocialBehaviour(reason); + } else if ("Breach of the tenancy".equals(groundLabel)) { + reasonsForPossession.setBreachOfTheTenancy(reason); + } else if ("Absolute grounds".equals(groundLabel)) { + reasonsForPossession.setAbsoluteGrounds(reason); + } else if ("Other".equals(groundLabel) || "Other grounds".equals(groundLabel)) { + reasonsForPossession.setOtherGrounds(reason); + } else if ("No grounds".equals(groundLabel)) { + reasonsForPossession.setNoGrounds(reason); + } else if (groundLabel.contains("paragraph 25B(2) of Schedule 12")) { + reasonsForPossession.setParagraph25B2Schedule12(reason); + } + } + + private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPossession, + String ground, + String reason) { + switch (ground) { + case "1" -> reasonsForPossession.setGround1(reason); + case "2" -> reasonsForPossession.setGround2(reason); + case "2A" -> reasonsForPossession.setGround2A(reason); + case "2ZA" -> reasonsForPossession.setGround2ZA(reason); + case "3" -> reasonsForPossession.setGround3(reason); + case "4" -> reasonsForPossession.setGround4(reason); + case "5" -> reasonsForPossession.setGround5(reason); + case "6" -> reasonsForPossession.setGround6(reason); + case "7" -> reasonsForPossession.setGround7(reason); + case "7A" -> reasonsForPossession.setGround7A(reason); + case "7B" -> reasonsForPossession.setGround7B(reason); + case "8" -> reasonsForPossession.setGround8(reason); + case "9" -> reasonsForPossession.setGround9(reason); + case "10" -> reasonsForPossession.setGround10(reason); + case "10A" -> reasonsForPossession.setGround10A(reason); + case "11" -> reasonsForPossession.setGround11(reason); + case "12" -> reasonsForPossession.setGround12(reason); + case "13" -> reasonsForPossession.setGround13(reason); + case "14" -> reasonsForPossession.setGround14(reason); + case "14A" -> reasonsForPossession.setGround14A(reason); + case "14ZA" -> reasonsForPossession.setGround14ZA(reason); + case "15" -> reasonsForPossession.setGround15(reason); + case "15A" -> reasonsForPossession.setGround15A(reason); + case "16" -> reasonsForPossession.setGround16(reason); + case "17" -> reasonsForPossession.setGround17(reason); + case "A" -> reasonsForPossession.setGroundA(reason); + case "B" -> reasonsForPossession.setGroundB(reason); + case "C" -> reasonsForPossession.setGroundC(reason); + case "D" -> reasonsForPossession.setGroundD(reason); + case "E" -> reasonsForPossession.setGroundE(reason); + case "F" -> reasonsForPossession.setGroundF(reason); + case "G" -> reasonsForPossession.setGroundG(reason); + case "H" -> reasonsForPossession.setGroundH(reason); + case "I" -> reasonsForPossession.setGroundI(reason); + default -> { + } + } + } + + private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossession, + String section, + String reason) { + switch (section) { + case "157" -> reasonsForPossession.setSection157(reason); + case "170" -> reasonsForPossession.setSection170(reason); + case "178" -> reasonsForPossession.setSection178(reason); + case "181" -> reasonsForPossession.setSection181(reason); + case "186" -> reasonsForPossession.setSection186(reason); + case "187" -> reasonsForPossession.setSection187(reason); + case "191" -> reasonsForPossession.setSection191(reason); + case "199" -> reasonsForPossession.setSection199(reason); + default -> { + } + } } private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index b3bca4b4c5..8e5b1c6106 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -14,9 +14,12 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; @@ -85,18 +88,18 @@ public List> buildClaimGroundSummariesFromDraft(PC addAssuredRentArrearsGrounds(summaries, draftCaseData); } else if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.NO) { Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); }); } } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds()); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds()); - addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds()); - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt()); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt()); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt(), draftCaseData); }); } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY || tenancyType == TenancyLicenceType.DEMOTED_TENANCY @@ -113,17 +116,17 @@ private void addAssuredRentArrearsGrounds(List> su if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { addGrounds(summaries, selected.getRentArrearsGrounds().stream() .map(this::mapAssuredRentArrearsGround) - .toList()); + .toList(), draftCaseData); } if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) - .toList()); + .toList(), draftCaseData); } if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) - .toList()); + .toList(), draftCaseData); } }); } @@ -138,11 +141,11 @@ private void addIntroductoryDemotedOrOtherGrounds(List> summaries, @@ -152,6 +155,14 @@ private void addGrounds(List> summaries, } } + private void addGrounds(List> summaries, + Set grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds), draftCaseData); + } + } + private void addGrounds(List> summaries, List grounds) { if (!CollectionUtils.isEmpty(grounds)) { @@ -162,6 +173,149 @@ private void addGrounds(List> summaries, } } + private void addGrounds(List> summaries, + List grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder() + .code(((Enum) ground).name()) + .label(ground.getLabel()) + .reason(getDraftReason(draftCaseData, ground)) + .build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + return switch (((Enum) ground).name()) { + case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); + case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); + case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); + case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); + case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); + case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); + case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); + case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); + case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); + case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; + case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); + case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); + case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); + case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); + case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); + case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); + case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); + case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); + case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); + case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); + case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); + case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); + case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); + case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); + case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); + case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); + case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); + case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); + case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); + case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); + case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); + case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); + case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); + case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); + case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); + case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); + case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); + case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); + case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); + case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); + case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); + case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); + case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); + case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); + case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); + case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); + case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); + case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); + default -> null; + }; + } + + private String getSection84ACondition1Reason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons reasons = draftCaseData.getSecureOrFlexibleGroundsReasons(); + return reasons == null ? null : reasons.getAntiSocialCondition1OfS84AGround(); + } + + private String getAntiSocialReason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons secureOrFlexibleReasons = getSecureOrFlexibleReason(draftCaseData); + if (secureOrFlexibleReasons != null) { + return secureOrFlexibleReasons.getAntiSocialGround(); + } + + IntroductoryDemotedOtherGroundReason introductoryDemotedOtherReason = + getIntroductoryDemotedOtherGroundReason(draftCaseData); + return introductoryDemotedOtherReason == null + ? null : introductoryDemotedOtherReason.getAntiSocialBehaviourGround(); + } + + private SecureOrFlexibleGroundsReasons getSecureOrFlexibleReason(PCSCase draftCaseData) { + return draftCaseData.getSecureOrFlexibleGroundsReasons(); + } + + private RentArrearsGroundsReasons getRentArrearsGroundsReasons(PCSCase draftCaseData) { + return draftCaseData.getRentArrearsGroundsReasons(); + } + + private IntroductoryDemotedOtherGroundReason getIntroductoryDemotedOtherGroundReason(PCSCase draftCaseData) { + return draftCaseData.getIntroductoryDemotedOtherGroundReason(); + } + private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index d95fe478ac..494a471028 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -18,6 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -47,8 +48,14 @@ void shouldSetSummaryTabFields() { .propertyAddress(propertyAddress) .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder().label("Ground 1").build()), - listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + listValue(ClaimGroundSummary.builder() + .label("Rent arrears (ground 10)") + .reason("Ground 10 reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .build()) )) .additionalReasonsForPossession(AdditionalReasons.builder() .hasReasons(VerticalYesNo.YES) @@ -103,9 +110,12 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getGroundsForPossession().getGrounds()) + .isEqualTo("Rent arrears (ground 10), Condition 1 of Section 84A of the Housing Act 1985"); assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); + assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) + .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); @@ -253,6 +263,202 @@ void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { .isEqualTo(address); } + @Test + void shouldSetEachGroundReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Antisocial behaviour") + .reason("Antisocial reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Premium paid in connection with mutual exchange (ground 6)") + .reason("Premium reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Offence during a riot (ground 2ZA)") + .reason("Riot reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Landlord’s works (ground 10)") + .reason("Works reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Housing association special circumstances accommodation (ground 14)") + .reason("Housing reason") + .build()) + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getGround6()).isEqualTo("Premium reason"); + assertThat(reasons.getGround2ZA()).isEqualTo("Riot reason"); + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getGround10()).isEqualTo("Works reason"); + assertThat(reasons.getGround14()).isEqualTo("Housing reason"); + } + + @Test + void shouldSetEachGroundNumberReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (ground 1)", "Reason 1"), + groundSummary("Ground label (ground 2)", "Reason 2"), + groundSummary("Ground label (ground 2A)", "Reason 2A"), + groundSummary("Ground label (ground 2ZA)", "Reason 2ZA"), + groundSummary("Ground label (ground 3)", "Reason 3"), + groundSummary("Ground label (ground 4)", "Reason 4"), + groundSummary("Ground label (ground 5)", "Reason 5"), + groundSummary("Ground label (ground 6)", "Reason 6"), + groundSummary("Ground label (ground 7)", "Reason 7"), + groundSummary("Ground label (ground 7A)", "Reason 7A"), + groundSummary("Ground label (ground 7B)", "Reason 7B"), + groundSummary("Ground label (ground 8)", "Reason 8"), + groundSummary("Ground label (ground 9)", "Reason 9"), + groundSummary("Ground label (ground 10)", "Reason 10"), + groundSummary("Ground label (ground 10A)", "Reason 10A"), + groundSummary("Ground label (ground 11)", "Reason 11"), + groundSummary("Ground label (ground 12)", "Reason 12"), + groundSummary("Ground label (ground 13)", "Reason 13"), + groundSummary("Ground label (ground 14)", "Reason 14"), + groundSummary("Ground label (ground 14A)", "Reason 14A"), + groundSummary("Ground label (ground 14ZA)", "Reason 14ZA"), + groundSummary("Ground label (ground 15)", "Reason 15"), + groundSummary("Ground label (ground 15A)", "Reason 15A"), + groundSummary("Ground label (ground 16)", "Reason 16"), + groundSummary("Ground label (ground 17)", "Reason 17"), + groundSummary("Ground label (ground A)", "Reason A"), + groundSummary("Ground label (ground B)", "Reason B"), + groundSummary("Ground label (ground C)", "Reason C"), + groundSummary("Ground label (ground D)", "Reason D"), + groundSummary("Ground label (ground E)", "Reason E"), + groundSummary("Ground label (ground F)", "Reason F"), + groundSummary("Ground label (ground G)", "Reason G"), + groundSummary("Ground label (ground H)", "Reason H"), + groundSummary("Ground label (ground I)", "Reason I"), + groundSummary("Ground label (ground Z)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getGround1()).isEqualTo("Reason 1"); + assertThat(reasons.getGround2()).isEqualTo("Reason 2"); + assertThat(reasons.getGround2A()).isEqualTo("Reason 2A"); + assertThat(reasons.getGround2ZA()).isEqualTo("Reason 2ZA"); + assertThat(reasons.getGround3()).isEqualTo("Reason 3"); + assertThat(reasons.getGround4()).isEqualTo("Reason 4"); + assertThat(reasons.getGround5()).isEqualTo("Reason 5"); + assertThat(reasons.getGround6()).isEqualTo("Reason 6"); + assertThat(reasons.getGround7()).isEqualTo("Reason 7"); + assertThat(reasons.getGround7A()).isEqualTo("Reason 7A"); + assertThat(reasons.getGround7B()).isEqualTo("Reason 7B"); + assertThat(reasons.getGround8()).isEqualTo("Reason 8"); + assertThat(reasons.getGround9()).isEqualTo("Reason 9"); + assertThat(reasons.getGround10()).isEqualTo("Reason 10"); + assertThat(reasons.getGround10A()).isEqualTo("Reason 10A"); + assertThat(reasons.getGround11()).isEqualTo("Reason 11"); + assertThat(reasons.getGround12()).isEqualTo("Reason 12"); + assertThat(reasons.getGround13()).isEqualTo("Reason 13"); + assertThat(reasons.getGround14()).isEqualTo("Reason 14"); + assertThat(reasons.getGround14A()).isEqualTo("Reason 14A"); + assertThat(reasons.getGround14ZA()).isEqualTo("Reason 14ZA"); + assertThat(reasons.getGround15()).isEqualTo("Reason 15"); + assertThat(reasons.getGround15A()).isEqualTo("Reason 15A"); + assertThat(reasons.getGround16()).isEqualTo("Reason 16"); + assertThat(reasons.getGround17()).isEqualTo("Reason 17"); + assertThat(reasons.getGroundA()).isEqualTo("Reason A"); + assertThat(reasons.getGroundB()).isEqualTo("Reason B"); + assertThat(reasons.getGroundC()).isEqualTo("Reason C"); + assertThat(reasons.getGroundD()).isEqualTo("Reason D"); + assertThat(reasons.getGroundE()).isEqualTo("Reason E"); + assertThat(reasons.getGroundF()).isEqualTo("Reason F"); + assertThat(reasons.getGroundG()).isEqualTo("Reason G"); + assertThat(reasons.getGroundH()).isEqualTo("Reason H"); + assertThat(reasons.getGroundI()).isEqualTo("Reason I"); + } + + @Test + void shouldSetEachSectionReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (section 157)", "Reason 157"), + groundSummary("Ground label (section 170)", "Reason 170"), + groundSummary("Ground label (section 178)", "Reason 178"), + groundSummary("Ground label (section 181)", "Reason 181"), + groundSummary("Ground label (section 186)", "Reason 186"), + groundSummary("Ground label (section 187)", "Reason 187"), + groundSummary("Ground label (section 191)", "Reason 191"), + groundSummary("Ground label (section 199)", "Reason 199"), + groundSummary("Ground label (section 999)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getSection157()).isEqualTo("Reason 157"); + assertThat(reasons.getSection170()).isEqualTo("Reason 170"); + assertThat(reasons.getSection178()).isEqualTo("Reason 178"); + assertThat(reasons.getSection181()).isEqualTo("Reason 181"); + assertThat(reasons.getSection186()).isEqualTo("Reason 186"); + assertThat(reasons.getSection187()).isEqualTo("Reason 187"); + assertThat(reasons.getSection191()).isEqualTo("Reason 191"); + assertThat(reasons.getSection199()).isEqualTo("Reason 199"); + } + + @Test + void shouldSetNonNumberedGroundReasonsInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Breach of the tenancy", "Breach reason"), + groundSummary("Absolute grounds", "Absolute reason"), + groundSummary("Other", "Other reason"), + groundSummary("Other grounds", "Other grounds reason"), + groundSummary("No grounds", "No grounds reason"), + groundSummary("Converted contract paragraph 25B(2) of Schedule 12", "Paragraph reason"), + groundSummary("Unmapped label", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getCondition2OfSection84A()).isEqualTo("Condition 2 reason"); + assertThat(reasons.getCondition3OfSection84A()).isEqualTo("Condition 3 reason"); + assertThat(reasons.getCondition4OfSection84A()).isEqualTo("Condition 4 reason"); + assertThat(reasons.getCondition5OfSection84A()).isEqualTo("Condition 5 reason"); + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getBreachOfTheTenancy()).isEqualTo("Breach reason"); + assertThat(reasons.getAbsoluteGrounds()).isEqualTo("Absolute reason"); + assertThat(reasons.getOtherGrounds()).isEqualTo("Other grounds reason"); + assertThat(reasons.getNoGrounds()).isEqualTo("No grounds reason"); + assertThat(reasons.getParagraph25B2Schedule12()).isEqualTo("Paragraph reason"); + } + @Test void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { // Given @@ -361,4 +567,11 @@ private static ListValue listValue(T value) { .value(value) .build(); } + + private static ListValue groundSummary(String label, String reason) { + return listValue(ClaimGroundSummary.builder() + .label(label) + .reason(reason) + .build()); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 18680825c4..e0e4f827f6 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -24,12 +24,15 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; @@ -266,8 +269,12 @@ void shouldBuildClaimGroundSummariesFromDraft() { .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm .ADAPTED_ACCOMMODATION - )) - .build()) + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner occupier reason") + .breachOfTenancyConditionsReason("Breach reason") + .build()) .groundsForPossessionWales(GroundsForPossessionWales.builder() .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) @@ -302,6 +309,109 @@ void shouldBuildClaimGroundSummariesFromDraft() { "Owner occupier (ground 1)", "Breach of tenancy conditions (ground 12)" ); + assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); + assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); + assertNoReason(summaries, "Serious rent arrears (ground 8)"); + assertNoReason(summaries, "Rent arrears (ground 10)"); + } + + @Test + void shouldMapAllAssuredDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10, + AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, + AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, + AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, + AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, + AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, + AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, + AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, + AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, + AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds + .ALTERNATIVE_ACCOMMODATION_GROUND9, + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_PROPERTY_GROUND13, + AssuredAdditionalDiscretionaryGrounds + .NUISANCE_ANNOYANCE_GROUND14, + AssuredAdditionalDiscretionaryGrounds + .DOMESTIC_VIOLENCE_GROUND14A, + AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_FURNITURE_GROUND15, + AssuredAdditionalDiscretionaryGrounds + .EMPLOYEE_LANDLORD_GROUND16, + AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner reason") + .repossessionByLenderReason("Lender reason") + .holidayLetReason("Holiday reason") + .studentLetReason("Student reason") + .ministerOfReligionReason("Minister reason") + .redevelopmentReason("Redevelopment reason") + .deathOfTenantReason("Death reason") + .antisocialBehaviourReason("ASB reason") + .noRightToRentReason("No right reason") + .suitableAltAccommodationReason("Alternative reason") + .breachOfTenancyConditionsReason("Breach reason") + .propertyDeteriorationReason("Property reason") + .nuisanceAnnoyanceReason("Nuisance reason") + .domesticViolenceReason("Domestic reason") + .offenceDuringRiotReason("Riot reason") + .furnitureDeteriorationReason("Furniture reason") + .employeeOfLandlordReason("Employee reason") + .tenancyByFalseStatementReason("False statement reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); + assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); + assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); + assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); + assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); + assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); + assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); + assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), + "Alternative reason"); + assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Property reason"); + assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); + assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), + "Domestic reason"); + assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), + "Furniture reason"); + assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), + "Employee reason"); + assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), + "False statement reason"); + assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); } @Test @@ -395,6 +505,10 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 )) .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .holidayLetReason("Holiday reason") + .propertyDeteriorationReason("Deterioration reason") + .build()) .build(); // When @@ -409,6 +523,9 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() ); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Deterioration reason"); } @Test @@ -423,20 +540,29 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL )) .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY + .PREMIUM_PAID_MUTUAL_EXCHANGE )) .secureAntisocialAdditionalGrounds(Set.of( SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 )) .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS )) .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES )) .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("Antisocial reason") + .riotOffenceGround("Riot reason") + .premiumMutualExchangeGround("Premium reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .landlordWorksGround("Landlord works reason") + .housingAssocSpecialGround("Housing association reason") + .build()) .build(); // When @@ -449,11 +575,169 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { .map(ClaimGroundSummary::getLabel) .containsExactlyInAnyOrder( SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel() + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + .getLabel() ); + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Landlord works reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing association reason"); + } + + @Test + void shouldMapAllSecureAndFlexibleDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY, + SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, + SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds + .TENANCY_OBTAINED_BY_FALSE_STATEMENT, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE, + SecureOrFlexibleDiscretionaryGrounds + .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm + .CHARITABLE_LANDLORD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .SPECIAL_NEEDS_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .UNDER_OCCUPYING_AFTER_SUCCESSION + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("ASB reason") + .breachOfTenancyGround("Breach reason") + .nuisanceOrImmoralUseGround("Nuisance reason") + .domesticViolenceGround("Domestic reason") + .riotOffenceGround("Riot reason") + .propertyDeteriorationGround("Property reason") + .furnitureDeteriorationGround("Furniture reason") + .tenancyByFalseStatementGround("False statement reason") + .premiumMutualExchangeGround("Premium reason") + .unreasonableConductGround("Unreasonable reason") + .refusalToMoveBackGround("Refusal reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .antiSocialCondition2OfS84AGround("Condition 2 reason") + .antiSocialCondition3OfS84AGround("Condition 3 reason") + .antiSocialCondition4OfS84AGround("Condition 4 reason") + .antiSocialCondition5OfS84AGround("Condition 5 reason") + .overcrowdingGround("Overcrowding reason") + .landlordWorksGround("Works reason") + .propertySoldGround("Sold reason") + .charitableLandlordGround("Charitable reason") + .tiedAccommodationGround("Tied reason") + .adaptedAccommodationGround("Adapted reason") + .housingAssocSpecialGround("Housing reason") + .specialNeedsAccommodationGround("Special needs reason") + .underOccupancySuccessionGround("Under occupation reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), + "Nuisance reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), + "Domestic reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), + "Property reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), + "Furniture reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), + "False statement reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION + .getLabel(), "Unreasonable reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), + "Refusal reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), + "Condition 2 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), + "Condition 3 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), + "Condition 4 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), + "Condition 5 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), + "Overcrowding reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Works reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + "Sold reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), + "Charitable reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), + "Tied reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), + "Adapted reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), + "Special needs reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), + "Under occupation reason"); } @Test @@ -466,9 +750,15 @@ void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { .introductoryDemotedOrOtherGroundsForPossession( IntroductoryDemotedOtherGroundsForPossession.builder() .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS + )) .build() ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .antiSocialBehaviourGround("Intro antisocial reason") + .build()) .build(); // When @@ -479,7 +769,13 @@ void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { assertThat(summaries) .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) - .containsExactly(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel()); + .containsExactlyInAnyOrder( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() + ); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + "Intro antisocial reason"); + assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); } @Test @@ -494,6 +790,9 @@ void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) .build() ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .noGrounds("No grounds reason") + .build()) .build(); // When @@ -505,6 +804,43 @@ void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); + } + + @Test + void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, + IntroductoryDemotedOrOtherGrounds.OTHER + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .breachOfTheTenancyGround("Breach reason") + .absoluteGrounds("Absolute reason") + .otherGround("Other reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + "Absolute reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); } @Test @@ -657,5 +993,24 @@ private static Stream claimGroundScenarios() { ); } + private static void assertReason(List> summaries, + String label, + String reason) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isEqualTo(reason); + } + + private static void assertNoReason(List> summaries, String label) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isNull(); + } } From 615627749d23d37085cbc4cae4be7588e82fada1 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 17:06:12 +0100 Subject: [PATCH 020/138] HDPI-2978: Build Case Summary tab --- .../GroundsForPossessionTabDetails.java | 5 +- .../pcs/ccd/view/CaseSummaryTabView.java | 48 ++++++++++++++++++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 36 +++++++++++++- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java index 0fb214c9e7..76e8fd108a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java @@ -6,6 +6,8 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import static uk.gov.hmcts.ccd.sdk.type.FieldType.TextArea; + @Builder @Data @NoArgsConstructor @@ -13,7 +15,8 @@ public class GroundsForPossessionTabDetails { @CCD( - label = "Grounds" + label = "Grounds", + typeOverride = TextArea ) private String grounds; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index ced75a04ad..5b8f5df194 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -32,6 +32,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -49,6 +50,9 @@ public class CaseSummaryTabView { Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); private static final Pattern SECTION_REFERENCE_PATTERN = Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_84A_CONDITION_PATTERN = + Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); + private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -460,10 +464,50 @@ private String getGrounds(PCSCase pcsCase) { return null; } - return pcsCase.getClaimGroundSummaries().stream() + List grounds = new ArrayList<>(pcsCase.getClaimGroundSummaries().stream() .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) - .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .toList()); + + groupSection84AConditions(grounds); + + return grounds.stream() + .reduce((firstGround, secondGround) -> firstGround + "\n" + secondGround) .orElse(null); } + + private void groupSection84AConditions(List grounds) { + int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); + if (antisocialIndex < 0) { + return; + } + + List section84AConditions = grounds.stream() + .filter(this::isSection84ACondition) + .sorted(this::compareSection84AConditions) + .toList(); + + if (section84AConditions.isEmpty()) { + return; + } + + grounds.set(antisocialIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); + grounds.removeAll(section84AConditions); + } + + private boolean isSection84ACondition(String label) { + return SECTION_84A_CONDITION_PATTERN.matcher(label).matches(); + } + + private int compareSection84AConditions(String firstCondition, String secondCondition) { + return Integer.compare( + getSection84AConditionNumber(firstCondition), + getSection84AConditionNumber(secondCondition) + ); + } + + private int getSection84AConditionNumber(String label) { + Matcher matcher = SECTION_84A_CONDITION_PATTERN.matcher(label); + return matcher.matches() ? Integer.parseInt(matcher.group(1)) : 0; + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 494a471028..39518926ac 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -111,7 +111,7 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) - .isEqualTo("Rent arrears (ground 10), Condition 1 of Section 84A of the Housing Act 1985"); + .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) @@ -307,6 +307,40 @@ void shouldSetEachGroundReasonInSummaryTab() { assertThat(reasons.getGround14()).isEqualTo("Housing reason"); } + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Nuisance reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", + "Antisocial behaviour: " + String.join(", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985", + "Condition 3 of Section 84A of the Housing Act 1985", + "Condition 4 of Section 84A of the Housing Act 1985", + "Condition 5 of Section 84A of the Housing Act 1985" + ), + "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Landlord’s works (ground 10)" + )); + } + @Test void shouldSetEachGroundNumberReasonInSummaryTab() { // Given From cbd58caffe30b58f27fb4cc2238588e4a1bf52de Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 10:42:24 +0100 Subject: [PATCH 021/138] HDPI-2978: Build Case Summary tab --- ...096__add_claim_submitted_date.sql => V096__add_created_at.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V096__add_claim_submitted_date.sql => V096__add_created_at.sql} (100%) diff --git a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_created_at.sql similarity index 100% rename from src/main/resources/db/migration/V096__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V096__add_created_at.sql From 36d38ac53cfea2de384e973f57ace477dcbc5641 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 14:05:36 +0100 Subject: [PATCH 022/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 15 ++++------- .../tabs/summary/TenancyTabDetails.java | 3 +-- .../pcs/ccd/service/PcsCaseService.java | 25 ++++++++++++++--- .../db/migration/V096__add_created_at.sql | 2 +- .../pcs/ccd/service/PcsCaseServiceTest.java | 27 ++++++++++++++++++- 5 files changed, 55 insertions(+), 17 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 6895d7927d..2028b742e6 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 @@ -129,10 +129,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") .field("summaryTab_ClaimSubmittedDate") - .field("summaryTab_ReasonsForPossession", - "summaryTab_ReasonsForPossession!=\"\"") - .field("summaryTab_PossessionReasonsSubmittedDate", - "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_ReasonsForPossession", null) + .field("summaryTab_PossessionReasonsSubmittedDate", null) .field("summaryTab_ClaimSubmittedDate") .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", @@ -141,10 +139,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Defendant details", "summaryTab_DefendantDetails!=\"\"", "## Defendant details") - .field("summaryTab_DefendantDetails", - "summaryTab_DefendantDetails!=\"\"") - .field("summaryTab_AdditionalDefendants", - "summaryTab_AdditionalDefendants!=\"\"") + .field("summaryTab_DefendantDetails", null) + .field("summaryTab_AdditionalDefendants", null) .label("Rent arrears", "summaryTab_RentArrearsDetails!=\"\"", "## Rent arrears") @@ -156,7 +152,6 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Notice", "summaryTab_NoticeDetails!=\"\"", "## Notice") - .field("summaryTab_NoticeDetails", - "summaryTab_NoticeDetails!=\"\""); + .field("summaryTab_NoticeDetails", null); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java index f140e76b89..76ffe57915 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -18,8 +18,7 @@ public class TenancyTabDetails { private String agreementType; @CCD( - label = "Tenancy, occupation contract or licence agreement start date", - showCondition = "agreementStartDate!=\"\"" + label = "Tenancy, occupation contract or licence agreement start date" ) private String agreementStartDate; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index 6c7c939a99..56d3fecd5a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -1,7 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.service; -import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; @@ -14,13 +14,13 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.Clock; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @Service @Slf4j -@AllArgsConstructor public class PcsCaseService { private final PcsCaseRepository pcsCaseRepository; @@ -30,6 +30,25 @@ public class PcsCaseService { private final TenancyLicenceService tenancyLicenceService; private final AddressMapper addressMapper; private final CaseLinkService caseLinkService; + private final Clock ukClock; + + public PcsCaseService(PcsCaseRepository pcsCaseRepository, + ClaimService claimService, + PartyService partyService, + DocumentService documentService, + TenancyLicenceService tenancyLicenceService, + AddressMapper addressMapper, + CaseLinkService caseLinkService, + @Qualifier("ukClock") Clock ukClock) { + this.pcsCaseRepository = pcsCaseRepository; + this.claimService = claimService; + this.partyService = partyService; + this.documentService = documentService; + this.tenancyLicenceService = tenancyLicenceService; + this.addressMapper = addressMapper; + this.caseLinkService = caseLinkService; + this.ukClock = ukClock; + } public PcsCaseEntity createCase(long caseReference, AddressUK propertyAddress, @@ -48,7 +67,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); - pcsCaseEntity.setCreatedAt(LocalDateTime.now()); + pcsCaseEntity.setCreatedAt(LocalDateTime.now(ukClock)); ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); List documentEntities = documentService.createAllDocuments(pcsCase); diff --git a/src/main/resources/db/migration/V096__add_created_at.sql b/src/main/resources/db/migration/V096__add_created_at.sql index d6c27708e8..5fce3fed69 100644 --- a/src/main/resources/db/migration/V096__add_created_at.sql +++ b/src/main/resources/db/migration/V096__add_created_at.sql @@ -1 +1 @@ -ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP; +ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP WITH TIME ZONE; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index 2c082ca805..4dc4b3627a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -26,6 +26,9 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.Clock; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -42,6 +45,12 @@ class PcsCaseServiceTest { private static final long CASE_REFERENCE = 1234L; + private static final ZoneId UK_ZONE_ID = ZoneId.of("Europe/London"); + private static final LocalDateTime FIXED_DATE_TIME = LocalDateTime.of(2026, 5, 14, 10, 30); + private static final Clock FIXED_UK_CLOCK = Clock.fixed( + FIXED_DATE_TIME.atZone(UK_ZONE_ID).toInstant(), + UK_ZONE_ID + ); @Mock private PcsCaseRepository pcsCaseRepository; @@ -73,7 +82,8 @@ void setUp() { documentService, tenancyLicenceService, addressMapper, - caseLinkService + caseLinkService, + FIXED_UK_CLOCK ); } @@ -140,6 +150,21 @@ void shouldDelegateToClaimServiceToCreateMainClaim() { verify(pcsCaseEntity).addClaim(mainClaimEntity); } + @Test + void shouldSetCreatedAtUsingUkClockWhenCreatingMainClaim() { + // Given + PcsCaseEntity pcsCaseEntity = stubFindCase(); + stubClaimCreation(); + + PCSCase caseData = PCSCase.builder().build(); + + // When + underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); + + // Then + verify(pcsCaseEntity).setCreatedAt(FIXED_DATE_TIME); + } + @Test void shouldCreatePartiesWithMainClaimOnCase() { // Given From 4b42c385b4c5dd461ed6bb20b2774bb408a373ba Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 14:46:15 +0100 Subject: [PATCH 023/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 4 +--- .../reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 7 +------ .../gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java | 3 +-- .../hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java | 5 ++--- 4 files changed, 5 insertions(+), 14 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 2028b742e6..352a1719e1 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 @@ -128,10 +128,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Summary", null, "## Summary") .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") - .field("summaryTab_ClaimSubmittedDate") .field("summaryTab_ReasonsForPossession", null) - .field("summaryTab_PossessionReasonsSubmittedDate", null) - .field("summaryTab_ClaimSubmittedDate") + .field("summaryTab_DateClaimSubmitted", null) .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", "## Claimant details") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 6c703fdb62..603649680e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -33,11 +33,6 @@ public class SummaryTab { ) private GroundsForPossessionTabDetails groundsForPossession; - @CCD( - label = "Date claim Submitted" - ) - private String claimSubmittedDate; - @CCD( label = "Reasons for possession" ) @@ -46,7 +41,7 @@ public class SummaryTab { @CCD( label = "Date claim Submitted" ) - private String possessionReasonsSubmittedDate; + private String dateClaimSubmitted; @CCD( label = "Claimant" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 5b8f5df194..6a38668b09 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -63,9 +63,8 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { .groundsForPossession(GroundsForPossessionTabDetails.builder() .grounds(getGrounds(pcsCase)) .build()) - .claimSubmittedDate(dateSubmitted) .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) + .dateClaimSubmitted(dateSubmitted) .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 39518926ac..7160aedf96 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -112,13 +112,12 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); - assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); @@ -201,7 +200,7 @@ void shouldNotSetEmptySummarySections() { // Then assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); assertThat(summaryTab.getReasonsForPossession()).isNull(); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getDateClaimSubmitted()).isNull(); assertThat(summaryTab.getClaimantDetails()).isNull(); assertThat(summaryTab.getDefendantDetails()).isNull(); assertThat(summaryTab.getAdditionalDefendants()).isNull(); From ca088db647a0ebedaadf2a460349d147bb3866b5 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 15:50:20 +0100 Subject: [PATCH 024/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 10 +- .../reform/pcs/ccd/view/CaseTabView.java | 4 +- .../ccd/view/ClaimGroundSummaryBuilder.java | 303 ++++++++ .../reform/pcs/ccd/view/ClaimGroundsView.java | 285 ------- .../reform/pcs/ccd/view/CaseTabViewTest.java | 8 +- .../view/ClaimGroundSummaryBuilderTest.java | 716 ++++++++++++++++++ .../pcs/ccd/view/ClaimGroundsViewTest.java | 675 ----------------- 7 files changed, 1030 insertions(+), 971 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.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 352a1719e1..67e53526ba 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 @@ -128,8 +128,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Summary", null, "## Summary") .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") - .field("summaryTab_ReasonsForPossession", null) - .field("summaryTab_DateClaimSubmitted", null) + .field("summaryTab_ReasonsForPossession") + .field("summaryTab_DateClaimSubmitted") .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", "## Claimant details") @@ -137,8 +137,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Defendant details", "summaryTab_DefendantDetails!=\"\"", "## Defendant details") - .field("summaryTab_DefendantDetails", null) - .field("summaryTab_AdditionalDefendants", null) + .field("summaryTab_DefendantDetails") + .field("summaryTab_AdditionalDefendants") .label("Rent arrears", "summaryTab_RentArrearsDetails!=\"\"", "## Rent arrears") @@ -150,6 +150,6 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Notice", "summaryTab_NoticeDetails!=\"\"", "## Notice") - .field("summaryTab_NoticeDetails", null); + .field("summaryTab_NoticeDetails"); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index d5b9d51cfe..24ea626b44 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -24,7 +24,7 @@ public class CaseTabView { static final String NAME_UNKNOWN = "Person unknown"; - private final ClaimGroundsView claimGroundsView; + private final ClaimGroundSummaryBuilder claimGroundSummaryBuilder; private final CaseSummaryTabView caseSummaryTabView; public void setCaseTabFields(PCSCase pcsCase) { @@ -49,7 +49,7 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { } List> draftGrounds = - claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) ? pcsCase.getClaimGroundSummaries() : draftGrounds); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java new file mode 100644 index 0000000000..d4c98b557b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -0,0 +1,303 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.PossessionGroundEnum; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +@Component +public class ClaimGroundSummaryBuilder { + + public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { + List> summaries = new ArrayList<>(); + + OccupationLicenceDetailsWales occupationLicenceDetailsWales = draftCaseData.getOccupationLicenceDetailsWales(); + OccupationLicenceTypeWales occupationLicenceType = occupationLicenceDetailsWales == null + ? null : occupationLicenceDetailsWales.getOccupationLicenceTypeWales(); + + if (occupationLicenceType == OccupationLicenceTypeWales.SECURE_CONTRACT) { + Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } else if (occupationLicenceType == OccupationLicenceTypeWales.STANDARD_CONTRACT + || occupationLicenceType == OccupationLicenceTypeWales.OTHER) { + Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } + + TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); + TenancyLicenceType tenancyType = tenancyLicenceDetails == null + ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); + + if (tenancyType == TenancyLicenceType.ASSURED_TENANCY) { + if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { + addAssuredRentArrearsGrounds(summaries, draftCaseData); + } else if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.NO) { + Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); + }); + } + } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY + || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { + Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt(), draftCaseData); + }); + } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY + || tenancyType == TenancyLicenceType.DEMOTED_TENANCY + || tenancyType == TenancyLicenceType.OTHER) { + addIntroductoryDemotedOrOtherGrounds(summaries, draftCaseData); + } + + return summaries; + } + + private void addAssuredRentArrearsGrounds(List> summaries, + PCSCase draftCaseData) { + Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { + if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { + addGrounds(summaries, selected.getRentArrearsGrounds().stream() + .map(this::mapAssuredRentArrearsGround) + .toList(), draftCaseData); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { + addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() + .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) + .toList(), draftCaseData); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { + addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() + .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) + .toList(), draftCaseData); + } + }); + } + + private void addIntroductoryDemotedOrOtherGrounds(List> summaries, + PCSCase draftCaseData) { + IntroductoryDemotedOtherGroundsForPossession selected = + draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); + + if (selected == null) { + return; + } + + if (selected.getHasIntroductoryDemotedOtherGroundsForPossession() == VerticalYesNo.NO) { + addGrounds(summaries, Set.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS), draftCaseData); + return; + } + + addGrounds(summaries, selected.getIntroductoryDemotedOrOtherGrounds(), draftCaseData); + } + + private void addGrounds(List> summaries, + Set grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds)); + } + } + + private void addGrounds(List> summaries, + Set grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds), draftCaseData); + } + } + + private void addGrounds(List> summaries, + List grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder().label(ground.getLabel()).build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private void addGrounds(List> summaries, + List grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder() + .code(((Enum) ground).name()) + .label(ground.getLabel()) + .reason(getDraftReason(draftCaseData, ground)) + .build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + return switch (((Enum) ground).name()) { + case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); + case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); + case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); + case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); + case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); + case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); + case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); + case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); + case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); + case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; + case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); + case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); + case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); + case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); + case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); + case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); + case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); + case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); + case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); + case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); + case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); + case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); + case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); + case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); + case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); + case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); + case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); + case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); + case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); + case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); + case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); + case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); + case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); + case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); + case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); + case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); + case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); + case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); + case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); + case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); + case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); + case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); + case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); + case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); + case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); + case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); + case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); + case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); + default -> null; + }; + } + + private String getSection84ACondition1Reason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons reasons = draftCaseData.getSecureOrFlexibleGroundsReasons(); + return reasons == null ? null : reasons.getAntiSocialCondition1OfS84AGround(); + } + + private String getAntiSocialReason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons secureOrFlexibleReasons = getSecureOrFlexibleReason(draftCaseData); + if (secureOrFlexibleReasons != null) { + return secureOrFlexibleReasons.getAntiSocialGround(); + } + + IntroductoryDemotedOtherGroundReason introductoryDemotedOtherReason = + getIntroductoryDemotedOtherGroundReason(draftCaseData); + return introductoryDemotedOtherReason == null + ? null : introductoryDemotedOtherReason.getAntiSocialBehaviourGround(); + } + + private SecureOrFlexibleGroundsReasons getSecureOrFlexibleReason(PCSCase draftCaseData) { + return draftCaseData.getSecureOrFlexibleGroundsReasons(); + } + + private RentArrearsGroundsReasons getRentArrearsGroundsReasons(PCSCase draftCaseData) { + return draftCaseData.getRentArrearsGroundsReasons(); + } + + private IntroductoryDemotedOtherGroundReason getIntroductoryDemotedOtherGroundReason(PCSCase draftCaseData) { + return draftCaseData.getIntroductoryDemotedOtherGroundReason(); + } + + private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { + if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { + return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; + } + + return AssuredDiscretionaryGround.valueOf(ground.name()); + } + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index 8e5b1c6106..ed83c518d1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -1,25 +1,15 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.ListValue; -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.PossessionGroundEnum; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; @@ -27,8 +17,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -37,7 +25,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.util.YesOrNoConverter; -import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; @@ -51,279 +38,7 @@ public class ClaimGroundsView { public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { getMainClaim(pcsCaseEntity) .ifPresent(mainClaim -> setClaimGroundFields(pcsCase, mainClaim)); - } - - public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { - List> summaries = new ArrayList<>(); - - OccupationLicenceDetailsWales occupationLicenceDetailsWales = draftCaseData.getOccupationLicenceDetailsWales(); - OccupationLicenceTypeWales occupationLicenceType = occupationLicenceDetailsWales == null - ? null : occupationLicenceDetailsWales.getOccupationLicenceTypeWales(); - - if (occupationLicenceType == OccupationLicenceTypeWales.SECURE_CONTRACT) { - Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); - addGrounds(summaries, selected.getEstateManagementGrounds()); - }); - - return summaries; - } else if (occupationLicenceType == OccupationLicenceTypeWales.STANDARD_CONTRACT - || occupationLicenceType == OccupationLicenceTypeWales.OTHER) { - Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds()); - addGrounds(summaries, selected.getDiscretionaryGrounds()); - addGrounds(summaries, selected.getEstateManagementGrounds()); - }); - - return summaries; - } - - TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); - TenancyLicenceType tenancyType = tenancyLicenceDetails == null - ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); - - if (tenancyType == TenancyLicenceType.ASSURED_TENANCY) { - if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { - addAssuredRentArrearsGrounds(summaries, draftCaseData); - } else if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.NO) { - Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { - addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); - addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); - }); - } - } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY - || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { - Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds(), draftCaseData); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds(), draftCaseData); - addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds(), draftCaseData); - addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt(), draftCaseData); - addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt(), draftCaseData); - }); - } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY - || tenancyType == TenancyLicenceType.DEMOTED_TENANCY - || tenancyType == TenancyLicenceType.OTHER) { - addIntroductoryDemotedOrOtherGrounds(summaries, draftCaseData); - } - - return summaries; - } - - private void addAssuredRentArrearsGrounds(List> summaries, - PCSCase draftCaseData) { - Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { - if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { - addGrounds(summaries, selected.getRentArrearsGrounds().stream() - .map(this::mapAssuredRentArrearsGround) - .toList(), draftCaseData); - } - if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { - addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() - .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) - .toList(), draftCaseData); - } - if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { - addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() - .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) - .toList(), draftCaseData); - } - }); - } - - private void addIntroductoryDemotedOrOtherGrounds(List> summaries, - PCSCase draftCaseData) { - IntroductoryDemotedOtherGroundsForPossession selected = - draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); - - if (selected == null) { - return; - } - - if (selected.getHasIntroductoryDemotedOtherGroundsForPossession() == VerticalYesNo.NO) { - addGrounds(summaries, Set.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS), draftCaseData); - return; - } - - addGrounds(summaries, selected.getIntroductoryDemotedOrOtherGrounds(), draftCaseData); - } - - private void addGrounds(List> summaries, - Set grounds) { - if (!CollectionUtils.isEmpty(grounds)) { - addGrounds(summaries, List.copyOf(grounds)); - } - } - - private void addGrounds(List> summaries, - Set grounds, - PCSCase draftCaseData) { - if (!CollectionUtils.isEmpty(grounds)) { - addGrounds(summaries, List.copyOf(grounds), draftCaseData); - } - } - - private void addGrounds(List> summaries, - List grounds) { - if (!CollectionUtils.isEmpty(grounds)) { - grounds.stream() - .map(ground -> ClaimGroundSummary.builder().label(ground.getLabel()).build()) - .map(summary -> ListValue.builder().value(summary).build()) - .forEach(summaries::add); - } - } - - private void addGrounds(List> summaries, - List grounds, - PCSCase draftCaseData) { - if (!CollectionUtils.isEmpty(grounds)) { - grounds.stream() - .map(ground -> ClaimGroundSummary.builder() - .code(((Enum) ground).name()) - .label(ground.getLabel()) - .reason(getDraftReason(draftCaseData, ground)) - .build()) - .map(summary -> ListValue.builder().value(summary).build()) - .forEach(summaries::add); - } - } - - private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { - return switch (((Enum) ground).name()) { - case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); - case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); - case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); - case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); - case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); - case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); - case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); - case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); - case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); - case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; - case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); - case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); - case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); - case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); - case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); - case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); - case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); - case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); - case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); - case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); - case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); - case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); - case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); - case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); - case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); - case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); - case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); - case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); - case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); - case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); - case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); - case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); - case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); - case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); - case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); - case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); - case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); - case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); - case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); - case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); - case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); - case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); - case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); - case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); - case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); - case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); - case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); - case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); - default -> null; - }; - } - - private String getSection84ACondition1Reason(PCSCase draftCaseData) { - SecureOrFlexibleGroundsReasons reasons = draftCaseData.getSecureOrFlexibleGroundsReasons(); - return reasons == null ? null : reasons.getAntiSocialCondition1OfS84AGround(); - } - - private String getAntiSocialReason(PCSCase draftCaseData) { - SecureOrFlexibleGroundsReasons secureOrFlexibleReasons = getSecureOrFlexibleReason(draftCaseData); - if (secureOrFlexibleReasons != null) { - return secureOrFlexibleReasons.getAntiSocialGround(); } - - IntroductoryDemotedOtherGroundReason introductoryDemotedOtherReason = - getIntroductoryDemotedOtherGroundReason(draftCaseData); - return introductoryDemotedOtherReason == null - ? null : introductoryDemotedOtherReason.getAntiSocialBehaviourGround(); - } - - private SecureOrFlexibleGroundsReasons getSecureOrFlexibleReason(PCSCase draftCaseData) { - return draftCaseData.getSecureOrFlexibleGroundsReasons(); - } - - private RentArrearsGroundsReasons getRentArrearsGroundsReasons(PCSCase draftCaseData) { - return draftCaseData.getRentArrearsGroundsReasons(); - } - - private IntroductoryDemotedOtherGroundReason getIntroductoryDemotedOtherGroundReason(PCSCase draftCaseData) { - return draftCaseData.getIntroductoryDemotedOtherGroundReason(); - } - - private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { - if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { - return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; - } - - return AssuredDiscretionaryGround.valueOf(ground.name()); - } - private void setClaimGroundFields(PCSCase pcsCase, ClaimEntity mainClaim) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 5b63229196..f6649c948f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -28,11 +28,11 @@ public class CaseTabViewTest { private CaseTabView underTest; @Mock - private ClaimGroundsView claimGroundsView; + private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; @BeforeEach void setUp() { - underTest = new CaseTabView(claimGroundsView, new CaseSummaryTabView()); + underTest = new CaseTabView(claimGroundSummaryBuilder, new CaseSummaryTabView()); } @Test @@ -291,7 +291,7 @@ void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { .build(); PCSCase draftCaseData = PCSCase.builder().build(); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); @@ -345,7 +345,7 @@ void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { listValue(ClaimGroundSummary.builder().label("Draft ground").build()) ); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java new file mode 100644 index 0000000000..306a8c3d0a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java @@ -0,0 +1,716 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; + +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +class ClaimGroundSummaryBuilderTest { + + private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; + + @BeforeEach + void setUp() { + claimGroundSummaryBuilder = new ClaimGroundSummaryBuilder(); + } + + @Test + void shouldBuildClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 + )) + .build()) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner occupier reason") + .breachOfTenancyConditionsReason("Breach reason") + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + "Serious rent arrears (ground 8)", + "Rent arrears (ground 10)", + "Owner occupier (ground 1)", + "Breach of tenancy conditions (ground 12)" + ); + assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); + assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); + assertNoReason(summaries, "Serious rent arrears (ground 8)"); + assertNoReason(summaries, "Rent arrears (ground 10)"); + } + + @Test + void shouldMapAllAssuredDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10, + AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, + AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, + AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, + AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, + AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, + AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, + AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, + AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, + AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds + .ALTERNATIVE_ACCOMMODATION_GROUND9, + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_PROPERTY_GROUND13, + AssuredAdditionalDiscretionaryGrounds + .NUISANCE_ANNOYANCE_GROUND14, + AssuredAdditionalDiscretionaryGrounds + .DOMESTIC_VIOLENCE_GROUND14A, + AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_FURNITURE_GROUND15, + AssuredAdditionalDiscretionaryGrounds + .EMPLOYEE_LANDLORD_GROUND16, + AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner reason") + .repossessionByLenderReason("Lender reason") + .holidayLetReason("Holiday reason") + .studentLetReason("Student reason") + .ministerOfReligionReason("Minister reason") + .redevelopmentReason("Redevelopment reason") + .deathOfTenantReason("Death reason") + .antisocialBehaviourReason("ASB reason") + .noRightToRentReason("No right reason") + .suitableAltAccommodationReason("Alternative reason") + .breachOfTenancyConditionsReason("Breach reason") + .propertyDeteriorationReason("Property reason") + .nuisanceAnnoyanceReason("Nuisance reason") + .domesticViolenceReason("Domestic reason") + .offenceDuringRiotReason("Riot reason") + .furnitureDeteriorationReason("Furniture reason") + .employeeOfLandlordReason("Employee reason") + .tenancyByFalseStatementReason("False statement reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); + assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); + assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); + assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); + assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); + assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); + assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); + assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), + "Alternative reason"); + assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Property reason"); + assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); + assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), + "Domestic reason"); + assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), + "Furniture reason"); + assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), + "Employee reason"); + assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), + "False statement reason"); + assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); + + // Then + assertThat(summaries).isEmpty(); + } + + @Test + void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), + SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), + EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() + ); + } + + @Test + void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), + DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() + ); + } + + @Test + void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.NO) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .holidayLetReason("Holiday reason") + .propertyDeteriorationReason("Deterioration reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() + ); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Deterioration reason"); + } + + @Test + void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("Antisocial reason") + .riotOffenceGround("Riot reason") + .premiumMutualExchangeGround("Premium reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .landlordWorksGround("Landlord works reason") + .housingAssocSpecialGround("Housing association reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + .getLabel() + ); + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Landlord works reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing association reason"); + } + + @Test + void shouldMapAllSecureAndFlexibleDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY, + SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, + SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds + .TENANCY_OBTAINED_BY_FALSE_STATEMENT, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE, + SecureOrFlexibleDiscretionaryGrounds + .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm + .CHARITABLE_LANDLORD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .SPECIAL_NEEDS_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .UNDER_OCCUPYING_AFTER_SUCCESSION + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("ASB reason") + .breachOfTenancyGround("Breach reason") + .nuisanceOrImmoralUseGround("Nuisance reason") + .domesticViolenceGround("Domestic reason") + .riotOffenceGround("Riot reason") + .propertyDeteriorationGround("Property reason") + .furnitureDeteriorationGround("Furniture reason") + .tenancyByFalseStatementGround("False statement reason") + .premiumMutualExchangeGround("Premium reason") + .unreasonableConductGround("Unreasonable reason") + .refusalToMoveBackGround("Refusal reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .antiSocialCondition2OfS84AGround("Condition 2 reason") + .antiSocialCondition3OfS84AGround("Condition 3 reason") + .antiSocialCondition4OfS84AGround("Condition 4 reason") + .antiSocialCondition5OfS84AGround("Condition 5 reason") + .overcrowdingGround("Overcrowding reason") + .landlordWorksGround("Works reason") + .propertySoldGround("Sold reason") + .charitableLandlordGround("Charitable reason") + .tiedAccommodationGround("Tied reason") + .adaptedAccommodationGround("Adapted reason") + .housingAssocSpecialGround("Housing reason") + .specialNeedsAccommodationGround("Special needs reason") + .underOccupancySuccessionGround("Under occupation reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), + "Nuisance reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), + "Domestic reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), + "Property reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), + "Furniture reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), + "False statement reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION + .getLabel(), "Unreasonable reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), + "Refusal reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), + "Condition 2 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), + "Condition 3 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), + "Condition 4 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), + "Condition 5 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), + "Overcrowding reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Works reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + "Sold reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), + "Charitable reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), + "Tied reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), + "Adapted reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), + "Special needs reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), + "Under occupation reason"); + } + + @Test + void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .antiSocialBehaviourGround("Intro antisocial reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() + ); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + "Intro antisocial reason"); + assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); + } + + @Test + void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .noGrounds("No grounds reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); + } + + @Test + void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, + IntroductoryDemotedOrOtherGrounds.OTHER + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .breachOfTheTenancyGround("Breach reason") + .absoluteGrounds("Absolute reason") + .otherGround("Other reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + "Absolute reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries).isEmpty(); + } + + private static void assertReason(List> summaries, + String label, + String reason) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isEqualTo(reason); + } + + private static void assertNoReason(List> summaries, String label) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isNull(); + } + + +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index e0e4f827f6..9fdbc5104f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,37 +12,20 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -221,645 +204,6 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { ); } - @Test - void shouldBuildClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.YES) - .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() - .rentArrearsGrounds(Set.of( - AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, - AssuredRentArrearsGround.RENT_ARREARS_GROUND10 - )) - .additionalMandatoryGrounds(Set.of( - AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 - )) - .additionalDiscretionaryGrounds(Set.of( - AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 - )) - .build()) - .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() - .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) - .discretionaryGrounds(Set.of( - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 - )) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) - .build() - ) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .ownerOccupierReason("Owner occupier reason") - .breachOfTenancyConditionsReason("Breach reason") - .build()) - .groundsForPossessionWales(GroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) - .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES - )) - .build()) - .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 - )) - .discretionaryGrounds(Set.of( - SecureContractDiscretionaryGroundsWales - .ANTISOCIAL_BEHAVIOUR_S157 - )) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.RESERVE_SUCCESSORS - )) - .build()) - .build(); - - // When - List> summaries = underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - "Serious rent arrears (ground 8)", - "Rent arrears (ground 10)", - "Owner occupier (ground 1)", - "Breach of tenancy conditions (ground 12)" - ); - assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); - assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); - assertNoReason(summaries, "Serious rent arrears (ground 8)"); - assertNoReason(summaries, "Rent arrears (ground 10)"); - } - - @Test - void shouldMapAllAssuredDraftGroundReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.YES) - .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() - .rentArrearsGrounds(Set.of( - AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, - AssuredRentArrearsGround.RENT_ARREARS_GROUND10, - AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 - )) - .additionalMandatoryGrounds(Set.of( - AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, - AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, - AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, - AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, - AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, - AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, - AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, - AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, - AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B - )) - .additionalDiscretionaryGrounds(Set.of( - AssuredAdditionalDiscretionaryGrounds - .ALTERNATIVE_ACCOMMODATION_GROUND9, - AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, - AssuredAdditionalDiscretionaryGrounds - .DETERIORATION_PROPERTY_GROUND13, - AssuredAdditionalDiscretionaryGrounds - .NUISANCE_ANNOYANCE_GROUND14, - AssuredAdditionalDiscretionaryGrounds - .DOMESTIC_VIOLENCE_GROUND14A, - AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, - AssuredAdditionalDiscretionaryGrounds - .DETERIORATION_FURNITURE_GROUND15, - AssuredAdditionalDiscretionaryGrounds - .EMPLOYEE_LANDLORD_GROUND16, - AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .ownerOccupierReason("Owner reason") - .repossessionByLenderReason("Lender reason") - .holidayLetReason("Holiday reason") - .studentLetReason("Student reason") - .ministerOfReligionReason("Minister reason") - .redevelopmentReason("Redevelopment reason") - .deathOfTenantReason("Death reason") - .antisocialBehaviourReason("ASB reason") - .noRightToRentReason("No right reason") - .suitableAltAccommodationReason("Alternative reason") - .breachOfTenancyConditionsReason("Breach reason") - .propertyDeteriorationReason("Property reason") - .nuisanceAnnoyanceReason("Nuisance reason") - .domesticViolenceReason("Domestic reason") - .offenceDuringRiotReason("Riot reason") - .furnitureDeteriorationReason("Furniture reason") - .employeeOfLandlordReason("Employee reason") - .tenancyByFalseStatementReason("False statement reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); - assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); - assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); - assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); - assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); - assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); - assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); - assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); - assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); - assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), - "Alternative reason"); - assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), - "Property reason"); - assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); - assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), - "Domestic reason"); - assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), - "Furniture reason"); - assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), - "Employee reason"); - assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), - "False statement reason"); - assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); - assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); - assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); - } - - @Test - void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); - - // Then - assertThat(summaries).isEmpty(); - } - - @Test - void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) - .build()) - .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 - )) - .discretionaryGrounds(Set.of( - SecureContractDiscretionaryGroundsWales - .ANTISOCIAL_BEHAVIOUR_S157 - )) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.RESERVE_SUCCESSORS - )) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), - SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), - EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() - ); - } - - @Test - void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) - .build()) - .groundsForPossessionWales(GroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) - .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES - )) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), - DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() - ); - } - - @Test - void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.NO) - .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() - .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) - .discretionaryGrounds(Set.of( - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .holidayLetReason("Holiday reason") - .propertyDeteriorationReason("Deterioration reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() - ); - assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), - "Deterioration reason"); - } - - @Test - void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) - .build()) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, - SecureOrFlexibleDiscretionaryGrounds - .PREMIUM_PAID_MUTUAL_EXCHANGE - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES - )) - .build()) - .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("Antisocial reason") - .riotOffenceGround("Riot reason") - .premiumMutualExchangeGround("Premium reason") - .antiSocialCondition1OfS84AGround("Condition 1 reason") - .landlordWorksGround("Landlord works reason") - .housingAssocSpecialGround("Housing association reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES - .getLabel() - ); - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - "Premium reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - "Condition 1 reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - "Landlord works reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), - "Housing association reason"); - } - - @Test - void shouldMapAllSecureAndFlexibleDraftGroundReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) - .build()) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY, - SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, - SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, - SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, - SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, - SecureOrFlexibleDiscretionaryGrounds - .TENANCY_OBTAINED_BY_FALSE_STATEMENT, - SecureOrFlexibleDiscretionaryGrounds - .PREMIUM_PAID_MUTUAL_EXCHANGE, - SecureOrFlexibleDiscretionaryGrounds - .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm - .CHARITABLE_LANDLORD - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .SPECIAL_NEEDS_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .UNDER_OCCUPYING_AFTER_SUCCESSION - )) - .build()) - .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("ASB reason") - .breachOfTenancyGround("Breach reason") - .nuisanceOrImmoralUseGround("Nuisance reason") - .domesticViolenceGround("Domestic reason") - .riotOffenceGround("Riot reason") - .propertyDeteriorationGround("Property reason") - .furnitureDeteriorationGround("Furniture reason") - .tenancyByFalseStatementGround("False statement reason") - .premiumMutualExchangeGround("Premium reason") - .unreasonableConductGround("Unreasonable reason") - .refusalToMoveBackGround("Refusal reason") - .antiSocialCondition1OfS84AGround("Condition 1 reason") - .antiSocialCondition2OfS84AGround("Condition 2 reason") - .antiSocialCondition3OfS84AGround("Condition 3 reason") - .antiSocialCondition4OfS84AGround("Condition 4 reason") - .antiSocialCondition5OfS84AGround("Condition 5 reason") - .overcrowdingGround("Overcrowding reason") - .landlordWorksGround("Works reason") - .propertySoldGround("Sold reason") - .charitableLandlordGround("Charitable reason") - .tiedAccommodationGround("Tied reason") - .adaptedAccommodationGround("Adapted reason") - .housingAssocSpecialGround("Housing reason") - .specialNeedsAccommodationGround("Special needs reason") - .underOccupancySuccessionGround("Under occupation reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), - "Breach reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), - "Nuisance reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), - "Domestic reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), - "Property reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), - "Furniture reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), - "False statement reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - "Premium reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION - .getLabel(), "Unreasonable reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), - "Refusal reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - "Condition 1 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), - "Condition 2 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), - "Condition 3 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), - "Condition 4 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), - "Condition 5 reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), - "Overcrowding reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - "Works reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), - "Sold reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), - "Charitable reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), - "Tied reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), - "Adapted reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), - "Housing reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), - "Special needs reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), - "Under occupation reason"); - } - - @Test - void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS - )) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .antiSocialBehaviourGround("Intro antisocial reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() - ); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - "Intro antisocial reason"); - assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); - } - - @Test - void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .noGrounds("No grounds reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); - assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); - } - - @Test - void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of( - IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, - IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, - IntroductoryDemotedOrOtherGrounds.OTHER - )) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .breachOfTheTenancyGround("Breach reason") - .absoluteGrounds("Absolute reason") - .otherGround("Other reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), - "Breach reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), - "Absolute reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); - } - - @Test - void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries).isEmpty(); - } - private static Stream claimGroundScenarios() { return Stream.of( argumentSet( @@ -993,24 +337,5 @@ private static Stream claimGroundScenarios() { ); } - private static void assertReason(List> summaries, - String label, - String reason) { - assertThat(summaries) - .map(ListValue::getValue) - .filteredOn(summary -> label.equals(summary.getLabel())) - .singleElement() - .extracting(ClaimGroundSummary::getReason) - .isEqualTo(reason); - } - - private static void assertNoReason(List> summaries, String label) { - assertThat(summaries) - .map(ListValue::getValue) - .filteredOn(summary -> label.equals(summary.getLabel())) - .singleElement() - .extracting(ClaimGroundSummary::getReason) - .isNull(); - } } From 22346b121781a896733759d89008d3c286ed974c Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 17:09:06 +0100 Subject: [PATCH 025/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 3 +- .../pcs/ccd/view/CaseSummaryTabView.java | 137 +++++++++++------- .../reform/pcs/ccd/view/ClaimGroundsView.java | 3 +- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 2 + .../pcs/ccd/view/CaseSummaryTabViewTest.java | 90 +++++++++++- 5 files changed, 182 insertions(+), 53 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 e0cbca9e34..7456129192 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 @@ -91,6 +91,8 @@ public PCSCase getCase(CaseViewRequest request) { draftCaseDataService .getUnsubmittedCaseData(caseReference, resumePossessionClaim) .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + } else { + caseTabView.setCaseTabFields(pcsCase); } setMarkdownFields(pcsCase, hasUnsubmittedCaseData); @@ -142,7 +144,6 @@ private PCSCase getSubmittedCase(long caseReference) { noticeOfPossessionView.setCaseFields(pcsCase, pcsCaseEntity); statementOfTruthView.setCaseFields(pcsCase, pcsCaseEntity); caseLinkView.setCaseFields(pcsCase, pcsCaseEntity); - caseTabView.setCaseTabFields(pcsCase); return pcsCase; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 6a38668b09..91c4ecad30 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -53,6 +53,48 @@ public class CaseSummaryTabView { private static final Pattern SECTION_84A_CONDITION_PATTERN = Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final String GROUND_1 = "1"; + private static final String GROUND_2 = "2"; + private static final String GROUND_2A = "2A"; + private static final String GROUND_2ZA = "2ZA"; + private static final String GROUND_3 = "3"; + private static final String GROUND_4 = "4"; + private static final String GROUND_5 = "5"; + private static final String GROUND_6 = "6"; + private static final String GROUND_7 = "7"; + private static final String GROUND_7A = "7A"; + private static final String GROUND_7B = "7B"; + private static final String GROUND_8 = "8"; + private static final String GROUND_9 = "9"; + private static final String GROUND_10 = "10"; + private static final String GROUND_10A = "10A"; + private static final String GROUND_11 = "11"; + private static final String GROUND_12 = "12"; + private static final String GROUND_13 = "13"; + private static final String GROUND_14 = "14"; + private static final String GROUND_14A = "14A"; + private static final String GROUND_14ZA = "14ZA"; + private static final String GROUND_15 = "15"; + private static final String GROUND_15A = "15A"; + private static final String GROUND_16 = "16"; + private static final String GROUND_17 = "17"; + private static final String GROUND_A = "A"; + private static final String GROUND_B = "B"; + private static final String GROUND_C = "C"; + private static final String GROUND_D = "D"; + private static final String GROUND_E = "E"; + private static final String GROUND_F = "F"; + private static final String GROUND_G = "G"; + private static final String GROUND_H = "H"; + private static final String GROUND_I = "I"; + private static final String SECTION_157 = "157"; + private static final String SECTION_170 = "170"; + private static final String SECTION_178 = "178"; + private static final String SECTION_181 = "181"; + private static final String SECTION_186 = "186"; + private static final String SECTION_187 = "187"; + private static final String SECTION_191 = "191"; + private static final String SECTION_199 = "199"; public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -180,7 +222,7 @@ private String getDefendantLastName(Party defendant) { private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { if (defendant.getAddressKnown() != VerticalYesNo.YES) { - return null; + return pcsCase.getPropertyAddress(); } return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); @@ -270,40 +312,40 @@ private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPoss String ground, String reason) { switch (ground) { - case "1" -> reasonsForPossession.setGround1(reason); - case "2" -> reasonsForPossession.setGround2(reason); - case "2A" -> reasonsForPossession.setGround2A(reason); - case "2ZA" -> reasonsForPossession.setGround2ZA(reason); - case "3" -> reasonsForPossession.setGround3(reason); - case "4" -> reasonsForPossession.setGround4(reason); - case "5" -> reasonsForPossession.setGround5(reason); - case "6" -> reasonsForPossession.setGround6(reason); - case "7" -> reasonsForPossession.setGround7(reason); - case "7A" -> reasonsForPossession.setGround7A(reason); - case "7B" -> reasonsForPossession.setGround7B(reason); - case "8" -> reasonsForPossession.setGround8(reason); - case "9" -> reasonsForPossession.setGround9(reason); - case "10" -> reasonsForPossession.setGround10(reason); - case "10A" -> reasonsForPossession.setGround10A(reason); - case "11" -> reasonsForPossession.setGround11(reason); - case "12" -> reasonsForPossession.setGround12(reason); - case "13" -> reasonsForPossession.setGround13(reason); - case "14" -> reasonsForPossession.setGround14(reason); - case "14A" -> reasonsForPossession.setGround14A(reason); - case "14ZA" -> reasonsForPossession.setGround14ZA(reason); - case "15" -> reasonsForPossession.setGround15(reason); - case "15A" -> reasonsForPossession.setGround15A(reason); - case "16" -> reasonsForPossession.setGround16(reason); - case "17" -> reasonsForPossession.setGround17(reason); - case "A" -> reasonsForPossession.setGroundA(reason); - case "B" -> reasonsForPossession.setGroundB(reason); - case "C" -> reasonsForPossession.setGroundC(reason); - case "D" -> reasonsForPossession.setGroundD(reason); - case "E" -> reasonsForPossession.setGroundE(reason); - case "F" -> reasonsForPossession.setGroundF(reason); - case "G" -> reasonsForPossession.setGroundG(reason); - case "H" -> reasonsForPossession.setGroundH(reason); - case "I" -> reasonsForPossession.setGroundI(reason); + case GROUND_1 -> reasonsForPossession.setGround1(reason); + case GROUND_2 -> reasonsForPossession.setGround2(reason); + case GROUND_2A -> reasonsForPossession.setGround2A(reason); + case GROUND_2ZA -> reasonsForPossession.setGround2ZA(reason); + case GROUND_3 -> reasonsForPossession.setGround3(reason); + case GROUND_4 -> reasonsForPossession.setGround4(reason); + case GROUND_5 -> reasonsForPossession.setGround5(reason); + case GROUND_6 -> reasonsForPossession.setGround6(reason); + case GROUND_7 -> reasonsForPossession.setGround7(reason); + case GROUND_7A -> reasonsForPossession.setGround7A(reason); + case GROUND_7B -> reasonsForPossession.setGround7B(reason); + case GROUND_8 -> reasonsForPossession.setGround8(reason); + case GROUND_9 -> reasonsForPossession.setGround9(reason); + case GROUND_10 -> reasonsForPossession.setGround10(reason); + case GROUND_10A -> reasonsForPossession.setGround10A(reason); + case GROUND_11 -> reasonsForPossession.setGround11(reason); + case GROUND_12 -> reasonsForPossession.setGround12(reason); + case GROUND_13 -> reasonsForPossession.setGround13(reason); + case GROUND_14 -> reasonsForPossession.setGround14(reason); + case GROUND_14A -> reasonsForPossession.setGround14A(reason); + case GROUND_14ZA -> reasonsForPossession.setGround14ZA(reason); + case GROUND_15 -> reasonsForPossession.setGround15(reason); + case GROUND_15A -> reasonsForPossession.setGround15A(reason); + case GROUND_16 -> reasonsForPossession.setGround16(reason); + case GROUND_17 -> reasonsForPossession.setGround17(reason); + case GROUND_A -> reasonsForPossession.setGroundA(reason); + case GROUND_B -> reasonsForPossession.setGroundB(reason); + case GROUND_C -> reasonsForPossession.setGroundC(reason); + case GROUND_D -> reasonsForPossession.setGroundD(reason); + case GROUND_E -> reasonsForPossession.setGroundE(reason); + case GROUND_F -> reasonsForPossession.setGroundF(reason); + case GROUND_G -> reasonsForPossession.setGroundG(reason); + case GROUND_H -> reasonsForPossession.setGroundH(reason); + case GROUND_I -> reasonsForPossession.setGroundI(reason); default -> { } } @@ -313,14 +355,14 @@ private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossessio String section, String reason) { switch (section) { - case "157" -> reasonsForPossession.setSection157(reason); - case "170" -> reasonsForPossession.setSection170(reason); - case "178" -> reasonsForPossession.setSection178(reason); - case "181" -> reasonsForPossession.setSection181(reason); - case "186" -> reasonsForPossession.setSection186(reason); - case "187" -> reasonsForPossession.setSection187(reason); - case "191" -> reasonsForPossession.setSection191(reason); - case "199" -> reasonsForPossession.setSection199(reason); + case SECTION_157 -> reasonsForPossession.setSection157(reason); + case SECTION_170 -> reasonsForPossession.setSection170(reason); + case SECTION_178 -> reasonsForPossession.setSection178(reason); + case SECTION_181 -> reasonsForPossession.setSection181(reason); + case SECTION_186 -> reasonsForPossession.setSection186(reason); + case SECTION_187 -> reasonsForPossession.setSection187(reason); + case SECTION_191 -> reasonsForPossession.setSection191(reason); + case SECTION_199 -> reasonsForPossession.setSection199(reason); default -> { } } @@ -476,11 +518,6 @@ private String getGrounds(PCSCase pcsCase) { } private void groupSection84AConditions(List grounds) { - int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); - if (antisocialIndex < 0) { - return; - } - List section84AConditions = grounds.stream() .filter(this::isSection84ACondition) .sorted(this::compareSection84AConditions) @@ -490,7 +527,9 @@ private void groupSection84AConditions(List grounds) { return; } - grounds.set(antisocialIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); + int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); + int groupIndex = antisocialIndex >= 0 ? antisocialIndex : grounds.indexOf(section84AConditions.getFirst()); + grounds.set(groupIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); grounds.removeAll(section84AConditions); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index ed83c518d1..63f55fc811 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -38,7 +38,8 @@ public class ClaimGroundsView { public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { getMainClaim(pcsCaseEntity) .ifPresent(mainClaim -> setClaimGroundFields(pcsCase, mainClaim)); - } + } + private void setClaimGroundFields(PCSCase pcsCase, ClaimEntity mainClaim) { 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 c1130537dc..7569c9af6a 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 @@ -388,6 +388,7 @@ void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(caseTabView).setDraftCaseTabFields(pcsCase, draftCaseData); + verify(caseTabView, never()).setCaseTabFields(any(PCSCase.class)); assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } @@ -400,6 +401,7 @@ void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); + verify(caseTabView).setCaseTabFields(any(PCSCase.class)); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 7160aedf96..5a0f05c343 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -111,7 +111,10 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) - .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); + .isEqualTo( + "Rent arrears (ground 10)\n" + + "Antisocial behaviour: Condition 1 of Section 84A of the Housing Act 1985" + ); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) .isEqualTo("Condition 1 reason"); @@ -122,11 +125,17 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(2); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) .isEqualTo(defendantAddress); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getAddressForService()) + .isEqualTo(propertyAddress); assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); @@ -230,6 +239,27 @@ void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(address); } + @Test + void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + } + @Test void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { // Given @@ -262,6 +292,38 @@ void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { .isEqualTo(address); } + @Test + void shouldDefaultAdditionalDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(propertyAddress); + } + @Test void shouldSetEachGroundReasonInSummaryTab() { // Given @@ -340,6 +402,30 @@ void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { )); } + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourWhenParentGroundIsMissing() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", + "Antisocial behaviour: " + String.join(", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985" + ), + "Landlord’s works (ground 10)" + )); + } + @Test void shouldSetEachGroundNumberReasonInSummaryTab() { // Given From b7f6f80a8a8a148fe7e548c26fb940bf3fdcb977 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 09:28:31 +0100 Subject: [PATCH 026/138] HDPI-2978: Build Case Summary tab --- .../ccd/view/ClaimGroundSummaryBuilder.java | 253 +++++++++++------- 1 file changed, 157 insertions(+), 96 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java index d4c98b557b..1952cd99e6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -15,9 +15,15 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -165,102 +171,157 @@ private void addGrounds(List> summaries, } private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { - return switch (((Enum) ground).name()) { - case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); - case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); - case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); - case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); - case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); - case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); - case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); - case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); - case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); - case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; - case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); - case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); - case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); - case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); - case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); - case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); - case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); - case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); - case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); - case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); - case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); - case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); - case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); - case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); - case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); - case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); - case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); - case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); - case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); - case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); - case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); - case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); - case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); - case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); - case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); - case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); - case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); - case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); - case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); - case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); - case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); - case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); - case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); - case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); - case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); - case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); - case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); - case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); - default -> null; - }; + String reason = getAssuredDraftReason(draftCaseData, ground); + if (reason != null) { + return reason; + } + + reason = getIntroductoryDemotedOrOtherDraftReason(draftCaseData, ground); + if (reason != null) { + return reason; + } + + return getSecureOrFlexibleDraftReason(draftCaseData, ground); + } + + private String getAssuredDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + RentArrearsGroundsReasons reasons = getRentArrearsGroundsReasons(draftCaseData); + + if (reasons == null) { + return null; + } + + if (ground == AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1) { + return reasons.getOwnerOccupierReason(); + } else if (ground == AssuredMandatoryGround.REPOSSESSION_GROUND2) { + return reasons.getRepossessionByLenderReason(); + } else if (ground == AssuredMandatoryGround.HOLIDAY_LET_GROUND3) { + return reasons.getHolidayLetReason(); + } else if (ground == AssuredMandatoryGround.STUDENT_LET_GROUND4) { + return reasons.getStudentLetReason(); + } else if (ground == AssuredMandatoryGround.MINISTER_RELIGION_GROUND5) { + return reasons.getMinisterOfReligionReason(); + } else if (ground == AssuredMandatoryGround.REDEVELOPMENT_GROUND6) { + return reasons.getRedevelopmentReason(); + } else if (ground == AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7) { + return reasons.getDeathOfTenantReason(); + } else if (ground == AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A) { + return reasons.getAntisocialBehaviourReason(); + } else if (ground == AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B) { + return reasons.getNoRightToRentReason(); + } else if (ground == AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9) { + return reasons.getSuitableAltAccommodationReason(); + } else if (ground == AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12) { + return reasons.getBreachOfTenancyConditionsReason(); + } else if (ground == AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13) { + return reasons.getPropertyDeteriorationReason(); + } else if (ground == AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14) { + return reasons.getNuisanceAnnoyanceReason(); + } else if (ground == AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A) { + return reasons.getDomesticViolenceReason(); + } else if (ground == AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA) { + return reasons.getOffenceDuringRiotReason(); + } else if (ground == AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15) { + return reasons.getFurnitureDeteriorationReason(); + } else if (ground == AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16) { + return reasons.getEmployeeOfLandlordReason(); + } else if (ground == AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17) { + return reasons.getTenancyByFalseStatementReason(); + } + + return null; + } + + private String getIntroductoryDemotedOrOtherDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + IntroductoryDemotedOtherGroundReason reasons = getIntroductoryDemotedOtherGroundReason(draftCaseData); + + if (ground == IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL) { + return getAntiSocialReason(draftCaseData); + } + + if (reasons == null) { + return null; + } + + if (ground == IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY) { + return reasons.getBreachOfTheTenancyGround(); + } else if (ground == IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS) { + return reasons.getAbsoluteGrounds(); + } else if (ground == IntroductoryDemotedOrOtherGrounds.OTHER) { + return reasons.getOtherGround(); + } else if (ground == IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS) { + return reasons.getNoGrounds(); + } + + return null; + } + + private String getSecureOrFlexibleDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + SecureOrFlexibleGroundsReasons reasons = getSecureOrFlexibleReason(draftCaseData); + + if (ground == SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL) { + return getAntiSocialReason(draftCaseData); + } + + if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_1) { + return getSection84ACondition1Reason(draftCaseData); + } + + if (reasons == null) { + return null; + } + + if (ground == SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY) { + return reasons.getBreachOfTenancyGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE) { + return reasons.getNuisanceOrImmoralUseGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE) { + return reasons.getDomesticViolenceGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE) { + return reasons.getRiotOffenceGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION) { + return reasons.getPropertyDeteriorationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION) { + return reasons.getFurnitureDeteriorationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT) { + return reasons.getTenancyByFalseStatementGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE) { + return reasons.getPremiumMutualExchangeGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION) { + return reasons.getUnreasonableConductGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK) { + return reasons.getRefusalToMoveBackGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_2) { + return reasons.getAntiSocialCondition2OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_3) { + return reasons.getAntiSocialCondition3OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_4) { + return reasons.getAntiSocialCondition4OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_5) { + return reasons.getAntiSocialCondition5OfS84AGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING) { + return reasons.getOvercrowdingGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS) { + return reasons.getLandlordWorksGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD) { + return reasons.getPropertySoldGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD) { + return reasons.getCharitableLandlordGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE) { + return reasons.getTiedAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION) { + return reasons.getAdaptedAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES) { + return reasons.getHousingAssocSpecialGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION) { + return reasons.getSpecialNeedsAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION) { + return reasons.getUnderOccupancySuccessionGround(); + } + + return null; } private String getSection84ACondition1Reason(PCSCase draftCaseData) { From 1a3bff6c0147a6909fcd222023780db1c5f4a044 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 10:55:41 +0100 Subject: [PATCH 027/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 5 ++- .../pcs/ccd/view/CaseSummaryTabView.java | 33 ++++++++++++------- .../reform/pcs/ccd/view/ClaimGroundsView.java | 4 +-- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 19 +++++++++++ 4 files changed, 47 insertions(+), 14 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 7456129192..5fb6eaa7d4 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 @@ -90,7 +90,10 @@ public PCSCase getCase(CaseViewRequest request) { if (hasUnsubmittedCaseData) { draftCaseDataService .getUnsubmittedCaseData(caseReference, resumePossessionClaim) - .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + .ifPresentOrElse( + draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft), + () -> caseTabView.setCaseTabFields(pcsCase) + ); } else { caseTabView.setCaseTabFields(pcsCase); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 91c4ecad30..fa58d8de8f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -53,6 +53,17 @@ public class CaseSummaryTabView { private static final Pattern SECTION_84A_CONDITION_PATTERN = Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final String SECTION_84A_CONDITION_1_PREFIX = "Condition 1"; + private static final String SECTION_84A_CONDITION_2_PREFIX = "Condition 2"; + private static final String SECTION_84A_CONDITION_3_PREFIX = "Condition 3"; + private static final String SECTION_84A_CONDITION_4_PREFIX = "Condition 4"; + private static final String SECTION_84A_CONDITION_5_PREFIX = "Condition 5"; + private static final String BREACH_OF_THE_TENANCY = "Breach of the tenancy"; + private static final String ABSOLUTE_GROUNDS = "Absolute grounds"; + private static final String OTHER = "Other"; + private static final String OTHER_GROUNDS = "Other grounds"; + private static final String NO_GROUNDS = "No grounds"; + private static final String PARAGRAPH_25B_2_SCHEDULE_12 = "paragraph 25B(2) of Schedule 12"; private static final String GROUND_1 = "1"; private static final String GROUND_2 = "2"; private static final String GROUND_2A = "2A"; @@ -283,27 +294,27 @@ private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession return; } - if (groundLabel.startsWith("Condition 1")) { + if (groundLabel.startsWith(SECTION_84A_CONDITION_1_PREFIX)) { reasonsForPossession.setCondition1OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 2")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_2_PREFIX)) { reasonsForPossession.setCondition2OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 3")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_3_PREFIX)) { reasonsForPossession.setCondition3OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 4")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_4_PREFIX)) { reasonsForPossession.setCondition4OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 5")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_5_PREFIX)) { reasonsForPossession.setCondition5OfSection84A(reason); - } else if ("Antisocial behaviour".equals(groundLabel)) { + } else if (ANTISOCIAL_BEHAVIOUR.equals(groundLabel)) { reasonsForPossession.setAntisocialBehaviour(reason); - } else if ("Breach of the tenancy".equals(groundLabel)) { + } else if (BREACH_OF_THE_TENANCY.equals(groundLabel)) { reasonsForPossession.setBreachOfTheTenancy(reason); - } else if ("Absolute grounds".equals(groundLabel)) { + } else if (ABSOLUTE_GROUNDS.equals(groundLabel)) { reasonsForPossession.setAbsoluteGrounds(reason); - } else if ("Other".equals(groundLabel) || "Other grounds".equals(groundLabel)) { + } else if (OTHER.equals(groundLabel) || OTHER_GROUNDS.equals(groundLabel)) { reasonsForPossession.setOtherGrounds(reason); - } else if ("No grounds".equals(groundLabel)) { + } else if (NO_GROUNDS.equals(groundLabel)) { reasonsForPossession.setNoGrounds(reason); - } else if (groundLabel.contains("paragraph 25B(2) of Schedule 12")) { + } else if (groundLabel.contains(PARAGRAPH_25B_2_SCHEDULE_12)) { reasonsForPossession.setParagraph25B2Schedule12(reason); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java index 63f55fc811..2a34d1a2d1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsView.java @@ -2,13 +2,13 @@ import org.springframework.stereotype.Component; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; -import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.PossessionGroundEnum; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; 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 7569c9af6a..e816a1ea43 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 @@ -392,6 +392,25 @@ void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } + @Test + void shouldSetSubmittedCaseTabFieldsWhenUnsubmittedCaseDataIsExpectedButDraftIsMissing() { + // Given + when(draftCaseDataService.hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(true); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.empty()); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); + verify(caseTabView).setCaseTabFields(pcsCase); + assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); + } + @Test void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { // When From fc3ea4fa69f0096fcc8d14f7100a938cf4097971 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 11 May 2026 11:46:15 +0100 Subject: [PATCH 028/138] HDPI-2978: Build Case Summary tab # Conflicts: # src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java # src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimView.java --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 44 ++- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 7 + .../GroundsForPossessionTabDetails.java | 19 ++ .../domain/tabs/summary/NoticeTabDetails.java | 19 ++ .../ReasonsForPossessionTabDetails.java | 24 ++ .../tabs/summary/RentArrearsTabDetails.java | 39 +++ .../SummaryAdditionalDefendantTabDetails.java | 30 ++ .../summary/SummaryClaimantTabDetails.java | 19 ++ .../summary/SummaryDefendantTabDetails.java | 30 ++ .../ccd/domain/tabs/summary/SummaryTab.java | 78 ++++++ .../tabs/summary/TenancyTabDetails.java | 25 ++ .../reform/pcs/ccd/entity/ClaimEntity.java | 3 + .../reform/pcs/ccd/view/CaseTabView.java | 265 +++++++++++++++++- .../V093__add_claim_submitted_date.sql | 1 + 14 files changed, 593 insertions(+), 10 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java create mode 100644 src/main/resources/db/migration/V093__add_claim_submitted_date.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 9fa96bc2dd..215551af09 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,10 +74,7 @@ public void configure(final ConfigBuilder builder) { .label("nextStepsMarkdownLabel", null, "${nextStepsMarkdown}") .field("nextStepsMarkdown", NEVER_SHOW); - builder.tab("summary", "Summary") - .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") - .field("confirmEvictionSummaryMarkup", NEVER_SHOW) - .field(PCSCase::getPropertyAddress); + buildSummaryTab(builder); builder.tab("CaseHistory", "History") .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) @@ -123,4 +120,43 @@ private void buildCasePartiesTab(ConfigBuilder builder .field("casePartiesTab_DefendantOneDetails") .field("casePartiesTab_DefendantsDetails"); } + + private void buildSummaryTab(ConfigBuilder builder) { + builder.tab("summary", "Summary") + .label("confirmEvictionSummaryMarkupLabel", null, "${confirmEvictionSummaryMarkup}") + .field("confirmEvictionSummaryMarkup", NEVER_SHOW) + .label("Summary", null, "## Summary") + .field("summaryTab_RepossessedPropertyAddress") + .field("summaryTab_GroundsForPossession") + .field("summaryTab_ClaimSubmittedDate") + .field("summaryTab_ReasonsForPossession", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_PossessionReasonsSubmittedDate", + "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_ClaimSubmittedDate") + .label("Claimant details", + "summaryTab_ClaimantDetails!=\"\"", + "## Claimant details") + .field("summaryTab_ClaimantDetails") + .label("Defendant details", + "summaryTab_DefendantDetails!=\"\"", + "## Defendant details") + .field("summaryTab_DefendantDetails", + "summaryTab_DefendantDetails!=\"\"") + .field("summaryTab_AdditionalDefendants", + "summaryTab_AdditionalDefendants!=\"\"") + .label("Rent arrears", + "summaryTab_RentArrearsDetails!=\"\"", + "## Rent arrears") + .field("summaryTab_RentArrearsDetails") + .label("Tenancy or occupation contract or licence", + "summaryTab_TenancyDetails!=\"\"", + "## Tenancy or occupation contract or licence") + .field("summaryTab_TenancyDetails") + .label("Notice", + "summaryTab_NoticeDetails!=\"\"", + "## Notice") + .field("summaryTab_NoticeDetails", + "summaryTab_NoticeDetails!=\"\""); + } } 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 bd7d9366e7..62fbf5866d 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 @@ -39,6 +39,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; @@ -549,6 +550,8 @@ public class PCSCase { @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) private List> claimGroundSummaries; + private String dateSubmitted; + @CCD( access = DefendantAccess.class, searchable = false @@ -602,4 +605,8 @@ public class PCSCase { @JsonUnwrapped(prefix = "casePartiesTab_") @CCD private CasePartiesTab casePartiesTab; + + @JsonUnwrapped(prefix = "summaryTab_") + @CCD + private SummaryTab summaryTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java new file mode 100644 index 0000000000..0fb214c9e7 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroundsForPossessionTabDetails { + + @CCD( + label = "Grounds" + ) + private String grounds; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java new file mode 100644 index 0000000000..e66f4960e0 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class NoticeTabDetails { + + @CCD( + label = "Date notice was served" + ) + private String noticeServedDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java new file mode 100644 index 0000000000..90aaac2db4 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java @@ -0,0 +1,24 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ReasonsForPossessionTabDetails { + + @CCD( + label = "Reasons for claiming possession under ground X" + ) + private String groundReasons; + + @CCD( + label = "Additional reasons for possession" + ) + private String additionalReasonsForPossession; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java new file mode 100644 index 0000000000..428462386b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java @@ -0,0 +1,39 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RentArrearsTabDetails { + + @CCD( + label = "Rent amount" + ) + private String rentAmount; + + @CCD( + label = "How rent is calculated" + ) + private String calculationFrequency; + + @CCD( + label = "Daily rate" + ) + private String dailyRate; + + @CCD( + label = "Rent arrears total at the time of claim issue" + ) + private String arrearsTotal; + + @CCD( + label = "Judgment requested for the outstanding arrears?" + ) + private String judgmentRequested; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java new file mode 100644 index 0000000000..8ecfbc2c1f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryAdditionalDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Additional defendant address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java new file mode 100644 index 0000000000..a9731b1739 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryClaimantTabDetails { + + @CCD( + label = "Claimant name" + ) + private String claimantName; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java new file mode 100644 index 0000000000..20647d131f --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java @@ -0,0 +1,30 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SummaryDefendantTabDetails { + + @CCD( + label = "First name" + ) + private String firstName; + + @CCD( + label = "Last name" + ) + private String lastName; + + @CCD( + label = "Defendant 1 address for service" + ) + private AddressUK addressForService; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java new file mode 100644 index 0000000000..27fb48eee8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -0,0 +1,78 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) +public class SummaryTab { + + @CCD( + label = "Address of property to be repossessed" + ) + private AddressUK repossessedPropertyAddress; + + @CCD( + label = "Grounds for possession" + ) + private GroundsForPossessionTabDetails groundsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String claimSubmittedDate; + + @CCD( + label = "Reasons for possession" + ) + private ReasonsForPossessionTabDetails reasonsForPossession; + + @CCD( + label = "Date claim Submitted" + ) + private String possessionReasonsSubmittedDate; + + @CCD( + label = "Claimant" + ) + private SummaryClaimantTabDetails claimantDetails; + + @CCD( + label = "Defendant 1" + ) + private SummaryDefendantTabDetails defendantDetails; + + @CCD( + label = "Additional defendant" + ) + private List> additionalDefendants; + + @CCD( + label = "Details of rent arrears" + ) + private RentArrearsTabDetails rentArrearsDetails; + + @CCD( + label = "Tenancy or occupation contract or licence details" + ) + private TenancyTabDetails tenancyDetails; + + @CCD( + label = "Notice details" + ) + private NoticeTabDetails noticeDetails; + + +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java new file mode 100644 index 0000000000..f140e76b89 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TenancyTabDetails { + + @CCD( + label = "Tenancy, occupation contract or licence agreement type" + ) + private String agreementType; + + @CCD( + label = "Tenancy, occupation contract or licence agreement start date", + showCondition = "agreementStartDate!=\"\"" + ) + private String agreementStartDate; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index a7658b12c2..b96e48a7e3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,6 +34,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -134,6 +135,8 @@ public class ClaimEntity { @Enumerated(EnumType.STRING) private LanguageUsed languageUsed; + private LocalDateTime claimSubmittedDate; + @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "claim") @Builder.Default @JsonManagedReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index a8abad4594..fef3cec681 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,24 +4,29 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import java.math.BigDecimal; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + @Component public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; + private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); + SummaryTab summaryTab = buildSummaryTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); + pcsCase.setSummaryTab(summaryTab); } private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { @@ -81,4 +86,252 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p .lastName(defendantLastName) .build(); } + + private SummaryTab buildSummaryTab(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + + return SummaryTab.builder() + .repossessedPropertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossession(GroundsForPossessionTabDetails.builder() + .grounds(getGrounds(pcsCase)) + .build()) + .claimSubmittedDate(pcsCase.getDateSubmitted()) + .reasonsForPossession(reasonsForPossession) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : pcsCase.getDateSubmitted()) + .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) + .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .tenancyDetails(buildTenancyTabDetails(pcsCase)) + .noticeDetails(buildNoticeTabDetails(pcsCase)) + .build(); + } + + private SummaryClaimantTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return SummaryClaimantTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } + + private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryAdditionalDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private SummaryDefendantTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return SummaryDefendantTabDetails.builder() + .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) + .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) + .addressForService(addressForService) + .build(); + } + + private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return null; + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + return null; + } + + return ReasonsForPossessionTabDetails.builder() + .groundReasons(additionalReasons.getHasReasons().getLabel()) + .additionalReasonsForPossession(additionalReasons.getReasons()) + .build(); + } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + + if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + return null; + } + + String agreementType = getAgreementType(tenancyLicenceDetails); + String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null + ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + + return TenancyTabDetails.builder() + .agreementType(agreementType) + .agreementStartDate(agreementStartDate) + .build(); + } + + private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { + if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { + return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); + } + + return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); + } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + + if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + return null; + } + + return NoticeTabDetails.builder() + .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .build(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + return pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .orElse(null); + } } diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql new file mode 100644 index 0000000000..63b1fa3595 --- /dev/null +++ b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql @@ -0,0 +1 @@ +ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; From 76cabe1f25ecf6e51d2ebe9f7645eddc8f5cee0f Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:35:23 +0100 Subject: [PATCH 029/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 69 +++- .../reform/pcs/ccd/view/CaseTabView.java | 62 +++- ...sql => V095__add_claim_submitted_date.sql} | 0 .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 109 +++++++ .../ccd/service/DraftCaseJsonMergerTest.java | 1 + .../reform/pcs/ccd/view/CaseTabViewTest.java | 294 +++++++++++++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 124 ++++++++ .../reform/pcs/ccd/view/ClaimViewTest.java | 22 ++ 8 files changed, 667 insertions(+), 14 deletions(-) rename src/main/resources/db/migration/{V093__add_claim_submitted_date.sql => V095__add_claim_submitted_date.sql} (100%) 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 cd6d7db231..b72782081e 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 @@ -3,6 +3,7 @@ import lombok.AllArgsConstructor; 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; @@ -10,9 +11,12 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.SearchCriteria; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; 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.PcsCaseEntity; @@ -37,6 +41,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Set; @@ -81,7 +86,10 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); + Optional draftCaseData = getUnsubmittedCaseData(caseReference, state); + boolean hasUnsubmittedCaseData = draftCaseData.isPresent(); + + draftCaseData.ifPresent(draft -> setSummaryTabFromDraftData(pcsCase, draft)); setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); @@ -94,12 +102,63 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private boolean caseHasUnsubmittedData(long caseReference, State state) { + private Optional getUnsubmittedCaseData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { - return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); - } else { - return false; + return draftCaseDataService.getUnsubmittedCaseData(caseReference, resumePossessionClaim); + } + + return Optional.empty(); + } + + private void setSummaryTabFromDraftData(PCSCase pcsCase, PCSCase draftCaseData) { + draftCaseData.setPropertyAddress(Optional.ofNullable(draftCaseData.getPropertyAddress()) + .orElse(pcsCase.getPropertyAddress())); + + if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { + draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); } + + if (draftCaseData.getDefendant1() != null) { + draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); + } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { + draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + } + + List> draftGrounds = + claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) + ? pcsCase.getClaimGroundSummaries() + : draftGrounds); + + caseTabView.setCaseTabFields(draftCaseData); + pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + } + + private List> buildDefendants(PCSCase draftCaseData) { + List> defendants = new ArrayList<>(); + defendants.add(buildDefendant(draftCaseData.getDefendant1())); + + if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES + && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { + draftCaseData.getAdditionalDefendants().stream() + .map(ListValue::getValue) + .map(this::buildDefendant) + .forEach(defendants::add); + } + + return defendants; + } + + private ListValue buildDefendant(DefendantDetails defendant) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(defendant.getNameKnown()) + .firstName(defendant.getFirstName()) + .lastName(defendant.getLastName()) + .addressKnown(defendant.getAddressKnown()) + .address(defendant.getCorrespondenceAddress()) + .build()) + .build(); } private PCSCase getSubmittedCase(long caseReference) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index fef3cec681..9b0b67b438 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -4,10 +4,32 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.*; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryAdditionalDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; import java.time.format.DateTimeFormatter; @@ -149,7 +171,8 @@ private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsC return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - private List> createAdditionalSummaryDefendantsDetails(PCSCase pcsCase) { + private List> createAdditionalSummaryDefendantsDetails( + PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; } @@ -244,14 +267,21 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); - if (tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) { + if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) + && (occupationLicenceDetailsWales == null + || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { return null; } - String agreementType = getAgreementType(tenancyLicenceDetails); - String agreementStartDate = tenancyLicenceDetails.getTenancyLicenceDate() == null - ? null : tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER); + String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null + ? getAgreementType(tenancyLicenceDetails) + : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); + String agreementStartDate = tenancyLicenceDetails != null + && tenancyLicenceDetails.getTenancyLicenceDate() != null + ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) + : getOccupationLicenceStartDate(occupationLicenceDetailsWales); return TenancyTabDetails.builder() .agreementType(agreementType) @@ -267,6 +297,22 @@ private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); } + private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { + return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); + } + + return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); + } + + private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { + return null; + } + + return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); + } + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V095__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V093__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V095__add_claim_submitted_date.sql 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 c659b0ec40..a128b2f6c0 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 @@ -10,9 +10,13 @@ import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; 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; @@ -51,10 +55,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mock.Strictness.LENIENT; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.resumePossessionClaim; @ExtendWith(MockitoExtension.class) class PCSCaseViewTest { @@ -254,6 +261,10 @@ private static ListValue asListValue(UUID id, Party party) { return ListValue.builder().id(id.toString()).value(party).build(); } + private static ListValue listValue(T value) { + return ListValue.builder().value(value).build(); + } + private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { PartyEntity partyEntity = mock(PartyEntity.class); @@ -298,6 +309,104 @@ void shouldSetCaseFields() { verify(caseFieldsView).setCaseFields(pcsCase); } + @Test + void shouldSetSummaryTabFromDraftDataWhenUnsubmittedCaseDataExists() { + // Given + AddressEntity addressEntity = mock(AddressEntity.class); + when(pcsCaseEntity.getPropertyAddress()).thenReturn(addressEntity); + AddressUK propertyAddress = stubAddressEntityModelMapper(addressEntity); + + Party claimant = mock(Party.class); + UUID claimantId = UUID.randomUUID(); + ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(claimantClaimParty)); + + AddressUK defendantOneAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK defendantTwoAddress = AddressUK.builder().postCode("E2 2AA").build(); + PCSCase draftCaseData = PCSCase.builder() + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantOneAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of(listValue(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantTwoAddress) + .build()))) + .summaryTab(SummaryTab.builder().build()) + .build(); + List> draftGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Draft ground").build())); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(caseTabView).setCaseTabFields(draftCaseData); + assertThat(draftCaseData.getPropertyAddress()).isEqualTo(propertyAddress); + assertThat(draftCaseData.getAllClaimants()).containsExactly(asListValue(claimantId, claimant)); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getLastName()).isEqualTo("One"); + assertThat(draftCaseData.getAllDefendants().get(0).getValue().getAddress()).isEqualTo(defendantOneAddress); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getLastName()).isEqualTo("Two"); + assertThat(draftCaseData.getAllDefendants().get(1).getValue().getAddress()).isEqualTo(defendantTwoAddress); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(draftGrounds); + assertThat(pcsCase.getSummaryTab()).isSameAs(draftCaseData.getSummaryTab()); + assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); + } + + @Test + void shouldFallbackToSubmittedSummaryDataWhenDraftDataIsPartial() { + // Given + Party defendant = mock(Party.class); + UUID defendantId = UUID.randomUUID(); + ClaimPartyEntity defendantClaimParty = createClaimPartyEntity(defendant, defendantId, PartyRole.DEFENDANT); + when(claimEntity.getClaimParties()).thenReturn(List.of(defendantClaimParty)); + + List> submittedGrounds = + List.of(listValue(ClaimGroundSummary.builder().label("Submitted ground").build())); + doAnswer(invocation -> { + PCSCase pcsCase = invocation.getArgument(0); + pcsCase.setClaimGroundSummaries(submittedGrounds); + return null; + }).when(claimGroundsView).setCaseFields(any(PCSCase.class), any(PcsCaseEntity.class)); + + PCSCase draftCaseData = PCSCase.builder() + .summaryTab(SummaryTab.builder().build()) + .build(); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.of(draftCaseData)); + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + assertThat(draftCaseData.getAllDefendants()).containsExactly(asListValue(defendantId, defendant)); + assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(submittedGrounds); + } + + @Test + void shouldNotLoadUnsubmittedCaseDataWhenCaseIsNotAwaitingSubmission() { + // When + underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); + + // Then + verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); + } + @Test void shouldCallEnforcementOrderMediator() { // When diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java index 479736bced..199fbeb5ea 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java @@ -93,6 +93,7 @@ void shouldKeepExistingFieldsWhenMerging() throws JsonProcessingException { "enforcementOrder.rawWarrantDetails.selectedDefendants", "enforcementOrder.rawWarrantDetails.vulnerablePeoplePresent", "enforcementOrder.rawWarrantDetails.vulnerableAdultsChildren", + "summaryTab", "casePartiesTab.claimantDetails.emailAddress", "casePartiesTab.claimantDetails.name", "casePartiesTab.claimantDetails.serviceAddress", diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 39da9a0f34..6ae9d007fd 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -6,12 +6,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; - +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -255,4 +272,279 @@ void shouldNotSetCasePartiesTabWithNoData() { assertThat(pcsCase.getCasePartiesTab().getDefendantOneDetails()).isNull(); assertThat(pcsCase.getCasePartiesTab().getDefendantsDetails()).isNull(); } + + @Test + void shouldSetSummaryTabFields() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .dateSubmitted("11 May 2026, 5:02:31PM") + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Ground 1").build()), + listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("Licence details") + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .build()) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()) + .isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldNotSetEmptySummarySections() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + assertThat(summaryTab.getReasonsForPossession()).isNull(); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getAdditionalDefendants()).isNull(); + assertThat(summaryTab.getRentArrearsDetails()).isNull(); + assertThat(summaryTab.getTenancyDetails()).isNull(); + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + RentArrearsTabDetails rentArrearsDetails = pcsCase.getSummaryTab().getRentArrearsDetails(); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); + } + + @Test + void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + @Test + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .licenceStartDate(LocalDate.of(2025, 5, 12)) + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); + } + + @Test + void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .otherLicenceTypeDetails("Other Welsh licence") + .build()) + .build(); + + // When + underTest.setCaseTabFields(pcsCase); + + // Then + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); + assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 2d50a056f1..2662d53560 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,19 +12,29 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -203,6 +213,112 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { ); } + @Test + void shouldBuildClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 + )) + .build()) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + "Serious rent arrears (ground 8)", + "Rent arrears (ground 10)", + "Owner occupier (ground 1)", + "Breach of tenancy conditions (ground 12)", + "Holiday let (ground 3)", + "Deterioration in the condition of the property (ground 13)", + "Antisocial behaviour", + "Rent arrears or breach of the tenancy (ground 1)", + "Condition 1 of Section 84A of the Housing Act 1985", + "Property sold for redevelopment (ground 10A)", + "Adapted accommodation (ground 13)", + "Antisocial behaviour", + "Notice given under a landlord’s break clause (section 199)", + "Rent arrears (breach of contract) (section 157)", + "Redevelopment schemes (ground B)", + "Landlord’s notice in connection with end of fixed term given (section 186)", + "Antisocial behaviour (breach of contract) (section 157)", + "Reserve successors (ground G)" + ); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); + + // Then + assertThat(summaries).isEmpty(); + } + private static Stream claimGroundScenarios() { return Stream.of( argumentSet( @@ -237,6 +353,14 @@ private static Stream claimGroundScenarios() { "Antisocial behaviour", // Expected label false // Is rent arrears ground ), + argumentSet( + "Secure or flexible tenancy antisocial ground", + ClaimGroundCategory.SECURE_OR_FLEXIBLE_ANTISOCIAL, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.name(), + "Reason for antisocial ground", // Reason + "Condition 1 of Section 84A of the Housing Act 1985", // Expected label + false // Is rent arrears ground + ), argumentSet( "Secure or flexible tenancy discretionary ground", ClaimGroundCategory.SECURE_OR_FLEXIBLE_DISCRETIONARY, diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index ce5b6bb0fd..41f3ff6083 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -16,6 +16,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -78,6 +79,20 @@ void shouldMapBasicClaimFields() { assertThat(pcsCase.getPreActionProtocolIncompleteExplanation()).isEqualTo("explanation"); } + @ParameterizedTest + @MethodSource("claimSubmittedDateScenarios") + void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { + // Given + when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); + when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); + } + @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( @@ -137,6 +152,13 @@ void shouldNotPopulateAnyClaimFieldsWhenNoClaimsExist() { assertThat(pcsCase.getClaimantType()).isNull(); } + private static Stream claimSubmittedDateScenarios() { + return Stream.of( + Arguments.of(null, null), + Arguments.of(LocalDateTime.of(2026, 5, 11, 17, 2, 31), "11 May 2026, 5:02:31PM") + ); + } + private static Stream complexClaimFieldsScenarios() { return Stream.of( Arguments.of( From c11bf01cc255e16d6ac507ef5b7413162277da2b Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:48:32 +0100 Subject: [PATCH 030/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 2 +- .../hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 2 +- 2 files changed, 2 insertions(+), 2 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 215551af09..6895d7927d 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 @@ -151,7 +151,7 @@ private void buildSummaryTab(ConfigBuilder builder) { .field("summaryTab_RentArrearsDetails") .label("Tenancy or occupation contract or licence", "summaryTab_TenancyDetails!=\"\"", - "## Tenancy or occupation contract or licence") + "## Tenancy, occupation contract or licence") .field("summaryTab_TenancyDetails") .label("Notice", "summaryTab_NoticeDetails!=\"\"", diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 27fb48eee8..baa5e6046f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -65,7 +65,7 @@ public class SummaryTab { private RentArrearsTabDetails rentArrearsDetails; @CCD( - label = "Tenancy or occupation contract or licence details" + label = "Tenancy, occupation contract or licence details" ) private TenancyTabDetails tenancyDetails; From d58f67dc33794367f142846e63f6a115cb7dca43 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 14:38:19 +0100 Subject: [PATCH 031/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V096__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V095__add_claim_submitted_date.sql => V096__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V095__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V095__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V096__add_claim_submitted_date.sql From 0c3182362b6e5f644050149541142ba47768f477 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 15:31:03 +0100 Subject: [PATCH 032/138] HDPI-2978: Build Case Summary tab --- .../hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index baa5e6046f..b7a5dc47f8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -73,6 +73,4 @@ public class SummaryTab { label = "Notice details" ) private NoticeTabDetails noticeDetails; - - } From 9e5dffe84bcfdf948c069100a506e66abd47aaf3 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 11 May 2026 11:46:15 +0100 Subject: [PATCH 033/138] HDPI-2978: Build Case Summary tab --- .../resources/db/migration/V093__add_claim_submitted_date.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/main/resources/db/migration/V093__add_claim_submitted_date.sql diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql new file mode 100644 index 0000000000..63b1fa3595 --- /dev/null +++ b/src/main/resources/db/migration/V093__add_claim_submitted_date.sql @@ -0,0 +1 @@ +ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; From 9b06258edb2f27ff7ede996812c05deda3ab7fc1 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 13:35:23 +0100 Subject: [PATCH 034/138] HDPI-2978: Build Case Summary tab --- ...date.sql => V095__add_claim_submitted_date.sql} | 0 .../hmcts/reform/pcs/ccd/view/ClaimViewTest.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+) rename src/main/resources/db/migration/{V093__add_claim_submitted_date.sql => V095__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V093__add_claim_submitted_date.sql b/src/main/resources/db/migration/V095__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V093__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V095__add_claim_submitted_date.sql diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index 41f3ff6083..fcec696e99 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -93,6 +93,20 @@ void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expect assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); } + @ParameterizedTest + @MethodSource("claimSubmittedDateScenarios") + void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { + // Given + when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); + when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); + } + @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( From 677197e7aada24089576e7a2be2e17c40ec99907 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 14:38:19 +0100 Subject: [PATCH 035/138] HDPI-2978: Build Case Summary tab --- .../resources/db/migration/V095__add_claim_submitted_date.sql | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/main/resources/db/migration/V095__add_claim_submitted_date.sql diff --git a/src/main/resources/db/migration/V095__add_claim_submitted_date.sql b/src/main/resources/db/migration/V095__add_claim_submitted_date.sql deleted file mode 100644 index 63b1fa3595..0000000000 --- a/src/main/resources/db/migration/V095__add_claim_submitted_date.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; From 02d0765a015c16e3336d8b2fe82a7404cb894692 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 15:36:36 +0100 Subject: [PATCH 036/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index b7a5dc47f8..d3ec0e4af5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -73,4 +73,5 @@ public class SummaryTab { label = "Notice details" ) private NoticeTabDetails noticeDetails; + } From 2c0febd9c37bc22dd3913dca2041740ead4b76c9 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 12 May 2026 23:35:41 +0100 Subject: [PATCH 037/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 1 + .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 4 +- ...tionalDefendantInformationTabDetails.java} | 4 +- .../ClaimantInformationTabDetails.java} | 4 +- .../DefendantInfomationTabDetails.java} | 4 +- .../RentArrearsTabDetails.java | 2 +- .../ccd/domain/tabs/summary/SummaryTab.java | 12 ++++-- .../reform/pcs/ccd/entity/ClaimEntity.java | 3 -- .../reform/pcs/ccd/entity/PcsCaseEntity.java | 3 ++ .../pcs/ccd/service/PcsCaseService.java | 2 + .../reform/pcs/ccd/view/CaseTabView.java | 43 ++++++++++++------- .../V096__add_claim_submitted_date.sql | 2 +- .../reform/pcs/ccd/view/CaseTabViewTest.java | 4 +- .../reform/pcs/ccd/view/ClaimViewTest.java | 22 ---------- 14 files changed, 55 insertions(+), 55 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryAdditionalDefendantTabDetails.java => shared/AdditionalDefendantInformationTabDetails.java} (82%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryClaimantTabDetails.java => shared/ClaimantInformationTabDetails.java} (73%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary/SummaryDefendantTabDetails.java => shared/DefendantInfomationTabDetails.java} (83%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/RentArrearsTabDetails.java (92%) 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 b72782081e..66a862a1b7 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 @@ -169,6 +169,7 @@ private PCSCase getSubmittedCase(long caseReference) { .legislativeCountry(pcsCaseEntity.getLegislativeCountry()) .caseManagementLocationNumber(pcsCaseEntity.getCaseManagementLocation()) .allDocuments(mapAndWrapDocuments(pcsCaseEntity)) + .dateSubmitted(pcsCaseEntity.getCreatedAt()) .build(); setDerivedProperties(pcsCase, pcsCaseEntity); 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 62fbf5866d..7f5c510eef 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 @@ -50,6 +50,7 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -550,7 +551,8 @@ public class PCSCase { @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) private List> claimGroundSummaries; - private String dateSubmitted; + @CCD(access = {ClaimantAccess.class, DefendantAccess.class}) + private LocalDateTime dateSubmitted; @CCD( access = DefendantAccess.class, diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java similarity index 82% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index 8ecfbc2c1f..22e1a5b870 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryAdditionalDefendantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryAdditionalDefendantTabDetails { +public class AdditionalDefendantInformationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java similarity index 73% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java index a9731b1739..dc008a923d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryClaimantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -10,7 +10,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryClaimantTabDetails { +public class ClaimantInformationTabDetails { @CCD( label = "Claimant name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java similarity index 83% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java index 20647d131f..9f1320f897 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryDefendantTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class SummaryDefendantTabDetails { +public class DefendantInfomationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java similarity index 92% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 428462386b..78ba11160e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index d3ec0e4af5..6c703fdb62 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -9,6 +9,10 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; @@ -37,7 +41,7 @@ public class SummaryTab { @CCD( label = "Reasons for possession" ) - private ReasonsForPossessionTabDetails reasonsForPossession; + private ReasonsForPossessionTabDetails reasonsForPossession; @CCD( label = "Date claim Submitted" @@ -47,17 +51,17 @@ public class SummaryTab { @CCD( label = "Claimant" ) - private SummaryClaimantTabDetails claimantDetails; + private ClaimantInformationTabDetails claimantDetails; @CCD( label = "Defendant 1" ) - private SummaryDefendantTabDetails defendantDetails; + private DefendantInfomationTabDetails defendantDetails; @CCD( label = "Additional defendant" ) - private List> additionalDefendants; + private List> additionalDefendants; @CCD( label = "Details of rent arrears" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index b96e48a7e3..a7658b12c2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,7 +34,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -135,8 +134,6 @@ public class ClaimEntity { @Enumerated(EnumType.STRING) private LanguageUsed languageUsed; - private LocalDateTime claimSubmittedDate; - @OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "claim") @Builder.Default @JsonManagedReference diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java index 2a8463d67a..dad941c991 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java @@ -23,6 +23,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.respondpossessionclaim.DefendantResponseEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -62,6 +63,8 @@ public class PcsCaseEntity { private Boolean preActionProtocolCompleted; + private LocalDateTime createdAt; + @OneToOne(mappedBy = "pcsCase", cascade = ALL, orphanRemoval = true) @JsonManagedReference private TenancyLicenceEntity tenancyLicence; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index 869e238e91..4494f5852c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -15,6 +15,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @@ -48,6 +49,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); + pcsCaseEntity.setCreatedAt(LocalDateTime.now()); ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); List documentEntities = documentService.createAllDocuments(pcsCase); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 9b0b67b438..2b7a75b0b6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -22,19 +22,21 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryAdditionalDefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryClaimantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryDefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @@ -43,6 +45,8 @@ public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); @@ -111,15 +115,16 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p private SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); return SummaryTab.builder() .repossessedPropertyAddress(pcsCase.getPropertyAddress()) .groundsForPossession(GroundsForPossessionTabDetails.builder() .grounds(getGrounds(pcsCase)) .build()) - .claimSubmittedDate(pcsCase.getDateSubmitted()) + .claimSubmittedDate(dateSubmitted) .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : pcsCase.getDateSubmitted()) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) @@ -129,13 +134,21 @@ private SummaryTab buildSummaryTab(PCSCase pcsCase) { .build(); } - private SummaryClaimantTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + private String formatSubmittedDate(LocalDateTime dateSubmitted) { + if (dateSubmitted == null) { + return null; + } + + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } + + private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { String claimantName = getSummaryClaimantName(pcsCase); if (claimantName == null) { return null; } - return SummaryClaimantTabDetails.builder() + return ClaimantInformationTabDetails.builder() .claimantName(claimantName) .build(); } @@ -163,7 +176,7 @@ private String getSummaryClaimantName(PCSCase pcsCase) { return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); } - private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } @@ -171,7 +184,7 @@ private SummaryDefendantTabDetails createSummaryDefendantOneDetails(PCSCase pcsC return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - private List> createAdditionalSummaryDefendantsDetails( + private List> createAdditionalSummaryDefendantsDetails( PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; @@ -182,13 +195,13 @@ private List> createAdditionalSu .map(ListValue::getValue) .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) .filter(defendantDetails -> defendantDetails != null) - .map(defendantDetails -> ListValue.builder() + .map(defendantDetails -> ListValue.builder() .value(defendantDetails) .build()) .toList(); } - private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); @@ -196,21 +209,21 @@ private SummaryAdditionalDefendantTabDetails createAdditionalSummaryDefendantDet return null; } - return SummaryAdditionalDefendantTabDetails.builder() + return AdditionalDefendantInformationTabDetails.builder() .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) .addressForService(addressForService) .build(); } - private SummaryDefendantTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; } - return SummaryDefendantTabDetails.builder() + return DefendantInfomationTabDetails.builder() .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) .addressForService(addressForService) diff --git a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql index 63b1fa3595..d6c27708e8 100644 --- a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql +++ b/src/main/resources/db/migration/V096__add_claim_submitted_date.sql @@ -1 +1 @@ -ALTER TABLE CLAIM ADD COLUMN CLAIM_SUBMITTED_DATE TIMESTAMP; +ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 6ae9d007fd..d380279a82 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -21,7 +21,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -280,7 +280,7 @@ void shouldSetSummaryTabFields() { AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); PCSCase pcsCase = PCSCase.builder() .propertyAddress(propertyAddress) - .dateSubmitted("11 May 2026, 5:02:31PM") + .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) .claimGroundSummaries(List.of( listValue(ClaimGroundSummary.builder().label("Ground 1").build()), listValue(ClaimGroundSummary.builder().label("Ground 2").build()) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index fcec696e99..3e83d132ec 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -16,7 +16,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -93,20 +92,6 @@ void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expect assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); } - @ParameterizedTest - @MethodSource("claimSubmittedDateScenarios") - void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { - // Given - when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); - when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); - - // When - underTest.setCaseFields(pcsCase, pcsCaseEntity); - - // Then - assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); - } - @ParameterizedTest @MethodSource("complexClaimFieldsScenarios") void shouldMapComplexClaimFields( @@ -166,13 +151,6 @@ void shouldNotPopulateAnyClaimFieldsWhenNoClaimsExist() { assertThat(pcsCase.getClaimantType()).isNull(); } - private static Stream claimSubmittedDateScenarios() { - return Stream.of( - Arguments.of(null, null), - Arguments.of(LocalDateTime.of(2026, 5, 11, 17, 2, 31), "11 May 2026, 5:02:31PM") - ); - } - private static Stream complexClaimFieldsScenarios() { return Stream.of( Arguments.of( From 84d0bf39156c1fb8dbca83b92619041fc008c994 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 12:57:42 +0100 Subject: [PATCH 038/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 71 +----- .../reform/pcs/ccd/view/CaseTabView.java | 56 +++++ .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 88 +------ .../reform/pcs/ccd/view/CaseTabViewTest.java | 110 +++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 235 ++++++++++++++++-- 5 files changed, 404 insertions(+), 156 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 66a862a1b7..b7c6df7352 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 @@ -3,7 +3,6 @@ import lombok.AllArgsConstructor; 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; @@ -11,12 +10,9 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.SearchCriteria; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; 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.PcsCaseEntity; @@ -41,7 +37,6 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; -import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Set; @@ -86,10 +81,13 @@ public PCSCase getCase(CaseViewRequest request) { long caseReference = request.caseRef(); State state = request.state(); PCSCase pcsCase = getSubmittedCase(caseReference); - Optional draftCaseData = getUnsubmittedCaseData(caseReference, state); - boolean hasUnsubmittedCaseData = draftCaseData.isPresent(); + boolean hasUnsubmittedCaseData = caseHasUnsubmittedData(caseReference, state); - draftCaseData.ifPresent(draft -> setSummaryTabFromDraftData(pcsCase, draft)); + if (hasUnsubmittedCaseData) { + draftCaseDataService + .getUnsubmittedCaseData(caseReference, resumePossessionClaim) + .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + } setMarkdownFields(pcsCase, hasUnsubmittedCaseData); enforcementOrderMediator.handleEnforcementRequirements(caseReference, pcsCase); @@ -102,63 +100,12 @@ public PCSCase getCase(CaseViewRequest request) { return pcsCase; } - private Optional getUnsubmittedCaseData(long caseReference, State state) { + private boolean caseHasUnsubmittedData(long caseReference, State state) { if (State.AWAITING_SUBMISSION_TO_HMCTS == state) { - return draftCaseDataService.getUnsubmittedCaseData(caseReference, resumePossessionClaim); - } - - return Optional.empty(); - } - - private void setSummaryTabFromDraftData(PCSCase pcsCase, PCSCase draftCaseData) { - draftCaseData.setPropertyAddress(Optional.ofNullable(draftCaseData.getPropertyAddress()) - .orElse(pcsCase.getPropertyAddress())); - - if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { - draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); - } - - if (draftCaseData.getDefendant1() != null) { - draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); - } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { - draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + return draftCaseDataService.hasUnsubmittedCaseData(caseReference, resumePossessionClaim); } - List> draftGrounds = - claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); - draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) - ? pcsCase.getClaimGroundSummaries() - : draftGrounds); - - caseTabView.setCaseTabFields(draftCaseData); - pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); - } - - private List> buildDefendants(PCSCase draftCaseData) { - List> defendants = new ArrayList<>(); - defendants.add(buildDefendant(draftCaseData.getDefendant1())); - - if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES - && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { - draftCaseData.getAdditionalDefendants().stream() - .map(ListValue::getValue) - .map(this::buildDefendant) - .forEach(defendants::add); - } - - return defendants; - } - - private ListValue buildDefendant(DefendantDetails defendant) { - return ListValue.builder() - .value(Party.builder() - .nameKnown(defendant.getNameKnown()) - .firstName(defendant.getFirstName()) - .lastName(defendant.getLastName()) - .addressKnown(defendant.getAddressKnown()) - .address(defendant.getCorrespondenceAddress()) - .build()) - .build(); + return false; } private PCSCase getSubmittedCase(long caseReference) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 2b7a75b0b6..86bffaa0d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -1,11 +1,13 @@ package uk.gov.hmcts.reform.pcs.ccd.view; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; @@ -41,6 +43,7 @@ import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @Component +@AllArgsConstructor public class CaseTabView { private static final String NAME_UNKNOWN = "Person unknown"; @@ -48,6 +51,8 @@ public class CaseTabView { private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + private final ClaimGroundsView claimGroundsView; + public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); SummaryTab summaryTab = buildSummaryTab(pcsCase); @@ -55,6 +60,57 @@ public void setCaseTabFields(PCSCase pcsCase) { pcsCase.setSummaryTab(summaryTab); } + public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { + draftCaseData.setPropertyAddress(java.util.Optional.ofNullable(draftCaseData.getPropertyAddress()) + .orElse(pcsCase.getPropertyAddress())); + + if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { + draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); + } + + if (draftCaseData.getDefendant1() != null) { + draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); + } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { + draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); + } + + List> draftGrounds = + claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) + ? pcsCase.getClaimGroundSummaries() + : draftGrounds); + + setCaseTabFields(draftCaseData); + pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + } + + private List> buildDefendants(PCSCase draftCaseData) { + List> defendants = new ArrayList<>(); + defendants.add(buildDefendant(draftCaseData.getDefendant1())); + + if (draftCaseData.getAddAnotherDefendant() == VerticalYesNo.YES + && !CollectionUtils.isEmpty(draftCaseData.getAdditionalDefendants())) { + draftCaseData.getAdditionalDefendants().stream() + .map(ListValue::getValue) + .map(this::buildDefendant) + .forEach(defendants::add); + } + + return defendants; + } + + private ListValue buildDefendant(DefendantDetails defendant) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(defendant.getNameKnown()) + .firstName(defendant.getFirstName()) + .lastName(defendant.getLastName()) + .addressKnown(defendant.getAddressKnown()) + .address(defendant.getCorrespondenceAddress()) + .build()) + .build(); + } + private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { CasePartiesTab tab = CasePartiesTab.builder().build(); 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 a128b2f6c0..2a72e2da9e 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 @@ -10,13 +10,9 @@ import uk.gov.hmcts.ccd.sdk.CaseViewRequest; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; 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; @@ -55,7 +51,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mock.Strictness.LENIENT; -import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -261,10 +256,6 @@ private static ListValue asListValue(UUID id, Party party) { return ListValue.builder().id(id.toString()).value(party).build(); } - private static ListValue listValue(T value) { - return ListValue.builder().value(value).build(); - } - private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { PartyEntity partyEntity = mock(PartyEntity.class); @@ -310,92 +301,33 @@ void shouldSetCaseFields() { } @Test - void shouldSetSummaryTabFromDraftDataWhenUnsubmittedCaseDataExists() { + void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { // Given - AddressEntity addressEntity = mock(AddressEntity.class); - when(pcsCaseEntity.getPropertyAddress()).thenReturn(addressEntity); - AddressUK propertyAddress = stubAddressEntityModelMapper(addressEntity); - - Party claimant = mock(Party.class); - UUID claimantId = UUID.randomUUID(); - ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); - when(claimEntity.getClaimParties()).thenReturn(List.of(claimantClaimParty)); - - AddressUK defendantOneAddress = AddressUK.builder().postCode("E1 1AA").build(); - AddressUK defendantTwoAddress = AddressUK.builder().postCode("E2 2AA").build(); - PCSCase draftCaseData = PCSCase.builder() - .defendant1(DefendantDetails.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .addressKnown(VerticalYesNo.YES) - .correspondenceAddress(defendantOneAddress) - .build()) - .addAnotherDefendant(VerticalYesNo.YES) - .additionalDefendants(List.of(listValue(DefendantDetails.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("Two") - .addressKnown(VerticalYesNo.YES) - .correspondenceAddress(defendantTwoAddress) - .build()))) - .summaryTab(SummaryTab.builder().build()) - .build(); - List> draftGrounds = - List.of(listValue(ClaimGroundSummary.builder().label("Draft ground").build())); + PCSCase draftCaseData = PCSCase.builder().build(); + when(draftCaseDataService.hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(true); when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) .thenReturn(Optional.of(draftCaseData)); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); // When PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); // Then + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); - verify(caseTabView).setCaseTabFields(draftCaseData); - assertThat(draftCaseData.getPropertyAddress()).isEqualTo(propertyAddress); - assertThat(draftCaseData.getAllClaimants()).containsExactly(asListValue(claimantId, claimant)); - assertThat(draftCaseData.getAllDefendants()).hasSize(2); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getLastName()).isEqualTo("One"); - assertThat(draftCaseData.getAllDefendants().get(0).getValue().getAddress()).isEqualTo(defendantOneAddress); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getLastName()).isEqualTo("Two"); - assertThat(draftCaseData.getAllDefendants().get(1).getValue().getAddress()).isEqualTo(defendantTwoAddress); - assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(draftGrounds); - assertThat(pcsCase.getSummaryTab()).isSameAs(draftCaseData.getSummaryTab()); + verify(caseTabView).setDraftCaseTabFields(pcsCase, draftCaseData); assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } @Test - void shouldFallbackToSubmittedSummaryDataWhenDraftDataIsPartial() { - // Given - Party defendant = mock(Party.class); - UUID defendantId = UUID.randomUUID(); - ClaimPartyEntity defendantClaimParty = createClaimPartyEntity(defendant, defendantId, PartyRole.DEFENDANT); - when(claimEntity.getClaimParties()).thenReturn(List.of(defendantClaimParty)); - - List> submittedGrounds = - List.of(listValue(ClaimGroundSummary.builder().label("Submitted ground").build())); - doAnswer(invocation -> { - PCSCase pcsCase = invocation.getArgument(0); - pcsCase.setClaimGroundSummaries(submittedGrounds); - return null; - }).when(claimGroundsView).setCaseFields(any(PCSCase.class), any(PcsCaseEntity.class)); - - PCSCase draftCaseData = PCSCase.builder() - .summaryTab(SummaryTab.builder().build()) - .build(); - when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) - .thenReturn(Optional.of(draftCaseData)); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); - + void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { // When underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); // Then - assertThat(draftCaseData.getAllDefendants()).containsExactly(asListValue(defendantId, defendant)); - assertThat(draftCaseData.getClaimGroundSummaries()).isEqualTo(submittedGrounds); + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); + verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index d380279a82..ffe98e2537 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -4,11 +4,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.Party; @@ -33,15 +35,19 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class CaseTabViewTest { private CaseTabView underTest; + @Mock + private ClaimGroundsView claimGroundsView; + @BeforeEach void setUp() { - underTest = new CaseTabView(); + underTest = new CaseTabView(claimGroundsView); } @Test @@ -542,6 +548,108 @@ void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); } + @Test + void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + List> submittedClaimants = List.of( + listValue(Party.builder().orgName("Submitted claimant").build()) + ); + List> submittedDefendants = List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Submitted") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .address(propertyAddress) + .build()) + ); + List> submittedGrounds = List.of( + listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) + ); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allClaimants(submittedClaimants) + .allDefendants(submittedDefendants) + .claimGroundSummaries(submittedGrounds) + .build(); + PCSCase draftCaseData = PCSCase.builder().build(); + + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Submitted claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Submitted"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Submitted ground"); + } + + @Test + void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { + // Given + AddressUK submittedPropertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK draftPropertyAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK defendantOneAddress = AddressUK.builder().postCode("M1 1AA").build(); + AddressUK additionalDefendantAddress = AddressUK.builder().postCode("B1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(submittedPropertyAddress) + .allClaimants(List.of(listValue(Party.builder().orgName("Submitted claimant").build()))) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) + )) + .build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(draftPropertyAddress) + .allClaimants(List.of(listValue(Party.builder().orgName("Draft claimant").build()))) + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Draft") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantOneAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of( + listValue(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Additional") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(additionalDefendantAddress) + .build()) + )) + .build(); + List> draftGrounds = List.of( + listValue(ClaimGroundSummary.builder().label("Draft ground").build()) + ); + + when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(draftPropertyAddress); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Draft claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Draft"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(defendantOneAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Additional"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(additionalDefendantAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Draft ground"); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 2662d53560..18680825c4 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,6 +12,9 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; @@ -34,6 +37,8 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; @@ -217,6 +222,10 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { void shouldBuildClaimGroundSummariesFromDraft() { // Given PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() .rentArrearsGrounds(Set.of( AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, @@ -291,21 +300,7 @@ void shouldBuildClaimGroundSummariesFromDraft() { "Serious rent arrears (ground 8)", "Rent arrears (ground 10)", "Owner occupier (ground 1)", - "Breach of tenancy conditions (ground 12)", - "Holiday let (ground 3)", - "Deterioration in the condition of the property (ground 13)", - "Antisocial behaviour", - "Rent arrears or breach of the tenancy (ground 1)", - "Condition 1 of Section 84A of the Housing Act 1985", - "Property sold for redevelopment (ground 10A)", - "Adapted accommodation (ground 13)", - "Antisocial behaviour", - "Notice given under a landlord’s break clause (section 199)", - "Rent arrears (breach of contract) (section 157)", - "Redevelopment schemes (ground B)", - "Landlord’s notice in connection with end of fixed term given (section 186)", - "Antisocial behaviour (breach of contract) (section 157)", - "Reserve successors (ground G)" + "Breach of tenancy conditions (ground 12)" ); } @@ -319,6 +314,216 @@ void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { assertThat(summaries).isEmpty(); } + @Test + void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), + SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), + EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() + ); + } + + @Test + void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), + DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() + ); + } + + @Test + void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.NO) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() + ); + } + + @Test + void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel() + ); + } + + @Test + void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel()); + } + + @Test + void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) + .build() + ) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries).isEmpty(); + } + private static Stream claimGroundScenarios() { return Stream.of( argumentSet( From 37ff4281e68fa59a7856f2b727b8d06a3da481bb Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 13:53:29 +0100 Subject: [PATCH 039/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabView.java | 334 ++++++++++++++++ .../reform/pcs/ccd/view/CaseTabView.java | 313 +-------------- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 364 ++++++++++++++++++ .../reform/pcs/ccd/view/CaseTabViewTest.java | 286 +------------- 4 files changed, 702 insertions(+), 595 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java new file mode 100644 index 0000000000..49f9365076 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -0,0 +1,334 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Locale; + +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + +@Component +public class CaseSummaryTabView { + + private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + + public SummaryTab buildSummaryTab(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); + + return SummaryTab.builder() + .repossessedPropertyAddress(pcsCase.getPropertyAddress()) + .groundsForPossession(GroundsForPossessionTabDetails.builder() + .grounds(getGrounds(pcsCase)) + .build()) + .claimSubmittedDate(dateSubmitted) + .reasonsForPossession(reasonsForPossession) + .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) + .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) + .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .tenancyDetails(buildTenancyTabDetails(pcsCase)) + .noticeDetails(buildNoticeTabDetails(pcsCase)) + .build(); + } + + private String formatSubmittedDate(LocalDateTime dateSubmitted) { + if (dateSubmitted == null) { + return null; + } + + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } + + private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return ClaimantInformationTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } + + private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private List> createAdditionalSummaryDefendantsDetails( + PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return AdditionalDefendantInformationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } + + private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return DefendantInfomationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } + + private String getDefendantFirstName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : CaseTabView.NAME_UNKNOWN; + } + + private String getDefendantLastName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : CaseTabView.NAME_UNKNOWN; + } + + private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return null; + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + return null; + } + + return ReasonsForPossessionTabDetails.builder() + .groundReasons(additionalReasons.getHasReasons().getLabel()) + .additionalReasonsForPossession(additionalReasons.getReasons()) + .build(); + } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { + TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); + OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); + + if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) + && (occupationLicenceDetailsWales == null + || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { + return null; + } + + String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null + ? getAgreementType(tenancyLicenceDetails) + : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); + String agreementStartDate = tenancyLicenceDetails != null + && tenancyLicenceDetails.getTenancyLicenceDate() != null + ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) + : getOccupationLicenceStartDate(occupationLicenceDetailsWales); + + return TenancyTabDetails.builder() + .agreementType(agreementType) + .agreementStartDate(agreementStartDate) + .build(); + } + + private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { + if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { + return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); + } + + return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); + } + + private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { + return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); + } + + return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); + } + + private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { + if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { + return null; + } + + return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); + } + + private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { + NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + + if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + return null; + } + + return NoticeTabDetails.builder() + .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .build(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + return pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .orElse(null); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 86bffaa0d7..d5b9d51cfe 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -5,57 +5,31 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; -import java.util.Locale; - -import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @Component @AllArgsConstructor public class CaseTabView { - private static final String NAME_UNKNOWN = "Person unknown"; - private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = - DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + static final String NAME_UNKNOWN = "Person unknown"; private final ClaimGroundsView claimGroundsView; + private final CaseSummaryTabView caseSummaryTabView; public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); - SummaryTab summaryTab = buildSummaryTab(pcsCase); + SummaryTab summaryTab = caseSummaryTabView.buildSummaryTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); pcsCase.setSummaryTab(summaryTab); } @@ -168,285 +142,4 @@ private DefendantTabDetails createDefendantTabDetails(Party defendant, PCSCase p .lastName(defendantLastName) .build(); } - - private SummaryTab buildSummaryTab(PCSCase pcsCase) { - ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); - String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); - - return SummaryTab.builder() - .repossessedPropertyAddress(pcsCase.getPropertyAddress()) - .groundsForPossession(GroundsForPossessionTabDetails.builder() - .grounds(getGrounds(pcsCase)) - .build()) - .claimSubmittedDate(dateSubmitted) - .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) - .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) - .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) - .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) - .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) - .tenancyDetails(buildTenancyTabDetails(pcsCase)) - .noticeDetails(buildNoticeTabDetails(pcsCase)) - .build(); - } - - private String formatSubmittedDate(LocalDateTime dateSubmitted) { - if (dateSubmitted == null) { - return null; - } - - return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); - } - - private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { - String claimantName = getSummaryClaimantName(pcsCase); - if (claimantName == null) { - return null; - } - - return ClaimantInformationTabDetails.builder() - .claimantName(claimantName) - .build(); - } - - private String getSummaryClaimantName(PCSCase pcsCase) { - ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); - if (claimantInformation != null) { - if (claimantInformation.getOrgNameFound() == NO) { - return claimantInformation.getFallbackClaimantName(); - } - - if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { - return claimantInformation.getOverriddenClaimantName(); - } - - if (claimantInformation.getClaimantName() != null) { - return claimantInformation.getClaimantName(); - } - } - - if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { - return null; - } - - return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); - } - - private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { - return null; - } - - return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); - } - - private List> createAdditionalSummaryDefendantsDetails( - PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { - return null; - } - - return pcsCase.getAllDefendants().stream() - .skip(1) - .map(ListValue::getValue) - .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) - .filter(defendantDetails -> defendantDetails != null) - .map(defendantDetails -> ListValue.builder() - .value(defendantDetails) - .build()) - .toList(); - } - - private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, - PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return AdditionalDefendantInformationTabDetails.builder() - .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) - .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) - .addressForService(addressForService) - .build(); - } - - private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return DefendantInfomationTabDetails.builder() - .firstName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : null) - .lastName(defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : null) - .addressForService(addressForService) - .build(); - } - - private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { - if (defendant.getAddressKnown() != VerticalYesNo.YES) { - return null; - } - - return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); - } - - private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { - AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); - if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { - return null; - } - - return ReasonsForPossessionTabDetails.builder() - .groundReasons(additionalReasons.getHasReasons().getLabel()) - .additionalReasonsForPossession(additionalReasons.getReasons()) - .build(); - } - - private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { - RentDetails rentDetails = pcsCase.getRentDetails(); - RentArrearsSection rentArrears = pcsCase.getRentArrears(); - - String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); - String calculationFrequency = getRentCalculationFrequency(rentDetails); - String dailyRate = getDailyRate(rentDetails); - String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); - String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null - ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); - - if (rentAmount == null - && calculationFrequency == null - && dailyRate == null - && arrearsTotal == null - && judgmentRequested == null) { - return null; - } - - return RentArrearsTabDetails.builder() - .rentAmount(rentAmount) - .calculationFrequency(calculationFrequency) - .dailyRate(dailyRate) - .arrearsTotal(arrearsTotal) - .judgmentRequested(judgmentRequested) - .build(); - } - - private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { - TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); - OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); - - if ((tenancyLicenceDetails == null || tenancyLicenceDetails.getTypeOfTenancyLicence() == null) - && (occupationLicenceDetailsWales == null - || occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == null)) { - return null; - } - - String agreementType = tenancyLicenceDetails != null && tenancyLicenceDetails.getTypeOfTenancyLicence() != null - ? getAgreementType(tenancyLicenceDetails) - : getOccupationLicenceAgreementType(occupationLicenceDetailsWales); - String agreementStartDate = tenancyLicenceDetails != null - && tenancyLicenceDetails.getTenancyLicenceDate() != null - ? tenancyLicenceDetails.getTenancyLicenceDate().format(SUMMARY_DATE_FORMATTER) - : getOccupationLicenceStartDate(occupationLicenceDetailsWales); - - return TenancyTabDetails.builder() - .agreementType(agreementType) - .agreementStartDate(agreementStartDate) - .build(); - } - - private String getAgreementType(TenancyLicenceDetails tenancyLicenceDetails) { - if (tenancyLicenceDetails.getTypeOfTenancyLicence() == TenancyLicenceType.OTHER) { - return tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence(); - } - - return tenancyLicenceDetails.getTypeOfTenancyLicence().getLabel(); - } - - private String getOccupationLicenceAgreementType(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { - if (occupationLicenceDetailsWales.getOccupationLicenceTypeWales() == OccupationLicenceTypeWales.OTHER) { - return occupationLicenceDetailsWales.getOtherLicenceTypeDetails(); - } - - return occupationLicenceDetailsWales.getOccupationLicenceTypeWales().getLabel(); - } - - private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occupationLicenceDetailsWales) { - if (occupationLicenceDetailsWales == null || occupationLicenceDetailsWales.getLicenceStartDate() == null) { - return null; - } - - return occupationLicenceDetailsWales.getLicenceStartDate().format(SUMMARY_DATE_FORMATTER); - } - - private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { - NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); - - if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { - return null; - } - - return NoticeTabDetails.builder() - .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) - .build(); - } - - private String getRentCalculationFrequency(RentDetails rentDetails) { - if (rentDetails == null || rentDetails.getFrequency() == null) { - return null; - } - - if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { - return rentDetails.getOtherFrequency(); - } - - return rentDetails.getFrequency().getLabel(); - } - - private String getDailyRate(RentDetails rentDetails) { - if (rentDetails == null) { - return null; - } - - if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { - return formatMoney(rentDetails.getAmendedDailyCharge()); - } - - if (rentDetails.getDailyCharge() != null) { - return formatMoney(rentDetails.getDailyCharge()); - } - - if (rentDetails.getFormattedCalculatedDailyCharge() != null) { - return rentDetails.getFormattedCalculatedDailyCharge(); - } - - return formatMoney(rentDetails.getCalculatedDailyCharge()); - } - - private String formatMoney(BigDecimal amount) { - if (amount == null) { - return null; - } - - if (amount.stripTrailingZeros().scale() <= 0) { - amount = amount.stripTrailingZeros(); - } - - return "£" + amount.toPlainString(); - } - - private String getGrounds(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { - return null; - } - - return pcsCase.getClaimGroundSummaries().stream() - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) - .orElse(null); - } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java new file mode 100644 index 0000000000..d95fe478ac --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -0,0 +1,364 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CaseSummaryTabViewTest { + + private CaseSummaryTabView underTest; + + @BeforeEach + void setUp() { + underTest = new CaseSummaryTabView(); + } + + @Test + void shouldSetSummaryTabFields() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Ground 1").build()), + listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("Licence details") + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .build()) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldNotSetEmptySummarySections() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + assertThat(summaryTab.getReasonsForPossession()).isNull(); + assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getAdditionalDefendants()).isNull(); + assertThat(summaryTab.getRentArrearsDetails()).isNull(); + assertThat(summaryTab.getTenancyDetails()).isNull(); + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + + @Test + void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(address); + } + + @Test + void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(address); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = underTest.buildSummaryTab(pcsCase).getRentArrearsDetails(); + + // Then + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); + } + + @Test + void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); + } + + @Test + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .licenceStartDate(LocalDate.of(2025, 5, 12)) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); + } + + @Test + void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { + // Given + PCSCase pcsCase = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .otherLicenceTypeDetails("Other Welsh licence") + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); + assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index ffe98e2537..4f37db5c2b 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -7,30 +7,15 @@ import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -47,7 +32,7 @@ class CaseTabViewTest { @BeforeEach void setUp() { - underTest = new CaseTabView(claimGroundsView); + underTest = new CaseTabView(claimGroundsView, new CaseSummaryTabView()); } @Test @@ -279,275 +264,6 @@ void shouldNotSetCasePartiesTabWithNoData() { assertThat(pcsCase.getCasePartiesTab().getDefendantsDetails()).isNull(); } - @Test - void shouldSetSummaryTabFields() { - // Given - AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) - .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder().label("Ground 1").build()), - listValue(ClaimGroundSummary.builder().label("Ground 2").build()) - )) - .additionalReasonsForPossession(AdditionalReasons.builder() - .hasReasons(VerticalYesNo.YES) - .reasons("Additional reasons") - .build()) - .claimantInformation(ClaimantInformation.builder() - .orgNameFound(YesOrNo.NO) - .fallbackClaimantName("Fallback claimant") - .build()) - .allDefendants(List.of( - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .addressKnown(VerticalYesNo.YES) - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("Two") - .addressKnown(VerticalYesNo.YES) - .address(defendantAddress) - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()) - )) - .rentDetails(RentDetails.builder() - .currentRent(new BigDecimal("100.00")) - .frequency(RentPaymentFrequency.OTHER) - .otherFrequency("Every 4 weeks") - .perDayCorrect(VerticalYesNo.NO) - .amendedDailyCharge(new BigDecimal("12.30")) - .build()) - .rentArrears(RentArrearsSection.builder() - .total(new BigDecimal("450.75")) - .build()) - .arrearsJudgmentWanted(VerticalYesNo.YES) - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .detailsOfOtherTypeOfTenancyLicence("Licence details") - .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) - .build()) - .noticeServedDetails(NoticeServedDetails.builder() - .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); - assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); - assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) - .isEqualTo("Additional reasons"); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) - .isEqualTo(defendantAddress); - assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); - assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); - assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); - assertThat(summaryTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); - assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); - assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); - assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); - assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); - } - - @Test - void shouldSetSummaryClaimantNameFromOverriddenName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .isClaimantNameCorrect(VerticalYesNo.NO) - .overriddenClaimantName("Overridden claimant") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); - } - - @Test - void shouldSetSummaryClaimantNameFromClaimantInformationName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .claimantName("Claimant information name") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()) - .isEqualTo("Claimant information name"); - } - - @Test - void shouldSetSummaryClaimantNameFromAllClaimants() { - // Given - PCSCase pcsCase = PCSCase.builder() - .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); - } - - @Test - void shouldNotSetEmptySummarySections() { - // Given - PCSCase pcsCase = PCSCase.builder() - .allDefendants(List.of(listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()))) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); - assertThat(summaryTab.getReasonsForPossession()).isNull(); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); - assertThat(summaryTab.getClaimantDetails()).isNull(); - assertThat(summaryTab.getDefendantDetails()).isNull(); - assertThat(summaryTab.getAdditionalDefendants()).isNull(); - assertThat(summaryTab.getRentArrearsDetails()).isNull(); - assertThat(summaryTab.getTenancyDetails()).isNull(); - assertThat(summaryTab.getNoticeDetails()).isNull(); - } - - @Test - void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .frequency(RentPaymentFrequency.WEEKLY) - .dailyCharge(new BigDecimal("1.50")) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - RentArrearsTabDetails rentArrearsDetails = pcsCase.getSummaryTab().getRentArrearsDetails(); - assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); - assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); - } - - @Test - void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .formattedCalculatedDailyCharge("£2.34") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); - } - - @Test - void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .calculatedDailyCharge(new BigDecimal("3.40")) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); - } - - @Test - void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { - // Given - PCSCase pcsCase = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Assured tenancy"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); - } - - @Test - void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { - // Given - PCSCase pcsCase = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) - .licenceStartDate(LocalDate.of(2025, 5, 12)) - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); - } - - @Test - void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { - // Given - PCSCase pcsCase = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) - .otherLicenceTypeDetails("Other Welsh licence") - .build()) - .build(); - - // When - underTest.setCaseTabFields(pcsCase); - - // Then - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementType()).isEqualTo("Other Welsh licence"); - assertThat(pcsCase.getSummaryTab().getTenancyDetails().getAgreementStartDate()).isNull(); - } - @Test void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { // Given From 3630adbbf8ee9a3f3352b31f3cc08294e01e5fc3 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 16:41:37 +0100 Subject: [PATCH 040/138] HDPI-2978: Build Case Summary tab --- .../ReasonsForPossessionTabDetails.java | 162 +++++++- .../pcs/ccd/view/CaseSummaryTabView.java | 145 ++++++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 221 ++++++++++- .../pcs/ccd/view/ClaimGroundsViewTest.java | 375 +++++++++++++++++- 4 files changed, 880 insertions(+), 23 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java index 90aaac2db4..c8647b148d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java @@ -12,10 +12,164 @@ @AllArgsConstructor public class ReasonsForPossessionTabDetails { - @CCD( - label = "Reasons for claiming possession under ground X" - ) - private String groundReasons; + @CCD(label = "Reasons for claiming possession under ground 1") + private String ground1; + + @CCD(label = "Reasons for claiming possession under ground 2") + private String ground2; + + @CCD(label = "Reasons for claiming possession under ground 2A") + private String ground2A; + + @CCD(label = "Reasons for claiming possession under ground 2ZA") + private String ground2ZA; + + @CCD(label = "Reasons for claiming possession under ground 3") + private String ground3; + + @CCD(label = "Reasons for claiming possession under ground 4") + private String ground4; + + @CCD(label = "Reasons for claiming possession under ground 5") + private String ground5; + + @CCD(label = "Reasons for claiming possession under ground 6") + private String ground6; + + @CCD(label = "Reasons for claiming possession under ground 7") + private String ground7; + + @CCD(label = "Reasons for claiming possession under ground 7A") + private String ground7A; + + @CCD(label = "Reasons for claiming possession under ground 7B") + private String ground7B; + + @CCD(label = "Reasons for claiming possession under ground 8") + private String ground8; + + @CCD(label = "Reasons for claiming possession under ground 9") + private String ground9; + + @CCD(label = "Reasons for claiming possession under ground 10") + private String ground10; + + @CCD(label = "Reasons for claiming possession under ground 10A") + private String ground10A; + + @CCD(label = "Reasons for claiming possession under ground 11") + private String ground11; + + @CCD(label = "Reasons for claiming possession under ground 12") + private String ground12; + + @CCD(label = "Reasons for claiming possession under ground 13") + private String ground13; + + @CCD(label = "Reasons for claiming possession under ground 14") + private String ground14; + + @CCD(label = "Reasons for claiming possession under ground 14A") + private String ground14A; + + @CCD(label = "Reasons for claiming possession under ground 14ZA") + private String ground14ZA; + + @CCD(label = "Reasons for claiming possession under ground 15") + private String ground15; + + @CCD(label = "Reasons for claiming possession under ground 15A") + private String ground15A; + + @CCD(label = "Reasons for claiming possession under ground 16") + private String ground16; + + @CCD(label = "Reasons for claiming possession under ground 17") + private String ground17; + + @CCD(label = "Reasons for claiming possession under ground A") + private String groundA; + + @CCD(label = "Reasons for claiming possession under ground B") + private String groundB; + + @CCD(label = "Reasons for claiming possession under ground C") + private String groundC; + + @CCD(label = "Reasons for claiming possession under ground D") + private String groundD; + + @CCD(label = "Reasons for claiming possession under ground E") + private String groundE; + + @CCD(label = "Reasons for claiming possession under ground F") + private String groundF; + + @CCD(label = "Reasons for claiming possession under ground G") + private String groundG; + + @CCD(label = "Reasons for claiming possession under ground H") + private String groundH; + + @CCD(label = "Reasons for claiming possession under ground I") + private String groundI; + + @CCD(label = "Reasons for claiming possession under Condition 1 of Section 84A of the Housing Act 1985") + private String condition1OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 2 of Section 84A of the Housing Act 1985") + private String condition2OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 3 of Section 84A of the Housing Act 1985") + private String condition3OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 4 of Section 84A of the Housing Act 1985") + private String condition4OfSection84A; + + @CCD(label = "Reasons for claiming possession under Condition 5 of Section 84A of the Housing Act 1985") + private String condition5OfSection84A; + + @CCD(label = "Reasons for claiming possession under section 157") + private String section157; + + @CCD(label = "Reasons for claiming possession under section 170") + private String section170; + + @CCD(label = "Reasons for claiming possession under section 178") + private String section178; + + @CCD(label = "Reasons for claiming possession under section 181") + private String section181; + + @CCD(label = "Reasons for claiming possession under section 186") + private String section186; + + @CCD(label = "Reasons for claiming possession under section 187") + private String section187; + + @CCD(label = "Reasons for claiming possession under section 191") + private String section191; + + @CCD(label = "Reasons for claiming possession under section 199") + private String section199; + + @CCD(label = "Reasons for claiming possession under paragraph 25B(2) of Schedule 12") + private String paragraph25B2Schedule12; + + @CCD(label = "Reasons for claiming possession under Antisocial behaviour") + private String antisocialBehaviour; + + @CCD(label = "Reasons for claiming possession under Breach of the tenancy") + private String breachOfTheTenancy; + + @CCD(label = "Reasons for claiming possession under Absolute grounds") + private String absoluteGrounds; + + @CCD(label = "Reasons for claiming possession under Other grounds") + private String otherGrounds; + + @CCD(label = "Reasons for claiming possession under No grounds") + private String noGrounds; @CCD( label = "Additional reasons for possession" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 49f9365076..ced75a04ad 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -2,6 +2,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; @@ -33,6 +34,8 @@ import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @@ -42,6 +45,10 @@ public class CaseSummaryTabView { private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); + private static final Pattern GROUND_REFERENCE_PATTERN = + Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_REFERENCE_PATTERN = + Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -178,14 +185,142 @@ private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); - if (additionalReasons == null || additionalReasons.getHasReasons() != VerticalYesNo.YES) { + ReasonsForPossessionTabDetails reasonsForPossession = + buildReasonsForPossessionFromGroundSummaries(pcsCase); + String additionalReasonsText = additionalReasons == null + || additionalReasons.getHasReasons() != VerticalYesNo.YES ? null : additionalReasons.getReasons(); + + if (reasonsForPossession == null && additionalReasonsText == null) { return null; } - return ReasonsForPossessionTabDetails.builder() - .groundReasons(additionalReasons.getHasReasons().getLabel()) - .additionalReasonsForPossession(additionalReasons.getReasons()) - .build(); + if (reasonsForPossession == null) { + reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + } + + reasonsForPossession.setAdditionalReasonsForPossession(additionalReasonsText); + return reasonsForPossession; + } + + private ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + ReasonsForPossessionTabDetails reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + boolean hasReason = false; + + for (ListValue listValue : pcsCase.getClaimGroundSummaries()) { + ClaimGroundSummary summary = listValue.getValue(); + if (summary == null || !StringUtils.hasText(summary.getReason())) { + continue; + } + + setGroundReason(reasonsForPossession, summary.getLabel(), summary.getReason()); + hasReason = true; + } + + return hasReason ? reasonsForPossession : null; + } + + private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession, + String groundLabel, + String reason) { + Matcher groundMatcher = GROUND_REFERENCE_PATTERN.matcher(groundLabel); + if (groundMatcher.find()) { + setGroundNumberReason(reasonsForPossession, groundMatcher.group(1), reason); + return; + } + + Matcher sectionMatcher = SECTION_REFERENCE_PATTERN.matcher(groundLabel); + if (sectionMatcher.find()) { + setSectionReason(reasonsForPossession, sectionMatcher.group(1), reason); + return; + } + + if (groundLabel.startsWith("Condition 1")) { + reasonsForPossession.setCondition1OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 2")) { + reasonsForPossession.setCondition2OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 3")) { + reasonsForPossession.setCondition3OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 4")) { + reasonsForPossession.setCondition4OfSection84A(reason); + } else if (groundLabel.startsWith("Condition 5")) { + reasonsForPossession.setCondition5OfSection84A(reason); + } else if ("Antisocial behaviour".equals(groundLabel)) { + reasonsForPossession.setAntisocialBehaviour(reason); + } else if ("Breach of the tenancy".equals(groundLabel)) { + reasonsForPossession.setBreachOfTheTenancy(reason); + } else if ("Absolute grounds".equals(groundLabel)) { + reasonsForPossession.setAbsoluteGrounds(reason); + } else if ("Other".equals(groundLabel) || "Other grounds".equals(groundLabel)) { + reasonsForPossession.setOtherGrounds(reason); + } else if ("No grounds".equals(groundLabel)) { + reasonsForPossession.setNoGrounds(reason); + } else if (groundLabel.contains("paragraph 25B(2) of Schedule 12")) { + reasonsForPossession.setParagraph25B2Schedule12(reason); + } + } + + private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPossession, + String ground, + String reason) { + switch (ground) { + case "1" -> reasonsForPossession.setGround1(reason); + case "2" -> reasonsForPossession.setGround2(reason); + case "2A" -> reasonsForPossession.setGround2A(reason); + case "2ZA" -> reasonsForPossession.setGround2ZA(reason); + case "3" -> reasonsForPossession.setGround3(reason); + case "4" -> reasonsForPossession.setGround4(reason); + case "5" -> reasonsForPossession.setGround5(reason); + case "6" -> reasonsForPossession.setGround6(reason); + case "7" -> reasonsForPossession.setGround7(reason); + case "7A" -> reasonsForPossession.setGround7A(reason); + case "7B" -> reasonsForPossession.setGround7B(reason); + case "8" -> reasonsForPossession.setGround8(reason); + case "9" -> reasonsForPossession.setGround9(reason); + case "10" -> reasonsForPossession.setGround10(reason); + case "10A" -> reasonsForPossession.setGround10A(reason); + case "11" -> reasonsForPossession.setGround11(reason); + case "12" -> reasonsForPossession.setGround12(reason); + case "13" -> reasonsForPossession.setGround13(reason); + case "14" -> reasonsForPossession.setGround14(reason); + case "14A" -> reasonsForPossession.setGround14A(reason); + case "14ZA" -> reasonsForPossession.setGround14ZA(reason); + case "15" -> reasonsForPossession.setGround15(reason); + case "15A" -> reasonsForPossession.setGround15A(reason); + case "16" -> reasonsForPossession.setGround16(reason); + case "17" -> reasonsForPossession.setGround17(reason); + case "A" -> reasonsForPossession.setGroundA(reason); + case "B" -> reasonsForPossession.setGroundB(reason); + case "C" -> reasonsForPossession.setGroundC(reason); + case "D" -> reasonsForPossession.setGroundD(reason); + case "E" -> reasonsForPossession.setGroundE(reason); + case "F" -> reasonsForPossession.setGroundF(reason); + case "G" -> reasonsForPossession.setGroundG(reason); + case "H" -> reasonsForPossession.setGroundH(reason); + case "I" -> reasonsForPossession.setGroundI(reason); + default -> { + } + } + } + + private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossession, + String section, + String reason) { + switch (section) { + case "157" -> reasonsForPossession.setSection157(reason); + case "170" -> reasonsForPossession.setSection170(reason); + case "178" -> reasonsForPossession.setSection178(reason); + case "181" -> reasonsForPossession.setSection181(reason); + case "186" -> reasonsForPossession.setSection186(reason); + case "187" -> reasonsForPossession.setSection187(reason); + case "191" -> reasonsForPossession.setSection191(reason); + case "199" -> reasonsForPossession.setSection199(reason); + default -> { + } + } } private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index d95fe478ac..494a471028 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -18,6 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -47,8 +48,14 @@ void shouldSetSummaryTabFields() { .propertyAddress(propertyAddress) .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder().label("Ground 1").build()), - listValue(ClaimGroundSummary.builder().label("Ground 2").build()) + listValue(ClaimGroundSummary.builder() + .label("Rent arrears (ground 10)") + .reason("Ground 10 reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .build()) )) .additionalReasonsForPossession(AdditionalReasons.builder() .hasReasons(VerticalYesNo.YES) @@ -103,9 +110,12 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Ground 1, Ground 2"); + assertThat(summaryTab.getGroundsForPossession().getGrounds()) + .isEqualTo("Rent arrears (ground 10), Condition 1 of Section 84A of the Housing Act 1985"); assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); - assertThat(summaryTab.getReasonsForPossession().getGroundReasons()).isEqualTo("Yes"); + assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); + assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) + .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); @@ -253,6 +263,202 @@ void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { .isEqualTo(address); } + @Test + void shouldSetEachGroundReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Antisocial behaviour") + .reason("Antisocial reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Premium paid in connection with mutual exchange (ground 6)") + .reason("Premium reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Offence during a riot (ground 2ZA)") + .reason("Riot reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Landlord’s works (ground 10)") + .reason("Works reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Housing association special circumstances accommodation (ground 14)") + .reason("Housing reason") + .build()) + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getGround6()).isEqualTo("Premium reason"); + assertThat(reasons.getGround2ZA()).isEqualTo("Riot reason"); + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getGround10()).isEqualTo("Works reason"); + assertThat(reasons.getGround14()).isEqualTo("Housing reason"); + } + + @Test + void shouldSetEachGroundNumberReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (ground 1)", "Reason 1"), + groundSummary("Ground label (ground 2)", "Reason 2"), + groundSummary("Ground label (ground 2A)", "Reason 2A"), + groundSummary("Ground label (ground 2ZA)", "Reason 2ZA"), + groundSummary("Ground label (ground 3)", "Reason 3"), + groundSummary("Ground label (ground 4)", "Reason 4"), + groundSummary("Ground label (ground 5)", "Reason 5"), + groundSummary("Ground label (ground 6)", "Reason 6"), + groundSummary("Ground label (ground 7)", "Reason 7"), + groundSummary("Ground label (ground 7A)", "Reason 7A"), + groundSummary("Ground label (ground 7B)", "Reason 7B"), + groundSummary("Ground label (ground 8)", "Reason 8"), + groundSummary("Ground label (ground 9)", "Reason 9"), + groundSummary("Ground label (ground 10)", "Reason 10"), + groundSummary("Ground label (ground 10A)", "Reason 10A"), + groundSummary("Ground label (ground 11)", "Reason 11"), + groundSummary("Ground label (ground 12)", "Reason 12"), + groundSummary("Ground label (ground 13)", "Reason 13"), + groundSummary("Ground label (ground 14)", "Reason 14"), + groundSummary("Ground label (ground 14A)", "Reason 14A"), + groundSummary("Ground label (ground 14ZA)", "Reason 14ZA"), + groundSummary("Ground label (ground 15)", "Reason 15"), + groundSummary("Ground label (ground 15A)", "Reason 15A"), + groundSummary("Ground label (ground 16)", "Reason 16"), + groundSummary("Ground label (ground 17)", "Reason 17"), + groundSummary("Ground label (ground A)", "Reason A"), + groundSummary("Ground label (ground B)", "Reason B"), + groundSummary("Ground label (ground C)", "Reason C"), + groundSummary("Ground label (ground D)", "Reason D"), + groundSummary("Ground label (ground E)", "Reason E"), + groundSummary("Ground label (ground F)", "Reason F"), + groundSummary("Ground label (ground G)", "Reason G"), + groundSummary("Ground label (ground H)", "Reason H"), + groundSummary("Ground label (ground I)", "Reason I"), + groundSummary("Ground label (ground Z)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getGround1()).isEqualTo("Reason 1"); + assertThat(reasons.getGround2()).isEqualTo("Reason 2"); + assertThat(reasons.getGround2A()).isEqualTo("Reason 2A"); + assertThat(reasons.getGround2ZA()).isEqualTo("Reason 2ZA"); + assertThat(reasons.getGround3()).isEqualTo("Reason 3"); + assertThat(reasons.getGround4()).isEqualTo("Reason 4"); + assertThat(reasons.getGround5()).isEqualTo("Reason 5"); + assertThat(reasons.getGround6()).isEqualTo("Reason 6"); + assertThat(reasons.getGround7()).isEqualTo("Reason 7"); + assertThat(reasons.getGround7A()).isEqualTo("Reason 7A"); + assertThat(reasons.getGround7B()).isEqualTo("Reason 7B"); + assertThat(reasons.getGround8()).isEqualTo("Reason 8"); + assertThat(reasons.getGround9()).isEqualTo("Reason 9"); + assertThat(reasons.getGround10()).isEqualTo("Reason 10"); + assertThat(reasons.getGround10A()).isEqualTo("Reason 10A"); + assertThat(reasons.getGround11()).isEqualTo("Reason 11"); + assertThat(reasons.getGround12()).isEqualTo("Reason 12"); + assertThat(reasons.getGround13()).isEqualTo("Reason 13"); + assertThat(reasons.getGround14()).isEqualTo("Reason 14"); + assertThat(reasons.getGround14A()).isEqualTo("Reason 14A"); + assertThat(reasons.getGround14ZA()).isEqualTo("Reason 14ZA"); + assertThat(reasons.getGround15()).isEqualTo("Reason 15"); + assertThat(reasons.getGround15A()).isEqualTo("Reason 15A"); + assertThat(reasons.getGround16()).isEqualTo("Reason 16"); + assertThat(reasons.getGround17()).isEqualTo("Reason 17"); + assertThat(reasons.getGroundA()).isEqualTo("Reason A"); + assertThat(reasons.getGroundB()).isEqualTo("Reason B"); + assertThat(reasons.getGroundC()).isEqualTo("Reason C"); + assertThat(reasons.getGroundD()).isEqualTo("Reason D"); + assertThat(reasons.getGroundE()).isEqualTo("Reason E"); + assertThat(reasons.getGroundF()).isEqualTo("Reason F"); + assertThat(reasons.getGroundG()).isEqualTo("Reason G"); + assertThat(reasons.getGroundH()).isEqualTo("Reason H"); + assertThat(reasons.getGroundI()).isEqualTo("Reason I"); + } + + @Test + void shouldSetEachSectionReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (section 157)", "Reason 157"), + groundSummary("Ground label (section 170)", "Reason 170"), + groundSummary("Ground label (section 178)", "Reason 178"), + groundSummary("Ground label (section 181)", "Reason 181"), + groundSummary("Ground label (section 186)", "Reason 186"), + groundSummary("Ground label (section 187)", "Reason 187"), + groundSummary("Ground label (section 191)", "Reason 191"), + groundSummary("Ground label (section 199)", "Reason 199"), + groundSummary("Ground label (section 999)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getSection157()).isEqualTo("Reason 157"); + assertThat(reasons.getSection170()).isEqualTo("Reason 170"); + assertThat(reasons.getSection178()).isEqualTo("Reason 178"); + assertThat(reasons.getSection181()).isEqualTo("Reason 181"); + assertThat(reasons.getSection186()).isEqualTo("Reason 186"); + assertThat(reasons.getSection187()).isEqualTo("Reason 187"); + assertThat(reasons.getSection191()).isEqualTo("Reason 191"); + assertThat(reasons.getSection199()).isEqualTo("Reason 199"); + } + + @Test + void shouldSetNonNumberedGroundReasonsInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Breach of the tenancy", "Breach reason"), + groundSummary("Absolute grounds", "Absolute reason"), + groundSummary("Other", "Other reason"), + groundSummary("Other grounds", "Other grounds reason"), + groundSummary("No grounds", "No grounds reason"), + groundSummary("Converted contract paragraph 25B(2) of Schedule 12", "Paragraph reason"), + groundSummary("Unmapped label", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); + + // Then + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getCondition2OfSection84A()).isEqualTo("Condition 2 reason"); + assertThat(reasons.getCondition3OfSection84A()).isEqualTo("Condition 3 reason"); + assertThat(reasons.getCondition4OfSection84A()).isEqualTo("Condition 4 reason"); + assertThat(reasons.getCondition5OfSection84A()).isEqualTo("Condition 5 reason"); + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getBreachOfTheTenancy()).isEqualTo("Breach reason"); + assertThat(reasons.getAbsoluteGrounds()).isEqualTo("Absolute reason"); + assertThat(reasons.getOtherGrounds()).isEqualTo("Other grounds reason"); + assertThat(reasons.getNoGrounds()).isEqualTo("No grounds reason"); + assertThat(reasons.getParagraph25B2Schedule12()).isEqualTo("Paragraph reason"); + } + @Test void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { // Given @@ -361,4 +567,11 @@ private static ListValue listValue(T value) { .value(value) .build(); } + + private static ListValue groundSummary(String label, String reason) { + return listValue(ClaimGroundSummary.builder() + .label(label) + .reason(reason) + .build()); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index 18680825c4..e0e4f827f6 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -24,12 +24,15 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; @@ -266,8 +269,12 @@ void shouldBuildClaimGroundSummariesFromDraft() { .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm .ADAPTED_ACCOMMODATION - )) - .build()) + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner occupier reason") + .breachOfTenancyConditionsReason("Breach reason") + .build()) .groundsForPossessionWales(GroundsForPossessionWales.builder() .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) @@ -302,6 +309,109 @@ void shouldBuildClaimGroundSummariesFromDraft() { "Owner occupier (ground 1)", "Breach of tenancy conditions (ground 12)" ); + assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); + assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); + assertNoReason(summaries, "Serious rent arrears (ground 8)"); + assertNoReason(summaries, "Rent arrears (ground 10)"); + } + + @Test + void shouldMapAllAssuredDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10, + AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, + AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, + AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, + AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, + AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, + AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, + AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, + AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, + AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds + .ALTERNATIVE_ACCOMMODATION_GROUND9, + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_PROPERTY_GROUND13, + AssuredAdditionalDiscretionaryGrounds + .NUISANCE_ANNOYANCE_GROUND14, + AssuredAdditionalDiscretionaryGrounds + .DOMESTIC_VIOLENCE_GROUND14A, + AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_FURNITURE_GROUND15, + AssuredAdditionalDiscretionaryGrounds + .EMPLOYEE_LANDLORD_GROUND16, + AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner reason") + .repossessionByLenderReason("Lender reason") + .holidayLetReason("Holiday reason") + .studentLetReason("Student reason") + .ministerOfReligionReason("Minister reason") + .redevelopmentReason("Redevelopment reason") + .deathOfTenantReason("Death reason") + .antisocialBehaviourReason("ASB reason") + .noRightToRentReason("No right reason") + .suitableAltAccommodationReason("Alternative reason") + .breachOfTenancyConditionsReason("Breach reason") + .propertyDeteriorationReason("Property reason") + .nuisanceAnnoyanceReason("Nuisance reason") + .domesticViolenceReason("Domestic reason") + .offenceDuringRiotReason("Riot reason") + .furnitureDeteriorationReason("Furniture reason") + .employeeOfLandlordReason("Employee reason") + .tenancyByFalseStatementReason("False statement reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); + assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); + assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); + assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); + assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); + assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); + assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); + assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), + "Alternative reason"); + assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Property reason"); + assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); + assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), + "Domestic reason"); + assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), + "Furniture reason"); + assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), + "Employee reason"); + assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), + "False statement reason"); + assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); } @Test @@ -395,6 +505,10 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 )) .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .holidayLetReason("Holiday reason") + .propertyDeteriorationReason("Deterioration reason") + .build()) .build(); // When @@ -409,6 +523,9 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() ); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Deterioration reason"); } @Test @@ -423,20 +540,29 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL )) .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY + .PREMIUM_PAID_MUTUAL_EXCHANGE )) .secureAntisocialAdditionalGrounds(Set.of( SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 )) .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS )) .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES )) .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("Antisocial reason") + .riotOffenceGround("Riot reason") + .premiumMutualExchangeGround("Premium reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .landlordWorksGround("Landlord works reason") + .housingAssocSpecialGround("Housing association reason") + .build()) .build(); // When @@ -449,11 +575,169 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { .map(ClaimGroundSummary::getLabel) .containsExactlyInAnyOrder( SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel() + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + .getLabel() ); + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Landlord works reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing association reason"); + } + + @Test + void shouldMapAllSecureAndFlexibleDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY, + SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, + SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds + .TENANCY_OBTAINED_BY_FALSE_STATEMENT, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE, + SecureOrFlexibleDiscretionaryGrounds + .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm + .CHARITABLE_LANDLORD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .SPECIAL_NEEDS_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .UNDER_OCCUPYING_AFTER_SUCCESSION + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("ASB reason") + .breachOfTenancyGround("Breach reason") + .nuisanceOrImmoralUseGround("Nuisance reason") + .domesticViolenceGround("Domestic reason") + .riotOffenceGround("Riot reason") + .propertyDeteriorationGround("Property reason") + .furnitureDeteriorationGround("Furniture reason") + .tenancyByFalseStatementGround("False statement reason") + .premiumMutualExchangeGround("Premium reason") + .unreasonableConductGround("Unreasonable reason") + .refusalToMoveBackGround("Refusal reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .antiSocialCondition2OfS84AGround("Condition 2 reason") + .antiSocialCondition3OfS84AGround("Condition 3 reason") + .antiSocialCondition4OfS84AGround("Condition 4 reason") + .antiSocialCondition5OfS84AGround("Condition 5 reason") + .overcrowdingGround("Overcrowding reason") + .landlordWorksGround("Works reason") + .propertySoldGround("Sold reason") + .charitableLandlordGround("Charitable reason") + .tiedAccommodationGround("Tied reason") + .adaptedAccommodationGround("Adapted reason") + .housingAssocSpecialGround("Housing reason") + .specialNeedsAccommodationGround("Special needs reason") + .underOccupancySuccessionGround("Under occupation reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), + "Nuisance reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), + "Domestic reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), + "Property reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), + "Furniture reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), + "False statement reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION + .getLabel(), "Unreasonable reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), + "Refusal reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), + "Condition 2 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), + "Condition 3 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), + "Condition 4 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), + "Condition 5 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), + "Overcrowding reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Works reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + "Sold reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), + "Charitable reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), + "Tied reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), + "Adapted reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), + "Special needs reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), + "Under occupation reason"); } @Test @@ -466,9 +750,15 @@ void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { .introductoryDemotedOrOtherGroundsForPossession( IntroductoryDemotedOtherGroundsForPossession.builder() .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS + )) .build() ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .antiSocialBehaviourGround("Intro antisocial reason") + .build()) .build(); // When @@ -479,7 +769,13 @@ void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { assertThat(summaries) .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) - .containsExactly(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel()); + .containsExactlyInAnyOrder( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() + ); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + "Intro antisocial reason"); + assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); } @Test @@ -494,6 +790,9 @@ void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) .build() ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .noGrounds("No grounds reason") + .build()) .build(); // When @@ -505,6 +804,43 @@ void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); + } + + @Test + void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, + IntroductoryDemotedOrOtherGrounds.OTHER + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .breachOfTheTenancyGround("Breach reason") + .absoluteGrounds("Absolute reason") + .otherGround("Other reason") + .build()) + .build(); + + // When + List> summaries = + underTest.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + "Absolute reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); } @Test @@ -657,5 +993,24 @@ private static Stream claimGroundScenarios() { ); } + private static void assertReason(List> summaries, + String label, + String reason) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isEqualTo(reason); + } + + private static void assertNoReason(List> summaries, String label) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isNull(); + } } From d3c4196becef1d2e975c08c7ffd173bf6ba464dc Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 13 May 2026 17:06:12 +0100 Subject: [PATCH 041/138] HDPI-2978: Build Case Summary tab --- .../GroundsForPossessionTabDetails.java | 5 +- .../pcs/ccd/view/CaseSummaryTabView.java | 48 ++++++++++++++++++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 36 +++++++++++++- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java index 0fb214c9e7..76e8fd108a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java @@ -6,6 +6,8 @@ import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import static uk.gov.hmcts.ccd.sdk.type.FieldType.TextArea; + @Builder @Data @NoArgsConstructor @@ -13,7 +15,8 @@ public class GroundsForPossessionTabDetails { @CCD( - label = "Grounds" + label = "Grounds", + typeOverride = TextArea ) private String grounds; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index ced75a04ad..5b8f5df194 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -32,6 +32,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -49,6 +50,9 @@ public class CaseSummaryTabView { Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); private static final Pattern SECTION_REFERENCE_PATTERN = Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_84A_CONDITION_PATTERN = + Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); + private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -460,10 +464,50 @@ private String getGrounds(PCSCase pcsCase) { return null; } - return pcsCase.getClaimGroundSummaries().stream() + List grounds = new ArrayList<>(pcsCase.getClaimGroundSummaries().stream() .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) - .reduce((firstGround, secondGround) -> firstGround + ", " + secondGround) + .toList()); + + groupSection84AConditions(grounds); + + return grounds.stream() + .reduce((firstGround, secondGround) -> firstGround + "\n" + secondGround) .orElse(null); } + + private void groupSection84AConditions(List grounds) { + int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); + if (antisocialIndex < 0) { + return; + } + + List section84AConditions = grounds.stream() + .filter(this::isSection84ACondition) + .sorted(this::compareSection84AConditions) + .toList(); + + if (section84AConditions.isEmpty()) { + return; + } + + grounds.set(antisocialIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); + grounds.removeAll(section84AConditions); + } + + private boolean isSection84ACondition(String label) { + return SECTION_84A_CONDITION_PATTERN.matcher(label).matches(); + } + + private int compareSection84AConditions(String firstCondition, String secondCondition) { + return Integer.compare( + getSection84AConditionNumber(firstCondition), + getSection84AConditionNumber(secondCondition) + ); + } + + private int getSection84AConditionNumber(String label) { + Matcher matcher = SECTION_84A_CONDITION_PATTERN.matcher(label); + return matcher.matches() ? Integer.parseInt(matcher.group(1)) : 0; + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 494a471028..39518926ac 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -111,7 +111,7 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) - .isEqualTo("Rent arrears (ground 10), Condition 1 of Section 84A of the Housing Act 1985"); + .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) @@ -307,6 +307,40 @@ void shouldSetEachGroundReasonInSummaryTab() { assertThat(reasons.getGround14()).isEqualTo("Housing reason"); } + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Nuisance reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", + "Antisocial behaviour: " + String.join(", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985", + "Condition 3 of Section 84A of the Housing Act 1985", + "Condition 4 of Section 84A of the Housing Act 1985", + "Condition 5 of Section 84A of the Housing Act 1985" + ), + "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Landlord’s works (ground 10)" + )); + } + @Test void shouldSetEachGroundNumberReasonInSummaryTab() { // Given From ea108603889dbd67167b4660fa5c3eac5c7345b9 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 10:42:24 +0100 Subject: [PATCH 042/138] HDPI-2978: Build Case Summary tab --- ...096__add_claim_submitted_date.sql => V096__add_created_at.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V096__add_claim_submitted_date.sql => V096__add_created_at.sql} (100%) diff --git a/src/main/resources/db/migration/V096__add_claim_submitted_date.sql b/src/main/resources/db/migration/V096__add_created_at.sql similarity index 100% rename from src/main/resources/db/migration/V096__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V096__add_created_at.sql From 71040f0f1e2958fe29a967fd7a0369da8516cbf9 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 14:05:36 +0100 Subject: [PATCH 043/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 15 ++++------- .../tabs/summary/TenancyTabDetails.java | 3 +-- .../pcs/ccd/service/PcsCaseService.java | 25 ++++++++++++++--- .../db/migration/V096__add_created_at.sql | 2 +- .../pcs/ccd/service/PcsCaseServiceTest.java | 27 ++++++++++++++++++- 5 files changed, 55 insertions(+), 17 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 6895d7927d..2028b742e6 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 @@ -129,10 +129,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") .field("summaryTab_ClaimSubmittedDate") - .field("summaryTab_ReasonsForPossession", - "summaryTab_ReasonsForPossession!=\"\"") - .field("summaryTab_PossessionReasonsSubmittedDate", - "summaryTab_ReasonsForPossession!=\"\"") + .field("summaryTab_ReasonsForPossession", null) + .field("summaryTab_PossessionReasonsSubmittedDate", null) .field("summaryTab_ClaimSubmittedDate") .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", @@ -141,10 +139,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Defendant details", "summaryTab_DefendantDetails!=\"\"", "## Defendant details") - .field("summaryTab_DefendantDetails", - "summaryTab_DefendantDetails!=\"\"") - .field("summaryTab_AdditionalDefendants", - "summaryTab_AdditionalDefendants!=\"\"") + .field("summaryTab_DefendantDetails", null) + .field("summaryTab_AdditionalDefendants", null) .label("Rent arrears", "summaryTab_RentArrearsDetails!=\"\"", "## Rent arrears") @@ -156,7 +152,6 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Notice", "summaryTab_NoticeDetails!=\"\"", "## Notice") - .field("summaryTab_NoticeDetails", - "summaryTab_NoticeDetails!=\"\""); + .field("summaryTab_NoticeDetails", null); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java index f140e76b89..76ffe57915 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -18,8 +18,7 @@ public class TenancyTabDetails { private String agreementType; @CCD( - label = "Tenancy, occupation contract or licence agreement start date", - showCondition = "agreementStartDate!=\"\"" + label = "Tenancy, occupation contract or licence agreement start date" ) private String agreementStartDate; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index 4494f5852c..e904cd995a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -1,7 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.service; -import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; @@ -15,13 +15,13 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.Clock; import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @Service @Slf4j -@AllArgsConstructor public class PcsCaseService { private final PcsCaseRepository pcsCaseRepository; @@ -31,6 +31,25 @@ public class PcsCaseService { private final TenancyLicenceService tenancyLicenceService; private final AddressMapper addressMapper; private final CaseLinkService caseLinkService; + private final Clock ukClock; + + public PcsCaseService(PcsCaseRepository pcsCaseRepository, + ClaimService claimService, + PartyService partyService, + DocumentService documentService, + TenancyLicenceService tenancyLicenceService, + AddressMapper addressMapper, + CaseLinkService caseLinkService, + @Qualifier("ukClock") Clock ukClock) { + this.pcsCaseRepository = pcsCaseRepository; + this.claimService = claimService; + this.partyService = partyService; + this.documentService = documentService; + this.tenancyLicenceService = tenancyLicenceService; + this.addressMapper = addressMapper; + this.caseLinkService = caseLinkService; + this.ukClock = ukClock; + } public PcsCaseEntity createCase(long caseReference, AddressUK propertyAddress, @@ -49,7 +68,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); - pcsCaseEntity.setCreatedAt(LocalDateTime.now()); + pcsCaseEntity.setCreatedAt(LocalDateTime.now(ukClock)); ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); List documentEntities = documentService.createAllDocuments(pcsCase); diff --git a/src/main/resources/db/migration/V096__add_created_at.sql b/src/main/resources/db/migration/V096__add_created_at.sql index d6c27708e8..5fce3fed69 100644 --- a/src/main/resources/db/migration/V096__add_created_at.sql +++ b/src/main/resources/db/migration/V096__add_created_at.sql @@ -1 +1 @@ -ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP; +ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP WITH TIME ZONE; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index d98e030a00..533b245df0 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -27,6 +27,9 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.Clock; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -43,6 +46,12 @@ class PcsCaseServiceTest { private static final long CASE_REFERENCE = 1234L; + private static final ZoneId UK_ZONE_ID = ZoneId.of("Europe/London"); + private static final LocalDateTime FIXED_DATE_TIME = LocalDateTime.of(2026, 5, 14, 10, 30); + private static final Clock FIXED_UK_CLOCK = Clock.fixed( + FIXED_DATE_TIME.atZone(UK_ZONE_ID).toInstant(), + UK_ZONE_ID + ); @Mock private PcsCaseRepository pcsCaseRepository; @@ -74,7 +83,8 @@ void setUp() { documentService, tenancyLicenceService, addressMapper, - caseLinkService + caseLinkService, + FIXED_UK_CLOCK ); } @@ -141,6 +151,21 @@ void shouldDelegateToClaimServiceToCreateMainClaim() { verify(pcsCaseEntity).addClaim(mainClaimEntity); } + @Test + void shouldSetCreatedAtUsingUkClockWhenCreatingMainClaim() { + // Given + PcsCaseEntity pcsCaseEntity = stubFindCase(); + stubClaimCreation(); + + PCSCase caseData = PCSCase.builder().build(); + + // When + underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); + + // Then + verify(pcsCaseEntity).setCreatedAt(FIXED_DATE_TIME); + } + @Test void shouldCreatePartiesWithMainClaimOnCase() { // Given From 8209c518836f60e5db42bd714bfb15daf4ff7a49 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 14:46:15 +0100 Subject: [PATCH 044/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 4 +--- .../reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 7 +------ .../gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java | 3 +-- .../hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java | 5 ++--- 4 files changed, 5 insertions(+), 14 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 2028b742e6..352a1719e1 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 @@ -128,10 +128,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Summary", null, "## Summary") .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") - .field("summaryTab_ClaimSubmittedDate") .field("summaryTab_ReasonsForPossession", null) - .field("summaryTab_PossessionReasonsSubmittedDate", null) - .field("summaryTab_ClaimSubmittedDate") + .field("summaryTab_DateClaimSubmitted", null) .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", "## Claimant details") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 6c703fdb62..603649680e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -33,11 +33,6 @@ public class SummaryTab { ) private GroundsForPossessionTabDetails groundsForPossession; - @CCD( - label = "Date claim Submitted" - ) - private String claimSubmittedDate; - @CCD( label = "Reasons for possession" ) @@ -46,7 +41,7 @@ public class SummaryTab { @CCD( label = "Date claim Submitted" ) - private String possessionReasonsSubmittedDate; + private String dateClaimSubmitted; @CCD( label = "Claimant" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 5b8f5df194..6a38668b09 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -63,9 +63,8 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { .groundsForPossession(GroundsForPossessionTabDetails.builder() .grounds(getGrounds(pcsCase)) .build()) - .claimSubmittedDate(dateSubmitted) .reasonsForPossession(reasonsForPossession) - .possessionReasonsSubmittedDate(reasonsForPossession == null ? null : dateSubmitted) + .dateClaimSubmitted(dateSubmitted) .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 39518926ac..7160aedf96 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -112,13 +112,12 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); - assertThat(summaryTab.getClaimSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); @@ -201,7 +200,7 @@ void shouldNotSetEmptySummarySections() { // Then assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); assertThat(summaryTab.getReasonsForPossession()).isNull(); - assertThat(summaryTab.getPossessionReasonsSubmittedDate()).isNull(); + assertThat(summaryTab.getDateClaimSubmitted()).isNull(); assertThat(summaryTab.getClaimantDetails()).isNull(); assertThat(summaryTab.getDefendantDetails()).isNull(); assertThat(summaryTab.getAdditionalDefendants()).isNull(); From 9e9ac6a1ca2e845fcdc2db0c35a2422cb0303804 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 15:50:20 +0100 Subject: [PATCH 045/138] HDPI-2978: Build Case Summary tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 10 +- .../reform/pcs/ccd/view/CaseTabView.java | 4 +- .../ccd/view/ClaimGroundSummaryBuilder.java | 303 ++++++++ .../reform/pcs/ccd/view/CaseTabViewTest.java | 8 +- .../view/ClaimGroundSummaryBuilderTest.java | 716 ++++++++++++++++++ .../pcs/ccd/view/ClaimGroundsViewTest.java | 675 ----------------- 6 files changed, 1030 insertions(+), 686 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.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 352a1719e1..67e53526ba 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 @@ -128,8 +128,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Summary", null, "## Summary") .field("summaryTab_RepossessedPropertyAddress") .field("summaryTab_GroundsForPossession") - .field("summaryTab_ReasonsForPossession", null) - .field("summaryTab_DateClaimSubmitted", null) + .field("summaryTab_ReasonsForPossession") + .field("summaryTab_DateClaimSubmitted") .label("Claimant details", "summaryTab_ClaimantDetails!=\"\"", "## Claimant details") @@ -137,8 +137,8 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Defendant details", "summaryTab_DefendantDetails!=\"\"", "## Defendant details") - .field("summaryTab_DefendantDetails", null) - .field("summaryTab_AdditionalDefendants", null) + .field("summaryTab_DefendantDetails") + .field("summaryTab_AdditionalDefendants") .label("Rent arrears", "summaryTab_RentArrearsDetails!=\"\"", "## Rent arrears") @@ -150,6 +150,6 @@ private void buildSummaryTab(ConfigBuilder builder) { .label("Notice", "summaryTab_NoticeDetails!=\"\"", "## Notice") - .field("summaryTab_NoticeDetails", null); + .field("summaryTab_NoticeDetails"); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index d5b9d51cfe..24ea626b44 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -24,7 +24,7 @@ public class CaseTabView { static final String NAME_UNKNOWN = "Person unknown"; - private final ClaimGroundsView claimGroundsView; + private final ClaimGroundSummaryBuilder claimGroundSummaryBuilder; private final CaseSummaryTabView caseSummaryTabView; public void setCaseTabFields(PCSCase pcsCase) { @@ -49,7 +49,7 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { } List> draftGrounds = - claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData); + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) ? pcsCase.getClaimGroundSummaries() : draftGrounds); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java new file mode 100644 index 0000000000..d4c98b557b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -0,0 +1,303 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.PossessionGroundEnum; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +@Component +public class ClaimGroundSummaryBuilder { + + public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { + List> summaries = new ArrayList<>(); + + OccupationLicenceDetailsWales occupationLicenceDetailsWales = draftCaseData.getOccupationLicenceDetailsWales(); + OccupationLicenceTypeWales occupationLicenceType = occupationLicenceDetailsWales == null + ? null : occupationLicenceDetailsWales.getOccupationLicenceTypeWales(); + + if (occupationLicenceType == OccupationLicenceTypeWales.SECURE_CONTRACT) { + Optional.ofNullable(draftCaseData.getSecureContractGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } else if (occupationLicenceType == OccupationLicenceTypeWales.STANDARD_CONTRACT + || occupationLicenceType == OccupationLicenceTypeWales.OTHER) { + Optional.ofNullable(draftCaseData.getGroundsForPossessionWales()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds()); + addGrounds(summaries, selected.getDiscretionaryGrounds()); + addGrounds(summaries, selected.getEstateManagementGrounds()); + }); + + return summaries; + } + + TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); + TenancyLicenceType tenancyType = tenancyLicenceDetails == null + ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); + + if (tenancyType == TenancyLicenceType.ASSURED_TENANCY) { + if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { + addAssuredRentArrearsGrounds(summaries, draftCaseData); + } else if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.NO) { + Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { + addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); + }); + } + } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY + || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { + Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureAntisocialAdditionalGrounds(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt(), draftCaseData); + addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt(), draftCaseData); + }); + } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY + || tenancyType == TenancyLicenceType.DEMOTED_TENANCY + || tenancyType == TenancyLicenceType.OTHER) { + addIntroductoryDemotedOrOtherGrounds(summaries, draftCaseData); + } + + return summaries; + } + + private void addAssuredRentArrearsGrounds(List> summaries, + PCSCase draftCaseData) { + Optional.ofNullable(draftCaseData.getAssuredRentArrearsPossessionGrounds()).ifPresent(selected -> { + if (!CollectionUtils.isEmpty(selected.getRentArrearsGrounds())) { + addGrounds(summaries, selected.getRentArrearsGrounds().stream() + .map(this::mapAssuredRentArrearsGround) + .toList(), draftCaseData); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalMandatoryGrounds())) { + addGrounds(summaries, selected.getAdditionalMandatoryGrounds().stream() + .map(ground -> AssuredMandatoryGround.valueOf(ground.name())) + .toList(), draftCaseData); + } + if (!CollectionUtils.isEmpty(selected.getAdditionalDiscretionaryGrounds())) { + addGrounds(summaries, selected.getAdditionalDiscretionaryGrounds().stream() + .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) + .toList(), draftCaseData); + } + }); + } + + private void addIntroductoryDemotedOrOtherGrounds(List> summaries, + PCSCase draftCaseData) { + IntroductoryDemotedOtherGroundsForPossession selected = + draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); + + if (selected == null) { + return; + } + + if (selected.getHasIntroductoryDemotedOtherGroundsForPossession() == VerticalYesNo.NO) { + addGrounds(summaries, Set.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS), draftCaseData); + return; + } + + addGrounds(summaries, selected.getIntroductoryDemotedOrOtherGrounds(), draftCaseData); + } + + private void addGrounds(List> summaries, + Set grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds)); + } + } + + private void addGrounds(List> summaries, + Set grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + addGrounds(summaries, List.copyOf(grounds), draftCaseData); + } + } + + private void addGrounds(List> summaries, + List grounds) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder().label(ground.getLabel()).build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private void addGrounds(List> summaries, + List grounds, + PCSCase draftCaseData) { + if (!CollectionUtils.isEmpty(grounds)) { + grounds.stream() + .map(ground -> ClaimGroundSummary.builder() + .code(((Enum) ground).name()) + .label(ground.getLabel()) + .reason(getDraftReason(draftCaseData, ground)) + .build()) + .map(summary -> ListValue.builder().value(summary).build()) + .forEach(summaries::add); + } + } + + private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + return switch (((Enum) ground).name()) { + case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); + case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); + case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); + case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); + case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); + case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); + case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); + case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); + case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); + case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; + case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); + case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); + case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); + case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); + case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); + case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); + case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); + case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); + case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null + ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); + case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); + case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); + case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); + case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); + case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null + ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); + case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); + case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); + case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); + case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); + case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); + case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); + case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); + case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); + case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); + case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); + case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); + case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); + case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); + case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); + case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); + case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); + case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); + case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); + case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); + case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); + case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); + case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); + case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); + case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null + ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); + default -> null; + }; + } + + private String getSection84ACondition1Reason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons reasons = draftCaseData.getSecureOrFlexibleGroundsReasons(); + return reasons == null ? null : reasons.getAntiSocialCondition1OfS84AGround(); + } + + private String getAntiSocialReason(PCSCase draftCaseData) { + SecureOrFlexibleGroundsReasons secureOrFlexibleReasons = getSecureOrFlexibleReason(draftCaseData); + if (secureOrFlexibleReasons != null) { + return secureOrFlexibleReasons.getAntiSocialGround(); + } + + IntroductoryDemotedOtherGroundReason introductoryDemotedOtherReason = + getIntroductoryDemotedOtherGroundReason(draftCaseData); + return introductoryDemotedOtherReason == null + ? null : introductoryDemotedOtherReason.getAntiSocialBehaviourGround(); + } + + private SecureOrFlexibleGroundsReasons getSecureOrFlexibleReason(PCSCase draftCaseData) { + return draftCaseData.getSecureOrFlexibleGroundsReasons(); + } + + private RentArrearsGroundsReasons getRentArrearsGroundsReasons(PCSCase draftCaseData) { + return draftCaseData.getRentArrearsGroundsReasons(); + } + + private IntroductoryDemotedOtherGroundReason getIntroductoryDemotedOtherGroundReason(PCSCase draftCaseData) { + return draftCaseData.getIntroductoryDemotedOtherGroundReason(); + } + + private PossessionGroundEnum mapAssuredRentArrearsGround(AssuredRentArrearsGround ground) { + if (ground == AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8) { + return AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8; + } + + return AssuredDiscretionaryGround.valueOf(ground.name()); + } + +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 4f37db5c2b..c612303243 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -28,11 +28,11 @@ class CaseTabViewTest { private CaseTabView underTest; @Mock - private ClaimGroundsView claimGroundsView; + private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; @BeforeEach void setUp() { - underTest = new CaseTabView(claimGroundsView, new CaseSummaryTabView()); + underTest = new CaseTabView(claimGroundSummaryBuilder, new CaseSummaryTabView()); } @Test @@ -291,7 +291,7 @@ void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { .build(); PCSCase draftCaseData = PCSCase.builder().build(); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); @@ -345,7 +345,7 @@ void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { listValue(ClaimGroundSummary.builder().label("Draft ground").build()) ); - when(claimGroundsView.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java new file mode 100644 index 0000000000..306a8c3d0a --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java @@ -0,0 +1,716 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; + +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +class ClaimGroundSummaryBuilderTest { + + private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; + + @BeforeEach + void setUp() { + claimGroundSummaryBuilder = new ClaimGroundSummaryBuilder(); + } + + @Test + void shouldBuildClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 + )) + .build()) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) + .build() + ) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner occupier reason") + .breachOfTenancyConditionsReason("Breach reason") + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + "Serious rent arrears (ground 8)", + "Rent arrears (ground 10)", + "Owner occupier (ground 1)", + "Breach of tenancy conditions (ground 12)" + ); + assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); + assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); + assertNoReason(summaries, "Serious rent arrears (ground 8)"); + assertNoReason(summaries, "Rent arrears (ground 10)"); + } + + @Test + void shouldMapAllAssuredDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.YES) + .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() + .rentArrearsGrounds(Set.of( + AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, + AssuredRentArrearsGround.RENT_ARREARS_GROUND10, + AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 + )) + .additionalMandatoryGrounds(Set.of( + AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, + AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, + AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, + AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, + AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, + AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, + AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, + AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, + AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B + )) + .additionalDiscretionaryGrounds(Set.of( + AssuredAdditionalDiscretionaryGrounds + .ALTERNATIVE_ACCOMMODATION_GROUND9, + AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_PROPERTY_GROUND13, + AssuredAdditionalDiscretionaryGrounds + .NUISANCE_ANNOYANCE_GROUND14, + AssuredAdditionalDiscretionaryGrounds + .DOMESTIC_VIOLENCE_GROUND14A, + AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, + AssuredAdditionalDiscretionaryGrounds + .DETERIORATION_FURNITURE_GROUND15, + AssuredAdditionalDiscretionaryGrounds + .EMPLOYEE_LANDLORD_GROUND16, + AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .ownerOccupierReason("Owner reason") + .repossessionByLenderReason("Lender reason") + .holidayLetReason("Holiday reason") + .studentLetReason("Student reason") + .ministerOfReligionReason("Minister reason") + .redevelopmentReason("Redevelopment reason") + .deathOfTenantReason("Death reason") + .antisocialBehaviourReason("ASB reason") + .noRightToRentReason("No right reason") + .suitableAltAccommodationReason("Alternative reason") + .breachOfTenancyConditionsReason("Breach reason") + .propertyDeteriorationReason("Property reason") + .nuisanceAnnoyanceReason("Nuisance reason") + .domesticViolenceReason("Domestic reason") + .offenceDuringRiotReason("Riot reason") + .furnitureDeteriorationReason("Furniture reason") + .employeeOfLandlordReason("Employee reason") + .tenancyByFalseStatementReason("False statement reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); + assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); + assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); + assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); + assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); + assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); + assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); + assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), + "Alternative reason"); + assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Property reason"); + assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); + assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), + "Domestic reason"); + assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), + "Furniture reason"); + assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), + "Employee reason"); + assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), + "False statement reason"); + assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); + assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); + + // Then + assertThat(summaries).isEmpty(); + } + + @Test + void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .build()) + .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 + )) + .discretionaryGrounds(Set.of( + SecureContractDiscretionaryGroundsWales + .ANTISOCIAL_BEHAVIOUR_S157 + )) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.RESERVE_SUCCESSORS + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), + SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), + EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() + ); + } + + @Test + void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), + DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() + ); + } + + @Test + void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .claimDueToRentArrears(YesOrNo.NO) + .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() + .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) + .discretionaryGrounds(Set.of( + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 + )) + .build()) + .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() + .holidayLetReason("Holiday reason") + .propertyDeteriorationReason("Deterioration reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() + ); + assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); + assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + "Deterioration reason"); + } + + @Test + void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("Antisocial reason") + .riotOffenceGround("Riot reason") + .premiumMutualExchangeGround("Premium reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .landlordWorksGround("Landlord works reason") + .housingAssocSpecialGround("Housing association reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), + SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES + .getLabel() + ); + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Landlord works reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing association reason"); + } + + @Test + void shouldMapAllSecureAndFlexibleDraftGroundReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) + .build()) + .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() + .secureOrFlexibleMandatoryGrounds(Set.of( + SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL + )) + .secureOrFlexibleDiscretionaryGrounds(Set.of( + SecureOrFlexibleDiscretionaryGrounds + .RENT_ARREARS_OR_BREACH_OF_TENANCY, + SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, + SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, + SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, + SecureOrFlexibleDiscretionaryGrounds + .TENANCY_OBTAINED_BY_FALSE_STATEMENT, + SecureOrFlexibleDiscretionaryGrounds + .PREMIUM_PAID_MUTUAL_EXCHANGE, + SecureOrFlexibleDiscretionaryGrounds + .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK + )) + .secureAntisocialAdditionalGrounds(Set.of( + SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, + SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 + )) + .secureOrFlexibleMandatoryGroundsAlt(Set.of( + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, + SecureOrFlexibleMandatoryGroundsAlternativeAccomm + .CHARITABLE_LANDLORD + )) + .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .ADAPTED_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .SPECIAL_NEEDS_ACCOMMODATION, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .UNDER_OCCUPYING_AFTER_SUCCESSION + )) + .build()) + .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() + .antiSocialGround("ASB reason") + .breachOfTenancyGround("Breach reason") + .nuisanceOrImmoralUseGround("Nuisance reason") + .domesticViolenceGround("Domestic reason") + .riotOffenceGround("Riot reason") + .propertyDeteriorationGround("Property reason") + .furnitureDeteriorationGround("Furniture reason") + .tenancyByFalseStatementGround("False statement reason") + .premiumMutualExchangeGround("Premium reason") + .unreasonableConductGround("Unreasonable reason") + .refusalToMoveBackGround("Refusal reason") + .antiSocialCondition1OfS84AGround("Condition 1 reason") + .antiSocialCondition2OfS84AGround("Condition 2 reason") + .antiSocialCondition3OfS84AGround("Condition 3 reason") + .antiSocialCondition4OfS84AGround("Condition 4 reason") + .antiSocialCondition5OfS84AGround("Condition 5 reason") + .overcrowdingGround("Overcrowding reason") + .landlordWorksGround("Works reason") + .propertySoldGround("Sold reason") + .charitableLandlordGround("Charitable reason") + .tiedAccommodationGround("Tied reason") + .adaptedAccommodationGround("Adapted reason") + .housingAssocSpecialGround("Housing reason") + .specialNeedsAccommodationGround("Special needs reason") + .underOccupancySuccessionGround("Under occupation reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), + "Nuisance reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), + "Domestic reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), + "Property reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), + "Furniture reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), + "False statement reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), + "Premium reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION + .getLabel(), "Unreasonable reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), + "Refusal reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), + "Condition 1 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), + "Condition 2 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), + "Condition 3 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), + "Condition 4 reason"); + assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), + "Condition 5 reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), + "Overcrowding reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), + "Works reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), + "Sold reason"); + assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), + "Charitable reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), + "Tied reason"); + assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), + "Adapted reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), + "Housing reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), + "Special needs reason"); + assertReason(summaries, + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), + "Under occupation reason"); + } + + @Test + void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .antiSocialBehaviourGround("Intro antisocial reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() + ); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + "Intro antisocial reason"); + assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); + } + + @Test + void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .noGrounds("No grounds reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); + assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); + } + + @Test + void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .introductoryDemotedOrOtherGroundsForPossession( + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, + IntroductoryDemotedOrOtherGrounds.OTHER + )) + .build() + ) + .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() + .breachOfTheTenancyGround("Breach reason") + .absoluteGrounds("Absolute reason") + .otherGround("Other reason") + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + "Breach reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + "Absolute reason"); + assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); + } + + @Test + void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries).isEmpty(); + } + + private static void assertReason(List> summaries, + String label, + String reason) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isEqualTo(reason); + } + + private static void assertNoReason(List> summaries, String label) { + assertThat(summaries) + .map(ListValue::getValue) + .filteredOn(summary -> label.equals(summary.getLabel())) + .singleElement() + .extracting(ClaimGroundSummary::getReason) + .isNull(); + } + + +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java index e0e4f827f6..9fdbc5104f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundsViewTest.java @@ -12,37 +12,20 @@ import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.DiscretionaryGroundWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.GroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.MandatoryGroundWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; -import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; @@ -221,645 +204,6 @@ void shouldOrderGroundsByCategoryRankThenGroundRank() { ); } - @Test - void shouldBuildClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.YES) - .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() - .rentArrearsGrounds(Set.of( - AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, - AssuredRentArrearsGround.RENT_ARREARS_GROUND10 - )) - .additionalMandatoryGrounds(Set.of( - AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1 - )) - .additionalDiscretionaryGrounds(Set.of( - AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12 - )) - .build()) - .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() - .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) - .discretionaryGrounds(Set.of( - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 - )) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .introductoryDemotedOrOtherGrounds(Set.of(IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL)) - .build() - ) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .ownerOccupierReason("Owner occupier reason") - .breachOfTenancyConditionsReason("Breach reason") - .build()) - .groundsForPossessionWales(GroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) - .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES - )) - .build()) - .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 - )) - .discretionaryGrounds(Set.of( - SecureContractDiscretionaryGroundsWales - .ANTISOCIAL_BEHAVIOUR_S157 - )) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.RESERVE_SUCCESSORS - )) - .build()) - .build(); - - // When - List> summaries = underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - "Serious rent arrears (ground 8)", - "Rent arrears (ground 10)", - "Owner occupier (ground 1)", - "Breach of tenancy conditions (ground 12)" - ); - assertReason(summaries, "Owner occupier (ground 1)", "Owner occupier reason"); - assertReason(summaries, "Breach of tenancy conditions (ground 12)", "Breach reason"); - assertNoReason(summaries, "Serious rent arrears (ground 8)"); - assertNoReason(summaries, "Rent arrears (ground 10)"); - } - - @Test - void shouldMapAllAssuredDraftGroundReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.YES) - .assuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds.builder() - .rentArrearsGrounds(Set.of( - AssuredRentArrearsGround.SERIOUS_RENT_ARREARS_GROUND8, - AssuredRentArrearsGround.RENT_ARREARS_GROUND10, - AssuredRentArrearsGround.PERSISTENT_DELAY_GROUND11 - )) - .additionalMandatoryGrounds(Set.of( - AssuredAdditionalMandatoryGrounds.OWNER_OCCUPIER_GROUND1, - AssuredAdditionalMandatoryGrounds.REPOSSESSION_GROUND2, - AssuredAdditionalMandatoryGrounds.HOLIDAY_LET_GROUND3, - AssuredAdditionalMandatoryGrounds.STUDENT_LET_GROUND4, - AssuredAdditionalMandatoryGrounds.MINISTER_RELIGION_GROUND5, - AssuredAdditionalMandatoryGrounds.REDEVELOPMENT_GROUND6, - AssuredAdditionalMandatoryGrounds.DEATH_OF_TENANT_GROUND7, - AssuredAdditionalMandatoryGrounds.ANTISOCIAL_BEHAVIOUR_GROUND7A, - AssuredAdditionalMandatoryGrounds.NO_RIGHT_TO_RENT_GROUND7B - )) - .additionalDiscretionaryGrounds(Set.of( - AssuredAdditionalDiscretionaryGrounds - .ALTERNATIVE_ACCOMMODATION_GROUND9, - AssuredAdditionalDiscretionaryGrounds.BREACH_TENANCY_GROUND12, - AssuredAdditionalDiscretionaryGrounds - .DETERIORATION_PROPERTY_GROUND13, - AssuredAdditionalDiscretionaryGrounds - .NUISANCE_ANNOYANCE_GROUND14, - AssuredAdditionalDiscretionaryGrounds - .DOMESTIC_VIOLENCE_GROUND14A, - AssuredAdditionalDiscretionaryGrounds.OFFENCE_RIOT_GROUND14ZA, - AssuredAdditionalDiscretionaryGrounds - .DETERIORATION_FURNITURE_GROUND15, - AssuredAdditionalDiscretionaryGrounds - .EMPLOYEE_LANDLORD_GROUND16, - AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .ownerOccupierReason("Owner reason") - .repossessionByLenderReason("Lender reason") - .holidayLetReason("Holiday reason") - .studentLetReason("Student reason") - .ministerOfReligionReason("Minister reason") - .redevelopmentReason("Redevelopment reason") - .deathOfTenantReason("Death reason") - .antisocialBehaviourReason("ASB reason") - .noRightToRentReason("No right reason") - .suitableAltAccommodationReason("Alternative reason") - .breachOfTenancyConditionsReason("Breach reason") - .propertyDeteriorationReason("Property reason") - .nuisanceAnnoyanceReason("Nuisance reason") - .domesticViolenceReason("Domestic reason") - .offenceDuringRiotReason("Riot reason") - .furnitureDeteriorationReason("Furniture reason") - .employeeOfLandlordReason("Employee reason") - .tenancyByFalseStatementReason("False statement reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1.getLabel(), "Owner reason"); - assertReason(summaries, AssuredMandatoryGround.REPOSSESSION_GROUND2.getLabel(), "Lender reason"); - assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); - assertReason(summaries, AssuredMandatoryGround.STUDENT_LET_GROUND4.getLabel(), "Student reason"); - assertReason(summaries, AssuredMandatoryGround.MINISTER_RELIGION_GROUND5.getLabel(), "Minister reason"); - assertReason(summaries, AssuredMandatoryGround.REDEVELOPMENT_GROUND6.getLabel(), "Redevelopment reason"); - assertReason(summaries, AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7.getLabel(), "Death reason"); - assertReason(summaries, AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A.getLabel(), "ASB reason"); - assertReason(summaries, AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B.getLabel(), "No right reason"); - assertReason(summaries, AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9.getLabel(), - "Alternative reason"); - assertReason(summaries, AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12.getLabel(), "Breach reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), - "Property reason"); - assertReason(summaries, AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14.getLabel(), "Nuisance reason"); - assertReason(summaries, AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A.getLabel(), - "Domestic reason"); - assertReason(summaries, AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA.getLabel(), "Riot reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15.getLabel(), - "Furniture reason"); - assertReason(summaries, AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16.getLabel(), - "Employee reason"); - assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), - "False statement reason"); - assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); - assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); - assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); - } - - @Test - void shouldReturnEmptyClaimGroundSummariesFromEmptyDraft() { - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(PCSCase.builder().build()); - - // Then - assertThat(summaries).isEmpty(); - } - - @Test - void shouldBuildSecureContractWalesClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) - .build()) - .secureContractGroundsForPossessionWales(SecureContractGroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186 - )) - .discretionaryGrounds(Set.of( - SecureContractDiscretionaryGroundsWales - .ANTISOCIAL_BEHAVIOUR_S157 - )) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.RESERVE_SUCCESSORS - )) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - SecureContractMandatoryGroundsWales.LANDLORD_NOTICE_S186.getLabel(), - SecureContractDiscretionaryGroundsWales.ANTISOCIAL_BEHAVIOUR_S157.getLabel(), - EstateManagementGroundsWales.RESERVE_SUCCESSORS.getLabel() - ); - } - - @Test - void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.STANDARD_CONTRACT) - .build()) - .groundsForPossessionWales(GroundsForPossessionWales.builder() - .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) - .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) - .estateManagementGrounds(Set.of( - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES - )) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), - DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), - EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() - ); - } - - @Test - void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) - .build()) - .claimDueToRentArrears(YesOrNo.NO) - .noRentArrearsGroundsOptions(AssuredNoArrearsPossessionGrounds.builder() - .mandatoryGrounds(Set.of(AssuredMandatoryGround.HOLIDAY_LET_GROUND3)) - .discretionaryGrounds(Set.of( - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 - )) - .build()) - .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() - .holidayLetReason("Holiday reason") - .propertyDeteriorationReason("Deterioration reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() - ); - assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); - assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), - "Deterioration reason"); - } - - @Test - void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.SECURE_TENANCY) - .build()) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, - SecureOrFlexibleDiscretionaryGrounds - .PREMIUM_PAID_MUTUAL_EXCHANGE - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES - )) - .build()) - .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("Antisocial reason") - .riotOffenceGround("Riot reason") - .premiumMutualExchangeGround("Premium reason") - .antiSocialCondition1OfS84AGround("Condition 1 reason") - .landlordWorksGround("Landlord works reason") - .housingAssocSpecialGround("Housing association reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), - SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES - .getLabel() - ); - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - "Premium reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - "Condition 1 reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - "Landlord works reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), - "Housing association reason"); - } - - @Test - void shouldMapAllSecureAndFlexibleDraftGroundReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.FLEXIBLE_TENANCY) - .build()) - .secureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds.builder() - .secureOrFlexibleMandatoryGrounds(Set.of( - SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL - )) - .secureOrFlexibleDiscretionaryGrounds(Set.of( - SecureOrFlexibleDiscretionaryGrounds - .RENT_ARREARS_OR_BREACH_OF_TENANCY, - SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, - SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, - SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, - SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, - SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, - SecureOrFlexibleDiscretionaryGrounds - .TENANCY_OBTAINED_BY_FALSE_STATEMENT, - SecureOrFlexibleDiscretionaryGrounds - .PREMIUM_PAID_MUTUAL_EXCHANGE, - SecureOrFlexibleDiscretionaryGrounds - .UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK - )) - .secureAntisocialAdditionalGrounds(Set.of( - SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, - SecureAntisocialAdditionalGrounds.S84A_CONDITION_5 - )) - .secureOrFlexibleMandatoryGroundsAlt(Set.of( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, - SecureOrFlexibleMandatoryGroundsAlternativeAccomm - .CHARITABLE_LANDLORD - )) - .secureOrFlexibleDiscretionaryGroundsAlt(Set.of( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .ADAPTED_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .SPECIAL_NEEDS_ACCOMMODATION, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .UNDER_OCCUPYING_AFTER_SUCCESSION - )) - .build()) - .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("ASB reason") - .breachOfTenancyGround("Breach reason") - .nuisanceOrImmoralUseGround("Nuisance reason") - .domesticViolenceGround("Domestic reason") - .riotOffenceGround("Riot reason") - .propertyDeteriorationGround("Property reason") - .furnitureDeteriorationGround("Furniture reason") - .tenancyByFalseStatementGround("False statement reason") - .premiumMutualExchangeGround("Premium reason") - .unreasonableConductGround("Unreasonable reason") - .refusalToMoveBackGround("Refusal reason") - .antiSocialCondition1OfS84AGround("Condition 1 reason") - .antiSocialCondition2OfS84AGround("Condition 2 reason") - .antiSocialCondition3OfS84AGround("Condition 3 reason") - .antiSocialCondition4OfS84AGround("Condition 4 reason") - .antiSocialCondition5OfS84AGround("Condition 5 reason") - .overcrowdingGround("Overcrowding reason") - .landlordWorksGround("Works reason") - .propertySoldGround("Sold reason") - .charitableLandlordGround("Charitable reason") - .tiedAccommodationGround("Tied reason") - .adaptedAccommodationGround("Adapted reason") - .housingAssocSpecialGround("Housing reason") - .specialNeedsAccommodationGround("Special needs reason") - .underOccupancySuccessionGround("Under occupation reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), - "Breach reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), - "Nuisance reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE.getLabel(), - "Domestic reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION.getLabel(), - "Property reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION.getLabel(), - "Furniture reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT.getLabel(), - "False statement reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), - "Premium reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION - .getLabel(), "Unreasonable reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK.getLabel(), - "Refusal reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_1.getLabel(), - "Condition 1 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_2.getLabel(), - "Condition 2 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_3.getLabel(), - "Condition 3 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_4.getLabel(), - "Condition 4 reason"); - assertReason(summaries, SecureAntisocialAdditionalGrounds.S84A_CONDITION_5.getLabel(), - "Condition 5 reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING.getLabel(), - "Overcrowding reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS.getLabel(), - "Works reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD.getLabel(), - "Sold reason"); - assertReason(summaries, SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD.getLabel(), - "Charitable reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE.getLabel(), - "Tied reason"); - assertReason(summaries, SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION.getLabel(), - "Adapted reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES.getLabel(), - "Housing reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION.getLabel(), - "Special needs reason"); - assertReason(summaries, - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION.getLabel(), - "Under occupation reason"); - } - - @Test - void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS - )) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .antiSocialBehaviourGround("Intro antisocial reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() - ); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - "Intro antisocial reason"); - assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); - } - - @Test - void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .noGrounds("No grounds reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); - assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); - } - - @Test - void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of( - IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY, - IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, - IntroductoryDemotedOrOtherGrounds.OTHER - )) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .breachOfTheTenancyGround("Breach reason") - .absoluteGrounds("Absolute reason") - .otherGround("Other reason") - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), - "Breach reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), - "Absolute reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); - } - - @Test - void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .build(); - - // When - List> summaries = - underTest.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries).isEmpty(); - } - private static Stream claimGroundScenarios() { return Stream.of( argumentSet( @@ -993,24 +337,5 @@ private static Stream claimGroundScenarios() { ); } - private static void assertReason(List> summaries, - String label, - String reason) { - assertThat(summaries) - .map(ListValue::getValue) - .filteredOn(summary -> label.equals(summary.getLabel())) - .singleElement() - .extracting(ClaimGroundSummary::getReason) - .isEqualTo(reason); - } - - private static void assertNoReason(List> summaries, String label) { - assertThat(summaries) - .map(ListValue::getValue) - .filteredOn(summary -> label.equals(summary.getLabel())) - .singleElement() - .extracting(ClaimGroundSummary::getReason) - .isNull(); - } } From c4d4ce34a07e4b8aaea90ecb77a90678302bb0dd Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 14 May 2026 17:09:06 +0100 Subject: [PATCH 046/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 3 +- .../pcs/ccd/view/CaseSummaryTabView.java | 137 +++++++++++------- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 2 + .../pcs/ccd/view/CaseSummaryTabViewTest.java | 90 +++++++++++- 4 files changed, 180 insertions(+), 52 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 b7c6df7352..5d5ae1d819 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 @@ -87,6 +87,8 @@ public PCSCase getCase(CaseViewRequest request) { draftCaseDataService .getUnsubmittedCaseData(caseReference, resumePossessionClaim) .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + } else { + caseTabView.setCaseTabFields(pcsCase); } setMarkdownFields(pcsCase, hasUnsubmittedCaseData); @@ -133,7 +135,6 @@ private PCSCase getSubmittedCase(long caseReference) { noticeOfPossessionView.setCaseFields(pcsCase, pcsCaseEntity); statementOfTruthView.setCaseFields(pcsCase, pcsCaseEntity); caseLinkView.setCaseFields(pcsCase, pcsCaseEntity); - caseTabView.setCaseTabFields(pcsCase); return pcsCase; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 6a38668b09..91c4ecad30 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -53,6 +53,48 @@ public class CaseSummaryTabView { private static final Pattern SECTION_84A_CONDITION_PATTERN = Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final String GROUND_1 = "1"; + private static final String GROUND_2 = "2"; + private static final String GROUND_2A = "2A"; + private static final String GROUND_2ZA = "2ZA"; + private static final String GROUND_3 = "3"; + private static final String GROUND_4 = "4"; + private static final String GROUND_5 = "5"; + private static final String GROUND_6 = "6"; + private static final String GROUND_7 = "7"; + private static final String GROUND_7A = "7A"; + private static final String GROUND_7B = "7B"; + private static final String GROUND_8 = "8"; + private static final String GROUND_9 = "9"; + private static final String GROUND_10 = "10"; + private static final String GROUND_10A = "10A"; + private static final String GROUND_11 = "11"; + private static final String GROUND_12 = "12"; + private static final String GROUND_13 = "13"; + private static final String GROUND_14 = "14"; + private static final String GROUND_14A = "14A"; + private static final String GROUND_14ZA = "14ZA"; + private static final String GROUND_15 = "15"; + private static final String GROUND_15A = "15A"; + private static final String GROUND_16 = "16"; + private static final String GROUND_17 = "17"; + private static final String GROUND_A = "A"; + private static final String GROUND_B = "B"; + private static final String GROUND_C = "C"; + private static final String GROUND_D = "D"; + private static final String GROUND_E = "E"; + private static final String GROUND_F = "F"; + private static final String GROUND_G = "G"; + private static final String GROUND_H = "H"; + private static final String GROUND_I = "I"; + private static final String SECTION_157 = "157"; + private static final String SECTION_170 = "170"; + private static final String SECTION_178 = "178"; + private static final String SECTION_181 = "181"; + private static final String SECTION_186 = "186"; + private static final String SECTION_187 = "187"; + private static final String SECTION_191 = "191"; + private static final String SECTION_199 = "199"; public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); @@ -180,7 +222,7 @@ private String getDefendantLastName(Party defendant) { private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { if (defendant.getAddressKnown() != VerticalYesNo.YES) { - return null; + return pcsCase.getPropertyAddress(); } return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); @@ -270,40 +312,40 @@ private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPoss String ground, String reason) { switch (ground) { - case "1" -> reasonsForPossession.setGround1(reason); - case "2" -> reasonsForPossession.setGround2(reason); - case "2A" -> reasonsForPossession.setGround2A(reason); - case "2ZA" -> reasonsForPossession.setGround2ZA(reason); - case "3" -> reasonsForPossession.setGround3(reason); - case "4" -> reasonsForPossession.setGround4(reason); - case "5" -> reasonsForPossession.setGround5(reason); - case "6" -> reasonsForPossession.setGround6(reason); - case "7" -> reasonsForPossession.setGround7(reason); - case "7A" -> reasonsForPossession.setGround7A(reason); - case "7B" -> reasonsForPossession.setGround7B(reason); - case "8" -> reasonsForPossession.setGround8(reason); - case "9" -> reasonsForPossession.setGround9(reason); - case "10" -> reasonsForPossession.setGround10(reason); - case "10A" -> reasonsForPossession.setGround10A(reason); - case "11" -> reasonsForPossession.setGround11(reason); - case "12" -> reasonsForPossession.setGround12(reason); - case "13" -> reasonsForPossession.setGround13(reason); - case "14" -> reasonsForPossession.setGround14(reason); - case "14A" -> reasonsForPossession.setGround14A(reason); - case "14ZA" -> reasonsForPossession.setGround14ZA(reason); - case "15" -> reasonsForPossession.setGround15(reason); - case "15A" -> reasonsForPossession.setGround15A(reason); - case "16" -> reasonsForPossession.setGround16(reason); - case "17" -> reasonsForPossession.setGround17(reason); - case "A" -> reasonsForPossession.setGroundA(reason); - case "B" -> reasonsForPossession.setGroundB(reason); - case "C" -> reasonsForPossession.setGroundC(reason); - case "D" -> reasonsForPossession.setGroundD(reason); - case "E" -> reasonsForPossession.setGroundE(reason); - case "F" -> reasonsForPossession.setGroundF(reason); - case "G" -> reasonsForPossession.setGroundG(reason); - case "H" -> reasonsForPossession.setGroundH(reason); - case "I" -> reasonsForPossession.setGroundI(reason); + case GROUND_1 -> reasonsForPossession.setGround1(reason); + case GROUND_2 -> reasonsForPossession.setGround2(reason); + case GROUND_2A -> reasonsForPossession.setGround2A(reason); + case GROUND_2ZA -> reasonsForPossession.setGround2ZA(reason); + case GROUND_3 -> reasonsForPossession.setGround3(reason); + case GROUND_4 -> reasonsForPossession.setGround4(reason); + case GROUND_5 -> reasonsForPossession.setGround5(reason); + case GROUND_6 -> reasonsForPossession.setGround6(reason); + case GROUND_7 -> reasonsForPossession.setGround7(reason); + case GROUND_7A -> reasonsForPossession.setGround7A(reason); + case GROUND_7B -> reasonsForPossession.setGround7B(reason); + case GROUND_8 -> reasonsForPossession.setGround8(reason); + case GROUND_9 -> reasonsForPossession.setGround9(reason); + case GROUND_10 -> reasonsForPossession.setGround10(reason); + case GROUND_10A -> reasonsForPossession.setGround10A(reason); + case GROUND_11 -> reasonsForPossession.setGround11(reason); + case GROUND_12 -> reasonsForPossession.setGround12(reason); + case GROUND_13 -> reasonsForPossession.setGround13(reason); + case GROUND_14 -> reasonsForPossession.setGround14(reason); + case GROUND_14A -> reasonsForPossession.setGround14A(reason); + case GROUND_14ZA -> reasonsForPossession.setGround14ZA(reason); + case GROUND_15 -> reasonsForPossession.setGround15(reason); + case GROUND_15A -> reasonsForPossession.setGround15A(reason); + case GROUND_16 -> reasonsForPossession.setGround16(reason); + case GROUND_17 -> reasonsForPossession.setGround17(reason); + case GROUND_A -> reasonsForPossession.setGroundA(reason); + case GROUND_B -> reasonsForPossession.setGroundB(reason); + case GROUND_C -> reasonsForPossession.setGroundC(reason); + case GROUND_D -> reasonsForPossession.setGroundD(reason); + case GROUND_E -> reasonsForPossession.setGroundE(reason); + case GROUND_F -> reasonsForPossession.setGroundF(reason); + case GROUND_G -> reasonsForPossession.setGroundG(reason); + case GROUND_H -> reasonsForPossession.setGroundH(reason); + case GROUND_I -> reasonsForPossession.setGroundI(reason); default -> { } } @@ -313,14 +355,14 @@ private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossessio String section, String reason) { switch (section) { - case "157" -> reasonsForPossession.setSection157(reason); - case "170" -> reasonsForPossession.setSection170(reason); - case "178" -> reasonsForPossession.setSection178(reason); - case "181" -> reasonsForPossession.setSection181(reason); - case "186" -> reasonsForPossession.setSection186(reason); - case "187" -> reasonsForPossession.setSection187(reason); - case "191" -> reasonsForPossession.setSection191(reason); - case "199" -> reasonsForPossession.setSection199(reason); + case SECTION_157 -> reasonsForPossession.setSection157(reason); + case SECTION_170 -> reasonsForPossession.setSection170(reason); + case SECTION_178 -> reasonsForPossession.setSection178(reason); + case SECTION_181 -> reasonsForPossession.setSection181(reason); + case SECTION_186 -> reasonsForPossession.setSection186(reason); + case SECTION_187 -> reasonsForPossession.setSection187(reason); + case SECTION_191 -> reasonsForPossession.setSection191(reason); + case SECTION_199 -> reasonsForPossession.setSection199(reason); default -> { } } @@ -476,11 +518,6 @@ private String getGrounds(PCSCase pcsCase) { } private void groupSection84AConditions(List grounds) { - int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); - if (antisocialIndex < 0) { - return; - } - List section84AConditions = grounds.stream() .filter(this::isSection84ACondition) .sorted(this::compareSection84AConditions) @@ -490,7 +527,9 @@ private void groupSection84AConditions(List grounds) { return; } - grounds.set(antisocialIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); + int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); + int groupIndex = antisocialIndex >= 0 ? antisocialIndex : grounds.indexOf(section84AConditions.getFirst()); + grounds.set(groupIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); grounds.removeAll(section84AConditions); } 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 2a72e2da9e..f17aeb51d3 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 @@ -316,6 +316,7 @@ void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(caseTabView).setDraftCaseTabFields(pcsCase, draftCaseData); + verify(caseTabView, never()).setCaseTabFields(any(PCSCase.class)); assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } @@ -328,6 +329,7 @@ void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); verify(draftCaseDataService, never()).getUnsubmittedCaseData(any(Long.class), any()); verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); + verify(caseTabView).setCaseTabFields(any(PCSCase.class)); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 7160aedf96..5a0f05c343 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -111,7 +111,10 @@ void shouldSetSummaryTabFields() { // Then assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); assertThat(summaryTab.getGroundsForPossession().getGrounds()) - .isEqualTo("Rent arrears (ground 10)\nCondition 1 of Section 84A of the Housing Act 1985"); + .isEqualTo( + "Rent arrears (ground 10)\n" + + "Antisocial behaviour: Condition 1 of Section 84A of the Housing Act 1985" + ); assertThat(summaryTab.getReasonsForPossession().getGround10()).isEqualTo("Ground 10 reason"); assertThat(summaryTab.getReasonsForPossession().getCondition1OfSection84A()) .isEqualTo("Condition 1 reason"); @@ -122,11 +125,17 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants()).hasSize(2); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) .isEqualTo(defendantAddress); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().get(1).getValue().getAddressForService()) + .isEqualTo(propertyAddress); assertThat(summaryTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); assertThat(summaryTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); @@ -230,6 +239,27 @@ void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(address); } + @Test + void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + } + @Test void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { // Given @@ -262,6 +292,38 @@ void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { .isEqualTo(address); } + @Test + void shouldDefaultAdditionalDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(propertyAddress); + } + @Test void shouldSetEachGroundReasonInSummaryTab() { // Given @@ -340,6 +402,30 @@ void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { )); } + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourWhenParentGroundIsMissing() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", + "Antisocial behaviour: " + String.join(", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985" + ), + "Landlord’s works (ground 10)" + )); + } + @Test void shouldSetEachGroundNumberReasonInSummaryTab() { // Given From 07bf5e50e280f117956be786e294b43558c9971d Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 09:28:31 +0100 Subject: [PATCH 047/138] HDPI-2978: Build Case Summary tab --- .../ccd/view/ClaimGroundSummaryBuilder.java | 253 +++++++++++------- 1 file changed, 157 insertions(+), 96 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java index d4c98b557b..1952cd99e6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -15,9 +15,15 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -165,102 +171,157 @@ private void addGrounds(List> summaries, } private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { - return switch (((Enum) ground).name()) { - case "OWNER_OCCUPIER_GROUND1" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOwnerOccupierReason(); - case "REPOSSESSION_GROUND2" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRepossessionByLenderReason(); - case "HOLIDAY_LET_GROUND3" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getHolidayLetReason(); - case "STUDENT_LET_GROUND4" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getStudentLetReason(); - case "MINISTER_RELIGION_GROUND5" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getMinisterOfReligionReason(); - case "REDEVELOPMENT_GROUND6" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getRedevelopmentReason(); - case "DEATH_OF_TENANT_GROUND7" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDeathOfTenantReason(); - case "ANTISOCIAL_BEHAVIOUR_GROUND7A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getAntisocialBehaviourReason(); - case "NO_RIGHT_TO_RENT_GROUND7B" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNoRightToRentReason(); - case "RENT_ARREARS_GROUND10", "PERSISTENT_DELAY_GROUND11", "SERIOUS_RENT_ARREARS_GROUND8" -> null; - case "ALTERNATIVE_ACCOMMODATION_GROUND9" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getSuitableAltAccommodationReason(); - case "BREACH_TENANCY_GROUND12" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getBreachOfTenancyConditionsReason(); - case "DETERIORATION_PROPERTY_GROUND13" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getPropertyDeteriorationReason(); - case "NUISANCE_ANNOYANCE_GROUND14" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getNuisanceAnnoyanceReason(); - case "DOMESTIC_VIOLENCE_GROUND14A" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getDomesticViolenceReason(); - case "OFFENCE_RIOT_GROUND14ZA" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getOffenceDuringRiotReason(); - case "DETERIORATION_FURNITURE_GROUND15" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getFurnitureDeteriorationReason(); - case "EMPLOYEE_LANDLORD_GROUND16" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getEmployeeOfLandlordReason(); - case "FALSE_STATEMENT_GROUND17" -> getRentArrearsGroundsReasons(draftCaseData) == null - ? null : getRentArrearsGroundsReasons(draftCaseData).getTenancyByFalseStatementReason(); - case "ANTI_SOCIAL" -> getAntiSocialReason(draftCaseData); - case "BREACH_OF_THE_TENANCY" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getBreachOfTheTenancyGround(); - case "ABSOLUTE_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getAbsoluteGrounds(); - case "OTHER" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getOtherGround(); - case "NO_GROUNDS" -> getIntroductoryDemotedOtherGroundReason(draftCaseData) == null - ? null : getIntroductoryDemotedOtherGroundReason(draftCaseData).getNoGrounds(); - case "RENT_ARREARS_OR_BREACH_OF_TENANCY" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getBreachOfTenancyGround(); - case "NUISANCE_OR_IMMORAL_USE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getNuisanceOrImmoralUseGround(); - case "DOMESTIC_VIOLENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getDomesticViolenceGround(); - case "RIOT_OFFENCE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRiotOffenceGround(); - case "PROPERTY_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertyDeteriorationGround(); - case "FURNITURE_DETERIORATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getFurnitureDeteriorationGround(); - case "TENANCY_OBTAINED_BY_FALSE_STATEMENT" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTenancyByFalseStatementGround(); - case "PREMIUM_PAID_MUTUAL_EXCHANGE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPremiumMutualExchangeGround(); - case "UNREASONABLE_CONDUCT_TIED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnreasonableConductGround(); - case "REFUSAL_TO_MOVE_BACK" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getRefusalToMoveBackGround(); - case "S84A_CONDITION_1" -> getSection84ACondition1Reason(draftCaseData); - case "S84A_CONDITION_2" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition2OfS84AGround(); - case "S84A_CONDITION_3" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition3OfS84AGround(); - case "S84A_CONDITION_4" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition4OfS84AGround(); - case "S84A_CONDITION_5" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAntiSocialCondition5OfS84AGround(); - case "OVERCROWDING" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getOvercrowdingGround(); - case "LANDLORD_WORKS" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getLandlordWorksGround(); - case "PROPERTY_SOLD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getPropertySoldGround(); - case "CHARITABLE_LANDLORD" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getCharitableLandlordGround(); - case "TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getTiedAccommodationGround(); - case "ADAPTED_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getAdaptedAccommodationGround(); - case "HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getHousingAssocSpecialGround(); - case "SPECIAL_NEEDS_ACCOMMODATION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getSpecialNeedsAccommodationGround(); - case "UNDER_OCCUPYING_AFTER_SUCCESSION" -> getSecureOrFlexibleReason(draftCaseData) == null - ? null : getSecureOrFlexibleReason(draftCaseData).getUnderOccupancySuccessionGround(); - default -> null; - }; + String reason = getAssuredDraftReason(draftCaseData, ground); + if (reason != null) { + return reason; + } + + reason = getIntroductoryDemotedOrOtherDraftReason(draftCaseData, ground); + if (reason != null) { + return reason; + } + + return getSecureOrFlexibleDraftReason(draftCaseData, ground); + } + + private String getAssuredDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + RentArrearsGroundsReasons reasons = getRentArrearsGroundsReasons(draftCaseData); + + if (reasons == null) { + return null; + } + + if (ground == AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1) { + return reasons.getOwnerOccupierReason(); + } else if (ground == AssuredMandatoryGround.REPOSSESSION_GROUND2) { + return reasons.getRepossessionByLenderReason(); + } else if (ground == AssuredMandatoryGround.HOLIDAY_LET_GROUND3) { + return reasons.getHolidayLetReason(); + } else if (ground == AssuredMandatoryGround.STUDENT_LET_GROUND4) { + return reasons.getStudentLetReason(); + } else if (ground == AssuredMandatoryGround.MINISTER_RELIGION_GROUND5) { + return reasons.getMinisterOfReligionReason(); + } else if (ground == AssuredMandatoryGround.REDEVELOPMENT_GROUND6) { + return reasons.getRedevelopmentReason(); + } else if (ground == AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7) { + return reasons.getDeathOfTenantReason(); + } else if (ground == AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A) { + return reasons.getAntisocialBehaviourReason(); + } else if (ground == AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B) { + return reasons.getNoRightToRentReason(); + } else if (ground == AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9) { + return reasons.getSuitableAltAccommodationReason(); + } else if (ground == AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12) { + return reasons.getBreachOfTenancyConditionsReason(); + } else if (ground == AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13) { + return reasons.getPropertyDeteriorationReason(); + } else if (ground == AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14) { + return reasons.getNuisanceAnnoyanceReason(); + } else if (ground == AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A) { + return reasons.getDomesticViolenceReason(); + } else if (ground == AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA) { + return reasons.getOffenceDuringRiotReason(); + } else if (ground == AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15) { + return reasons.getFurnitureDeteriorationReason(); + } else if (ground == AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16) { + return reasons.getEmployeeOfLandlordReason(); + } else if (ground == AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17) { + return reasons.getTenancyByFalseStatementReason(); + } + + return null; + } + + private String getIntroductoryDemotedOrOtherDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + IntroductoryDemotedOtherGroundReason reasons = getIntroductoryDemotedOtherGroundReason(draftCaseData); + + if (ground == IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL) { + return getAntiSocialReason(draftCaseData); + } + + if (reasons == null) { + return null; + } + + if (ground == IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY) { + return reasons.getBreachOfTheTenancyGround(); + } else if (ground == IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS) { + return reasons.getAbsoluteGrounds(); + } else if (ground == IntroductoryDemotedOrOtherGrounds.OTHER) { + return reasons.getOtherGround(); + } else if (ground == IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS) { + return reasons.getNoGrounds(); + } + + return null; + } + + private String getSecureOrFlexibleDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { + SecureOrFlexibleGroundsReasons reasons = getSecureOrFlexibleReason(draftCaseData); + + if (ground == SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL) { + return getAntiSocialReason(draftCaseData); + } + + if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_1) { + return getSection84ACondition1Reason(draftCaseData); + } + + if (reasons == null) { + return null; + } + + if (ground == SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY) { + return reasons.getBreachOfTenancyGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE) { + return reasons.getNuisanceOrImmoralUseGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE) { + return reasons.getDomesticViolenceGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE) { + return reasons.getRiotOffenceGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION) { + return reasons.getPropertyDeteriorationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION) { + return reasons.getFurnitureDeteriorationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT) { + return reasons.getTenancyByFalseStatementGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE) { + return reasons.getPremiumMutualExchangeGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION) { + return reasons.getUnreasonableConductGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK) { + return reasons.getRefusalToMoveBackGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_2) { + return reasons.getAntiSocialCondition2OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_3) { + return reasons.getAntiSocialCondition3OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_4) { + return reasons.getAntiSocialCondition4OfS84AGround(); + } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_5) { + return reasons.getAntiSocialCondition5OfS84AGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING) { + return reasons.getOvercrowdingGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS) { + return reasons.getLandlordWorksGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD) { + return reasons.getPropertySoldGround(); + } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD) { + return reasons.getCharitableLandlordGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE) { + return reasons.getTiedAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION) { + return reasons.getAdaptedAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm + .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES) { + return reasons.getHousingAssocSpecialGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION) { + return reasons.getSpecialNeedsAccommodationGround(); + } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION) { + return reasons.getUnderOccupancySuccessionGround(); + } + + return null; } private String getSection84ACondition1Reason(PCSCase draftCaseData) { From 6eb1356dd40375399ccdd2e3629cebe9ee7da8dd Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 10:55:41 +0100 Subject: [PATCH 048/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 5 ++- .../pcs/ccd/view/CaseSummaryTabView.java | 33 ++++++++++++------- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 19 +++++++++++ 3 files changed, 45 insertions(+), 12 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 5d5ae1d819..73bcb3847f 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 @@ -86,7 +86,10 @@ public PCSCase getCase(CaseViewRequest request) { if (hasUnsubmittedCaseData) { draftCaseDataService .getUnsubmittedCaseData(caseReference, resumePossessionClaim) - .ifPresent(draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft)); + .ifPresentOrElse( + draft -> caseTabView.setDraftCaseTabFields(pcsCase, draft), + () -> caseTabView.setCaseTabFields(pcsCase) + ); } else { caseTabView.setCaseTabFields(pcsCase); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 91c4ecad30..fa58d8de8f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -53,6 +53,17 @@ public class CaseSummaryTabView { private static final Pattern SECTION_84A_CONDITION_PATTERN = Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final String SECTION_84A_CONDITION_1_PREFIX = "Condition 1"; + private static final String SECTION_84A_CONDITION_2_PREFIX = "Condition 2"; + private static final String SECTION_84A_CONDITION_3_PREFIX = "Condition 3"; + private static final String SECTION_84A_CONDITION_4_PREFIX = "Condition 4"; + private static final String SECTION_84A_CONDITION_5_PREFIX = "Condition 5"; + private static final String BREACH_OF_THE_TENANCY = "Breach of the tenancy"; + private static final String ABSOLUTE_GROUNDS = "Absolute grounds"; + private static final String OTHER = "Other"; + private static final String OTHER_GROUNDS = "Other grounds"; + private static final String NO_GROUNDS = "No grounds"; + private static final String PARAGRAPH_25B_2_SCHEDULE_12 = "paragraph 25B(2) of Schedule 12"; private static final String GROUND_1 = "1"; private static final String GROUND_2 = "2"; private static final String GROUND_2A = "2A"; @@ -283,27 +294,27 @@ private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession return; } - if (groundLabel.startsWith("Condition 1")) { + if (groundLabel.startsWith(SECTION_84A_CONDITION_1_PREFIX)) { reasonsForPossession.setCondition1OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 2")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_2_PREFIX)) { reasonsForPossession.setCondition2OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 3")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_3_PREFIX)) { reasonsForPossession.setCondition3OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 4")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_4_PREFIX)) { reasonsForPossession.setCondition4OfSection84A(reason); - } else if (groundLabel.startsWith("Condition 5")) { + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_5_PREFIX)) { reasonsForPossession.setCondition5OfSection84A(reason); - } else if ("Antisocial behaviour".equals(groundLabel)) { + } else if (ANTISOCIAL_BEHAVIOUR.equals(groundLabel)) { reasonsForPossession.setAntisocialBehaviour(reason); - } else if ("Breach of the tenancy".equals(groundLabel)) { + } else if (BREACH_OF_THE_TENANCY.equals(groundLabel)) { reasonsForPossession.setBreachOfTheTenancy(reason); - } else if ("Absolute grounds".equals(groundLabel)) { + } else if (ABSOLUTE_GROUNDS.equals(groundLabel)) { reasonsForPossession.setAbsoluteGrounds(reason); - } else if ("Other".equals(groundLabel) || "Other grounds".equals(groundLabel)) { + } else if (OTHER.equals(groundLabel) || OTHER_GROUNDS.equals(groundLabel)) { reasonsForPossession.setOtherGrounds(reason); - } else if ("No grounds".equals(groundLabel)) { + } else if (NO_GROUNDS.equals(groundLabel)) { reasonsForPossession.setNoGrounds(reason); - } else if (groundLabel.contains("paragraph 25B(2) of Schedule 12")) { + } else if (groundLabel.contains(PARAGRAPH_25B_2_SCHEDULE_12)) { reasonsForPossession.setParagraph25B2Schedule12(reason); } } 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 f17aeb51d3..2da0b8aac5 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 @@ -320,6 +320,25 @@ void shouldSetDraftCaseTabFieldsWhenUnsubmittedCaseDataExists() { assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); } + @Test + void shouldSetSubmittedCaseTabFieldsWhenUnsubmittedCaseDataIsExpectedButDraftIsMissing() { + // Given + when(draftCaseDataService.hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(true); + when(draftCaseDataService.getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim)) + .thenReturn(Optional.empty()); + + // When + PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, State.AWAITING_SUBMISSION_TO_HMCTS)); + + // Then + verify(draftCaseDataService).hasUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(draftCaseDataService).getUnsubmittedCaseData(CASE_REFERENCE, resumePossessionClaim); + verify(caseTabView, never()).setDraftCaseTabFields(any(PCSCase.class), any(PCSCase.class)); + verify(caseTabView).setCaseTabFields(pcsCase); + assertThat(pcsCase.getNextStepsMarkdown()).contains("Resume claim"); + } + @Test void shouldNotFetchUnsubmittedCaseDataWhenNoUnsubmittedCaseDataExists() { // When From 877511687435e8a551b68c0c370c7317867bb6ff Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 14:15:11 +0100 Subject: [PATCH 049/138] HDPI-2978: Build Case Summary tab --- .../{V096__add_created_at.sql => V101__add_created_at.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V096__add_created_at.sql => V101__add_created_at.sql} (100%) diff --git a/src/main/resources/db/migration/V096__add_created_at.sql b/src/main/resources/db/migration/V101__add_created_at.sql similarity index 100% rename from src/main/resources/db/migration/V096__add_created_at.sql rename to src/main/resources/db/migration/V101__add_created_at.sql From 07492bceb751b9690c1d165defa96c05abf1339b Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 14:16:57 +0100 Subject: [PATCH 050/138] HDPI-2978: Build Case Summary tab --- src/main/resources/db/migration/V096__add_created_at.sql | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/main/resources/db/migration/V096__add_created_at.sql diff --git a/src/main/resources/db/migration/V096__add_created_at.sql b/src/main/resources/db/migration/V096__add_created_at.sql deleted file mode 100644 index 5fce3fed69..0000000000 --- a/src/main/resources/db/migration/V096__add_created_at.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP WITH TIME ZONE; From c600073752440fd6c24c402372a642133fe9b280 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 15 May 2026 14:48:08 +0100 Subject: [PATCH 051/138] HDPI-2978: Build Case Summary tab --- .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 93 ++----------------- .../reform/pcs/ccd/view/ClaimViewTest.java | 16 +--- 2 files changed, 9 insertions(+), 100 deletions(-) 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 e816a1ea43..96df0cb154 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 @@ -18,26 +18,23 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; -import uk.gov.hmcts.reform.pcs.ccd.entity.party.ClaimPartyEntity; -import uk.gov.hmcts.reform.pcs.ccd.entity.party.ClaimPartyId; 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.service.CaseTitleService; import uk.gov.hmcts.reform.pcs.ccd.service.DraftCaseDataService; import uk.gov.hmcts.reform.pcs.ccd.view.AlternativesToPossessionView; import uk.gov.hmcts.reform.pcs.ccd.view.AsbProhibitedConductView; import uk.gov.hmcts.reform.pcs.ccd.view.CaseTabView; +import uk.gov.hmcts.reform.pcs.ccd.view.CaseLinkView; import uk.gov.hmcts.reform.pcs.ccd.view.ClaimGroundsView; import uk.gov.hmcts.reform.pcs.ccd.view.ClaimView; -import uk.gov.hmcts.reform.pcs.ccd.view.HousingActWalesView; import uk.gov.hmcts.reform.pcs.ccd.view.NoticeOfPossessionView; +import uk.gov.hmcts.reform.pcs.ccd.view.PartiesView; import uk.gov.hmcts.reform.pcs.ccd.view.RentArrearsView; import uk.gov.hmcts.reform.pcs.ccd.view.RentDetailsView; import uk.gov.hmcts.reform.pcs.ccd.view.StatementOfTruthView; import uk.gov.hmcts.reform.pcs.ccd.view.TenancyLicenceView; import uk.gov.hmcts.reform.pcs.ccd.view.globalsearch.CaseFieldsView; -import uk.gov.hmcts.reform.pcs.ccd.view.CaseLinkView; import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; @@ -86,8 +83,6 @@ class PCSCaseViewTest { @Mock private AlternativesToPossessionView alternativesToPossessionView; @Mock - private HousingActWalesView housingActWalesView; - @Mock private AsbProhibitedConductView asbProhibitedConductView; @Mock private RentArrearsView rentArrearsView; @@ -108,6 +103,8 @@ class PCSCaseViewTest { private CaseLinkView caseLinkView; @Mock private CaseTabView caseTabView; + @Mock + private PartiesView partiesView; private PCSCaseView underTest; @@ -118,10 +115,10 @@ void setUp() { underTest = new PCSCaseView(pcsCaseRepository, securityContextService, modelMapper, draftCaseDataService, caseTitleService, claimView, tenancyLicenceView, claimGroundsView, rentDetailsView, - alternativesToPossessionView, housingActWalesView, asbProhibitedConductView, + alternativesToPossessionView, asbProhibitedConductView, rentArrearsView, noticeOfPossessionView, statementOfTruthView, caseFieldsView, caseLinkView, enforcementOrderMediator, - caseTabView + caseTabView, partiesView ); } @@ -228,63 +225,6 @@ void shouldMapDateSubmittedFromCaseCreatedAt() { assertThat(pcsCase.getDateSubmitted()).isEqualTo(createdAt); } - @Test - void shouldMapAllParties() { - // Given - Party claimant = mock(Party.class); - UUID claimantId = UUID.randomUUID(); - ClaimPartyEntity claimantClaimParty = createClaimPartyEntity(claimant, claimantId, PartyRole.CLAIMANT); - - Party defendant1 = mock(Party.class); - UUID defendant1Id = UUID.randomUUID(); - ClaimPartyEntity defendant1ClaimParty = createClaimPartyEntity(defendant1, defendant1Id, PartyRole.DEFENDANT); - - Party defendant2 = mock(Party.class); - UUID defendant2Id = UUID.randomUUID(); - ClaimPartyEntity defendant2ClaimParty = createClaimPartyEntity(defendant2, defendant2Id, PartyRole.DEFENDANT); - - Party underlessee1 = mock(Party.class); - UUID underlessee1Id = UUID.randomUUID(); - ClaimPartyEntity underlessee1ClaimParty = createClaimPartyEntity( - underlessee1, - underlessee1Id, - PartyRole.UNDERLESSEE_OR_MORTGAGEE - ); - - Party underlessee2 = mock(Party.class); - UUID underlessee2Id = UUID.randomUUID(); - ClaimPartyEntity underlessee2ClaimParty = createClaimPartyEntity( - underlessee2, - underlessee2Id, - PartyRole.UNDERLESSEE_OR_MORTGAGEE - ); - - when(claimEntity.getClaimParties()).thenReturn( - List.of(claimantClaimParty, defendant1ClaimParty, defendant2ClaimParty, - underlessee1ClaimParty, underlessee2ClaimParty - )); - - // When - PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); - - // Then - assertThat(pcsCase.getAllClaimants()) - .containsExactly(asListValue(claimantId, claimant)); - - assertThat(pcsCase.getAllDefendants()) - .containsExactly( - asListValue(defendant1Id, defendant1), - asListValue(defendant2Id, defendant2) - ); - - assertThat(pcsCase.getAllUnderlesseeOrMortgagees()) - .containsExactly( - asListValue(underlessee1Id, underlessee1), - asListValue(underlessee2Id, underlessee2) - ); - - } - @Test void shouldReturnEmptyListWhenNoDocumentsExist() { // Given @@ -323,37 +263,18 @@ void shouldMapDocuments() { .containsExactly("doc1.pdf", "doc2.pdf"); } - private static ListValue asListValue(UUID id, Party party) { - return ListValue.builder().id(id.toString()).value(party).build(); - } - - private ClaimPartyEntity createClaimPartyEntity(Party party, UUID partyId, PartyRole partyRole) { - PartyEntity partyEntity = mock(PartyEntity.class); - - when(modelMapper.map(partyEntity, Party.class)).thenReturn(party); - - ClaimPartyId claimPartyId = new ClaimPartyId(); - claimPartyId.setPartyId(partyId); - - return ClaimPartyEntity.builder() - .id(claimPartyId) - .role(partyRole) - .party(partyEntity) - .build(); - } - @Test void shouldSetCaseFieldsInViewHelpers() { // When PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); // Then + verify(partiesView).setCaseFields(pcsCase, pcsCaseEntity); verify(claimView).setCaseFields(pcsCase, pcsCaseEntity); verify(tenancyLicenceView).setCaseFields(pcsCase, pcsCaseEntity); verify(claimGroundsView).setCaseFields(pcsCase, pcsCaseEntity); verify(rentDetailsView).setCaseFields(pcsCase, pcsCaseEntity); verify(alternativesToPossessionView).setCaseFields(pcsCase, pcsCaseEntity); - verify(housingActWalesView).setCaseFields(pcsCase, pcsCaseEntity); verify(asbProhibitedConductView).setCaseFields(pcsCase, pcsCaseEntity); verify(rentArrearsView).setCaseFields(pcsCase, pcsCaseEntity); verify(noticeOfPossessionView).setCaseFields(pcsCase, pcsCaseEntity); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java index 3e83d132ec..17dbb1f157 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimViewTest.java @@ -58,6 +58,7 @@ void shouldMapBasicClaimFields() { when(claimEntity.getLanguageUsed()).thenReturn(LanguageUsed.ENGLISH); when(claimEntity.getAdditionalDocsProvided()).thenReturn(VerticalYesNo.YES); when(claimEntity.getPreActionProtocolIncompleteExplanation()).thenReturn("explanation"); + when(claimEntity.getIsExemptLandlord()).thenReturn(VerticalYesNo.NO); // When underTest.setCaseFields(pcsCase, pcsCaseEntity); @@ -76,20 +77,7 @@ void shouldMapBasicClaimFields() { assertThat(pcsCase.getLanguageUsed()).isEqualTo(LanguageUsed.ENGLISH); assertThat(pcsCase.getWantToUploadDocuments()).isEqualTo(VerticalYesNo.YES); assertThat(pcsCase.getPreActionProtocolIncompleteExplanation()).isEqualTo("explanation"); - } - - @ParameterizedTest - @MethodSource("claimSubmittedDateScenarios") - void shouldMapClaimSubmittedDate(LocalDateTime claimSubmittedDate, String expectedDateSubmitted) { - // Given - when(pcsCaseEntity.getClaims()).thenReturn(List.of(claimEntity)); - when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); - - // When - underTest.setCaseFields(pcsCase, pcsCaseEntity); - - // Then - assertThat(pcsCase.getDateSubmitted()).isEqualTo(expectedDateSubmitted); + assertThat(pcsCase.getIsExemptLandlord()).isEqualTo(VerticalYesNo.NO); } @ParameterizedTest From be13cf7b3cf2b5659df593bea664ab57f4e15434 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 15 May 2026 20:55:22 +0100 Subject: [PATCH 052/138] HDPI-2983: fix spelling mistake --- ...abDetails.java => DefendantInformationTabDetails.java} | 2 +- .../reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 4 ++-- .../gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/{DefendantInfomationTabDetails.java => DefendantInformationTabDetails.java} (92%) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java similarity index 92% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index 9f1320f897..216d0d5eb6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class DefendantInfomationTabDetails { +public class DefendantInformationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 603649680e..c4a0ed8ccc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -11,7 +11,7 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; @@ -51,7 +51,7 @@ public class SummaryTab { @CCD( label = "Defendant 1" ) - private DefendantInfomationTabDetails defendantDetails; + private DefendantInformationTabDetails defendantDetails; @CCD( label = "Additional defendant" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index fa58d8de8f..2a94d3a453 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -19,7 +19,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; @@ -169,7 +169,7 @@ private String getSummaryClaimantName(PCSCase pcsCase) { return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); } - private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + private DefendantInformationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } @@ -209,14 +209,14 @@ private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendan .build(); } - private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + private DefendantInformationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; } - return DefendantInfomationTabDetails.builder() + return DefendantInformationTabDetails.builder() .firstName(getDefendantFirstName(defendant)) .lastName(getDefendantLastName(defendant)) .addressForService(addressForService) From 3bdf5864470801f99db037a33528c737cee33039 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 15 May 2026 21:13:32 +0100 Subject: [PATCH 053/138] HDPI-2983: apply shared tab details classes to case details tab --- ...itionalDefendantInformationTabDetails.java | 24 -------- .../domain/tabs/details/CaseDetailsTab.java | 22 +++++-- .../ClaimantInformationTabDetails.java | 18 ------ .../DefendantInformationTabDetails.java | 17 ------ .../GroundsForPossessionTabDetails.java | 25 -------- .../ReasonsForPossessionTabDetails.java | 4 -- .../tabs/details/RentArrearsTabDetails.java | 58 ------------------- .../GroundsForPossessionTabDetails.java | 7 ++- .../ReasonsForPossessionTabDetails.java | 2 +- .../tabs/shared/RentArrearsTabDetails.java | 19 ++++++ .../ccd/domain/tabs/summary/SummaryTab.java | 2 + .../pcs/ccd/view/CaseSummaryTabView.java | 4 +- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 2 +- 13 files changed, 47 insertions(+), 157 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/GroundsForPossessionTabDetails.java (71%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/ReasonsForPossessionTabDetails.java (99%) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java deleted file mode 100644 index 287858aef2..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/AdditionalDefendantInformationTabDetails.java +++ /dev/null @@ -1,24 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; -import uk.gov.hmcts.ccd.sdk.type.AddressUK; - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class AdditionalDefendantInformationTabDetails { - @CCD( - label = "Additional defendant" - ) - private DefendantInformationTabDetails defendantInformationDetails; - - @CCD( - label = "Additional defendant address for service" - ) - private AddressUK defendantOneAddress; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index b9c2d066ed..9cefdea3f5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -9,7 +9,12 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; @@ -55,10 +60,10 @@ public class CaseDetailsTab { ) private RentArrearsTabDetails rentArrearsDetails; -// @CCD( -// label = "Reasons for possession" -// ) -// private ReasonsForPossessionTabDetails reasonsForPossessionDetails; + @CCD( + label = "Reasons for possession" + ) + private ReasonsForPossessionTabDetails reasonsForPossessionDetails; @CCD( label = "Applications" @@ -78,7 +83,7 @@ public class CaseDetailsTab { @CCD( label = "Claimant contact details" ) - private ClaimantTabDetails claimantContactDetails; + private ClaimantInformationTabDetails claimantContactDetails; @CCD( label = "Claimant circumstances" @@ -95,6 +100,11 @@ public class CaseDetailsTab { ) private AddressUK defendantOneAddress; + @CCD( + label = "Additional defendant" + ) + private AdditionalDefendantInformationTabDetails additionalDefendantDetails; + @CCD( label = "Defendant’ circumstances" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java deleted file mode 100644 index 3b8094d854..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantInformationTabDetails.java +++ /dev/null @@ -1,18 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class ClaimantInformationTabDetails { - @CCD( - label = "Claimant name" - ) - private String name; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java deleted file mode 100644 index 055f028909..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantInformationTabDetails.java +++ /dev/null @@ -1,17 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class DefendantInformationTabDetails { - - @CCD - private String firstName; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java deleted file mode 100644 index 8633d5e344..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/GroundsForPossessionTabDetails.java +++ /dev/null @@ -1,25 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; - - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class GroundsForPossessionTabDetails { - - @CCD( - label = "Grounds" - ) - private String grounds; - - @CCD( - label = "Description of other grounds" - ) - private String otherGroundsDescription; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java deleted file mode 100644 index 3f084cba0b..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ReasonsForPossessionTabDetails.java +++ /dev/null @@ -1,4 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -public class ReasonsForPossessionTabDetails { -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java deleted file mode 100644 index c6ba204b20..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/RentArrearsTabDetails.java +++ /dev/null @@ -1,58 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; -import uk.gov.hmcts.ccd.sdk.type.Document; -import uk.gov.hmcts.ccd.sdk.type.ListValue; - -import java.util.List; - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class RentArrearsTabDetails { - - @CCD( - label = "Rent amount" - ) - private String rentAmount; - - @CCD( - label = "How rent is calculated" - ) - private String rentCalculation; - - @CCD( - label = "Frequency" - ) - private String frequency; - - @CCD( - label = "Daily rate" - ) - private String dailyRate; - - @CCD( - label = "Previous steps taken to recover rent arrears?" - ) - private String stepsToRecoverArrears; - - @CCD( - label = "Rent statement" - ) - private List> rentStatement; - - @CCD( - label = "Rent arrears total at the time of claim issue" - ) - private String totalRentArrears; - - @CCD( - label = "Judgment requested for the outstanding arrears?" - ) - private String judgementRequested; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java similarity index 71% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java index 76e8fd108a..19ab35c4c3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; @@ -19,4 +19,9 @@ public class GroundsForPossessionTabDetails { typeOverride = TextArea ) private String grounds; + + @CCD( + label = "Description of other grounds" + ) + private String otherGroundsDescription; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java similarity index 99% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java index c8647b148d..4d97e5a438 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 78ba11160e..2baf4e7434 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -5,6 +5,10 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; + +import java.util.List; @Builder @Data @@ -22,11 +26,26 @@ public class RentArrearsTabDetails { ) private String calculationFrequency; + @CCD( + label = "Frequency" + ) + private String frequency; + @CCD( label = "Daily rate" ) private String dailyRate; + @CCD( + label = "Previous steps taken to recover rent arrears?" + ) + private String stepsToRecoverArrears; + + @CCD( + label = "Rent statement" + ) + private List> rentStatement; + @CCD( label = "Rent arrears total at the time of claim issue" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index c4a0ed8ccc..e650b8f1e6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -12,6 +12,8 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 2a94d3a453..bb4c3ad233 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -21,9 +21,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 5a0f05c343..4a181aabd0 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -18,7 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; From fa73d1797e34eacc2824f3e21b69113bdbfc0673 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 15 May 2026 22:59:52 +0100 Subject: [PATCH 054/138] HDPI-2983: move grounds and rent arrears tab details builder into shared builder classes --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 23 ++ .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 5 + .../pcs/ccd/view/CaseDetailsTabView.java | 227 ++++-------------- .../pcs/ccd/view/CaseSummaryTabView.java | 129 +--------- .../reform/pcs/ccd/view/CaseTabView.java | 6 + .../ClaimGroundSummaryBuilder.java | 13 +- .../pcs/ccd/view/builder/GroundsBuilder.java | 69 ++++++ .../builder/RentArrearsTabDetailsBuilder.java | 87 +++++++ .../pcs/ccd/view/CaseSummaryTabViewTest.java | 11 +- .../reform/pcs/ccd/view/CaseTabViewTest.java | 9 +- .../view/ClaimGroundSummaryBuilderTest.java | 1 + 11 files changed, 281 insertions(+), 299 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/{ => builder}/ClaimGroundSummaryBuilder.java (97%) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilder.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.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 67e53526ba..b2b57e8ae1 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 @@ -93,6 +93,8 @@ public void configure(final ConfigBuilder builder) { .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .field(PCSCase::getCaseFileView, null, "#ARGUMENT(CaseFileView)"); + buildCaseDetailsTab(builder); + builder.tab("caseLinks", "Linked Cases") .forRoles(UserRole.PCS_SOLICITOR) .field(PCSCase::getLinkedCasesComponentLauncher, null, "#ARGUMENT(LinkedCases)") @@ -152,4 +154,25 @@ private void buildSummaryTab(ConfigBuilder builder) { "## Notice") .field("summaryTab_NoticeDetails"); } + + private void buildCaseDetailsTab(ConfigBuilder builder) { + builder.tab("caseDetails", "Case Details") + .label("Case details", null, "### Case details") + .field("caseDetailsTab_ClaimDetails") + .field("caseDetailsTab_PropertyAddress") + .field("caseDetailsTab_GroundsForPossessionDetails") + .field("caseDetailsTab_TenancyLicenceDetails") + .field("caseDetailsTab_NoticeDetails") + .field("caseDetailsTab_ActionsTakenDetails") + .field("caseDetailsTab_RentArrearsDetails") + .label("Claimant Details", null, "### Claimant Details") + .label("Defendant Details", null, "### Defendant Details") + .label( + "Underlessee or mortgagee", + null, + "### Underlessee or mortgagee entitled to claim relief against forfeiture" + ) + .label("Demotion of tenancy", null, "### Demotion of tenancy") + .label("Suspension of right to buy", null, "### Suspension of right to buy"); + } } 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 7f5c510eef..15d7d5e7da 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 @@ -39,6 +39,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.respondpossessionclaim.PossessionClaimResponse; import uk.gov.hmcts.reform.pcs.ccd.domain.statementoftruth.StatementOfTruthDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.ASBQuestionsDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.EstateManagementGroundsWales; @@ -611,4 +612,8 @@ public class PCSCase { @JsonUnwrapped(prefix = "summaryTab_") @CCD private SummaryTab summaryTab; + + @JsonUnwrapped(prefix = "caseDetailsTab_") + @CCD + private CaseDetailsTab caseDetailsTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 69245c78fe..89312ed319 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -1,6 +1,9 @@ package uk.gov.hmcts.reform.pcs.ccd.view; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; @@ -9,46 +12,36 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexiblePossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ActionsTakenTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Set; +import java.util.List; -import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.ASSURED_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.DEMOTED_TENANCY; -import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.FLEXIBLE_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.INTRODUCTORY_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.OTHER; -import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.SECURE_TENANCY; +@AllArgsConstructor @Component public class CaseDetailsTabView { private static final String NO_ANSWER = " "; private static final DateTimeFormatter PATTERN = DateTimeFormatter.ofPattern("d MMMM yyyy"); - private static final String SEPARATE = ", "; + + private final GroundsBuilder groundsBuilder; + private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); @@ -56,6 +49,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase); NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); + RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); return CaseDetailsTab.builder() .claimDetails(claimTabDetails) @@ -64,6 +58,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .tenancyLicenceDetails(tenancyLicenceTabDetails) .noticeDetails(noticeTabDetails) .actionsTakenDetails(actionsTakenTabDetails) + .rentArrearsDetails(rentArrearsTabDetails) .build(); } @@ -79,179 +74,37 @@ private ClaimTabDetails buildClaimTabDetails(PCSCase pcsCase) { } private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCase pcsCase) { - AssuredRentArrearsPossessionGrounds assuredRentArrearsPossessionGrounds = - pcsCase.getAssuredRentArrearsPossessionGrounds(); - AssuredNoArrearsPossessionGrounds noRentArrearsPossessionGrounds = pcsCase.getNoRentArrearsGroundsOptions(); - SecureOrFlexiblePossessionGrounds secureOrFlexiblePossessionGrounds = - pcsCase.getSecureOrFlexiblePossessionGrounds(); - IntroductoryDemotedOtherGroundsForPossession introductoryDemotedOrOtherGroundsForPossession = - pcsCase.getIntroductoryDemotedOrOtherGroundsForPossession(); - - if( - assuredRentArrearsPossessionGrounds == null && - noRentArrearsPossessionGrounds == null && - secureOrFlexiblePossessionGrounds == null - ) { + List> groundSummaries = pcsCase.getClaimGroundSummaries(); + if (CollectionUtils.isEmpty(groundSummaries)) { return GroundsForPossessionTabDetails.builder() .grounds(NO_ANSWER) .build(); } - String grounds = NO_ANSWER; - String otherGroundsDescription = ""; TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); TenancyLicenceType tenancyType = tenancyLicenceDetails != null ? tenancyLicenceDetails.getTypeOfTenancyLicence() : null; + String otherGroundsDescription = ""; - if ( - assuredRentArrearsPossessionGrounds != null && - pcsCase.getClaimDueToRentArrears() == YesOrNo.YES && - tenancyType == ASSURED_TENANCY - ) { - grounds = getAssuredRentArrearsPossessionGrounds(assuredRentArrearsPossessionGrounds); - } else if ( - noRentArrearsPossessionGrounds != null && - pcsCase.getClaimDueToRentArrears() == YesOrNo.NO && - tenancyType == ASSURED_TENANCY - ) { - grounds = getAssuredNoArrearsPossessionGrounds(noRentArrearsPossessionGrounds); - } else if ( - secureOrFlexiblePossessionGrounds != null && - (tenancyType == SECURE_TENANCY || tenancyType == FLEXIBLE_TENANCY) - ) { - grounds = getSecureOrFlexiblePossessionGrounds(secureOrFlexiblePossessionGrounds); - } else if ( - introductoryDemotedOrOtherGroundsForPossession != null && - (tenancyType == INTRODUCTORY_TENANCY || tenancyType == DEMOTED_TENANCY || tenancyType == OTHER) - ) { - grounds = getIntroductoryDemotedOrOtherGrounds(introductoryDemotedOrOtherGroundsForPossession); - otherGroundsDescription = introductoryDemotedOrOtherGroundsForPossession.getOtherGroundDescription(); + if (tenancyType == INTRODUCTORY_TENANCY || tenancyType == DEMOTED_TENANCY || tenancyType == OTHER) { + otherGroundsDescription = groundSummaries.stream().filter( + claimGroundSummaryListValue -> { + ClaimGroundSummary claimGroundSummary = claimGroundSummaryListValue.getValue(); + return claimGroundSummary.getCode().equals(IntroductoryDemotedOrOtherGrounds.OTHER.name()); + }) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getDescription) + .findFirst() + .orElse(""); } return GroundsForPossessionTabDetails .builder() - .grounds(grounds) + .grounds(groundsBuilder.getGrounds(pcsCase)) .otherGroundsDescription(otherGroundsDescription) .build(); } - private String getAssuredRentArrearsPossessionGrounds(AssuredRentArrearsPossessionGrounds grounds) { - StringBuilder allGrounds = new StringBuilder(); - Set rentArrearsGrounds = - grounds.getRentArrearsGrounds(); - Set additionalMandatoryGrounds = - grounds.getAdditionalMandatoryGrounds(); - Set additionalDiscretionaryGrounds = - grounds.getAdditionalDiscretionaryGrounds(); - - if (rentArrearsGrounds != null) { - for (AssuredRentArrearsGround rentArrearsGround : rentArrearsGrounds) { - allGrounds.append(rentArrearsGround.getLabel()).append(SEPARATE); - } - } - - if (additionalMandatoryGrounds != null) { - for(AssuredAdditionalMandatoryGrounds mandatoryGround : additionalMandatoryGrounds) { - allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); - } - } - - if (additionalDiscretionaryGrounds != null) { - for(AssuredAdditionalDiscretionaryGrounds discretionaryGround : additionalDiscretionaryGrounds) { - allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); - } - } - - return allGrounds.toString(); - } - - private String getAssuredNoArrearsPossessionGrounds(AssuredNoArrearsPossessionGrounds grounds) { - StringBuilder allGrounds = new StringBuilder(); - Set mandatoryGrounds = grounds.getMandatoryGrounds(); - Set discretionaryGrounds = - grounds.getDiscretionaryGrounds(); - - for(AssuredMandatoryGround mandatoryGround : mandatoryGrounds) { - allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); - } - - for(AssuredDiscretionaryGround discretionaryGround : discretionaryGrounds) { - allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); - } - - return allGrounds.toString(); - } - - private String getSecureOrFlexiblePossessionGrounds(SecureOrFlexiblePossessionGrounds grounds) { - StringBuilder allGrounds = new StringBuilder(); - - Set secureOrFlexibleDiscretionaryGrounds = - grounds.getSecureOrFlexibleDiscretionaryGrounds(); - Set secureOrFlexibleMandatoryGrounds = - grounds.getSecureOrFlexibleMandatoryGrounds(); - Set secureOrFlexibleDiscretionaryGroundsAlt - = grounds.getSecureOrFlexibleDiscretionaryGroundsAlt(); - Set secureOrFlexibleMandatoryGroundsAlt - = grounds.getSecureOrFlexibleMandatoryGroundsAlt(); - Set secureAntisocialAdditionalGrounds - = grounds.getSecureAntisocialAdditionalGrounds(); - - if (secureOrFlexibleDiscretionaryGrounds != null) { - for (SecureOrFlexibleDiscretionaryGrounds discretionaryGround : secureOrFlexibleDiscretionaryGrounds) { - allGrounds.append(discretionaryGround.getLabel()).append(SEPARATE); - } - } - - if (secureOrFlexibleMandatoryGrounds != null) { - for (SecureOrFlexibleMandatoryGrounds mandatoryGround : secureOrFlexibleMandatoryGrounds) { - allGrounds.append(mandatoryGround.getLabel()).append(SEPARATE); - } - } - - if (secureOrFlexibleDiscretionaryGroundsAlt != null) { - for ( - SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm altDiscretionaryGround : - secureOrFlexibleDiscretionaryGroundsAlt - ) { - allGrounds.append(altDiscretionaryGround.getLabel()).append(SEPARATE); - } - } - - if (secureOrFlexibleMandatoryGroundsAlt != null) { - for ( - SecureOrFlexibleMandatoryGroundsAlternativeAccomm altMandatoryGround : - secureOrFlexibleMandatoryGroundsAlt - ) { - allGrounds.append(altMandatoryGround.getLabel()).append(SEPARATE); - } - } - - if (secureAntisocialAdditionalGrounds != null) { - for (SecureAntisocialAdditionalGrounds antisocialGround : secureAntisocialAdditionalGrounds) { - allGrounds.append(antisocialGround.getLabel()).append(SEPARATE); - } - } - - return allGrounds.toString(); - } - - private String getIntroductoryDemotedOrOtherGrounds( - IntroductoryDemotedOtherGroundsForPossession grounds - ) { - StringBuilder allGrounds = new StringBuilder(); - - Set introductoryDemotedOrOtherGrounds = - grounds.getIntroductoryDemotedOrOtherGrounds(); - - if (introductoryDemotedOrOtherGrounds != null) { - for (IntroductoryDemotedOrOtherGrounds otherGrounds : introductoryDemotedOrOtherGrounds) { - allGrounds.append(otherGrounds.getLabel()).append(SEPARATE); - } - } - - return allGrounds.toString(); - } - private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); if (tenancyLicenceDetails == null) { @@ -346,4 +199,26 @@ private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { .settlementAttempted(settlementAttempted != null ? settlementAttempted.getLabel() : NO_ANSWER) .build(); } + + private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + if (pcsCase.getShowRentSectionPage() != YesOrNo.YES) { + return null; + } + + RentArrearsTabDetails rentArrearsTabDetails = rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); + + if (rentArrearsTabDetails == null) { + return RentArrearsTabDetails.builder() + .rentAmount(NO_ANSWER) + .calculationFrequency(NO_ANSWER) + .frequency(NO_ANSWER) + .dailyRate(NO_ANSWER) + .stepsToRecoverArrears(NO_ANSWER) + .arrearsTotal(NO_ANSWER) + .judgmentRequested(NO_ANSWER) + .build(); + } + + return rentArrearsTabDetails; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index bb4c3ad233..56d0587d99 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.pcs.ccd.view; +import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -28,11 +29,12 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.regex.Matcher; @@ -40,6 +42,7 @@ import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; +@AllArgsConstructor @Component public class CaseSummaryTabView { @@ -107,6 +110,9 @@ public class CaseSummaryTabView { private static final String SECTION_191 = "191"; private static final String SECTION_199 = "199"; + private final GroundsBuilder groundsBuilder; + private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); @@ -114,7 +120,7 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { return SummaryTab.builder() .repossessedPropertyAddress(pcsCase.getPropertyAddress()) .groundsForPossession(GroundsForPossessionTabDetails.builder() - .grounds(getGrounds(pcsCase)) + .grounds(groundsBuilder.getGrounds(pcsCase)) .build()) .reasonsForPossession(reasonsForPossession) .dateClaimSubmitted(dateSubmitted) @@ -380,31 +386,7 @@ private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossessio } private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { - RentDetails rentDetails = pcsCase.getRentDetails(); - RentArrearsSection rentArrears = pcsCase.getRentArrears(); - - String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); - String calculationFrequency = getRentCalculationFrequency(rentDetails); - String dailyRate = getDailyRate(rentDetails); - String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); - String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null - ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); - - if (rentAmount == null - && calculationFrequency == null - && dailyRate == null - && arrearsTotal == null - && judgmentRequested == null) { - return null; - } - - return RentArrearsTabDetails.builder() - .rentAmount(rentAmount) - .calculationFrequency(calculationFrequency) - .dailyRate(dailyRate) - .arrearsTotal(arrearsTotal) - .judgmentRequested(judgmentRequested) - .build(); + return rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); } private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { @@ -466,97 +448,4 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) .build(); } - - private String getRentCalculationFrequency(RentDetails rentDetails) { - if (rentDetails == null || rentDetails.getFrequency() == null) { - return null; - } - - if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { - return rentDetails.getOtherFrequency(); - } - - return rentDetails.getFrequency().getLabel(); - } - - private String getDailyRate(RentDetails rentDetails) { - if (rentDetails == null) { - return null; - } - - if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { - return formatMoney(rentDetails.getAmendedDailyCharge()); - } - - if (rentDetails.getDailyCharge() != null) { - return formatMoney(rentDetails.getDailyCharge()); - } - - if (rentDetails.getFormattedCalculatedDailyCharge() != null) { - return rentDetails.getFormattedCalculatedDailyCharge(); - } - - return formatMoney(rentDetails.getCalculatedDailyCharge()); - } - - private String formatMoney(BigDecimal amount) { - if (amount == null) { - return null; - } - - if (amount.stripTrailingZeros().scale() <= 0) { - amount = amount.stripTrailingZeros(); - } - - return "£" + amount.toPlainString(); - } - - private String getGrounds(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { - return null; - } - - List grounds = new ArrayList<>(pcsCase.getClaimGroundSummaries().stream() - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .toList()); - - groupSection84AConditions(grounds); - - return grounds.stream() - .reduce((firstGround, secondGround) -> firstGround + "\n" + secondGround) - .orElse(null); - } - - private void groupSection84AConditions(List grounds) { - List section84AConditions = grounds.stream() - .filter(this::isSection84ACondition) - .sorted(this::compareSection84AConditions) - .toList(); - - if (section84AConditions.isEmpty()) { - return; - } - - int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); - int groupIndex = antisocialIndex >= 0 ? antisocialIndex : grounds.indexOf(section84AConditions.getFirst()); - grounds.set(groupIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); - grounds.removeAll(section84AConditions); - } - - private boolean isSection84ACondition(String label) { - return SECTION_84A_CONDITION_PATTERN.matcher(label).matches(); - } - - private int compareSection84AConditions(String firstCondition, String secondCondition) { - return Integer.compare( - getSection84AConditionNumber(firstCondition), - getSection84AConditionNumber(secondCondition) - ); - } - - private int getSection84AConditionNumber(String label) { - Matcher matcher = SECTION_84A_CONDITION_PATTERN.matcher(label); - return matcher.matches() ? Integer.parseInt(matcher.group(1)) : 0; - } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 24ea626b44..b500a6c155 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -13,7 +13,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimGroundSummaryBuilder; import java.util.ArrayList; import java.util.List; @@ -26,12 +28,15 @@ public class CaseTabView { private final ClaimGroundSummaryBuilder claimGroundSummaryBuilder; private final CaseSummaryTabView caseSummaryTabView; + private final CaseDetailsTabView caseDetailsTabView; public void setCaseTabFields(PCSCase pcsCase) { CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase); SummaryTab summaryTab = caseSummaryTabView.buildSummaryTab(pcsCase); + CaseDetailsTab detailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); pcsCase.setCasePartiesTab(casePartiesTab); pcsCase.setSummaryTab(summaryTab); + pcsCase.setCaseDetailsTab(detailsTab); } public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { @@ -56,6 +61,7 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { setCaseTabFields(draftCaseData); pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); + pcsCase.setCaseDetailsTab(draftCaseData.getCaseDetailsTab()); } private List> buildDefendants(PCSCase draftCaseData) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java similarity index 97% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java index 1952cd99e6..0513d37ce9 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.view; +package uk.gov.hmcts.reform.pcs.ccd.view.builder; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -164,12 +164,23 @@ private void addGrounds(List> summaries, .code(((Enum) ground).name()) .label(ground.getLabel()) .reason(getDraftReason(draftCaseData, ground)) + .description(getDescription(draftCaseData, ground)) .build()) .map(summary -> ListValue.builder().value(summary).build()) .forEach(summaries::add); } } + private String getDescription(PCSCase draftCaseData, PossessionGroundEnum ground) { + if (ground != IntroductoryDemotedOrOtherGrounds.OTHER) { + return null; + } + + IntroductoryDemotedOtherGroundsForPossession otherGroundsForPossession = + draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); + return otherGroundsForPossession != null ? otherGroundsForPossession.getOtherGroundDescription() : null; + } + private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { String reason = getAssuredDraftReason(draftCaseData, ground); if (reason != null) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilder.java new file mode 100644 index 0000000000..18035e93ba --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilder.java @@ -0,0 +1,69 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Component +public class GroundsBuilder { + + private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final Pattern SECTION_84A_CONDITION_PATTERN = + Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); + + public String getGrounds(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + List grounds = new ArrayList<>(pcsCase.getClaimGroundSummaries().stream() + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .toList()); + + groupSection84AConditions(grounds); + + return grounds.stream() + .reduce((firstGround, secondGround) -> firstGround + "\n" + secondGround) + .orElse(null); + } + + private void groupSection84AConditions(List grounds) { + List section84AConditions = grounds.stream() + .filter(this::isSection84ACondition) + .sorted(this::compareSection84AConditions) + .toList(); + + if (section84AConditions.isEmpty()) { + return; + } + + int antisocialIndex = grounds.indexOf(ANTISOCIAL_BEHAVIOUR); + int groupIndex = antisocialIndex >= 0 ? antisocialIndex : grounds.indexOf(section84AConditions.getFirst()); + grounds.set(groupIndex, ANTISOCIAL_BEHAVIOUR + ": " + String.join(", ", section84AConditions)); + grounds.removeAll(section84AConditions); + } + + private boolean isSection84ACondition(String label) { + return SECTION_84A_CONDITION_PATTERN.matcher(label).matches(); + } + + private int compareSection84AConditions(String firstCondition, String secondCondition) { + return Integer.compare( + getSection84AConditionNumber(firstCondition), + getSection84AConditionNumber(secondCondition) + ); + } + + private int getSection84AConditionNumber(String label) { + Matcher matcher = SECTION_84A_CONDITION_PATTERN.matcher(label); + return matcher.matches() ? Integer.parseInt(matcher.group(1)) : 0; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java new file mode 100644 index 0000000000..c809d7a273 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java @@ -0,0 +1,87 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; + +import java.math.BigDecimal; + +@Component +public class RentArrearsTabDetailsBuilder { + + public RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequency(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return null; + } + + return RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .build(); + } + + private String getDailyRate(RentDetails rentDetails) { + if (rentDetails == null) { + return null; + } + + if (rentDetails.getPerDayCorrect() == VerticalYesNo.NO && rentDetails.getAmendedDailyCharge() != null) { + return formatMoney(rentDetails.getAmendedDailyCharge()); + } + + if (rentDetails.getDailyCharge() != null) { + return formatMoney(rentDetails.getDailyCharge()); + } + + if (rentDetails.getFormattedCalculatedDailyCharge() != null) { + return rentDetails.getFormattedCalculatedDailyCharge(); + } + + return formatMoney(rentDetails.getCalculatedDailyCharge()); + } + + private String formatMoney(BigDecimal amount) { + if (amount == null) { + return null; + } + + if (amount.stripTrailingZeros().scale() <= 0) { + amount = amount.stripTrailingZeros(); + } + + return "£" + amount.toPlainString(); + } + + private String getRentCalculationFrequency(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER && rentDetails.getOtherFrequency() != null) { + return rentDetails.getOtherFrequency(); + } + + return rentDetails.getFrequency().getLabel(); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 4a181aabd0..7acf90746b 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; @@ -22,6 +23,8 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; import java.math.BigDecimal; import java.time.LocalDate; @@ -32,11 +35,17 @@ public class CaseSummaryTabViewTest { + @Mock + private GroundsBuilder groundsBuilder; + + @Mock + private RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + private CaseSummaryTabView underTest; @BeforeEach void setUp() { - underTest = new CaseSummaryTabView(); + underTest = new CaseSummaryTabView(groundsBuilder, rentArrearsTabDetailsBuilder); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c612303243..96d2510913 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -15,6 +15,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimGroundSummaryBuilder; import java.util.ArrayList; import java.util.List; @@ -30,9 +31,15 @@ class CaseTabViewTest { @Mock private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; + @Mock + private CaseSummaryTabView caseSummaryTabView; + + @Mock + private CaseDetailsTabView caseDetailsTabView; + @BeforeEach void setUp() { - underTest = new CaseTabView(claimGroundSummaryBuilder, new CaseSummaryTabView()); + underTest = new CaseTabView(claimGroundSummaryBuilder, caseSummaryTabView, caseDetailsTabView); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java index 306a8c3d0a..8818cd0147 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java @@ -37,6 +37,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimGroundSummaryBuilder; import java.util.List; import java.util.Set; From aa71cc5efbbc3b34e47f45b93f93347859cacef4 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 15 May 2026 23:58:28 +0100 Subject: [PATCH 055/138] HDPI-2983: move claimant information and reasons for possession tab details into separate shared builder --- .../pcs/ccd/view/CaseDetailsTabView.java | 31 +++ .../pcs/ccd/view/CaseSummaryTabView.java | 258 +----------------- .../ClaimantInformationTabDetailsBuilder.java | 48 ++++ ...ReasonsForPossessionTabDetailsBuilder.java | 196 +++++++++++++ .../pcs/ccd/view/CaseSummaryTabViewTest.java | 10 +- 5 files changed, 292 insertions(+), 251 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilder.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 89312ed319..ae3d045e79 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -15,13 +15,18 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ActionsTakenTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ApplicationsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; import java.time.LocalDate; @@ -42,6 +47,8 @@ public class CaseDetailsTabView { private final GroundsBuilder groundsBuilder; private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + private final ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + private final ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); @@ -50,6 +57,9 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); + ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = buildReasonsForPossession(pcsCase); + ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); + ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); return CaseDetailsTab.builder() .claimDetails(claimTabDetails) @@ -59,6 +69,9 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .noticeDetails(noticeTabDetails) .actionsTakenDetails(actionsTakenTabDetails) .rentArrearsDetails(rentArrearsTabDetails) + .reasonsForPossessionDetails(reasonsForPossessionTabDetails) + .applicationsDetails(applicationsTabDetails) + .claimantInformation(claimantInformationTabDetails) .build(); } @@ -221,4 +234,22 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { return rentArrearsTabDetails; } + + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + return reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); + } + + private ApplicationsTabDetails buildApplicationsTabDetails(PCSCase pcsCase) { + VerticalYesNo applicationWithClaim = pcsCase.getApplicationWithClaim(); + String planToMakeGeneralApplication = applicationWithClaim != null ? + applicationWithClaim.getLabel() : NO_ANSWER; + + return ApplicationsTabDetails.builder() + .planToMakeGeneralApplication(planToMakeGeneralApplication) + .build(); + } + + private ClaimantInformationTabDetails buildClaimantInformationTabDetails(PCSCase pcsCase) { + return claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 56d0587d99..fc12e127d1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -3,21 +3,15 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.RentArrearsSection; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; @@ -29,16 +23,15 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; -import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; @@ -49,72 +42,15 @@ public class CaseSummaryTabView { private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); - private static final Pattern GROUND_REFERENCE_PATTERN = - Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); - private static final Pattern SECTION_REFERENCE_PATTERN = - Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); - private static final Pattern SECTION_84A_CONDITION_PATTERN = - Pattern.compile("^Condition ([1-5]) of Section 84A of the Housing Act 1985$"); - private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; - private static final String SECTION_84A_CONDITION_1_PREFIX = "Condition 1"; - private static final String SECTION_84A_CONDITION_2_PREFIX = "Condition 2"; - private static final String SECTION_84A_CONDITION_3_PREFIX = "Condition 3"; - private static final String SECTION_84A_CONDITION_4_PREFIX = "Condition 4"; - private static final String SECTION_84A_CONDITION_5_PREFIX = "Condition 5"; - private static final String BREACH_OF_THE_TENANCY = "Breach of the tenancy"; - private static final String ABSOLUTE_GROUNDS = "Absolute grounds"; - private static final String OTHER = "Other"; - private static final String OTHER_GROUNDS = "Other grounds"; - private static final String NO_GROUNDS = "No grounds"; - private static final String PARAGRAPH_25B_2_SCHEDULE_12 = "paragraph 25B(2) of Schedule 12"; - private static final String GROUND_1 = "1"; - private static final String GROUND_2 = "2"; - private static final String GROUND_2A = "2A"; - private static final String GROUND_2ZA = "2ZA"; - private static final String GROUND_3 = "3"; - private static final String GROUND_4 = "4"; - private static final String GROUND_5 = "5"; - private static final String GROUND_6 = "6"; - private static final String GROUND_7 = "7"; - private static final String GROUND_7A = "7A"; - private static final String GROUND_7B = "7B"; - private static final String GROUND_8 = "8"; - private static final String GROUND_9 = "9"; - private static final String GROUND_10 = "10"; - private static final String GROUND_10A = "10A"; - private static final String GROUND_11 = "11"; - private static final String GROUND_12 = "12"; - private static final String GROUND_13 = "13"; - private static final String GROUND_14 = "14"; - private static final String GROUND_14A = "14A"; - private static final String GROUND_14ZA = "14ZA"; - private static final String GROUND_15 = "15"; - private static final String GROUND_15A = "15A"; - private static final String GROUND_16 = "16"; - private static final String GROUND_17 = "17"; - private static final String GROUND_A = "A"; - private static final String GROUND_B = "B"; - private static final String GROUND_C = "C"; - private static final String GROUND_D = "D"; - private static final String GROUND_E = "E"; - private static final String GROUND_F = "F"; - private static final String GROUND_G = "G"; - private static final String GROUND_H = "H"; - private static final String GROUND_I = "I"; - private static final String SECTION_157 = "157"; - private static final String SECTION_170 = "170"; - private static final String SECTION_178 = "178"; - private static final String SECTION_181 = "181"; - private static final String SECTION_186 = "186"; - private static final String SECTION_187 = "187"; - private static final String SECTION_191 = "191"; - private static final String SECTION_199 = "199"; private final GroundsBuilder groundsBuilder; private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + private final ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + private final ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; public SummaryTab buildSummaryTab(PCSCase pcsCase) { - ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossession(pcsCase); + ReasonsForPossessionTabDetails reasonsForPossession = + reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); return SummaryTab.builder() @@ -124,10 +60,10 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { .build()) .reasonsForPossession(reasonsForPossession) .dateClaimSubmitted(dateSubmitted) - .claimantDetails(createSummaryClaimantTabDetails(pcsCase)) + .claimantDetails(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)) .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) - .rentArrearsDetails(buildRentArrearsTabDetails(pcsCase)) + .rentArrearsDetails(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)) .tenancyDetails(buildTenancyTabDetails(pcsCase)) .noticeDetails(buildNoticeTabDetails(pcsCase)) .build(); @@ -141,40 +77,6 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); } - private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { - String claimantName = getSummaryClaimantName(pcsCase); - if (claimantName == null) { - return null; - } - - return ClaimantInformationTabDetails.builder() - .claimantName(claimantName) - .build(); - } - - private String getSummaryClaimantName(PCSCase pcsCase) { - ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); - if (claimantInformation != null) { - if (claimantInformation.getOrgNameFound() == NO) { - return claimantInformation.getFallbackClaimantName(); - } - - if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { - return claimantInformation.getOverriddenClaimantName(); - } - - if (claimantInformation.getClaimantName() != null) { - return claimantInformation.getClaimantName(); - } - } - - if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { - return null; - } - - return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); - } - private DefendantInformationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; @@ -245,150 +147,6 @@ private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); } - private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { - AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); - ReasonsForPossessionTabDetails reasonsForPossession = - buildReasonsForPossessionFromGroundSummaries(pcsCase); - String additionalReasonsText = additionalReasons == null - || additionalReasons.getHasReasons() != VerticalYesNo.YES ? null : additionalReasons.getReasons(); - - if (reasonsForPossession == null && additionalReasonsText == null) { - return null; - } - - if (reasonsForPossession == null) { - reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); - } - - reasonsForPossession.setAdditionalReasonsForPossession(additionalReasonsText); - return reasonsForPossession; - } - - private ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { - return null; - } - - ReasonsForPossessionTabDetails reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); - boolean hasReason = false; - - for (ListValue listValue : pcsCase.getClaimGroundSummaries()) { - ClaimGroundSummary summary = listValue.getValue(); - if (summary == null || !StringUtils.hasText(summary.getReason())) { - continue; - } - - setGroundReason(reasonsForPossession, summary.getLabel(), summary.getReason()); - hasReason = true; - } - - return hasReason ? reasonsForPossession : null; - } - - private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession, - String groundLabel, - String reason) { - Matcher groundMatcher = GROUND_REFERENCE_PATTERN.matcher(groundLabel); - if (groundMatcher.find()) { - setGroundNumberReason(reasonsForPossession, groundMatcher.group(1), reason); - return; - } - - Matcher sectionMatcher = SECTION_REFERENCE_PATTERN.matcher(groundLabel); - if (sectionMatcher.find()) { - setSectionReason(reasonsForPossession, sectionMatcher.group(1), reason); - return; - } - - if (groundLabel.startsWith(SECTION_84A_CONDITION_1_PREFIX)) { - reasonsForPossession.setCondition1OfSection84A(reason); - } else if (groundLabel.startsWith(SECTION_84A_CONDITION_2_PREFIX)) { - reasonsForPossession.setCondition2OfSection84A(reason); - } else if (groundLabel.startsWith(SECTION_84A_CONDITION_3_PREFIX)) { - reasonsForPossession.setCondition3OfSection84A(reason); - } else if (groundLabel.startsWith(SECTION_84A_CONDITION_4_PREFIX)) { - reasonsForPossession.setCondition4OfSection84A(reason); - } else if (groundLabel.startsWith(SECTION_84A_CONDITION_5_PREFIX)) { - reasonsForPossession.setCondition5OfSection84A(reason); - } else if (ANTISOCIAL_BEHAVIOUR.equals(groundLabel)) { - reasonsForPossession.setAntisocialBehaviour(reason); - } else if (BREACH_OF_THE_TENANCY.equals(groundLabel)) { - reasonsForPossession.setBreachOfTheTenancy(reason); - } else if (ABSOLUTE_GROUNDS.equals(groundLabel)) { - reasonsForPossession.setAbsoluteGrounds(reason); - } else if (OTHER.equals(groundLabel) || OTHER_GROUNDS.equals(groundLabel)) { - reasonsForPossession.setOtherGrounds(reason); - } else if (NO_GROUNDS.equals(groundLabel)) { - reasonsForPossession.setNoGrounds(reason); - } else if (groundLabel.contains(PARAGRAPH_25B_2_SCHEDULE_12)) { - reasonsForPossession.setParagraph25B2Schedule12(reason); - } - } - - private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPossession, - String ground, - String reason) { - switch (ground) { - case GROUND_1 -> reasonsForPossession.setGround1(reason); - case GROUND_2 -> reasonsForPossession.setGround2(reason); - case GROUND_2A -> reasonsForPossession.setGround2A(reason); - case GROUND_2ZA -> reasonsForPossession.setGround2ZA(reason); - case GROUND_3 -> reasonsForPossession.setGround3(reason); - case GROUND_4 -> reasonsForPossession.setGround4(reason); - case GROUND_5 -> reasonsForPossession.setGround5(reason); - case GROUND_6 -> reasonsForPossession.setGround6(reason); - case GROUND_7 -> reasonsForPossession.setGround7(reason); - case GROUND_7A -> reasonsForPossession.setGround7A(reason); - case GROUND_7B -> reasonsForPossession.setGround7B(reason); - case GROUND_8 -> reasonsForPossession.setGround8(reason); - case GROUND_9 -> reasonsForPossession.setGround9(reason); - case GROUND_10 -> reasonsForPossession.setGround10(reason); - case GROUND_10A -> reasonsForPossession.setGround10A(reason); - case GROUND_11 -> reasonsForPossession.setGround11(reason); - case GROUND_12 -> reasonsForPossession.setGround12(reason); - case GROUND_13 -> reasonsForPossession.setGround13(reason); - case GROUND_14 -> reasonsForPossession.setGround14(reason); - case GROUND_14A -> reasonsForPossession.setGround14A(reason); - case GROUND_14ZA -> reasonsForPossession.setGround14ZA(reason); - case GROUND_15 -> reasonsForPossession.setGround15(reason); - case GROUND_15A -> reasonsForPossession.setGround15A(reason); - case GROUND_16 -> reasonsForPossession.setGround16(reason); - case GROUND_17 -> reasonsForPossession.setGround17(reason); - case GROUND_A -> reasonsForPossession.setGroundA(reason); - case GROUND_B -> reasonsForPossession.setGroundB(reason); - case GROUND_C -> reasonsForPossession.setGroundC(reason); - case GROUND_D -> reasonsForPossession.setGroundD(reason); - case GROUND_E -> reasonsForPossession.setGroundE(reason); - case GROUND_F -> reasonsForPossession.setGroundF(reason); - case GROUND_G -> reasonsForPossession.setGroundG(reason); - case GROUND_H -> reasonsForPossession.setGroundH(reason); - case GROUND_I -> reasonsForPossession.setGroundI(reason); - default -> { - } - } - } - - private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossession, - String section, - String reason) { - switch (section) { - case SECTION_157 -> reasonsForPossession.setSection157(reason); - case SECTION_170 -> reasonsForPossession.setSection170(reason); - case SECTION_178 -> reasonsForPossession.setSection178(reason); - case SECTION_181 -> reasonsForPossession.setSection181(reason); - case SECTION_186 -> reasonsForPossession.setSection186(reason); - case SECTION_187 -> reasonsForPossession.setSection187(reason); - case SECTION_191 -> reasonsForPossession.setSection191(reason); - case SECTION_199 -> reasonsForPossession.setSection199(reason); - default -> { - } - } - } - - private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { - return rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); - } - private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilder.java new file mode 100644 index 0000000000..9b1a8882b8 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilder.java @@ -0,0 +1,48 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; + +import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; + +@Component +public class ClaimantInformationTabDetailsBuilder { + + public ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { + String claimantName = getSummaryClaimantName(pcsCase); + if (claimantName == null) { + return null; + } + + return ClaimantInformationTabDetails.builder() + .claimantName(claimantName) + .build(); + } + + private String getSummaryClaimantName(PCSCase pcsCase) { + ClaimantInformation claimantInformation = pcsCase.getClaimantInformation(); + if (claimantInformation != null) { + if (claimantInformation.getOrgNameFound() == NO) { + return claimantInformation.getFallbackClaimantName(); + } + + if (claimantInformation.getIsClaimantNameCorrect() == VerticalYesNo.NO) { + return claimantInformation.getOverriddenClaimantName(); + } + + if (claimantInformation.getClaimantName() != null) { + return claimantInformation.getClaimantName(); + } + } + + if (CollectionUtils.isEmpty(pcsCase.getAllClaimants())) { + return null; + } + + return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java new file mode 100644 index 0000000000..e9dd57b2c1 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java @@ -0,0 +1,196 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Component +public class ReasonsForPossessionTabDetailsBuilder { + + private static final Pattern GROUND_REFERENCE_PATTERN = + Pattern.compile("\\(ground ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final Pattern SECTION_REFERENCE_PATTERN = + Pattern.compile("\\(section ([^)]+)\\)", Pattern.CASE_INSENSITIVE); + private static final String ANTISOCIAL_BEHAVIOUR = "Antisocial behaviour"; + private static final String SECTION_84A_CONDITION_1_PREFIX = "Condition 1"; + private static final String SECTION_84A_CONDITION_2_PREFIX = "Condition 2"; + private static final String SECTION_84A_CONDITION_3_PREFIX = "Condition 3"; + private static final String SECTION_84A_CONDITION_4_PREFIX = "Condition 4"; + private static final String SECTION_84A_CONDITION_5_PREFIX = "Condition 5"; + private static final String BREACH_OF_THE_TENANCY = "Breach of the tenancy"; + private static final String ABSOLUTE_GROUNDS = "Absolute grounds"; + private static final String OTHER = "Other"; + private static final String OTHER_GROUNDS = "Other grounds"; + private static final String NO_GROUNDS = "No grounds"; + private static final String PARAGRAPH_25B_2_SCHEDULE_12 = "paragraph 25B(2) of Schedule 12"; + private static final String GROUND_1 = "1"; + private static final String GROUND_2 = "2"; + private static final String GROUND_2A = "2A"; + private static final String GROUND_2ZA = "2ZA"; + private static final String GROUND_3 = "3"; + private static final String GROUND_4 = "4"; + private static final String GROUND_5 = "5"; + private static final String GROUND_6 = "6"; + private static final String GROUND_7 = "7"; + private static final String GROUND_7A = "7A"; + private static final String GROUND_7B = "7B"; + private static final String GROUND_8 = "8"; + private static final String GROUND_9 = "9"; + private static final String GROUND_10 = "10"; + private static final String GROUND_10A = "10A"; + private static final String GROUND_11 = "11"; + private static final String GROUND_12 = "12"; + private static final String GROUND_13 = "13"; + private static final String GROUND_14 = "14"; + private static final String GROUND_14A = "14A"; + private static final String GROUND_14ZA = "14ZA"; + private static final String GROUND_15 = "15"; + private static final String GROUND_15A = "15A"; + private static final String GROUND_16 = "16"; + private static final String GROUND_17 = "17"; + private static final String GROUND_A = "A"; + private static final String GROUND_B = "B"; + private static final String GROUND_C = "C"; + private static final String GROUND_D = "D"; + private static final String GROUND_E = "E"; + private static final String GROUND_F = "F"; + private static final String GROUND_G = "G"; + private static final String GROUND_H = "H"; + private static final String GROUND_I = "I"; + private static final String SECTION_157 = "157"; + private static final String SECTION_170 = "170"; + private static final String SECTION_178 = "178"; + private static final String SECTION_181 = "181"; + private static final String SECTION_186 = "186"; + private static final String SECTION_187 = "187"; + private static final String SECTION_191 = "191"; + private static final String SECTION_199 = "199"; + + public ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { + return null; + } + + ReasonsForPossessionTabDetails reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + boolean hasReason = false; + + for (ListValue listValue : pcsCase.getClaimGroundSummaries()) { + ClaimGroundSummary summary = listValue.getValue(); + if (summary == null || !StringUtils.hasText(summary.getReason())) { + continue; + } + + setGroundReason(reasonsForPossession, summary.getLabel(), summary.getReason()); + hasReason = true; + } + + return hasReason ? reasonsForPossession : null; + } + + private void setGroundReason(ReasonsForPossessionTabDetails reasonsForPossession, + String groundLabel, + String reason) { + Matcher groundMatcher = GROUND_REFERENCE_PATTERN.matcher(groundLabel); + if (groundMatcher.find()) { + setGroundNumberReason(reasonsForPossession, groundMatcher.group(1), reason); + return; + } + + Matcher sectionMatcher = SECTION_REFERENCE_PATTERN.matcher(groundLabel); + if (sectionMatcher.find()) { + setSectionReason(reasonsForPossession, sectionMatcher.group(1), reason); + return; + } + + if (groundLabel.startsWith(SECTION_84A_CONDITION_1_PREFIX)) { + reasonsForPossession.setCondition1OfSection84A(reason); + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_2_PREFIX)) { + reasonsForPossession.setCondition2OfSection84A(reason); + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_3_PREFIX)) { + reasonsForPossession.setCondition3OfSection84A(reason); + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_4_PREFIX)) { + reasonsForPossession.setCondition4OfSection84A(reason); + } else if (groundLabel.startsWith(SECTION_84A_CONDITION_5_PREFIX)) { + reasonsForPossession.setCondition5OfSection84A(reason); + } else if (ANTISOCIAL_BEHAVIOUR.equals(groundLabel)) { + reasonsForPossession.setAntisocialBehaviour(reason); + } else if (BREACH_OF_THE_TENANCY.equals(groundLabel)) { + reasonsForPossession.setBreachOfTheTenancy(reason); + } else if (ABSOLUTE_GROUNDS.equals(groundLabel)) { + reasonsForPossession.setAbsoluteGrounds(reason); + } else if (OTHER.equals(groundLabel) || OTHER_GROUNDS.equals(groundLabel)) { + reasonsForPossession.setOtherGrounds(reason); + } else if (NO_GROUNDS.equals(groundLabel)) { + reasonsForPossession.setNoGrounds(reason); + } else if (groundLabel.contains(PARAGRAPH_25B_2_SCHEDULE_12)) { + reasonsForPossession.setParagraph25B2Schedule12(reason); + } + } + + private void setGroundNumberReason(ReasonsForPossessionTabDetails reasonsForPossession, + String ground, + String reason) { + switch (ground) { + case GROUND_1 -> reasonsForPossession.setGround1(reason); + case GROUND_2 -> reasonsForPossession.setGround2(reason); + case GROUND_2A -> reasonsForPossession.setGround2A(reason); + case GROUND_2ZA -> reasonsForPossession.setGround2ZA(reason); + case GROUND_3 -> reasonsForPossession.setGround3(reason); + case GROUND_4 -> reasonsForPossession.setGround4(reason); + case GROUND_5 -> reasonsForPossession.setGround5(reason); + case GROUND_6 -> reasonsForPossession.setGround6(reason); + case GROUND_7 -> reasonsForPossession.setGround7(reason); + case GROUND_7A -> reasonsForPossession.setGround7A(reason); + case GROUND_7B -> reasonsForPossession.setGround7B(reason); + case GROUND_8 -> reasonsForPossession.setGround8(reason); + case GROUND_9 -> reasonsForPossession.setGround9(reason); + case GROUND_10 -> reasonsForPossession.setGround10(reason); + case GROUND_10A -> reasonsForPossession.setGround10A(reason); + case GROUND_11 -> reasonsForPossession.setGround11(reason); + case GROUND_12 -> reasonsForPossession.setGround12(reason); + case GROUND_13 -> reasonsForPossession.setGround13(reason); + case GROUND_14 -> reasonsForPossession.setGround14(reason); + case GROUND_14A -> reasonsForPossession.setGround14A(reason); + case GROUND_14ZA -> reasonsForPossession.setGround14ZA(reason); + case GROUND_15 -> reasonsForPossession.setGround15(reason); + case GROUND_15A -> reasonsForPossession.setGround15A(reason); + case GROUND_16 -> reasonsForPossession.setGround16(reason); + case GROUND_17 -> reasonsForPossession.setGround17(reason); + case GROUND_A -> reasonsForPossession.setGroundA(reason); + case GROUND_B -> reasonsForPossession.setGroundB(reason); + case GROUND_C -> reasonsForPossession.setGroundC(reason); + case GROUND_D -> reasonsForPossession.setGroundD(reason); + case GROUND_E -> reasonsForPossession.setGroundE(reason); + case GROUND_F -> reasonsForPossession.setGroundF(reason); + case GROUND_G -> reasonsForPossession.setGroundG(reason); + case GROUND_H -> reasonsForPossession.setGroundH(reason); + case GROUND_I -> reasonsForPossession.setGroundI(reason); + default -> { + } + } + } + + private void setSectionReason(ReasonsForPossessionTabDetails reasonsForPossession, + String section, + String reason) { + switch (section) { + case SECTION_157 -> reasonsForPossession.setSection157(reason); + case SECTION_170 -> reasonsForPossession.setSection170(reason); + case SECTION_178 -> reasonsForPossession.setSection178(reason); + case SECTION_181 -> reasonsForPossession.setSection181(reason); + case SECTION_186 -> reasonsForPossession.setSection186(reason); + case SECTION_187 -> reasonsForPossession.setSection187(reason); + case SECTION_191 -> reasonsForPossession.setSection191(reason); + case SECTION_199 -> reasonsForPossession.setSection199(reason); + default -> { + } + } + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 7acf90746b..c618c26206 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -24,6 +24,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; import java.math.BigDecimal; @@ -41,11 +42,18 @@ public class CaseSummaryTabViewTest { @Mock private RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + @Mock + private ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + private CaseSummaryTabView underTest; @BeforeEach void setUp() { - underTest = new CaseSummaryTabView(groundsBuilder, rentArrearsTabDetailsBuilder); + underTest = new CaseSummaryTabView( + groundsBuilder, + rentArrearsTabDetailsBuilder, + reasonsForPossessionTabDetailsBuilder + ); } @Test From 1af005b962d8e14c144040a4079b8ae6aa58d1ed Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 10:25:24 +0100 Subject: [PATCH 056/138] HDPI-2978: Build Case Summary tab --- ...abDetails.java => DefendantInformationTabDetails.java} | 2 +- .../reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 4 ++-- .../gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java | 8 ++++---- .../uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java | 3 --- .../uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java | 6 ++++-- 5 files changed, 11 insertions(+), 12 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/{DefendantInfomationTabDetails.java => DefendantInformationTabDetails.java} (92%) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java similarity index 92% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index 9f1320f897..216d0d5eb6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInfomationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -11,7 +11,7 @@ @Data @NoArgsConstructor @AllArgsConstructor -public class DefendantInfomationTabDetails { +public class DefendantInformationTabDetails { @CCD( label = "First name" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 603649680e..c4a0ed8ccc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -11,7 +11,7 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; @@ -51,7 +51,7 @@ public class SummaryTab { @CCD( label = "Defendant 1" ) - private DefendantInfomationTabDetails defendantDetails; + private DefendantInformationTabDetails defendantDetails; @CCD( label = "Additional defendant" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index fa58d8de8f..2a94d3a453 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -19,7 +19,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInfomationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; @@ -169,7 +169,7 @@ private String getSummaryClaimantName(PCSCase pcsCase) { return pcsCase.getAllClaimants().getFirst().getValue().getOrgName(); } - private DefendantInfomationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { + private DefendantInformationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } @@ -209,14 +209,14 @@ private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendan .build(); } - private DefendantInfomationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + private DefendantInformationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; } - return DefendantInfomationTabDetails.builder() + return DefendantInformationTabDetails.builder() .firstName(getDefendantFirstName(defendant)) .lastName(getDefendantLastName(defendant)) .addressForService(addressForService) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 24ea626b44..086565af47 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -35,9 +35,6 @@ public void setCaseTabFields(PCSCase pcsCase) { } public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { - draftCaseData.setPropertyAddress(java.util.Optional.ofNullable(draftCaseData.getPropertyAddress()) - .orElse(pcsCase.getPropertyAddress())); - if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c612303243..9b4e01f73f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -265,7 +265,7 @@ void shouldNotSetCasePartiesTabWithNoData() { } @Test - void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { + void shouldSetDraftSummaryTabFieldsUsingPreFilledDraftDataAndSubmittedFallbacks() { // Given AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); List> submittedClaimants = List.of( @@ -289,7 +289,9 @@ void shouldSetDraftSummaryTabFieldsUsingSubmittedFallbacks() { .allDefendants(submittedDefendants) .claimGroundSummaries(submittedGrounds) .build(); - PCSCase draftCaseData = PCSCase.builder().build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); From c433f7cadb0f5f1dbb08564da6e74d53503612b3 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 10:44:27 +0100 Subject: [PATCH 057/138] HDPI-2978: Build Case Summary tab --- .../reform/pcs/ccd/view/CaseTabView.java | 10 +------ .../reform/pcs/ccd/view/CaseTabViewTest.java | 28 +++---------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 086565af47..329e80d0e0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -35,21 +35,13 @@ public void setCaseTabFields(PCSCase pcsCase) { } public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { - if (CollectionUtils.isEmpty(draftCaseData.getAllClaimants())) { - draftCaseData.setAllClaimants(pcsCase.getAllClaimants()); - } - if (draftCaseData.getDefendant1() != null) { draftCaseData.setAllDefendants(buildDefendants(draftCaseData)); - } else if (CollectionUtils.isEmpty(draftCaseData.getAllDefendants())) { - draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); } List> draftGrounds = claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); - draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) - ? pcsCase.getClaimGroundSummaries() - : draftGrounds); + draftCaseData.setClaimGroundSummaries(draftGrounds); setCaseTabFields(draftCaseData); pcsCase.setSummaryTab(draftCaseData.getSummaryTab()); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 9b4e01f73f..be5b4d5ec2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -265,29 +265,11 @@ void shouldNotSetCasePartiesTabWithNoData() { } @Test - void shouldSetDraftSummaryTabFieldsUsingPreFilledDraftDataAndSubmittedFallbacks() { + void shouldSetDraftSummaryTabFieldsUsingDraftDataOnly() { // Given AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - List> submittedClaimants = List.of( - listValue(Party.builder().orgName("Submitted claimant").build()) - ); - List> submittedDefendants = List.of( - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Submitted") - .lastName("Defendant") - .addressKnown(VerticalYesNo.YES) - .address(propertyAddress) - .build()) - ); - List> submittedGrounds = List.of( - listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) - ); PCSCase pcsCase = PCSCase.builder() .propertyAddress(propertyAddress) - .allClaimants(submittedClaimants) - .allDefendants(submittedDefendants) - .claimGroundSummaries(submittedGrounds) .build(); PCSCase draftCaseData = PCSCase.builder() .propertyAddress(propertyAddress) @@ -301,11 +283,9 @@ void shouldSetDraftSummaryTabFieldsUsingPreFilledDraftDataAndSubmittedFallbacks( // Then SummaryTab summaryTab = pcsCase.getSummaryTab(); assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Submitted claimant"); - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Submitted"); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Submitted ground"); + assertThat(summaryTab.getClaimantDetails()).isNull(); + assertThat(summaryTab.getDefendantDetails()).isNull(); + assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); } @Test From ef8703a1dd0d93411ecce63dc2b92832221e5a00 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 11:38:27 +0100 Subject: [PATCH 058/138] HDPI-2978: Build Case Summary tab --- .../gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 11 +++++- .../reform/pcs/ccd/entity/ClaimEntity.java | 3 ++ .../reform/pcs/ccd/entity/PcsCaseEntity.java | 3 -- .../reform/pcs/ccd/service/ClaimService.java | 9 +++-- .../pcs/ccd/service/PcsCaseService.java | 3 +- .../V101__add_claim_submitted_date.sql | 1 + .../db/migration/V101__add_created_at.sql | 1 - .../hmcts/reform/pcs/ccd/PCSCaseViewTest.java | 8 ++-- .../pcs/ccd/service/ClaimServiceTest.java | 38 ++++++++++++------- .../pcs/ccd/service/PcsCaseServiceTest.java | 10 ++--- 10 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 src/main/resources/db/migration/V101__add_claim_submitted_date.sql delete mode 100644 src/main/resources/db/migration/V101__add_created_at.sql 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 73bcb3847f..04938bc076 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 @@ -15,6 +15,7 @@ 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; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; @@ -37,6 +38,7 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.security.SecurityContextService; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import java.util.Set; @@ -121,7 +123,7 @@ private PCSCase getSubmittedCase(long caseReference) { .legislativeCountry(pcsCaseEntity.getLegislativeCountry()) .caseManagementLocationNumber(pcsCaseEntity.getCaseManagementLocation()) .allDocuments(mapAndWrapDocuments(pcsCaseEntity)) - .dateSubmitted(pcsCaseEntity.getCreatedAt()) + .dateSubmitted(getClaimSubmittedDate(pcsCaseEntity)) .build(); setDerivedProperties(pcsCase, pcsCaseEntity); @@ -142,6 +144,13 @@ private PCSCase getSubmittedCase(long caseReference) { return pcsCase; } + private LocalDateTime getClaimSubmittedDate(PcsCaseEntity pcsCaseEntity) { + return pcsCaseEntity.getClaims().stream() + .findFirst() + .map(ClaimEntity::getClaimSubmittedDate) + .orElse(null); + } + private void setDerivedProperties(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { boolean pcqIdSet = findPartyForCurrentUser(pcsCaseEntity) .map(party -> party.getPcqId() != null) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index a7658b12c2..a4f268c0c3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -34,6 +34,7 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -179,6 +180,8 @@ public class ClaimEntity { @JdbcTypeCode(SqlTypes.NAMED_ENUM) private VerticalYesNo isExemptLandlord; + private LocalDateTime claimSubmittedDate; + public void setAsbProhibitedConductEntity(AsbProhibitedConductEntity asbProhibitedConductEntity) { if (this.asbProhibitedConductEntity != null) { this.asbProhibitedConductEntity.setClaim(null); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java index dad941c991..2a8463d67a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/PcsCaseEntity.java @@ -23,7 +23,6 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.respondpossessionclaim.DefendantResponseEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; -import java.time.LocalDateTime; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -63,8 +62,6 @@ public class PcsCaseEntity { private Boolean preActionProtocolCompleted; - private LocalDateTime createdAt; - @OneToOne(mappedBy = "pcsCase", cascade = ALL, orphanRemoval = true) @JsonManagedReference private TenancyLicenceEntity tenancyLicence; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java index b758a4d07b..6e26a840d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java @@ -13,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.ClaimRepository; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.time.LocalDateTime; import java.util.List; @Service @@ -27,9 +28,8 @@ public class ClaimService { private final NoticeOfPossessionService noticeOfPossessionService; private final StatementOfTruthService statementOfTruthService; - public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { - - ClaimEntity claimEntity = buildClaimEntity(pcsCase); + public ClaimEntity createMainClaimEntity(PCSCase pcsCase, LocalDateTime claimSubmittedDate) { + ClaimEntity claimEntity = buildClaimEntity(pcsCase, claimSubmittedDate); List claimGrounds = claimGroundService.createClaimGroundEntities(pcsCase); claimEntity.addClaimGrounds(claimGrounds); @@ -52,7 +52,7 @@ public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { } - private ClaimEntity buildClaimEntity(PCSCase pcsCase) { + private ClaimEntity buildClaimEntity(PCSCase pcsCase, LocalDateTime claimSubmittedDate) { AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); ClaimantCircumstances claimantCircumstances = pcsCase.getClaimantCircumstances(); @@ -87,6 +87,7 @@ private ClaimEntity buildClaimEntity(PCSCase pcsCase) { .genAppExpected(pcsCase.getApplicationWithClaim()) .languageUsed(pcsCase.getLanguageUsed()) .isExemptLandlord(pcsCase.getIsExemptLandlord()) + .claimSubmittedDate(claimSubmittedDate) .build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index e904cd995a..705d1fc2f1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -68,9 +68,8 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); - pcsCaseEntity.setCreatedAt(LocalDateTime.now(ukClock)); - ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase, LocalDateTime.now(ukClock)); List documentEntities = documentService.createAllDocuments(pcsCase); documentEntities.forEach(doc -> doc.setClaim(claimEntity)); pcsCaseEntity.addDocuments(documentEntities); diff --git a/src/main/resources/db/migration/V101__add_claim_submitted_date.sql b/src/main/resources/db/migration/V101__add_claim_submitted_date.sql new file mode 100644 index 0000000000..e1cf546ba9 --- /dev/null +++ b/src/main/resources/db/migration/V101__add_claim_submitted_date.sql @@ -0,0 +1 @@ +ALTER TABLE CLAIM ADD COLUMN claim_submitted_date TIMESTAMP WITH TIME ZONE; diff --git a/src/main/resources/db/migration/V101__add_created_at.sql b/src/main/resources/db/migration/V101__add_created_at.sql deleted file mode 100644 index 5fce3fed69..0000000000 --- a/src/main/resources/db/migration/V101__add_created_at.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE PCS_CASE ADD COLUMN CREATED_AT TIMESTAMP WITH TIME ZONE; 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 96df0cb154..b69d42b49d 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 @@ -213,16 +213,16 @@ void shouldMapLegislativeCountry() { } @Test - void shouldMapDateSubmittedFromCaseCreatedAt() { + void shouldMapDateSubmittedFromClaimSubmittedDate() { // Given - LocalDateTime createdAt = LocalDateTime.of(2026, 5, 12, 14, 30); - when(pcsCaseEntity.getCreatedAt()).thenReturn(createdAt); + LocalDateTime claimSubmittedDate = LocalDateTime.of(2026, 5, 12, 14, 30); + when(claimEntity.getClaimSubmittedDate()).thenReturn(claimSubmittedDate); // When PCSCase pcsCase = underTest.getCase(request(CASE_REFERENCE, DEFAULT_STATE)); // Then - assertThat(pcsCase.getDateSubmitted()).isEqualTo(createdAt); + assertThat(pcsCase.getDateSubmitted()).isEqualTo(claimSubmittedDate); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java index 147493b2c8..133f00be68 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java @@ -27,6 +27,7 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; +import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -42,6 +43,8 @@ @ExtendWith(MockitoExtension.class) class ClaimServiceTest { + private static final LocalDateTime CLAIM_SUBMITTED_DATE = LocalDateTime.of(2026, 5, 18, 12, 30); + @Mock private ClaimRepository claimRepository; @Mock @@ -89,7 +92,7 @@ void shouldCreateMainClaim() { when(claimGroundService.createClaimGroundEntities(pcsCase)).thenReturn(expectedClaimGrounds); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getAgainstTrespassers()).isEqualTo(VerticalYesNo.YES); @@ -110,6 +113,15 @@ void shouldCreateMainClaim() { verify(claimRepository).save(createdClaimEntity); } + @Test + void shouldCreateMainClaimWithClaimSubmittedDate() { + // When + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + + // Then + assertThat(createdClaimEntity.getClaimSubmittedDate()).isEqualTo(CLAIM_SUBMITTED_DATE); + } + @Test void shouldCreateMainClaim_WithAdditionalReasonsWhenPresent() { // Given @@ -119,7 +131,7 @@ void shouldCreateMainClaim_WithAdditionalReasonsWhenPresent() { // When ClaimEntity createdClaimEntity = - claimService.createMainClaimEntity(pcsCase); + claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getAdditionalReasons()) @@ -138,7 +150,7 @@ void shouldCreateMainClaim_WithDefendantCircumstancesDetails() { when(defendantCircumstances.getHasDefendantCircumstancesInfo()).thenReturn(defendantInfoProvided); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getDefendantCircumstances()).isEqualTo(circumstancesInfo); @@ -157,7 +169,7 @@ void shouldCreateMainClaim_WithClaimantCircumstancesDetails() { when(claimantCircumstances.getClaimantCircumstancesDetails()).thenReturn(circumstancesInfo); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getClaimantCircumstances()).isEqualTo(circumstancesInfo); @@ -170,7 +182,7 @@ void shouldCreateMainClaim_WithoutClaimantTypeDetailsWhenNull() { when(pcsCase.getClaimantType()).thenReturn(null); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getClaimantType()).isNull(); @@ -184,7 +196,7 @@ void shouldCreateMainClaim_WithoutClaimantTypeDetailsWhenValueCodeIsNull() { when(pcsCase.getClaimantType()).thenReturn(claimantTypeList); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getClaimantType()).isNull(); @@ -204,7 +216,7 @@ void shouldCreateMainClaim_WithClaimantTypeDetails(ClaimantType claimantType) { when(pcsCase.getClaimantType()).thenReturn(claimantTypeList); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getClaimantType()).isEqualTo(claimantType); @@ -218,7 +230,7 @@ void shouldSetAlternativesToPossession() { .thenReturn(possessionAlternativesEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getPossessionAlternativesEntity()).isEqualTo(possessionAlternativesEntity); @@ -234,7 +246,7 @@ void shouldSetAsbProhibitedConductForWalesProperties() { .thenReturn(asbProhibitedConductEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getAsbProhibitedConductEntity()).isEqualTo(asbProhibitedConductEntity); @@ -246,7 +258,7 @@ void shouldNotSSetAsbProhibitedConductForNonWalesProperties() { when(pcsCase.getLegislativeCountry()).thenReturn(ENGLAND); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getAsbProhibitedConductEntity()).isNull(); @@ -261,7 +273,7 @@ void shouldSetRentArrears() { .thenReturn(rentArrearsEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getRentArrears()).isEqualTo(rentArrearsEntity); @@ -275,7 +287,7 @@ void shouldSetNoticeOfPossession() { .thenReturn(noticeOfPossessionEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getNoticeOfPossession()).isEqualTo(noticeOfPossessionEntity); @@ -289,7 +301,7 @@ void shouldSetStatementOfTruth() { .thenReturn(statementOfTruthEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); // Then assertThat(createdClaimEntity.getStatementOfTruth()).isEqualTo(statementOfTruthEntity); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index 533b245df0..7e1d73f609 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -147,14 +147,14 @@ void shouldDelegateToClaimServiceToCreateMainClaim() { underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); // Then - verify(claimService).createMainClaimEntity(caseData); + verify(claimService).createMainClaimEntity(caseData, FIXED_DATE_TIME); verify(pcsCaseEntity).addClaim(mainClaimEntity); } @Test - void shouldSetCreatedAtUsingUkClockWhenCreatingMainClaim() { + void shouldSetClaimSubmittedDateUsingUkClockWhenCreatingMainClaim() { // Given - PcsCaseEntity pcsCaseEntity = stubFindCase(); + stubFindCase(); stubClaimCreation(); PCSCase caseData = PCSCase.builder().build(); @@ -163,7 +163,7 @@ void shouldSetCreatedAtUsingUkClockWhenCreatingMainClaim() { underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); // Then - verify(pcsCaseEntity).setCreatedAt(FIXED_DATE_TIME); + verify(claimService).createMainClaimEntity(caseData, FIXED_DATE_TIME); } @Test @@ -273,7 +273,7 @@ private PcsCaseEntity stubFindCase() { private ClaimEntity stubClaimCreation() { ClaimEntity claimEntity = mock(ClaimEntity.class); - when(claimService.createMainClaimEntity(any(PCSCase.class))).thenReturn(claimEntity); + when(claimService.createMainClaimEntity(any(PCSCase.class), any(LocalDateTime.class))).thenReturn(claimEntity); return claimEntity; } From f1583f09a92b572e8ad72fe5a6730973a5a9e98b Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 11:49:59 +0100 Subject: [PATCH 059/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7f5c510eef..7bd5db152e 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 @@ -609,6 +609,6 @@ public class PCSCase { private CasePartiesTab casePartiesTab; @JsonUnwrapped(prefix = "summaryTab_") - @CCD + @CCD(searchable = false) private SummaryTab summaryTab; } From cb0a2532c79bf7d7c583ff474682fac90f916d01 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Mon, 18 May 2026 14:39:37 +0100 Subject: [PATCH 060/138] HDPI-2983: build claimant details and move defendant details into shared builder --- .../domain/tabs/details/CaseDetailsTab.java | 4 +- .../details/ClaimantContactTabDetails.java | 25 ++++++ .../pcs/ccd/view/CaseDetailsTabView.java | 78 +++++++++++++++++- .../pcs/ccd/view/CaseSummaryTabView.java | 80 ++----------------- .../reform/pcs/ccd/view/CaseTabView.java | 2 +- ...DefendantInformationTabDetailsBuilder.java | 47 +++++++++++ .../builder/DefendantInformationBuilder.java | 26 ++++++ ...DefendantInformationTabDetailsBuilder.java | 35 ++++++++ 8 files changed, 221 insertions(+), 76 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 9cefdea3f5..4e1ff9e2b4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -83,7 +83,7 @@ public class CaseDetailsTab { @CCD( label = "Claimant contact details" ) - private ClaimantInformationTabDetails claimantContactDetails; + private ClaimantContactTabDetails claimantContactDetails; @CCD( label = "Claimant circumstances" @@ -103,7 +103,7 @@ public class CaseDetailsTab { @CCD( label = "Additional defendant" ) - private AdditionalDefendantInformationTabDetails additionalDefendantDetails; + private List> additionalDefendantDetails; @CCD( label = "Defendant’ circumstances" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java new file mode 100644 index 0000000000..d69182c578 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java @@ -0,0 +1,25 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ClaimantContactTabDetails { + + @CCD ( + label = "Email address for notifications" + ) + private String emailAddress; + + @CCD ( + label = "Contact phone number" + ) + private String phoneNumber; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index ae3d045e79..4250e7125d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -3,12 +3,15 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantContactPreferences; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @@ -18,13 +21,18 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ApplicationsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimantContactTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.AdditionalDefendantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.DefendantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; @@ -49,6 +57,8 @@ public class CaseDetailsTabView { private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; private final ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; private final ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; + private final DefendantInformationTabDetailsBuilder defendantInformationTabDetailsBuilder; + private final AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase); @@ -60,8 +70,10 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = buildReasonsForPossession(pcsCase); ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); + DefendantInformationTabDetails defendantInformationTabDetails = + defendantInformationTabDetailsBuilder.buildDefendantOneDetails(pcsCase); - return CaseDetailsTab.builder() + CaseDetailsTab caseDetailsTab = CaseDetailsTab.builder() .claimDetails(claimTabDetails) .propertyAddress(pcsCase.getPropertyAddress()) .groundsForPossessionDetails(groundsForPossessionTabDetails) @@ -72,7 +84,20 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .reasonsForPossessionDetails(reasonsForPossessionTabDetails) .applicationsDetails(applicationsTabDetails) .claimantInformation(claimantInformationTabDetails) + .defendantInformationDetails(defendantInformationTabDetails) .build(); + + if (claimantInformationTabDetails != null) { + caseDetailsTab.setClaimantAddress(getClaimantAddress(pcsCase)); + caseDetailsTab.setClaimantContactDetails(buildClaimantContactTabDetails(pcsCase)); + } + + if (defendantInformationTabDetails != null) { + List> additionalDefendantInformationTabDetails = + additionalDefendantInformationTabDetailsBuilder.buildAdditionalDefendantsDetails(pcsCase); + caseDetailsTab.setAdditionalDefendantDetails(additionalDefendantInformationTabDetails); + } + return caseDetailsTab; } private ClaimTabDetails buildClaimTabDetails(PCSCase pcsCase) { @@ -252,4 +277,55 @@ private ApplicationsTabDetails buildApplicationsTabDetails(PCSCase pcsCase) { private ClaimantInformationTabDetails buildClaimantInformationTabDetails(PCSCase pcsCase) { return claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); } + + private AddressUK getClaimantAddress(PCSCase pcsCase) { + List> claimants = pcsCase.getAllClaimants(); + if (!CollectionUtils.isEmpty(claimants)) { + Party claimant = claimants.getFirst().getValue(); + return claimant.getAddress(); + } + + ClaimantContactPreferences claimantContactPreferences = pcsCase.getClaimantContactPreferences(); + if (claimantContactPreferences != null ) { + YesOrNo orgAddressFound = claimantContactPreferences.getOrgAddressFound(); + VerticalYesNo correctClaimantAddress = claimantContactPreferences.getIsCorrectClaimantContactAddress(); + if (orgAddressFound == YesOrNo.YES && correctClaimantAddress == VerticalYesNo.YES) { + return claimantContactPreferences.getOrganisationAddress(); + } + + return claimantContactPreferences.getOverriddenClaimantContactAddress(); + } + + return AddressUK.builder() + .addressLine1(NO_ANSWER) + .postTown(NO_ANSWER) + .postCode(NO_ANSWER) + .country(NO_ANSWER) + .build(); + } + + private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase) { + List> claimants = pcsCase.getAllClaimants(); + ClaimantContactPreferences claimantContactPreferences = pcsCase.getClaimantContactPreferences(); + String emailAddress = null; + String phoneNumber = null; + + if (!CollectionUtils.isEmpty(claimants)) { + Party claimant = claimants.getFirst().getValue(); + emailAddress = claimant.getEmailAddress(); + phoneNumber = claimant.getPhoneNumber(); + } else if (claimantContactPreferences != null) { + VerticalYesNo isCorrectClaimantContactEmail = claimantContactPreferences.getIsCorrectClaimantContactEmail(); + emailAddress = isCorrectClaimantContactEmail == VerticalYesNo.YES ? + claimantContactPreferences.getClaimantContactEmail() : + claimantContactPreferences.getOverriddenClaimantContactEmail(); + phoneNumber = claimantContactPreferences.getClaimantContactPhoneNumber(); + } + + + return ClaimantContactTabDetails.builder() + .emailAddress(emailAddress != null ? emailAddress : NO_ANSWER) + .phoneNumber(phoneNumber != null ? phoneNumber : NO_ANSWER) + .build(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index fc12e127d1..964838c0ca 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -23,7 +23,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.AdditionalDefendantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.DefendantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; @@ -47,6 +49,8 @@ public class CaseSummaryTabView { private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; private final ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; private final ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; + private final DefendantInformationTabDetailsBuilder defendantInformationTabDetailsBuilder; + private final AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = @@ -61,8 +65,10 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { .reasonsForPossession(reasonsForPossession) .dateClaimSubmitted(dateSubmitted) .claimantDetails(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)) - .defendantDetails(createSummaryDefendantOneDetails(pcsCase)) - .additionalDefendants(createAdditionalSummaryDefendantsDetails(pcsCase)) + .defendantDetails(defendantInformationTabDetailsBuilder.buildDefendantOneDetails(pcsCase)) + .additionalDefendants( + additionalDefendantInformationTabDetailsBuilder.buildAdditionalDefendantsDetails(pcsCase) + ) .rentArrearsDetails(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)) .tenancyDetails(buildTenancyTabDetails(pcsCase)) .noticeDetails(buildNoticeTabDetails(pcsCase)) @@ -77,76 +83,6 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); } - private DefendantInformationTabDetails createSummaryDefendantOneDetails(PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { - return null; - } - - return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); - } - - private List> createAdditionalSummaryDefendantsDetails( - PCSCase pcsCase) { - if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { - return null; - } - - return pcsCase.getAllDefendants().stream() - .skip(1) - .map(ListValue::getValue) - .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) - .filter(defendantDetails -> defendantDetails != null) - .map(defendantDetails -> ListValue.builder() - .value(defendantDetails) - .build()) - .toList(); - } - - private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, - PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return AdditionalDefendantInformationTabDetails.builder() - .firstName(getDefendantFirstName(defendant)) - .lastName(getDefendantLastName(defendant)) - .addressForService(addressForService) - .build(); - } - - private DefendantInformationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); - - if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { - return null; - } - - return DefendantInformationTabDetails.builder() - .firstName(getDefendantFirstName(defendant)) - .lastName(getDefendantLastName(defendant)) - .addressForService(addressForService) - .build(); - } - - private String getDefendantFirstName(Party defendant) { - return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : CaseTabView.NAME_UNKNOWN; - } - - private String getDefendantLastName(Party defendant) { - return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : CaseTabView.NAME_UNKNOWN; - } - - private AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { - if (defendant.getAddressKnown() != VerticalYesNo.YES) { - return pcsCase.getPropertyAddress(); - } - - return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); - } - private TenancyTabDetails buildTenancyTabDetails(PCSCase pcsCase) { TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); OccupationLicenceDetailsWales occupationLicenceDetailsWales = pcsCase.getOccupationLicenceDetailsWales(); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index b500a6c155..7d077013a4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -24,7 +24,7 @@ @AllArgsConstructor public class CaseTabView { - static final String NAME_UNKNOWN = "Person unknown"; + public static final String NAME_UNKNOWN = "Person unknown"; private final ClaimGroundSummaryBuilder claimGroundSummaryBuilder; private final CaseSummaryTabView caseSummaryTabView; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java new file mode 100644 index 0000000000..a31d8e0138 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java @@ -0,0 +1,47 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; + +import java.util.List; + +@Component +public class AdditionalDefendantInformationTabDetailsBuilder extends DefendantInformationBuilder { + public List> buildAdditionalDefendantsDetails( + PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, + PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java new file mode 100644 index 0000000000..7baebb8f2b --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java @@ -0,0 +1,26 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + + +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.view.CaseTabView; + +public class DefendantInformationBuilder { + protected AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + if (defendant.getAddressKnown() != VerticalYesNo.YES) { + return pcsCase.getPropertyAddress(); + } + + return defendant.getAddress() != null ? defendant.getAddress() : pcsCase.getPropertyAddress(); + } + + protected String getDefendantFirstName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getFirstName() : CaseTabView.NAME_UNKNOWN; + } + + protected String getDefendantLastName(Party defendant) { + return defendant.getNameKnown() == VerticalYesNo.YES ? defendant.getLastName() : CaseTabView.NAME_UNKNOWN; + } +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java new file mode 100644 index 0000000000..460b6e3561 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java @@ -0,0 +1,35 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; + +@Component +public class DefendantInformationTabDetailsBuilder extends DefendantInformationBuilder { + + public DefendantInformationTabDetails buildDefendantOneDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + + private DefendantInformationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { + AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + + if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { + return null; + } + + return DefendantInformationTabDetails.builder() + .firstName(getDefendantFirstName(defendant)) + .lastName(getDefendantLastName(defendant)) + .addressForService(addressForService) + .build(); + } +} From 08b090e1bd0b403b133bfef3d25f4dde44ed5ec3 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 15:22:40 +0100 Subject: [PATCH 061/138] HDPI-2978: Build Case Summary tab --- .../service/DefendantResponseServiceTest.java | 7 +- .../reform/pcs/ccd/view/CaseTabViewTest.java | 98 +++++++++++++++++++ 2 files changed, 101 insertions(+), 4 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java index 72b311a055..1377c4bbe4 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DefendantResponseServiceTest.java @@ -102,13 +102,12 @@ class DefendantResponseServiceTest { @Captor private ArgumentCaptor counterClaimCaptor; - private static final Clock FIXED_UTC_CLOCK = Clock.fixed( - Instant.parse("2026-04-22T21:00:00Z"), ZoneOffset.UTC); - private DefendantResponseService underTest; @BeforeEach void setUp() { + Clock fixedUtcClock = Clock.fixed(Instant.parse("2026-04-22T21:00:00Z"), ZoneOffset.UTC); + underTest = new DefendantResponseService( partyService, partyRepository, @@ -119,7 +118,7 @@ void setUp() { householdCircumstancesService, paymentAgreementService, documentService, - FIXED_UTC_CLOCK + fixedUtcClock ); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index be5b4d5ec2..fd96d71b3f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -348,6 +348,104 @@ void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { assertThat(draftCaseData.getAllDefendants()).hasSize(2); } + @Test + void shouldSetDraftDefendantWhenNoAdditionalDefendantHasBeenSelected() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("M1 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(propertyAddress) + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Single") + .lastName("Defendant") + .addressKnown(VerticalYesNo.YES) + .correspondenceAddress(defendantAddress) + .build()) + .addAnotherDefendant(VerticalYesNo.NO) + .build(); + + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + assertThat(draftCaseData.getAllDefendants()).hasSize(1); + Party defendant = draftCaseData.getAllDefendants().getFirst().getValue(); + assertThat(defendant.getNameKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(defendant.getFirstName()).isEqualTo("Single"); + assertThat(defendant.getLastName()).isEqualTo("Defendant"); + assertThat(defendant.getAddressKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(defendant.getAddress()).isEqualTo(defendantAddress); + assertThat(pcsCase.getSummaryTab().getAdditionalDefendants()).isNull(); + } + + @Test + void shouldNotSetAdditionalDraftDefendantsWhenAdditionalDefendantListIsEmpty() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(propertyAddress) + .defendant1(DefendantDetails.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Only") + .lastName("Defendant") + .addressKnown(VerticalYesNo.NO) + .build()) + .addAnotherDefendant(VerticalYesNo.YES) + .additionalDefendants(List.of()) + .build(); + + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + assertThat(draftCaseData.getAllDefendants()).hasSize(1); + assertThat(pcsCase.getSummaryTab().getDefendantDetails().getFirstName()).isEqualTo("Only"); + assertThat(pcsCase.getSummaryTab().getDefendantDetails().getLastName()).isEqualTo("Defendant"); + assertThat(pcsCase.getSummaryTab().getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(pcsCase.getSummaryTab().getAdditionalDefendants()).isNull(); + } + + @Test + void shouldNotOverwriteExistingDraftDefendantsWhenDefendantOneIsMissing() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + List> existingDefendants = List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Existing") + .lastName("Defendant") + .build()) + ); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + PCSCase draftCaseData = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(existingDefendants) + .build(); + + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + assertThat(draftCaseData.getAllDefendants()).isSameAs(existingDefendants); + assertThat(pcsCase.getSummaryTab().getDefendantDetails().getFirstName()).isEqualTo("Existing"); + assertThat(pcsCase.getSummaryTab().getDefendantDetails().getLastName()).isEqualTo("Defendant"); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From fbb6127871269750445e8166fd1471315174fbb8 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 16:10:35 +0100 Subject: [PATCH 062/138] HDPI-2978: Build Case Summary tab --- .../ccd/domain/tabs/summary/SummaryTab.java | 40 +++++-------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index c4a0ed8ccc..8ae40a822e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -23,54 +23,34 @@ @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) public class SummaryTab { - @CCD( - label = "Address of property to be repossessed" - ) + @CCD(label = "Address of property to be repossessed") private AddressUK repossessedPropertyAddress; - @CCD( - label = "Grounds for possession" - ) + @CCD(label = "Grounds for possession") private GroundsForPossessionTabDetails groundsForPossession; - @CCD( - label = "Reasons for possession" - ) + @CCD(label = "Reasons for possession") private ReasonsForPossessionTabDetails reasonsForPossession; - @CCD( - label = "Date claim Submitted" - ) + @CCD(label = "Date claim Submitted") private String dateClaimSubmitted; - @CCD( - label = "Claimant" - ) + @CCD(label = "Claimant") private ClaimantInformationTabDetails claimantDetails; - @CCD( - label = "Defendant 1" - ) + @CCD(label = "Defendant 1") private DefendantInformationTabDetails defendantDetails; - @CCD( - label = "Additional defendant" - ) + @CCD(label = "Additional defendant") private List> additionalDefendants; - @CCD( - label = "Details of rent arrears" - ) + @CCD(label = "Details of rent arrears") private RentArrearsTabDetails rentArrearsDetails; - @CCD( - label = "Tenancy, occupation contract or licence details" - ) + @CCD(label = "Tenancy, occupation contract or licence details") private TenancyTabDetails tenancyDetails; - @CCD( - label = "Notice details" - ) + @CCD(label = "Notice details") private NoticeTabDetails noticeDetails; } From aeea08433748c656c5edbda6b7b0819ab91d3cff Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Mon, 18 May 2026 16:44:27 +0100 Subject: [PATCH 063/138] HDPI-2978: Build Case Summary tab --- .../reform/pcs/ccd/service/PcsCaseService.java | 8 ++++---- .../reform/pcs/ccd/view/CaseSummaryTabView.java | 9 ++++++++- .../pcs/ccd/service/PcsCaseServiceTest.java | 13 ++++++------- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 16 +++++++++++++++- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index 705d1fc2f1..0ee90a6da1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -31,7 +31,7 @@ public class PcsCaseService { private final TenancyLicenceService tenancyLicenceService; private final AddressMapper addressMapper; private final CaseLinkService caseLinkService; - private final Clock ukClock; + private final Clock utcClock; public PcsCaseService(PcsCaseRepository pcsCaseRepository, ClaimService claimService, @@ -40,7 +40,7 @@ public PcsCaseService(PcsCaseRepository pcsCaseRepository, TenancyLicenceService tenancyLicenceService, AddressMapper addressMapper, CaseLinkService caseLinkService, - @Qualifier("ukClock") Clock ukClock) { + @Qualifier("utcClock") Clock utcClock) { this.pcsCaseRepository = pcsCaseRepository; this.claimService = claimService; this.partyService = partyService; @@ -48,7 +48,7 @@ public PcsCaseService(PcsCaseRepository pcsCaseRepository, this.tenancyLicenceService = tenancyLicenceService; this.addressMapper = addressMapper; this.caseLinkService = caseLinkService; - this.ukClock = ukClock; + this.utcClock = utcClock; } public PcsCaseEntity createCase(long caseReference, @@ -69,7 +69,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); - ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase, LocalDateTime.now(ukClock)); + ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase, LocalDateTime.now(utcClock)); List documentEntities = documentService.createAllDocuments(pcsCase); documentEntities.forEach(doc -> doc.setClaim(claimEntity)); pcsCaseEntity.addDocuments(documentEntities); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 2a94d3a453..e0dfb559d8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -31,6 +31,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -39,6 +40,7 @@ import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; +import static uk.gov.hmcts.reform.pcs.config.ClockConfiguration.UK_ZONE_ID; @Component public class CaseSummaryTabView { @@ -132,7 +134,12 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return null; } - return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + return dateSubmitted + .atZone(ZoneOffset.UTC) + .withZoneSameInstant(UK_ZONE_ID) + .format(SUBMITTED_DATE_FORMATTER) + .replace("am", "AM") + .replace("pm", "PM"); } private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index 7e1d73f609..6adc4eab18 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -29,7 +29,7 @@ import java.time.Clock; import java.time.LocalDateTime; -import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -46,11 +46,10 @@ class PcsCaseServiceTest { private static final long CASE_REFERENCE = 1234L; - private static final ZoneId UK_ZONE_ID = ZoneId.of("Europe/London"); private static final LocalDateTime FIXED_DATE_TIME = LocalDateTime.of(2026, 5, 14, 10, 30); - private static final Clock FIXED_UK_CLOCK = Clock.fixed( - FIXED_DATE_TIME.atZone(UK_ZONE_ID).toInstant(), - UK_ZONE_ID + private static final Clock FIXED_UTC_CLOCK = Clock.fixed( + FIXED_DATE_TIME.atZone(ZoneOffset.UTC).toInstant(), + ZoneOffset.UTC ); @Mock @@ -84,7 +83,7 @@ void setUp() { tenancyLicenceService, addressMapper, caseLinkService, - FIXED_UK_CLOCK + FIXED_UTC_CLOCK ); } @@ -152,7 +151,7 @@ void shouldDelegateToClaimServiceToCreateMainClaim() { } @Test - void shouldSetClaimSubmittedDateUsingUkClockWhenCreatingMainClaim() { + void shouldSetClaimSubmittedDateUsingUtcClockWhenCreatingMainClaim() { // Given stubFindCase(); stubClaimCreation(); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 5a0f05c343..20c6fc6b13 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -120,7 +120,7 @@ void shouldSetSummaryTabFields() { .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 6:02:31PM"); assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); @@ -146,6 +146,20 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); } + @Test + void shouldDisplaySubmittedDateInGmtWhenNotBritishSummerTime() { + // Given + PCSCase pcsCase = PCSCase.builder() + .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); + } + @Test void shouldSetSummaryClaimantNameFromOverriddenName() { // Given From 69ba8a88e65f2492eb9cc35cbd6f584f9aebbfb2 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Mon, 18 May 2026 22:01:58 +0100 Subject: [PATCH 064/138] HDPI-2983: build mortgage, suspension of right to buy and demotion of tenancy vies in case details tab --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 54 ++++-- .../hmcts/reform/pcs/ccd/domain/PCSCase.java | 2 +- .../domain/tabs/details/CaseDetailsTab.java | 7 +- .../domain/tabs/details/CostsTabDetails.java | 19 ++ .../SuspensionOfRightToBuyTabDetails.java | 2 +- ...lesseeOrMortgageInformationTabDetails.java | 13 +- .../pcs/ccd/view/CaseDetailsTabView.java | 171 ++++++++++++++++-- .../reform/pcs/ccd/view/CaseTabView.java | 70 +++++++ 8 files changed, 311 insertions(+), 27 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.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 b2b57e8ae1..a49b022294 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 @@ -158,21 +158,51 @@ private void buildSummaryTab(ConfigBuilder builder) { private void buildCaseDetailsTab(ConfigBuilder builder) { builder.tab("caseDetails", "Case Details") .label("Case details", null, "### Case details") - .field("caseDetailsTab_ClaimDetails") - .field("caseDetailsTab_PropertyAddress") - .field("caseDetailsTab_GroundsForPossessionDetails") - .field("caseDetailsTab_TenancyLicenceDetails") - .field("caseDetailsTab_NoticeDetails") - .field("caseDetailsTab_ActionsTakenDetails") - .field("caseDetailsTab_RentArrearsDetails") - .label("Claimant Details", null, "### Claimant Details") - .label("Defendant Details", null, "### Defendant Details") + .field("detailsTab_ClaimDetails") + .field("detailsTab_PropertyAddress") + .field("detailsTab_GroundsForPossessionDetails") + .field("detailsTab_TenancyLicenceDetails") + .field("detailsTab_NoticeDetails") + .field("detailsTab_ActionsTakenDetails") + .field("detailsTab_RentArrearsDetails") + .field("detailsTab_CostsDetails") + .field("detailsTab_ReasonsForPossessionDetails") + .field("detailsTab_ApplicationsDetails") + .label( + "Claimant Details", + "detailsTab_ClaimantInformation!=\"\"", + "### Claimant Details" + ) + .field("detailsTab_ClaimantInformation") + .field("detailsTab_ClaimantAddress") + .field("detailsTab_ClaimantContactDetails") + .field("detailsTab_ClaimantCircumstances") + .label( + "Defendant Details", + "detailsTab_DefendantInformationDetails!=\"\"", + "### Defendant Details" + ) + .field("detailsTab_DefendantInformationDetails") + .field("detailsTab_DefendantOneAddress") + .field("detailsTab_AdditionalDefendants") + .field("detailsTab_DefendantCircumstanceDetails") .label( "Underlessee or mortgagee", - null, + "detailsTab_MortgageDetails!=\"\"", "### Underlessee or mortgagee entitled to claim relief against forfeiture" ) - .label("Demotion of tenancy", null, "### Demotion of tenancy") - .label("Suspension of right to buy", null, "### Suspension of right to buy"); + .field("detailsTab_MortgageDetails") + .label( + "Demotion of tenancy", + "detailsTab_DemotionOfTenancyDetails!=\"\"", + "### Demotion of tenancy" + ) + .field("detailsTab_DemotionOfTenancyDetails") + .label( + "Suspension of right to buy", + "detailsTab_SuspensionOfRightToBuyDetails!=\"\"", + "### Suspension of right to buy" + ) + .field("detailsTab_SuspensionOfRightToBuyDetails"); } } 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 15d7d5e7da..41a2ccd004 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 @@ -613,7 +613,7 @@ public class PCSCase { @CCD private SummaryTab summaryTab; - @JsonUnwrapped(prefix = "caseDetailsTab_") + @JsonUnwrapped(prefix = "detailsTab_") @CCD private CaseDetailsTab caseDetailsTab; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 4e1ff9e2b4..33b8fb0d6e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -60,6 +60,11 @@ public class CaseDetailsTab { ) private RentArrearsTabDetails rentArrearsDetails; + @CCD( + label = "Costs" + ) + private CostsTabDetails costsDetails; + @CCD( label = "Reasons for possession" ) @@ -103,7 +108,7 @@ public class CaseDetailsTab { @CCD( label = "Additional defendant" ) - private List> additionalDefendantDetails; + private List> additionalDefendants; @CCD( label = "Defendant’ circumstances" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java new file mode 100644 index 0000000000..67d8753578 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java @@ -0,0 +1,19 @@ +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import uk.gov.hmcts.ccd.sdk.api.CCD; + +@Builder +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CostsTabDetails { + + @CCD( + label = "Asking for costs back?" + ) + private String askingForCosts; +} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java index 1a80819f5c..4543248063 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java @@ -15,7 +15,7 @@ public class SuspensionOfRightToBuyTabDetails { @CCD( label = "Section of the Housing Act suspension of right to buy claim made under" ) - private String section; + private String housingAct; @CCD( label = "Reasons for requesting suspension of right to buy order" diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index 82482e1daf..07e4dec3bb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import uk.gov.hmcts.ccd.sdk.api.CCD; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; @Builder @Data @@ -13,7 +14,7 @@ public class UnderlesseeOrMortgageInformationTabDetails { @CCD( - label = "Underlessee or mortgagee’s address for service known?" + label = "Underlessee or mortgagee’s address for name known?" ) private String nameKnown; @@ -21,4 +22,14 @@ public class UnderlesseeOrMortgageInformationTabDetails { label = "Name" ) private String name; + + @CCD( + label = "Underlessee or mortgagee’s address for service known?" + ) + private String addressKnown; + + @CCD( + label = "Underlessee or mortgagee correspondence address" + ) + private AddressUK address; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 4250e7125d..0453f516cf 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -6,12 +6,18 @@ import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantContactPreferences; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantCircumstances; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancy; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.SuspensionOfRightToBuy; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; @@ -22,8 +28,13 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimantContactTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CostsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DefendantCircumstanceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DemotionOfTenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.SuspensionOfRightToBuyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.UnderlesseeOrMortgageInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; @@ -41,7 +52,10 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Set; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.DEMOTED_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.INTRODUCTORY_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.OTHER; @@ -67,11 +81,17 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); + CostsTabDetails costsTabDetails = buildCostsTabDetails(pcsCase); ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = buildReasonsForPossession(pcsCase); ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder.buildDefendantOneDetails(pcsCase); + List> underlesseeMortgageTabDetailsList = + buildUnderlesseeMortgageTabDetailsList(pcsCase); + DemotionOfTenancyTabDetails demotionOfTenancyTabDetails = buildDemotionOfTenancyTabDetails(pcsCase); + SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyTabDetails = + buildSuspensionOfRightToBuyTabDetails(pcsCase); CaseDetailsTab caseDetailsTab = CaseDetailsTab.builder() .claimDetails(claimTabDetails) @@ -81,10 +101,14 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .noticeDetails(noticeTabDetails) .actionsTakenDetails(actionsTakenTabDetails) .rentArrearsDetails(rentArrearsTabDetails) + .costsDetails(costsTabDetails) .reasonsForPossessionDetails(reasonsForPossessionTabDetails) .applicationsDetails(applicationsTabDetails) .claimantInformation(claimantInformationTabDetails) .defendantInformationDetails(defendantInformationTabDetails) + .mortgageDetails(underlesseeMortgageTabDetailsList) + .demotionOfTenancyDetails(demotionOfTenancyTabDetails) + .suspensionOfRightToBuyDetails(suspensionOfRightToBuyTabDetails) .build(); if (claimantInformationTabDetails != null) { @@ -95,7 +119,8 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { if (defendantInformationTabDetails != null) { List> additionalDefendantInformationTabDetails = additionalDefendantInformationTabDetailsBuilder.buildAdditionalDefendantsDetails(pcsCase); - caseDetailsTab.setAdditionalDefendantDetails(additionalDefendantInformationTabDetails); + caseDetailsTab.setAdditionalDefendants(additionalDefendantInformationTabDetails); + caseDetailsTab.setDefendantCircumstanceDetails(buildDefendantCircumstanceTabDetails(pcsCase)); } return caseDetailsTab; } @@ -175,14 +200,15 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { .build(); } + YesOrNo noticeServed = pcsCase.getNoticeServed(); NoticeTabDetails noticeTabDetails = NoticeTabDetails.builder() - .noticeServed(pcsCase.getNoticeServed().getValue()) + .noticeServed(noticeServed.getValue()) .noticeMethod(NO_ANSWER) .noticeDate(NO_ANSWER) .build(); NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); - if (noticeTabDetails != null) { + if (noticeServed == YesOrNo.YES && noticeTabDetails != null) { NoticeServiceMethod method = noticeServedDetails.getNoticeServiceMethod(); noticeTabDetails.setNoticeDocuments(noticeServedDetails.getNoticeDocuments()); @@ -260,6 +286,13 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { return rentArrearsTabDetails; } + private CostsTabDetails buildCostsTabDetails(PCSCase pcsCase) { + VerticalYesNo claimingCostsWanted = pcsCase.getClaimingCostsWanted(); + return CostsTabDetails.builder() + .askingForCosts(claimingCostsWanted != null ? claimingCostsWanted.getLabel() : NO_ANSWER) + .build(); + } + private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { return reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); } @@ -280,20 +313,24 @@ private ClaimantInformationTabDetails buildClaimantInformationTabDetails(PCSCase private AddressUK getClaimantAddress(PCSCase pcsCase) { List> claimants = pcsCase.getAllClaimants(); + ClaimantContactPreferences claimantContactPreferences = pcsCase.getClaimantContactPreferences(); + AddressUK address = null; + if (!CollectionUtils.isEmpty(claimants)) { Party claimant = claimants.getFirst().getValue(); - return claimant.getAddress(); - } - - ClaimantContactPreferences claimantContactPreferences = pcsCase.getClaimantContactPreferences(); - if (claimantContactPreferences != null ) { + address = claimant.getAddress(); + } else if (claimantContactPreferences != null ) { YesOrNo orgAddressFound = claimantContactPreferences.getOrgAddressFound(); VerticalYesNo correctClaimantAddress = claimantContactPreferences.getIsCorrectClaimantContactAddress(); if (orgAddressFound == YesOrNo.YES && correctClaimantAddress == VerticalYesNo.YES) { - return claimantContactPreferences.getOrganisationAddress(); + address = claimantContactPreferences.getOrganisationAddress(); + } else { + address = claimantContactPreferences.getOverriddenClaimantContactAddress(); } + } - return claimantContactPreferences.getOverriddenClaimantContactAddress(); + if (address != null) { + return address; } return AddressUK.builder() @@ -319,7 +356,9 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase emailAddress = isCorrectClaimantContactEmail == VerticalYesNo.YES ? claimantContactPreferences.getClaimantContactEmail() : claimantContactPreferences.getOverriddenClaimantContactEmail(); - phoneNumber = claimantContactPreferences.getClaimantContactPhoneNumber(); + if (claimantContactPreferences.getClaimantProvidePhoneNumber() == VerticalYesNo.YES) { + phoneNumber = claimantContactPreferences.getClaimantContactPhoneNumber(); + } } @@ -328,4 +367,114 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase .phoneNumber(phoneNumber != null ? phoneNumber : NO_ANSWER) .build(); } + + private DefendantCircumstanceTabDetails buildDefendantCircumstanceTabDetails(PCSCase pcsCase) { + DefendantCircumstances defendantCircumstances = pcsCase.getDefendantCircumstances(); + String circumstances = null; + VerticalYesNo circumstancesGiven = null; + + if (defendantCircumstances != null) { + circumstancesGiven = defendantCircumstances.getHasDefendantCircumstancesInfo(); + circumstances = defendantCircumstances.getDefendantCircumstancesInfo(); + } + + + return DefendantCircumstanceTabDetails.builder() + .defendantCircumstancesGiven(circumstancesGiven != null ? circumstancesGiven.getLabel() : NO_ANSWER) + .defendantCircumstances(circumstances) + .build(); + } + + private List> buildUnderlesseeMortgageTabDetailsList( + PCSCase pcsCase + ) { + List> underlesseeMortgageParties = pcsCase.getAllUnderlesseeOrMortgagees(); + if (CollectionUtils.isEmpty(underlesseeMortgageParties)) { + return null; + } + + return underlesseeMortgageParties.stream() + .map(this::buildUnderlesseeMortgageTabDetails) + .toList(); + } + + private ListValue buildUnderlesseeMortgageTabDetails( + ListValue underlesseeMortgageePartyListValue + ) { + Party underlesseeMortgageeParty = underlesseeMortgageePartyListValue.getValue(); + VerticalYesNo nameKnown = underlesseeMortgageeParty.getNameKnown(); + String name = nameKnown == VerticalYesNo.YES ? underlesseeMortgageeParty.getOrgName() : null; + VerticalYesNo addressKnown = underlesseeMortgageeParty.getAddressKnown(); + AddressUK address = addressKnown == VerticalYesNo.YES ? underlesseeMortgageeParty.getAddress() : null; + + return ListValue.builder() + .value(UnderlesseeOrMortgageInformationTabDetails.builder() + .nameKnown(nameKnown.getLabel()) + .name(name) + .addressKnown(addressKnown.getLabel()) + .address(address) + .build()) + .build(); + } + + private DemotionOfTenancyTabDetails buildDemotionOfTenancyTabDetails(PCSCase pcsCase) { + Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); + + if ( + CollectionUtils.isEmpty(alternativesToPossessionSet) || + !alternativesToPossessionSet.contains(DEMOTION_OF_TENANCY) + ) { + return null; + } + + DemotionOfTenancy demotionOfTenancy = pcsCase.getDemotionOfTenancy(); + if (demotionOfTenancy == null) { + return DemotionOfTenancyTabDetails.builder() + .housingAct(NO_ANSWER) + .statementOfExpressTermsServed(NO_ANSWER) + .reasons(NO_ANSWER) + .build(); + } + + DemotionOfTenancyHousingAct housingAct = demotionOfTenancy.getHousingAct(); + VerticalYesNo statementOfExpressTermsServed = demotionOfTenancy.getStatementOfExpressTermsServed(); + String statementOfExpressTermsDetails = null; + + if (statementOfExpressTermsServed == VerticalYesNo.YES) { + statementOfExpressTermsDetails = demotionOfTenancy.getStatementOfExpressTermsDetails(); + } + String reason = demotionOfTenancy.getReason(); + + return DemotionOfTenancyTabDetails.builder() + .housingAct(housingAct != null ? housingAct.getLabel() : NO_ANSWER) + .statementOfExpressTermsServed( + statementOfExpressTermsServed != null ? statementOfExpressTermsServed.getLabel() : NO_ANSWER + ) + .terms(statementOfExpressTermsDetails) + .reasons(reason != null ? reason : NO_ANSWER) + .build(); + } + + private SuspensionOfRightToBuyTabDetails buildSuspensionOfRightToBuyTabDetails(PCSCase pcsCase) { + Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); + if (!alternativesToPossessionSet.contains(SUSPENSION_OF_RIGHT_TO_BUY)) { + return null; + } + + SuspensionOfRightToBuy suspensionOfRightToBuyDemotionOfTenancy = pcsCase.getSuspensionOfRightToBuy(); + if (suspensionOfRightToBuyDemotionOfTenancy == null) { + return SuspensionOfRightToBuyTabDetails.builder() + .housingAct(NO_ANSWER) + .reasons(NO_ANSWER) + .build(); + } + + SuspensionOfRightToBuyHousingAct housingAct = suspensionOfRightToBuyDemotionOfTenancy.getHousingAct(); + String reason = suspensionOfRightToBuyDemotionOfTenancy.getReason(); + + return SuspensionOfRightToBuyTabDetails.builder() + .housingAct(housingAct != null ? housingAct.getLabel() : NO_ANSWER) + .reasons(reason != null ? reason : NO_ANSWER) + .build(); + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 7d077013a4..18aade55b4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -5,9 +5,14 @@ import org.springframework.util.CollectionUtils; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancy; 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.SuspensionOfRightToBuy; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyDemotionOfTenancy; +import uk.gov.hmcts.reform.pcs.ccd.domain.UnderlesseeMortgageeDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.CasePartiesTab; @@ -19,6 +24,10 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; + +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; @Component @AllArgsConstructor @@ -53,6 +62,25 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { draftCaseData.setAllDefendants(pcsCase.getAllDefendants()); } + if (CollectionUtils.isEmpty(draftCaseData.getAllUnderlesseeOrMortgagees())) { + draftCaseData.setAllUnderlesseeOrMortgagees(buildUnderlesseeOrMortgageParties(draftCaseData)); + } + + Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy = + pcsCase.getSuspensionOfRightToBuyDemotionOfTenancy(); + + if ( + suspensionOfRightToBuyDemotionOfTenancy != null && + !CollectionUtils.isEmpty(alternativesToPossessionSet) && + alternativesToPossessionSet.containsAll(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) + ) { + draftCaseData.setDemotionOfTenancy(buildDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy)); + draftCaseData.setSuspensionOfRightToBuy( + buildSuspensionOfRightToBuyHousingAct(suspensionOfRightToBuyDemotionOfTenancy) + ); + } + List> draftGrounds = claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); draftCaseData.setClaimGroundSummaries(CollectionUtils.isEmpty(draftGrounds) @@ -91,6 +119,48 @@ private ListValue buildDefendant(DefendantDetails defendant) { .build(); } + private List> buildUnderlesseeOrMortgageParties(PCSCase draftCaseData) { + UnderlesseeMortgageeDetails underlesseeOrMortgagee1 = draftCaseData.getUnderlesseeOrMortgagee1(); + + if (underlesseeOrMortgagee1 == null) { + return null; + } + + List> underlesseeMortgageParties = new ArrayList<>(); + underlesseeMortgageParties.add(buildUnderlesseeOrMortgageParty(underlesseeOrMortgagee1)); + + return underlesseeMortgageParties; + } + + private ListValue buildUnderlesseeOrMortgageParty(UnderlesseeMortgageeDetails underlesseeMortgageeDetails) { + return ListValue.builder() + .value(Party.builder() + .nameKnown(underlesseeMortgageeDetails.getNameKnown()) + .orgName(underlesseeMortgageeDetails.getName()) + .addressKnown(underlesseeMortgageeDetails.getAddressKnown()) + .address(underlesseeMortgageeDetails.getAddress()) + .build()) + .build(); + } + + private DemotionOfTenancy buildDemotionOfTenancy( + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy + ) { + return DemotionOfTenancy.builder() + .housingAct(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOfTenancyActs()) + .reason(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOrderReason()) + .build(); + } + + private SuspensionOfRightToBuy buildSuspensionOfRightToBuyHousingAct( + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy + ) { + return SuspensionOfRightToBuy.builder() + .housingAct(suspensionOfRightToBuyDemotionOfTenancy.getSuspensionOfRightToBuyActs()) + .reason(suspensionOfRightToBuyDemotionOfTenancy.getSuspensionOrderReason()) + .build(); + } + private CasePartiesTab buildCasePartiesTab(PCSCase pcsCase) { CasePartiesTab tab = CasePartiesTab.builder().build(); From c751ab339a1cf57fcd6b5f441251cab3e7f00c07 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 08:40:50 +0100 Subject: [PATCH 065/138] HDPI-2983: add extra details for defendants tab details for case details tab --- ...itionalDefendantInformationTabDetails.java | 10 ++++ .../DefendantInformationTabDetails.java | 10 ++++ .../pcs/ccd/view/CaseDetailsTabView.java | 4 +- .../pcs/ccd/view/CaseSummaryTabView.java | 17 +------ ...DefendantInformationTabDetailsBuilder.java | 47 +++++++++++++++++-- .../builder/DefendantInformationBuilder.java | 2 +- ...DefendantInformationTabDetailsBuilder.java | 34 +++++++++++++- 7 files changed, 101 insertions(+), 23 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index 22e1a5b870..f29eca1419 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -13,6 +13,11 @@ @AllArgsConstructor public class AdditionalDefendantInformationTabDetails { + @CCD( + label = "Additional defendant's name known?" + ) + private String nameKnown; + @CCD( label = "First name" ) @@ -23,6 +28,11 @@ public class AdditionalDefendantInformationTabDetails { ) private String lastName; + @CCD( + label = "Additional defendant's correspondence address known" + ) + private String addressKnown; + @CCD( label = "Additional defendant address for service" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index 216d0d5eb6..8daa7d17a0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -13,6 +13,11 @@ @AllArgsConstructor public class DefendantInformationTabDetails { + @CCD( + label = "Defendant 1's name known?" + ) + private String nameKnown; + @CCD( label = "First name" ) @@ -23,6 +28,11 @@ public class DefendantInformationTabDetails { ) private String lastName; + @CCD( + label = "Defendant 1's correspondence address known" + ) + private String addressKnown; + @CCD( label = "Defendant 1 address for service" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 0453f516cf..550e17394d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -86,7 +86,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); DefendantInformationTabDetails defendantInformationTabDetails = - defendantInformationTabDetailsBuilder.buildDefendantOneDetails(pcsCase); + defendantInformationTabDetailsBuilder.createDetailedDefendantDetails(pcsCase); List> underlesseeMortgageTabDetailsList = buildUnderlesseeMortgageTabDetailsList(pcsCase); DemotionOfTenancyTabDetails demotionOfTenancyTabDetails = buildDemotionOfTenancyTabDetails(pcsCase); @@ -118,7 +118,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { if (defendantInformationTabDetails != null) { List> additionalDefendantInformationTabDetails = - additionalDefendantInformationTabDetailsBuilder.buildAdditionalDefendantsDetails(pcsCase); + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); caseDetailsTab.setAdditionalDefendants(additionalDefendantInformationTabDetails); caseDetailsTab.setDefendantCircumstanceDetails(buildDefendantCircumstanceTabDetails(pcsCase)); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 964838c0ca..b95e216fe9 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -2,20 +2,10 @@ import lombok.AllArgsConstructor; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import uk.gov.hmcts.ccd.sdk.type.AddressUK; -import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; 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.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; @@ -32,11 +22,8 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.List; import java.util.Locale; -import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; - @AllArgsConstructor @Component public class CaseSummaryTabView { @@ -65,9 +52,9 @@ public SummaryTab buildSummaryTab(PCSCase pcsCase) { .reasonsForPossession(reasonsForPossession) .dateClaimSubmitted(dateSubmitted) .claimantDetails(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)) - .defendantDetails(defendantInformationTabDetailsBuilder.buildDefendantOneDetails(pcsCase)) + .defendantDetails(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)) .additionalDefendants( - additionalDefendantInformationTabDetailsBuilder.buildAdditionalDefendantsDetails(pcsCase) + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase) ) .rentArrearsDetails(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)) .tenancyDetails(buildTenancyTabDetails(pcsCase)) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java index a31d8e0138..060772c5ce 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java @@ -13,7 +13,7 @@ @Component public class AdditionalDefendantInformationTabDetailsBuilder extends DefendantInformationBuilder { - public List> buildAdditionalDefendantsDetails( + public List> buildSummaryAdditionalDefendantsDetails( PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { return null; @@ -30,18 +30,59 @@ public List> buildAdditional .toList(); } + public List> buildDetailedAdditionalDefendantsDetails( + PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants()) || pcsCase.getAllDefendants().size() < 2) { + return null; + } + + return pcsCase.getAllDefendants().stream() + .skip(1) + .map(ListValue::getValue) + .map(defendant -> createAdditionalDetailedDefendantDetails(defendant, pcsCase)) + .filter(defendantDetails -> defendantDetails != null) + .map(defendantDetails -> ListValue.builder() + .value(defendantDetails) + .build()) + .toList(); + } + private AdditionalDefendantInformationTabDetails createAdditionalSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + AddressUK addressForService = getDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; } - return uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails.builder() + return AdditionalDefendantInformationTabDetails.builder() .firstName(getDefendantFirstName(defendant)) .lastName(getDefendantLastName(defendant)) .addressForService(addressForService) .build(); } + + private AdditionalDefendantInformationTabDetails createAdditionalDetailedDefendantDetails(Party defendant, + PCSCase pcsCase) { + VerticalYesNo nameKnown = defendant.getNameKnown(); + VerticalYesNo addressKnown = defendant.getAddressKnown(); + + AdditionalDefendantInformationTabDetails additionalDefendantInformationTabDetails = + AdditionalDefendantInformationTabDetails.builder() + .nameKnown(nameKnown.getLabel()) + .addressKnown(addressKnown.getLabel()) + .build(); + + if (nameKnown == VerticalYesNo.YES) { + additionalDefendantInformationTabDetails.setFirstName(getDefendantFirstName(defendant)); + additionalDefendantInformationTabDetails.setLastName(getDefendantLastName(defendant)); + } + + if (addressKnown == VerticalYesNo.YES) { + AddressUK addressForService = getDefendantAddressForService(defendant, pcsCase); + additionalDefendantInformationTabDetails.setAddressForService(addressForService); + } + + return additionalDefendantInformationTabDetails; + } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java index 7baebb8f2b..5cf49a9f10 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationBuilder.java @@ -8,7 +8,7 @@ import uk.gov.hmcts.reform.pcs.ccd.view.CaseTabView; public class DefendantInformationBuilder { - protected AddressUK getSummaryDefendantAddressForService(Party defendant, PCSCase pcsCase) { + protected AddressUK getDefendantAddressForService(Party defendant, PCSCase pcsCase) { if (defendant.getAddressKnown() != VerticalYesNo.YES) { return pcsCase.getPropertyAddress(); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java index 460b6e3561..137785a7e7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java @@ -11,7 +11,7 @@ @Component public class DefendantInformationTabDetailsBuilder extends DefendantInformationBuilder { - public DefendantInformationTabDetails buildDefendantOneDetails(PCSCase pcsCase) { + public DefendantInformationTabDetails buildSummaryDefendantOneDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } @@ -19,8 +19,16 @@ public DefendantInformationTabDetails buildDefendantOneDetails(PCSCase pcsCase) return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } + public DefendantInformationTabDetails createDetailedDefendantDetails(PCSCase pcsCase) { + if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { + return null; + } + + return createDetailedDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); + } + private DefendantInformationTabDetails createSummaryDefendantDetails(Party defendant, PCSCase pcsCase) { - AddressUK addressForService = getSummaryDefendantAddressForService(defendant, pcsCase); + AddressUK addressForService = getDefendantAddressForService(defendant, pcsCase); if (defendant.getNameKnown() != VerticalYesNo.YES && addressForService == null) { return null; @@ -32,4 +40,26 @@ private DefendantInformationTabDetails createSummaryDefendantDetails(Party defen .addressForService(addressForService) .build(); } + + private DefendantInformationTabDetails createDetailedDefendantDetails(Party defendant, PCSCase pcsCase) { + VerticalYesNo nameKnown = defendant.getNameKnown(); + VerticalYesNo addressKnown = defendant.getAddressKnown(); + + DefendantInformationTabDetails defendantInformationTabDetails = DefendantInformationTabDetails.builder() + .nameKnown(nameKnown.getLabel()) + .addressKnown(addressKnown.getLabel()) + .build(); + + if (nameKnown == VerticalYesNo.YES) { + defendantInformationTabDetails.setFirstName(getDefendantFirstName(defendant)); + defendantInformationTabDetails.setLastName(getDefendantLastName(defendant)); + } + + if (addressKnown == VerticalYesNo.YES) { + AddressUK addressForService = getDefendantAddressForService(defendant, pcsCase); + defendantInformationTabDetails.setAddressForService(addressForService); + } + + return defendantInformationTabDetails; + } } From ceee783ba0d91f2733e2962bcf895e2042643e16 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 09:58:01 +0100 Subject: [PATCH 066/138] HDPI-2983: fix buildSuspensionOfRightToBuyTabDetails null pointer exception --- .../uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 550e17394d..3aec46e6ad 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -457,7 +457,10 @@ private DemotionOfTenancyTabDetails buildDemotionOfTenancyTabDetails(PCSCase pcs private SuspensionOfRightToBuyTabDetails buildSuspensionOfRightToBuyTabDetails(PCSCase pcsCase) { Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); - if (!alternativesToPossessionSet.contains(SUSPENSION_OF_RIGHT_TO_BUY)) { + if ( + CollectionUtils.isEmpty(alternativesToPossessionSet) || + !alternativesToPossessionSet.contains(SUSPENSION_OF_RIGHT_TO_BUY) + ) { return null; } From 02671e16efa0e5861f71f89702791c64302f2a6d Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 19 May 2026 10:02:50 +0100 Subject: [PATCH 067/138] HDPI-2978: Build Case Summary tab --- .../GroundsForPossessionTabDetails.java | 2 +- .../ReasonsForPossessionTabDetails.java | 2 +- .../ccd/domain/tabs/summary/SummaryTab.java | 5 +- .../reform/pcs/ccd/entity/ClaimEntity.java | 4 + .../reform/pcs/ccd/service/ClaimService.java | 8 +- .../pcs/ccd/service/PcsCaseService.java | 26 +-- .../pcs/ccd/view/CaseSummaryTabView.java | 13 +- .../ccd/view/ClaimGroundSummaryBuilder.java | 176 ++++++++------- .../pcs/ccd/service/ClaimServiceTest.java | 38 ++-- .../pcs/ccd/service/PcsCaseServiceTest.java | 30 +-- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 10 +- .../view/ClaimGroundSummaryBuilderTest.java | 200 ++++++++++-------- 12 files changed, 252 insertions(+), 262 deletions(-) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/GroundsForPossessionTabDetails.java (87%) rename src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/{summary => shared}/ReasonsForPossessionTabDetails.java (99%) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java similarity index 87% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java index 76e8fd108a..0c2e6ca98e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java similarity index 99% rename from src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java rename to src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java index c8647b148d..4d97e5a438 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary; +package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 8ae40a822e..1cfcc7ad5d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -9,10 +9,7 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.*; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java index a4f268c0c3..f1ba9a84e8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/entity/ClaimEntity.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; @@ -19,6 +20,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.type.SqlTypes; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; @@ -180,6 +182,8 @@ public class ClaimEntity { @JdbcTypeCode(SqlTypes.NAMED_ENUM) private VerticalYesNo isExemptLandlord; + @CreationTimestamp + @Column(updatable = false, nullable = false) private LocalDateTime claimSubmittedDate; public void setAsbProhibitedConductEntity(AsbProhibitedConductEntity asbProhibitedConductEntity) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java index 6e26a840d7..3dc3aee331 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimService.java @@ -13,7 +13,6 @@ import uk.gov.hmcts.reform.pcs.ccd.repository.ClaimRepository; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; -import java.time.LocalDateTime; import java.util.List; @Service @@ -28,8 +27,8 @@ public class ClaimService { private final NoticeOfPossessionService noticeOfPossessionService; private final StatementOfTruthService statementOfTruthService; - public ClaimEntity createMainClaimEntity(PCSCase pcsCase, LocalDateTime claimSubmittedDate) { - ClaimEntity claimEntity = buildClaimEntity(pcsCase, claimSubmittedDate); + public ClaimEntity createMainClaimEntity(PCSCase pcsCase) { + ClaimEntity claimEntity = buildClaimEntity(pcsCase); List claimGrounds = claimGroundService.createClaimGroundEntities(pcsCase); claimEntity.addClaimGrounds(claimGrounds); @@ -52,7 +51,7 @@ public ClaimEntity createMainClaimEntity(PCSCase pcsCase, LocalDateTime claimSub } - private ClaimEntity buildClaimEntity(PCSCase pcsCase, LocalDateTime claimSubmittedDate) { + private ClaimEntity buildClaimEntity(PCSCase pcsCase) { AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); ClaimantCircumstances claimantCircumstances = pcsCase.getClaimantCircumstances(); @@ -87,7 +86,6 @@ private ClaimEntity buildClaimEntity(PCSCase pcsCase, LocalDateTime claimSubmitt .genAppExpected(pcsCase.getApplicationWithClaim()) .languageUsed(pcsCase.getLanguageUsed()) .isExemptLandlord(pcsCase.getIsExemptLandlord()) - .claimSubmittedDate(claimSubmittedDate) .build(); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java index 0ee90a6da1..869e238e91 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseService.java @@ -1,7 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.service; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; @@ -15,13 +15,12 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; -import java.time.Clock; -import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @Service @Slf4j +@AllArgsConstructor public class PcsCaseService { private final PcsCaseRepository pcsCaseRepository; @@ -31,25 +30,6 @@ public class PcsCaseService { private final TenancyLicenceService tenancyLicenceService; private final AddressMapper addressMapper; private final CaseLinkService caseLinkService; - private final Clock utcClock; - - public PcsCaseService(PcsCaseRepository pcsCaseRepository, - ClaimService claimService, - PartyService partyService, - DocumentService documentService, - TenancyLicenceService tenancyLicenceService, - AddressMapper addressMapper, - CaseLinkService caseLinkService, - @Qualifier("utcClock") Clock utcClock) { - this.pcsCaseRepository = pcsCaseRepository; - this.claimService = claimService; - this.partyService = partyService; - this.documentService = documentService; - this.tenancyLicenceService = tenancyLicenceService; - this.addressMapper = addressMapper; - this.caseLinkService = caseLinkService; - this.utcClock = utcClock; - } public PcsCaseEntity createCase(long caseReference, AddressUK propertyAddress, @@ -69,7 +49,7 @@ public PcsCaseEntity createCase(long caseReference, public void createMainClaimOnCase(long caseReference, PCSCase pcsCase) { PcsCaseEntity pcsCaseEntity = loadCase(caseReference); - ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase, LocalDateTime.now(utcClock)); + ClaimEntity claimEntity = claimService.createMainClaimEntity(pcsCase); List documentEntities = documentService.createAllDocuments(pcsCase); documentEntities.forEach(doc -> doc.setClaim(claimEntity)); pcsCaseEntity.addDocuments(documentEntities); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index e0dfb559d8..bb4c3ad233 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -21,9 +21,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.TenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; @@ -31,7 +31,6 @@ import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -40,7 +39,6 @@ import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; -import static uk.gov.hmcts.reform.pcs.config.ClockConfiguration.UK_ZONE_ID; @Component public class CaseSummaryTabView { @@ -134,12 +132,7 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return null; } - return dateSubmitted - .atZone(ZoneOffset.UTC) - .withZoneSameInstant(UK_ZONE_ID) - .format(SUBMITTED_DATE_FORMATTER) - .replace("am", "AM") - .replace("pm", "PM"); + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); } private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java index 1952cd99e6..279ed1e663 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -29,12 +29,71 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.function.BiFunction; +import java.util.function.Function; @Component public class ClaimGroundSummaryBuilder { + private static final Map> + SECURE_OR_FLEXIBLE_DRAFT_REASON_LOOKUP = Map.ofEntries( + draftReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + ClaimGroundSummaryBuilder::getSection84ACondition1Reason), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY, + SecureOrFlexibleGroundsReasons::getBreachOfTenancyGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE, + SecureOrFlexibleGroundsReasons::getNuisanceOrImmoralUseGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE, + SecureOrFlexibleGroundsReasons::getDomesticViolenceGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE, + SecureOrFlexibleGroundsReasons::getRiotOffenceGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION, + SecureOrFlexibleGroundsReasons::getPropertyDeteriorationGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION, + SecureOrFlexibleGroundsReasons::getFurnitureDeteriorationGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT, + SecureOrFlexibleGroundsReasons::getTenancyByFalseStatementGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE, + SecureOrFlexibleGroundsReasons::getPremiumMutualExchangeGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION, + SecureOrFlexibleGroundsReasons::getUnreasonableConductGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK, + SecureOrFlexibleGroundsReasons::getRefusalToMoveBackGround), + secureOrFlexibleReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_2, + SecureOrFlexibleGroundsReasons::getAntiSocialCondition2OfS84AGround), + secureOrFlexibleReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_3, + SecureOrFlexibleGroundsReasons::getAntiSocialCondition3OfS84AGround), + secureOrFlexibleReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_4, + SecureOrFlexibleGroundsReasons::getAntiSocialCondition4OfS84AGround), + secureOrFlexibleReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_5, + SecureOrFlexibleGroundsReasons::getAntiSocialCondition5OfS84AGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING, + SecureOrFlexibleGroundsReasons::getOvercrowdingGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS, + SecureOrFlexibleGroundsReasons::getLandlordWorksGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD, + SecureOrFlexibleGroundsReasons::getPropertySoldGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD, + SecureOrFlexibleGroundsReasons::getCharitableLandlordGround), + secureOrFlexibleReasonEntry( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE, + SecureOrFlexibleGroundsReasons::getTiedAccommodationGround), + secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION, + SecureOrFlexibleGroundsReasons::getAdaptedAccommodationGround), + secureOrFlexibleReasonEntry( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES, + SecureOrFlexibleGroundsReasons::getHousingAssocSpecialGround), + secureOrFlexibleReasonEntry( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION, + SecureOrFlexibleGroundsReasons::getSpecialNeedsAccommodationGround), + secureOrFlexibleReasonEntry( + SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION, + SecureOrFlexibleGroundsReasons::getUnderOccupancySuccessionGround) + ); + public List> buildClaimGroundSummariesFromDraft(PCSCase draftCaseData) { List> summaries = new ArrayList<>(); @@ -61,10 +120,14 @@ public List> buildClaimGroundSummariesFromDraft(PC return summaries; } - TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); - TenancyLicenceType tenancyType = tenancyLicenceDetails == null - ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); + addTenancyLicenceGrounds(summaries, draftCaseData); + + return summaries; + } + private void addTenancyLicenceGrounds(List> summaries, + PCSCase draftCaseData) { + TenancyLicenceType tenancyType = getTenancyType(draftCaseData); if (tenancyType == TenancyLicenceType.ASSURED_TENANCY) { if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { addAssuredRentArrearsGrounds(summaries, draftCaseData); @@ -74,8 +137,7 @@ public List> buildClaimGroundSummariesFromDraft(PC addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); }); } - } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY - || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY) { + } else if (isSecureOrFlexibleTenancy(tenancyType)) { Optional.ofNullable(draftCaseData.getSecureOrFlexiblePossessionGrounds()).ifPresent(selected -> { addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGrounds(), draftCaseData); addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGrounds(), draftCaseData); @@ -83,13 +145,25 @@ public List> buildClaimGroundSummariesFromDraft(PC addGrounds(summaries, selected.getSecureOrFlexibleMandatoryGroundsAlt(), draftCaseData); addGrounds(summaries, selected.getSecureOrFlexibleDiscretionaryGroundsAlt(), draftCaseData); }); - } else if (tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY - || tenancyType == TenancyLicenceType.DEMOTED_TENANCY - || tenancyType == TenancyLicenceType.OTHER) { + } else if (isIntroductoryDemotedOrOtherTenancy(tenancyType)) { addIntroductoryDemotedOrOtherGrounds(summaries, draftCaseData); } + } - return summaries; + private TenancyLicenceType getTenancyType(PCSCase draftCaseData) { + TenancyLicenceDetails tenancyLicenceDetails = draftCaseData.getTenancyLicenceDetails(); + return tenancyLicenceDetails == null ? null : tenancyLicenceDetails.getTypeOfTenancyLicence(); + } + + private boolean isSecureOrFlexibleTenancy(TenancyLicenceType tenancyType) { + return tenancyType == TenancyLicenceType.SECURE_TENANCY + || tenancyType == TenancyLicenceType.FLEXIBLE_TENANCY; + } + + private boolean isIntroductoryDemotedOrOtherTenancy(TenancyLicenceType tenancyType) { + return tenancyType == TenancyLicenceType.INTRODUCTORY_TENANCY + || tenancyType == TenancyLicenceType.DEMOTED_TENANCY + || tenancyType == TenancyLicenceType.OTHER; } private void addAssuredRentArrearsGrounds(List> summaries, @@ -257,71 +331,24 @@ private String getIntroductoryDemotedOrOtherDraftReason(PCSCase draftCaseData, P } private String getSecureOrFlexibleDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { - SecureOrFlexibleGroundsReasons reasons = getSecureOrFlexibleReason(draftCaseData); - - if (ground == SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL) { - return getAntiSocialReason(draftCaseData); - } - - if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_1) { - return getSection84ACondition1Reason(draftCaseData); - } - - if (reasons == null) { - return null; - } + BiFunction reasonAccessor = + SECURE_OR_FLEXIBLE_DRAFT_REASON_LOOKUP.get(ground); + return reasonAccessor == null ? null : reasonAccessor.apply(this, draftCaseData); + } - if (ground == SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY) { - return reasons.getBreachOfTenancyGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE) { - return reasons.getNuisanceOrImmoralUseGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.DOMESTIC_VIOLENCE) { - return reasons.getDomesticViolenceGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE) { - return reasons.getRiotOffenceGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PROPERTY_DETERIORATION) { - return reasons.getPropertyDeteriorationGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.FURNITURE_DETERIORATION) { - return reasons.getFurnitureDeteriorationGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.TENANCY_OBTAINED_BY_FALSE_STATEMENT) { - return reasons.getTenancyByFalseStatementGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE) { - return reasons.getPremiumMutualExchangeGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.UNREASONABLE_CONDUCT_TIED_ACCOMMODATION) { - return reasons.getUnreasonableConductGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGrounds.REFUSAL_TO_MOVE_BACK) { - return reasons.getRefusalToMoveBackGround(); - } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_2) { - return reasons.getAntiSocialCondition2OfS84AGround(); - } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_3) { - return reasons.getAntiSocialCondition3OfS84AGround(); - } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_4) { - return reasons.getAntiSocialCondition4OfS84AGround(); - } else if (ground == SecureAntisocialAdditionalGrounds.S84A_CONDITION_5) { - return reasons.getAntiSocialCondition5OfS84AGround(); - } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.OVERCROWDING) { - return reasons.getOvercrowdingGround(); - } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.LANDLORD_WORKS) { - return reasons.getLandlordWorksGround(); - } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.PROPERTY_SOLD) { - return reasons.getPropertySoldGround(); - } else if (ground == SecureOrFlexibleMandatoryGroundsAlternativeAccomm.CHARITABLE_LANDLORD) { - return reasons.getCharitableLandlordGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .TIED_ACCOMMODATION_NEEDED_FOR_EMPLOYEE) { - return reasons.getTiedAccommodationGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.ADAPTED_ACCOMMODATION) { - return reasons.getAdaptedAccommodationGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm - .HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES) { - return reasons.getHousingAssocSpecialGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.SPECIAL_NEEDS_ACCOMMODATION) { - return reasons.getSpecialNeedsAccommodationGround(); - } else if (ground == SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.UNDER_OCCUPYING_AFTER_SUCCESSION) { - return reasons.getUnderOccupancySuccessionGround(); - } + private static Map.Entry> + draftReasonEntry(PossessionGroundEnum ground, + BiFunction reasonAccessor) { + return Map.entry(ground, reasonAccessor); + } - return null; + private static Map.Entry> + secureOrFlexibleReasonEntry(PossessionGroundEnum ground, + Function reasonAccessor) { + return Map.entry(ground, (builder, draftCaseData) -> { + SecureOrFlexibleGroundsReasons reasons = builder.getSecureOrFlexibleReason(draftCaseData); + return reasons == null ? null : reasonAccessor.apply(reasons); + }); } private String getSection84ACondition1Reason(PCSCase draftCaseData) { @@ -330,11 +357,6 @@ private String getSection84ACondition1Reason(PCSCase draftCaseData) { } private String getAntiSocialReason(PCSCase draftCaseData) { - SecureOrFlexibleGroundsReasons secureOrFlexibleReasons = getSecureOrFlexibleReason(draftCaseData); - if (secureOrFlexibleReasons != null) { - return secureOrFlexibleReasons.getAntiSocialGround(); - } - IntroductoryDemotedOtherGroundReason introductoryDemotedOtherReason = getIntroductoryDemotedOtherGroundReason(draftCaseData); return introductoryDemotedOtherReason == null diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java index 133f00be68..147493b2c8 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/ClaimServiceTest.java @@ -27,7 +27,6 @@ import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; -import java.time.LocalDateTime; import java.util.List; import java.util.stream.Stream; @@ -43,8 +42,6 @@ @ExtendWith(MockitoExtension.class) class ClaimServiceTest { - private static final LocalDateTime CLAIM_SUBMITTED_DATE = LocalDateTime.of(2026, 5, 18, 12, 30); - @Mock private ClaimRepository claimRepository; @Mock @@ -92,7 +89,7 @@ void shouldCreateMainClaim() { when(claimGroundService.createClaimGroundEntities(pcsCase)).thenReturn(expectedClaimGrounds); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getAgainstTrespassers()).isEqualTo(VerticalYesNo.YES); @@ -113,15 +110,6 @@ void shouldCreateMainClaim() { verify(claimRepository).save(createdClaimEntity); } - @Test - void shouldCreateMainClaimWithClaimSubmittedDate() { - // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); - - // Then - assertThat(createdClaimEntity.getClaimSubmittedDate()).isEqualTo(CLAIM_SUBMITTED_DATE); - } - @Test void shouldCreateMainClaim_WithAdditionalReasonsWhenPresent() { // Given @@ -131,7 +119,7 @@ void shouldCreateMainClaim_WithAdditionalReasonsWhenPresent() { // When ClaimEntity createdClaimEntity = - claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getAdditionalReasons()) @@ -150,7 +138,7 @@ void shouldCreateMainClaim_WithDefendantCircumstancesDetails() { when(defendantCircumstances.getHasDefendantCircumstancesInfo()).thenReturn(defendantInfoProvided); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getDefendantCircumstances()).isEqualTo(circumstancesInfo); @@ -169,7 +157,7 @@ void shouldCreateMainClaim_WithClaimantCircumstancesDetails() { when(claimantCircumstances.getClaimantCircumstancesDetails()).thenReturn(circumstancesInfo); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getClaimantCircumstances()).isEqualTo(circumstancesInfo); @@ -182,7 +170,7 @@ void shouldCreateMainClaim_WithoutClaimantTypeDetailsWhenNull() { when(pcsCase.getClaimantType()).thenReturn(null); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getClaimantType()).isNull(); @@ -196,7 +184,7 @@ void shouldCreateMainClaim_WithoutClaimantTypeDetailsWhenValueCodeIsNull() { when(pcsCase.getClaimantType()).thenReturn(claimantTypeList); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getClaimantType()).isNull(); @@ -216,7 +204,7 @@ void shouldCreateMainClaim_WithClaimantTypeDetails(ClaimantType claimantType) { when(pcsCase.getClaimantType()).thenReturn(claimantTypeList); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getClaimantType()).isEqualTo(claimantType); @@ -230,7 +218,7 @@ void shouldSetAlternativesToPossession() { .thenReturn(possessionAlternativesEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getPossessionAlternativesEntity()).isEqualTo(possessionAlternativesEntity); @@ -246,7 +234,7 @@ void shouldSetAsbProhibitedConductForWalesProperties() { .thenReturn(asbProhibitedConductEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getAsbProhibitedConductEntity()).isEqualTo(asbProhibitedConductEntity); @@ -258,7 +246,7 @@ void shouldNotSSetAsbProhibitedConductForNonWalesProperties() { when(pcsCase.getLegislativeCountry()).thenReturn(ENGLAND); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getAsbProhibitedConductEntity()).isNull(); @@ -273,7 +261,7 @@ void shouldSetRentArrears() { .thenReturn(rentArrearsEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getRentArrears()).isEqualTo(rentArrearsEntity); @@ -287,7 +275,7 @@ void shouldSetNoticeOfPossession() { .thenReturn(noticeOfPossessionEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getNoticeOfPossession()).isEqualTo(noticeOfPossessionEntity); @@ -301,7 +289,7 @@ void shouldSetStatementOfTruth() { .thenReturn(statementOfTruthEntity); // When - ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase, CLAIM_SUBMITTED_DATE); + ClaimEntity createdClaimEntity = claimService.createMainClaimEntity(pcsCase); // Then assertThat(createdClaimEntity.getStatementOfTruth()).isEqualTo(statementOfTruthEntity); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java index 6adc4eab18..d98e030a00 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/PcsCaseServiceTest.java @@ -27,9 +27,6 @@ import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; -import java.time.Clock; -import java.time.LocalDateTime; -import java.time.ZoneOffset; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -46,11 +43,6 @@ class PcsCaseServiceTest { private static final long CASE_REFERENCE = 1234L; - private static final LocalDateTime FIXED_DATE_TIME = LocalDateTime.of(2026, 5, 14, 10, 30); - private static final Clock FIXED_UTC_CLOCK = Clock.fixed( - FIXED_DATE_TIME.atZone(ZoneOffset.UTC).toInstant(), - ZoneOffset.UTC - ); @Mock private PcsCaseRepository pcsCaseRepository; @@ -82,8 +74,7 @@ void setUp() { documentService, tenancyLicenceService, addressMapper, - caseLinkService, - FIXED_UTC_CLOCK + caseLinkService ); } @@ -146,25 +137,10 @@ void shouldDelegateToClaimServiceToCreateMainClaim() { underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); // Then - verify(claimService).createMainClaimEntity(caseData, FIXED_DATE_TIME); + verify(claimService).createMainClaimEntity(caseData); verify(pcsCaseEntity).addClaim(mainClaimEntity); } - @Test - void shouldSetClaimSubmittedDateUsingUtcClockWhenCreatingMainClaim() { - // Given - stubFindCase(); - stubClaimCreation(); - - PCSCase caseData = PCSCase.builder().build(); - - // When - underTest.createMainClaimOnCase(CASE_REFERENCE, caseData); - - // Then - verify(claimService).createMainClaimEntity(caseData, FIXED_DATE_TIME); - } - @Test void shouldCreatePartiesWithMainClaimOnCase() { // Given @@ -272,7 +248,7 @@ private PcsCaseEntity stubFindCase() { private ClaimEntity stubClaimCreation() { ClaimEntity claimEntity = mock(ClaimEntity.class); - when(claimService.createMainClaimEntity(any(PCSCase.class), any(LocalDateTime.class))).thenReturn(claimEntity); + when(claimService.createMainClaimEntity(any(PCSCase.class))).thenReturn(claimEntity); return claimEntity; } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 20c6fc6b13..81ea7b3773 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -18,7 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; @@ -120,7 +120,7 @@ void shouldSetSummaryTabFields() { .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 6:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); @@ -147,17 +147,17 @@ void shouldSetSummaryTabFields() { } @Test - void shouldDisplaySubmittedDateInGmtWhenNotBritishSummerTime() { + void shouldDisplaySubmittedDateInGmtWhenBritishSummerTimeApplies() { // Given PCSCase pcsCase = PCSCase.builder() - .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) + .dateSubmitted(LocalDateTime.of(2026, 7, 11, 17, 2, 31)) .build(); // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); // Then - assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 5:02:31PM"); } @Test diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java index 306a8c3d0a..957edca622 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; @@ -39,7 +42,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -323,6 +328,37 @@ void shouldBuildStandardContractWalesClaimGroundSummariesFromDraft() { ); } + @Test + void shouldBuildOtherOccupationLicenceWalesClaimGroundSummariesFromDraft() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() + .occupationLicenceTypeWales(OccupationLicenceTypeWales.OTHER) + .build()) + .groundsForPossessionWales(GroundsForPossessionWales.builder() + .mandatoryGrounds(Set.of(MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199)) + .discretionaryGrounds(Set.of(DiscretionaryGroundWales.RENT_ARREARS_S157)) + .estateManagementGrounds(Set.of( + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES + )) + .build()) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getLabel) + .containsExactlyInAnyOrder( + MandatoryGroundWales.LANDLORD_BREAK_CLAUSE_S199.getLabel(), + DiscretionaryGroundWales.RENT_ARREARS_S157.getLabel(), + EstateManagementGroundsWales.REDEVELOPMENT_SCHEMES.getLabel() + ); + } + @Test void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { // Given @@ -388,7 +424,6 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { )) .build()) .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("Antisocial reason") .riotOffenceGround("Riot reason") .premiumMutualExchangeGround("Premium reason") .antiSocialCondition1OfS84AGround("Condition 1 reason") @@ -414,7 +449,7 @@ void shouldBuildSecureOrFlexibleClaimGroundSummariesFromDraft() { SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm.HOUSING_ASSOCIATION_SPECIAL_CIRCUMSTANCES .getLabel() ); - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "Antisocial reason"); + assertNoReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel()); assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RIOT_OFFENCE.getLabel(), "Riot reason"); assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.PREMIUM_PAID_MUTUAL_EXCHANGE.getLabel(), "Premium reason"); @@ -483,7 +518,6 @@ void shouldMapAllSecureAndFlexibleDraftGroundReasons() { )) .build()) .secureOrFlexibleGroundsReasons(SecureOrFlexibleGroundsReasons.builder() - .antiSocialGround("ASB reason") .breachOfTenancyGround("Breach reason") .nuisanceOrImmoralUseGround("Nuisance reason") .domesticViolenceGround("Domestic reason") @@ -516,7 +550,7 @@ void shouldMapAllSecureAndFlexibleDraftGroundReasons() { claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); // Then - assertReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel(), "ASB reason"); + assertNoReason(summaries, SecureOrFlexibleMandatoryGrounds.ANTI_SOCIAL.getLabel()); assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY.getLabel(), "Breach reason"); assertReason(summaries, SecureOrFlexibleDiscretionaryGrounds.NUISANCE_OR_IMMORAL_USE.getLabel(), @@ -572,25 +606,23 @@ void shouldMapAllSecureAndFlexibleDraftGroundReasons() { "Under occupation reason"); } - @Test - void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { + @ParameterizedTest + @MethodSource("introductoryDemotedOrOtherTenancyDrafts") + void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft( + TenancyLicenceType tenancyType, + IntroductoryDemotedOtherGroundsForPossession groundsForPossession, + IntroductoryDemotedOtherGroundReason groundsReason, + List expectedLabels, + Map expectedReasons, + Set expectedLabelsWithNoReason + ) { // Given PCSCase draftCaseData = PCSCase.builder() .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .typeOfTenancyLicence(tenancyType) .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) - .introductoryDemotedOrOtherGrounds(Set.of( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS - )) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .antiSocialBehaviourGround("Intro antisocial reason") - .build()) + .introductoryDemotedOrOtherGroundsForPossession(groundsForPossession) + .introductoryDemotedOtherGroundReason(groundsReason) .build(); // When @@ -601,30 +633,18 @@ void shouldBuildIntroductoryDemotedOrOtherClaimGroundSummariesFromDraft() { assertThat(summaries) .map(ListValue::getValue) .map(ClaimGroundSummary::getLabel) - .containsExactlyInAnyOrder( - IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() - ); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), - "Intro antisocial reason"); - assertNoReason(summaries, IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()); + .containsExactlyInAnyOrderElementsOf(expectedLabels); + expectedReasons.forEach((label, reason) -> assertReason(summaries, label, reason)); + expectedLabelsWithNoReason.forEach(label -> assertNoReason(summaries, label)); } @Test - void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { + void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { // Given PCSCase draftCaseData = PCSCase.builder() .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.DEMOTED_TENANCY) + .typeOfTenancyLicence(TenancyLicenceType.OTHER) .build()) - .introductoryDemotedOrOtherGroundsForPossession( - IntroductoryDemotedOtherGroundsForPossession.builder() - .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) - .build() - ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .noGrounds("No grounds reason") - .build()) .build(); // When @@ -632,21 +652,47 @@ void shouldBuildNoGroundsSummaryForIntroductoryDemotedOrOtherDraft() { claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); // Then - assertThat(summaries) - .map(ListValue::getValue) - .map(ClaimGroundSummary::getLabel) - .containsExactly(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()); - assertReason(summaries, IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"); + assertThat(summaries).isEmpty(); } - @Test - void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .introductoryDemotedOrOtherGroundsForPossession( + private static Stream introductoryDemotedOrOtherTenancyDrafts() { + return Stream.of( + Arguments.of( + TenancyLicenceType.INTRODUCTORY_TENANCY, + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(Set.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL, + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS + )) + .build(), + IntroductoryDemotedOtherGroundReason.builder() + .antiSocialBehaviourGround("Intro antisocial reason") + .build(), + List.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel() + ), + Map.of( + IntroductoryDemotedOrOtherGrounds.ANTI_SOCIAL.getLabel(), + "Intro antisocial reason" + ), + Set.of(IntroductoryDemotedOrOtherGrounds.RENT_ARREARS.getLabel()) + ), + Arguments.of( + TenancyLicenceType.DEMOTED_TENANCY, + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.NO) + .build(), + IntroductoryDemotedOtherGroundReason.builder() + .noGrounds("No grounds reason") + .build(), + List.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel()), + Map.of(IntroductoryDemotedOrOtherNoGrounds.NO_GROUNDS.getLabel(), "No grounds reason"), + Set.of() + ), + Arguments.of( + TenancyLicenceType.OTHER, IntroductoryDemotedOtherGroundsForPossession.builder() .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) .introductoryDemotedOrOtherGrounds(Set.of( @@ -654,42 +700,28 @@ void shouldBuildOtherTenancyClaimGroundSummariesFromDraftWithReasons() { IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS, IntroductoryDemotedOrOtherGrounds.OTHER )) - .build() + .build(), + IntroductoryDemotedOtherGroundReason.builder() + .breachOfTheTenancyGround("Breach reason") + .absoluteGrounds("Absolute reason") + .otherGround("Other reason") + .build(), + List.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + IntroductoryDemotedOrOtherGrounds.OTHER.getLabel() + ), + Map.of( + IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), + "Breach reason", + IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), + "Absolute reason", + IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), + "Other reason" + ), + Set.of() ) - .introductoryDemotedOtherGroundReason(IntroductoryDemotedOtherGroundReason.builder() - .breachOfTheTenancyGround("Breach reason") - .absoluteGrounds("Absolute reason") - .otherGround("Other reason") - .build()) - .build(); - - // When - List> summaries = - claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.BREACH_OF_THE_TENANCY.getLabel(), - "Breach reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.ABSOLUTE_GROUNDS.getLabel(), - "Absolute reason"); - assertReason(summaries, IntroductoryDemotedOrOtherGrounds.OTHER.getLabel(), "Other reason"); - } - - @Test - void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGrounds() { - // Given - PCSCase draftCaseData = PCSCase.builder() - .tenancyLicenceDetails(TenancyLicenceDetails.builder() - .typeOfTenancyLicence(TenancyLicenceType.OTHER) - .build()) - .build(); - - // When - List> summaries = - claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); - - // Then - assertThat(summaries).isEmpty(); + ); } private static void assertReason(List> summaries, From 19df78b72ee615a8fad3fc29766f383a15b679ca Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 10:40:09 +0100 Subject: [PATCH 068/138] HDPI-2983: show additional mortgage in case details tab --- .../hmcts/reform/pcs/ccd/view/CaseTabView.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 18aade55b4..406d63f4e0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -129,9 +129,25 @@ private List> buildUnderlesseeOrMortgageParties(PCSCase draftCa List> underlesseeMortgageParties = new ArrayList<>(); underlesseeMortgageParties.add(buildUnderlesseeOrMortgageParty(underlesseeOrMortgagee1)); + List> additionalUnderlesseeOrMortgagee = + draftCaseData.getAdditionalUnderlesseeOrMortgagee(); + if (!CollectionUtils.isEmpty(additionalUnderlesseeOrMortgagee)) { + underlesseeMortgageParties.addAll( + additionalUnderlesseeOrMortgagee.stream() + .map(this::buildUnderlesseeOrMortgageParty) + .toList() + ); + } + return underlesseeMortgageParties; } + private ListValue buildUnderlesseeOrMortgageParty( + ListValue underlesseeMortgageeDetails + ) { + return buildUnderlesseeOrMortgageParty(underlesseeMortgageeDetails.getValue()); + } + private ListValue buildUnderlesseeOrMortgageParty(UnderlesseeMortgageeDetails underlesseeMortgageeDetails) { return ListValue.builder() .value(Party.builder() From 33f8293cde7ea3b2c17f28fa3a231bf3ed6d92fc Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 19 May 2026 10:55:58 +0100 Subject: [PATCH 069/138] HDPI-2978: Build Case Summary tab --- .../reform/pcs/ccd/domain/tabs/summary/SummaryTab.java | 7 ++++++- .../reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java index 1cfcc7ad5d..4a6adca954 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/SummaryTab.java @@ -9,7 +9,12 @@ import uk.gov.hmcts.ccd.sdk.api.CCD; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.*; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.util.List; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java index 279ed1e663..50a7ca7242 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -22,7 +22,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleGroundsReasons; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleMandatoryGroundsAlternativeAccomm; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; From dfc39ba5573478c32471a2458b78f3f102162e83 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 12:03:33 +0100 Subject: [PATCH 070/138] HDPI-2983: reverse changes --- ...AssuredAdditionalDiscretionaryGrounds.java | 24 +++++++------------ .../AssuredAdditionalMandatoryGrounds.java | 24 +++++++------------ .../grounds/AssuredRentArrearsGround.java | 12 +++------- 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java index 4a15b4f35e..a93e7bdb0f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalDiscretionaryGrounds.java @@ -1,44 +1,38 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; -import lombok.AllArgsConstructor; -import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Additional-only discretionary grounds for Assured tenancy (excludes grounds 10 and 11). */ -@AllArgsConstructor -@Getter public enum AssuredAdditionalDiscretionaryGrounds { @CCD(label = "Suitable alternative accommodation (ground 9)") - ALTERNATIVE_ACCOMMODATION_GROUND9("Suitable alternative accommodation (ground 9)"), + ALTERNATIVE_ACCOMMODATION_GROUND9, @CCD(label = "Breach of tenancy conditions (ground 12)") - BREACH_TENANCY_GROUND12("Breach of tenancy conditions (ground 12)"), + BREACH_TENANCY_GROUND12, @CCD(label = "Deterioration in the condition of the property (ground 13)") - DETERIORATION_PROPERTY_GROUND13("Deterioration in the condition of the property (ground 13)"), + DETERIORATION_PROPERTY_GROUND13, @CCD(label = "Nuisance, annoyance, illegal, or immoral use of the property (ground 14)") - NUISANCE_ANNOYANCE_GROUND14("Nuisance, annoyance, illegal, or immoral use of the property (ground 14)"), + NUISANCE_ANNOYANCE_GROUND14, @CCD(label = "Domestic violence (ground 14A)") - DOMESTIC_VIOLENCE_GROUND14A("Domestic violence (ground 14A)"), + DOMESTIC_VIOLENCE_GROUND14A, @CCD(label = "Offence during a riot (ground 14ZA)") - OFFENCE_RIOT_GROUND14ZA("Offence during a riot (ground 14ZA)"), + OFFENCE_RIOT_GROUND14ZA, @CCD(label = "Deterioration of furniture (ground 15)") - DETERIORATION_FURNITURE_GROUND15("Deterioration of furniture (ground 15)"), + DETERIORATION_FURNITURE_GROUND15, @CCD(label = "Employee of the landlord (ground 16)") - EMPLOYEE_LANDLORD_GROUND16("Employee of the landlord (ground 16)"), + EMPLOYEE_LANDLORD_GROUND16, @CCD(label = "Tenancy obtained by false statement (ground 17)") - FALSE_STATEMENT_GROUND17("Tenancy obtained by false statement (ground 17)"); - - private final String label; + FALSE_STATEMENT_GROUND17; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java index 52a57fd9db..f6c0b904e5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredAdditionalMandatoryGrounds.java @@ -1,44 +1,38 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; -import lombok.AllArgsConstructor; -import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Additional-only mandatory grounds for Assured tenancy (excludes ground 8). */ -@AllArgsConstructor -@Getter public enum AssuredAdditionalMandatoryGrounds { @CCD(label = "Owner occupier (ground 1)") - OWNER_OCCUPIER_GROUND1("Owner occupier (ground 1)"), + OWNER_OCCUPIER_GROUND1, @CCD(label = "Repossession by the landlord’s mortgage lender (ground 2)") - REPOSSESSION_GROUND2("Repossession by the landlord’s mortgage lender (ground 2)"), + REPOSSESSION_GROUND2, @CCD(label = "Holiday let (ground 3)") - HOLIDAY_LET_GROUND3("Holiday let (ground 3)"), + HOLIDAY_LET_GROUND3, @CCD(label = "Student let (ground 4)") - STUDENT_LET_GROUND4("Student let (ground 4)"), + STUDENT_LET_GROUND4, @CCD(label = "Property required for minister of religion (ground 5)") - MINISTER_RELIGION_GROUND5("Property required for minister of religion (ground 5)"), + MINISTER_RELIGION_GROUND5, @CCD(label = "Property required for redevelopment (ground 6)") - REDEVELOPMENT_GROUND6("Property required for redevelopment (ground 6)"), + REDEVELOPMENT_GROUND6, @CCD(label = "Death of the tenant (ground 7)") - DEATH_OF_TENANT_GROUND7("Death of the tenant (ground 7)"), + DEATH_OF_TENANT_GROUND7, @CCD(label = "Antisocial behaviour (ground 7A)") - ANTISOCIAL_BEHAVIOUR_GROUND7A("Antisocial behaviour (ground 7A)"), + ANTISOCIAL_BEHAVIOUR_GROUND7A, @CCD(label = "Tenant does not have a right to rent (ground 7B)") - NO_RIGHT_TO_RENT_GROUND7B("Tenant does not have a right to rent (ground 7B)"); - - private final String label; + NO_RIGHT_TO_RENT_GROUND7B; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java index 2857e186ae..da948fa506 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/grounds/AssuredRentArrearsGround.java @@ -1,24 +1,18 @@ package uk.gov.hmcts.reform.pcs.ccd.domain.grounds; -import lombok.AllArgsConstructor; -import lombok.Getter; import uk.gov.hmcts.ccd.sdk.api.CCD; /** * Enum representing rent arrears grounds for possession claims. */ -@AllArgsConstructor -@Getter public enum AssuredRentArrearsGround { @CCD(label = "Serious rent arrears (ground 8)") - SERIOUS_RENT_ARREARS_GROUND8("Serious rent arrears (ground 8)"), + SERIOUS_RENT_ARREARS_GROUND8, @CCD(label = "Rent arrears (ground 10)") - RENT_ARREARS_GROUND10("Rent arrears (ground 10)"), + RENT_ARREARS_GROUND10, @CCD(label = "Persistent delay in paying rent (ground 11)") - PERSISTENT_DELAY_GROUND11("Persistent delay in paying rent (ground 11)"); - - private final String label; + PERSISTENT_DELAY_GROUND11; } From 7a86a6ad15727a9ceebd2a17d5fd480fe48bc606 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 12:04:03 +0100 Subject: [PATCH 071/138] HDPI-2983: add other description for assured tenancy grounds --- .../pcs/ccd/view/CaseDetailsTabView.java | 12 ++++++++ .../builder/ClaimGroundSummaryBuilder.java | 30 +++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 3aec46e6ad..f68104f04a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -21,6 +21,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ActionsTakenTabDetails; @@ -56,6 +57,7 @@ import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.ASSURED_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.DEMOTED_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.INTRODUCTORY_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.OTHER; @@ -159,6 +161,16 @@ private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCa .map(ClaimGroundSummary::getDescription) .findFirst() .orElse(""); + } else if (tenancyType == ASSURED_TENANCY) { + otherGroundsDescription = groundSummaries.stream().filter( + claimGroundSummaryListValue -> { + ClaimGroundSummary claimGroundSummary = claimGroundSummaryListValue.getValue(); + return claimGroundSummary.getCode().equals(AssuredAdditionalOtherGround.OTHER.name()); + }) + .map(ListValue::getValue) + .map(ClaimGroundSummary::getDescription) + .findFirst() + .orElse(""); } return GroundsForPossessionTabDetails diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java index 0513d37ce9..60fc560a7f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java @@ -9,9 +9,12 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsPossessionGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundReason; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; @@ -29,6 +32,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -72,6 +76,7 @@ public List> buildClaimGroundSummariesFromDraft(PC Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); + addGrounds(summaries, selected.getOtherGround(), draftCaseData); }); } } else if (tenancyType == TenancyLicenceType.SECURE_TENANCY @@ -110,6 +115,11 @@ private void addAssuredRentArrearsGrounds(List> su .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) .toList(), draftCaseData); } + if(!CollectionUtils.isEmpty(selected.getAdditionalOtherGround())) { + addGrounds(summaries, selected.getAdditionalOtherGround().stream() + .map(ground -> AssuredAdditionalOtherGround.valueOf(ground.name())) + .toList(), draftCaseData); + } }); } @@ -172,13 +182,23 @@ private void addGrounds(List> summaries, } private String getDescription(PCSCase draftCaseData, PossessionGroundEnum ground) { - if (ground != IntroductoryDemotedOrOtherGrounds.OTHER) { - return null; + if (ground == IntroductoryDemotedOrOtherGrounds.OTHER) { + IntroductoryDemotedOtherGroundsForPossession otherGroundsForPossession = + draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); + return otherGroundsForPossession != null ? otherGroundsForPossession.getOtherGroundDescription() : null; } - IntroductoryDemotedOtherGroundsForPossession otherGroundsForPossession = - draftCaseData.getIntroductoryDemotedOrOtherGroundsForPossession(); - return otherGroundsForPossession != null ? otherGroundsForPossession.getOtherGroundDescription() : null; + if (ground == AssuredAdditionalOtherGround.OTHER) { + if (draftCaseData.getClaimDueToRentArrears() == YesOrNo.YES) { + AssuredRentArrearsPossessionGrounds grounds = draftCaseData.getAssuredRentArrearsPossessionGrounds(); + return grounds != null ? grounds.getAdditionalOtherGroundDescription() : null; + } else { + AssuredNoArrearsPossessionGrounds grounds = draftCaseData.getNoRentArrearsGroundsOptions(); + return grounds != null ? grounds.getOtherGroundDescription() : null; + } + } + + return null; } private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { From ddfb797815c07029a046c54be30e0a5497ca5de1 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 14:22:26 +0100 Subject: [PATCH 072/138] HDPI-2983: fix draft demotion of tenancy and suspend of right to buy draft data mapping bug --- .../hmcts/reform/pcs/ccd/view/CaseTabView.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index dfa8d3e0ec..47ba2bf980 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -57,16 +57,17 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { draftCaseData.setAllUnderlesseeOrMortgagees(buildUnderlesseeOrMortgageParties(draftCaseData)); } - Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); + Set alternativesToPossessionSet = draftCaseData.getAlternativesToPossession(); SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy = - pcsCase.getSuspensionOfRightToBuyDemotionOfTenancy(); + draftCaseData.getSuspensionOfRightToBuyDemotionOfTenancy(); if ( suspensionOfRightToBuyDemotionOfTenancy != null && !CollectionUtils.isEmpty(alternativesToPossessionSet) && alternativesToPossessionSet.containsAll(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) ) { - draftCaseData.setDemotionOfTenancy(buildDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy)); + DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + setDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy, demotionOfTenancy); draftCaseData.setSuspensionOfRightToBuy( buildSuspensionOfRightToBuyHousingAct(suspensionOfRightToBuyDemotionOfTenancy) ); @@ -148,13 +149,12 @@ private ListValue buildUnderlesseeOrMortgageParty(UnderlesseeMortgageeDet .build(); } - private DemotionOfTenancy buildDemotionOfTenancy( - SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy + private void setDemotionOfTenancy( + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy, + DemotionOfTenancy demotionOfTenancy ) { - return DemotionOfTenancy.builder() - .housingAct(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOfTenancyActs()) - .reason(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOrderReason()) - .build(); + demotionOfTenancy.setHousingAct(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOfTenancyActs()); + demotionOfTenancy.setReason(suspensionOfRightToBuyDemotionOfTenancy.getDemotionOrderReason()); } private SuspensionOfRightToBuy buildSuspensionOfRightToBuyHousingAct( From 15832b762ec88f30a7bc1f2c177f1efa360d05f5 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 14:51:56 +0100 Subject: [PATCH 073/138] HDPI-2983: fix notice table bug and remove costs table since it has been removed --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 - .../domain/tabs/details/CaseDetailsTab.java | 5 ----- .../domain/tabs/details/CostsTabDetails.java | 19 ------------------- .../pcs/ccd/view/CaseDetailsTabView.java | 12 +----------- 4 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.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 a49b022294..7ce3b88227 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 @@ -165,7 +165,6 @@ private void buildCaseDetailsTab(ConfigBuilder builder .field("detailsTab_NoticeDetails") .field("detailsTab_ActionsTakenDetails") .field("detailsTab_RentArrearsDetails") - .field("detailsTab_CostsDetails") .field("detailsTab_ReasonsForPossessionDetails") .field("detailsTab_ApplicationsDetails") .label( diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 33b8fb0d6e..39ee20bc20 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -60,11 +60,6 @@ public class CaseDetailsTab { ) private RentArrearsTabDetails rentArrearsDetails; - @CCD( - label = "Costs" - ) - private CostsTabDetails costsDetails; - @CCD( label = "Reasons for possession" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java deleted file mode 100644 index 67d8753578..0000000000 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CostsTabDetails.java +++ /dev/null @@ -1,19 +0,0 @@ -package uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import uk.gov.hmcts.ccd.sdk.api.CCD; - -@Builder -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CostsTabDetails { - - @CCD( - label = "Asking for costs back?" - ) - private String askingForCosts; -} diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index f68104f04a..6e475b7917 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -29,7 +29,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimantContactTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CostsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DefendantCircumstanceTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DemotionOfTenancyTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails; @@ -83,7 +82,6 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); - CostsTabDetails costsTabDetails = buildCostsTabDetails(pcsCase); ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = buildReasonsForPossession(pcsCase); ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); @@ -103,7 +101,6 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .noticeDetails(noticeTabDetails) .actionsTakenDetails(actionsTakenTabDetails) .rentArrearsDetails(rentArrearsTabDetails) - .costsDetails(costsTabDetails) .reasonsForPossessionDetails(reasonsForPossessionTabDetails) .applicationsDetails(applicationsTabDetails) .claimantInformation(claimantInformationTabDetails) @@ -237,7 +234,7 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { } case PERSONALLY_HANDED -> { LocalDateTime dateTime = noticeServedDetails.getNoticeHandedOverDateTime(); - String name = noticeTabDetails.getNoticePersonName(); + String name = noticeServedDetails.getNoticePersonName(); noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); noticeTabDetails.setNoticePersonName(name != null ? name : NO_ANSWER); } @@ -298,13 +295,6 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { return rentArrearsTabDetails; } - private CostsTabDetails buildCostsTabDetails(PCSCase pcsCase) { - VerticalYesNo claimingCostsWanted = pcsCase.getClaimingCostsWanted(); - return CostsTabDetails.builder() - .askingForCosts(claimingCostsWanted != null ? claimingCostsWanted.getLabel() : NO_ANSWER) - .build(); - } - private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { return reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); } From c92585b14721da154b653bad80040497ad94b9ff Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 19 May 2026 14:52:38 +0100 Subject: [PATCH 074/138] HDPI-2978: Build Case Summary tab --- ...itionalDefendantInformationTabDetails.java | 12 +++-------- .../shared/ClaimantInformationTabDetails.java | 4 +--- .../DefendantInformationTabDetails.java | 12 +++-------- .../GroundsForPossessionTabDetails.java | 5 +---- .../ReasonsForPossessionTabDetails.java | 4 +--- .../tabs/shared/RentArrearsTabDetails.java | 20 +++++-------------- .../domain/tabs/summary/NoticeTabDetails.java | 4 +--- .../tabs/summary/TenancyTabDetails.java | 8 ++------ 8 files changed, 17 insertions(+), 52 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index 22e1a5b870..6d784b3485 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -13,18 +13,12 @@ @AllArgsConstructor public class AdditionalDefendantInformationTabDetails { - @CCD( - label = "First name" - ) + @CCD(label = "First name") private String firstName; - @CCD( - label = "Last name" - ) + @CCD(label = "Last name") private String lastName; - @CCD( - label = "Additional defendant address for service" - ) + @CCD(label = "Additional defendant address for service") private AddressUK addressForService; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java index dc008a923d..b86bde12a9 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ClaimantInformationTabDetails.java @@ -12,8 +12,6 @@ @AllArgsConstructor public class ClaimantInformationTabDetails { - @CCD( - label = "Claimant name" - ) + @CCD(label = "Claimant name") private String claimantName; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index 216d0d5eb6..cc779e9fb4 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -13,18 +13,12 @@ @AllArgsConstructor public class DefendantInformationTabDetails { - @CCD( - label = "First name" - ) + @CCD(label = "First name") private String firstName; - @CCD( - label = "Last name" - ) + @CCD(label = "Last name") private String lastName; - @CCD( - label = "Defendant 1 address for service" - ) + @CCD(label = "Defendant 1 address for service") private AddressUK addressForService; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java index 0c2e6ca98e..7a58cde8de 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java @@ -14,9 +14,6 @@ @AllArgsConstructor public class GroundsForPossessionTabDetails { - @CCD( - label = "Grounds", - typeOverride = TextArea - ) + @CCD(label = "Grounds", typeOverride = TextArea) private String grounds; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java index 4d97e5a438..207b7661c1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java @@ -171,8 +171,6 @@ public class ReasonsForPossessionTabDetails { @CCD(label = "Reasons for claiming possession under No grounds") private String noGrounds; - @CCD( - label = "Additional reasons for possession" - ) + @CCD(label = "Additional reasons for possession") private String additionalReasonsForPossession; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 78ba11160e..62fb94e805 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -12,28 +12,18 @@ @AllArgsConstructor public class RentArrearsTabDetails { - @CCD( - label = "Rent amount" - ) + @CCD(label = "Rent amount") private String rentAmount; - @CCD( - label = "How rent is calculated" - ) + @CCD(label = "How rent is calculated") private String calculationFrequency; - @CCD( - label = "Daily rate" - ) + @CCD(label = "Daily rate") private String dailyRate; - @CCD( - label = "Rent arrears total at the time of claim issue" - ) + @CCD(label = "Rent arrears total at the time of claim issue") private String arrearsTotal; - @CCD( - label = "Judgment requested for the outstanding arrears?" - ) + @CCD(label = "Judgment requested for the outstanding arrears?") private String judgmentRequested; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java index e66f4960e0..f824dfa8fc 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/NoticeTabDetails.java @@ -12,8 +12,6 @@ @AllArgsConstructor public class NoticeTabDetails { - @CCD( - label = "Date notice was served" - ) + @CCD(label = "Date notice was served") private String noticeServedDate; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java index 76ffe57915..66da2079fb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/summary/TenancyTabDetails.java @@ -12,13 +12,9 @@ @AllArgsConstructor public class TenancyTabDetails { - @CCD( - label = "Tenancy, occupation contract or licence agreement type" - ) + @CCD(label = "Tenancy, occupation contract or licence agreement type") private String agreementType; - @CCD( - label = "Tenancy, occupation contract or licence agreement start date" - ) + @CCD(label = "Tenancy, occupation contract or licence agreement start date") private String agreementStartDate; } From c91eebec641d97c691df940515efc69ceaf36b01 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 15:07:22 +0100 Subject: [PATCH 075/138] HDPI-2983: add buildReasonsForPossession back into case summary --- .../pcs/ccd/view/CaseSummaryTabView.java | 2 +- ...ReasonsForPossessionTabDetailsBuilder.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 47c5bd905a..e8e5c498f3 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -47,7 +47,7 @@ public class CaseSummaryTabView { public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = - reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); + reasonsForPossessionTabDetailsBuilder.buildReasonsForPossession(pcsCase); String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); return SummaryTab.builder() diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java index e9dd57b2c1..aa30de6c2f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java @@ -4,7 +4,9 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; @@ -73,6 +75,25 @@ public class ReasonsForPossessionTabDetailsBuilder { private static final String SECTION_191 = "191"; private static final String SECTION_199 = "199"; + public ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + ReasonsForPossessionTabDetails reasonsForPossession = + buildReasonsForPossessionFromGroundSummaries(pcsCase); + String additionalReasonsText = additionalReasons == null + || additionalReasons.getHasReasons() != VerticalYesNo.YES ? null : additionalReasons.getReasons(); + + if (reasonsForPossession == null && additionalReasonsText == null) { + return null; + } + + if (reasonsForPossession == null) { + reasonsForPossession = ReasonsForPossessionTabDetails.builder().build(); + } + + reasonsForPossession.setAdditionalReasonsForPossession(additionalReasonsText); + return reasonsForPossession; + } + public ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { return null; From 492debfe2877ed0e06a65d8abc56c5d40d32a2ae Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 15:39:17 +0100 Subject: [PATCH 076/138] HDPI-2983: add additional reasons for possession into case details tab --- .../ReasonsForPossessionTabDetails.java | 6 +++++ .../pcs/ccd/view/CaseDetailsTabView.java | 7 ++--- .../pcs/ccd/view/CaseSummaryTabView.java | 8 +----- ...ReasonsForPossessionTabDetailsBuilder.java | 26 +++++++++++++++++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java index 4d97e5a438..4c33b9874c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/ReasonsForPossessionTabDetails.java @@ -175,4 +175,10 @@ public class ReasonsForPossessionTabDetails { label = "Additional reasons for possession" ) private String additionalReasonsForPossession; + + @CCD(label = "Do you have any additional reasons for possession?") + private String hasAdditionalReasons; + + @CCD(label = "Details of additional reasons") + private String additionalReasonsDetails; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 6e475b7917..a1fb68448b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -82,7 +82,8 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); - ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = buildReasonsForPossession(pcsCase); + ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = + reasonsForPossessionTabDetailsBuilder.buildDetailsReasonsForPossession(pcsCase); ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); DefendantInformationTabDetails defendantInformationTabDetails = @@ -295,10 +296,6 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { return rentArrearsTabDetails; } - private ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { - return reasonsForPossessionTabDetailsBuilder.buildReasonsForPossessionFromGroundSummaries(pcsCase); - } - private ApplicationsTabDetails buildApplicationsTabDetails(PCSCase pcsCase) { VerticalYesNo applicationWithClaim = pcsCase.getApplicationWithClaim(); String planToMakeGeneralApplication = applicationWithClaim != null ? diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index e8e5c498f3..03dbad7fdd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -6,12 +6,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; -import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; -import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; -import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.GroundsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.NoticeTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; @@ -47,7 +41,7 @@ public class CaseSummaryTabView { public SummaryTab buildSummaryTab(PCSCase pcsCase) { ReasonsForPossessionTabDetails reasonsForPossession = - reasonsForPossessionTabDetailsBuilder.buildReasonsForPossession(pcsCase); + reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase); String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); return SummaryTab.builder() diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java index aa30de6c2f..15d17cfd49 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilder.java @@ -75,7 +75,7 @@ public class ReasonsForPossessionTabDetailsBuilder { private static final String SECTION_191 = "191"; private static final String SECTION_199 = "199"; - public ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) { + public ReasonsForPossessionTabDetails buildSummaryReasonsForPossession(PCSCase pcsCase) { AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); ReasonsForPossessionTabDetails reasonsForPossession = buildReasonsForPossessionFromGroundSummaries(pcsCase); @@ -94,7 +94,29 @@ public ReasonsForPossessionTabDetails buildReasonsForPossession(PCSCase pcsCase) return reasonsForPossession; } - public ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { + public ReasonsForPossessionTabDetails buildDetailsReasonsForPossession(PCSCase pcsCase) { + ReasonsForPossessionTabDetails reasonsForPossession = + buildReasonsForPossessionFromGroundSummaries(pcsCase); + + if (reasonsForPossession == null) { + return null; + } + + AdditionalReasons additionalReasons = pcsCase.getAdditionalReasonsForPossession(); + + if (additionalReasons != null) { + VerticalYesNo hasReasons = additionalReasons.getHasReasons(); + reasonsForPossession.setHasAdditionalReasons(hasReasons != null ? hasReasons.getLabel() : null); + + if (hasReasons == VerticalYesNo.YES) { + reasonsForPossession.setAdditionalReasonsDetails(additionalReasons.getReasons()); + } + } + + return reasonsForPossession; + } + + private ReasonsForPossessionTabDetails buildReasonsForPossessionFromGroundSummaries(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getClaimGroundSummaries())) { return null; } From c57c1b95fdb2e0bbb0f13b210bb00be967385bec Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 15:58:23 +0100 Subject: [PATCH 077/138] HDPI-2983: fix bug where demotion of tenancy and suspension wasn't displayed on submit --- .../pcs/ccd/view/AlternativesToPossessionView.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/AlternativesToPossessionView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/AlternativesToPossessionView.java index 2baf4f2282..dd2b94ca9e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/AlternativesToPossessionView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/AlternativesToPossessionView.java @@ -2,6 +2,7 @@ import org.springframework.stereotype.Component; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancy; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuy; @@ -9,8 +10,12 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.claim.PossessionAlternativesEntity; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; import static uk.gov.hmcts.reform.pcs.ccd.util.YesOrNoConverter.toVerticalYesNo; @Component @@ -30,12 +35,15 @@ private static Optional getMainClaim(PcsCaseEntity pcsCaseEntity) { private static void setPossessionAlternativesFields(PCSCase pcsCase, PossessionAlternativesEntity possessionAlternatives) { + Set alternativesToPossession = new HashSet<>(); + if (possessionAlternatives.getSuspensionOfRTB() == YesOrNo.YES) { SuspensionOfRightToBuy suspensionOfRightToBuy = SuspensionOfRightToBuy.builder() .housingAct(possessionAlternatives.getSuspensionOfRTBHousingActSection()) .reason(possessionAlternatives.getSuspensionOfRTBReason()) .build(); pcsCase.setSuspensionOfRightToBuy(suspensionOfRightToBuy); + alternativesToPossession.add(SUSPENSION_OF_RIGHT_TO_BUY); } if (possessionAlternatives.getDotRequested() == YesOrNo.YES) { @@ -47,7 +55,10 @@ private static void setPossessionAlternativesFields(PCSCase pcsCase, .statementOfExpressTermsDetails(possessionAlternatives.getDotStatementDetails()) .build(); pcsCase.setDemotionOfTenancy(demotionOfTenancy); + alternativesToPossession.add(DEMOTION_OF_TENANCY); } + + pcsCase.setAlternativesToPossession(alternativesToPossession); } } From 8b0f4f340238ec3efc3bcdde7078a88403dbeb04 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 16:23:59 +0100 Subject: [PATCH 078/138] HDPI-2983: update tests --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 17 ++++++++++++++++- .../ClaimGroundSummaryBuilderTest.java | 3 +-- 2 files changed, 17 insertions(+), 3 deletions(-) rename src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/{ => builder}/ClaimGroundSummaryBuilderTest.java (99%) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 7d7dd6240b..0bd99c9ef2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -23,6 +23,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.AdditionalDefendantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.DefendantInformationTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; @@ -45,6 +48,15 @@ public class CaseSummaryTabViewTest { @Mock private ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + @Mock + private ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; + + @Mock + private DefendantInformationTabDetailsBuilder defendantInformationTabDetailsBuilder; + + @Mock + private AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; + private CaseSummaryTabView underTest; @BeforeEach @@ -52,7 +64,10 @@ void setUp() { underTest = new CaseSummaryTabView( groundsBuilder, rentArrearsTabDetailsBuilder, - reasonsForPossessionTabDetailsBuilder + reasonsForPossessionTabDetailsBuilder, + claimantInformationTabDetailsBuilder, + defendantInformationTabDetailsBuilder, + additionalDefendantInformationTabDetailsBuilder ); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java similarity index 99% rename from src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java rename to src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java index fe44e2a731..0a12576565 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java @@ -1,4 +1,4 @@ -package uk.gov.hmcts.reform.pcs.ccd.view; +package uk.gov.hmcts.reform.pcs.ccd.view.builder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -40,7 +40,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractGroundsForPossessionWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; -import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimGroundSummaryBuilder; import java.util.List; import java.util.Map; From 76eb724e85ebdfab592cfdf394129518e38c0fd6 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 17:11:19 +0100 Subject: [PATCH 079/138] HDPI-2983: update ClaimGroundSummaryBuilderTest --- .../ClaimGroundSummaryBuilderTest.java | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java index 0a12576565..3f67a6b80f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilderTest.java @@ -12,6 +12,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; @@ -41,6 +42,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractDiscretionaryGroundsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.SecureContractMandatoryGroundsWales; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -655,6 +657,101 @@ void shouldReturnEmptyClaimGroundSummariesForIntroductoryDraftWithoutSelectedGro assertThat(summaries).isEmpty(); } + @Test + void shouldAddDescriptionForIntroductoryDemotedOrOtherGrounds() { + // Given + String description = "Other description"; + Set introductoryDemotedOrOtherGrounds = new HashSet<>(); + introductoryDemotedOrOtherGrounds.add(IntroductoryDemotedOrOtherGrounds.OTHER); + IntroductoryDemotedOtherGroundsForPossession introductoryDemotedOtherGroundsForPossession = + IntroductoryDemotedOtherGroundsForPossession.builder() + .hasIntroductoryDemotedOtherGroundsForPossession(VerticalYesNo.YES) + .introductoryDemotedOrOtherGrounds(introductoryDemotedOrOtherGrounds) + .otherGroundDescription(description) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails( + TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.INTRODUCTORY_TENANCY) + .build()) + .introductoryDemotedOrOtherGroundsForPossession(introductoryDemotedOtherGroundsForPossession) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries.size()).isEqualTo(1); + ClaimGroundSummary claimGroundSummary = summaries.getFirst().getValue(); + assertThat(claimGroundSummary.getDescription()).isEqualTo(description); + } + + @Test + void shouldAddDescriptionForAssuredAdditionalOtherGroundWithRentArrears() { + // Given + String description = "Other description"; + Set additionalOtherGround = new HashSet<>(); + additionalOtherGround.add(AssuredAdditionalOtherGround.OTHER); + + AssuredRentArrearsPossessionGrounds assuredRentArrearsPossessionGrounds = + AssuredRentArrearsPossessionGrounds.builder() + .additionalOtherGround(additionalOtherGround) + .additionalOtherGroundDescription(description) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails( + TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .assuredRentArrearsPossessionGrounds(assuredRentArrearsPossessionGrounds) + .claimDueToRentArrears(YesOrNo.YES) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries.size()).isEqualTo(1); + ClaimGroundSummary claimGroundSummary = summaries.getFirst().getValue(); + assertThat(claimGroundSummary.getDescription()).isEqualTo(description); + } + + @Test + void shouldAddDescriptionForAssuredAdditionalOtherGroundWithNoRentArrears() { + // Given + String description = "Other description"; + Set additionalOtherGround = new HashSet<>(); + additionalOtherGround.add(AssuredAdditionalOtherGround.OTHER); + + AssuredNoArrearsPossessionGrounds assuredNoRentArrearsPossessionGrounds = + AssuredNoArrearsPossessionGrounds.builder() + .otherGround(additionalOtherGround) + .otherGroundDescription(description) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .tenancyLicenceDetails( + TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .build()) + .noRentArrearsGroundsOptions(assuredNoRentArrearsPossessionGrounds) + .claimDueToRentArrears(YesOrNo.NO) + .build(); + + // When + List> summaries = + claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData); + + // Then + assertThat(summaries.size()).isEqualTo(1); + ClaimGroundSummary claimGroundSummary = summaries.getFirst().getValue(); + assertThat(claimGroundSummary.getDescription()).isEqualTo(description); + } + private static Stream introductoryDemotedOrOtherTenancyDrafts() { return Stream.of( Arguments.of( From 704af27e40c23ee91386b15b7756c0c6fcbad89e Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 19 May 2026 17:39:49 +0100 Subject: [PATCH 080/138] HDPI-2983: add AdditionalDefendantInformationTabDetailsBuilderTest --- ...DefendantInformationTabDetailsBuilder.java | 5 +- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 64 ---- ...ndantInformationTabDetailsBuilderTest.java | 279 ++++++++++++++++++ 3 files changed, 282 insertions(+), 66 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java index 060772c5ce..847a3fe3f2 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java @@ -10,6 +10,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; import java.util.List; +import java.util.Objects; @Component public class AdditionalDefendantInformationTabDetailsBuilder extends DefendantInformationBuilder { @@ -23,7 +24,7 @@ public List> buildSummaryAdd .skip(1) .map(ListValue::getValue) .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) - .filter(defendantDetails -> defendantDetails != null) + .filter(Objects::nonNull) .map(defendantDetails -> ListValue.builder() .value(defendantDetails) .build()) @@ -40,7 +41,7 @@ public List> buildDetailedAd .skip(1) .map(ListValue::getValue) .map(defendant -> createAdditionalDetailedDefendantDetails(defendant, pcsCase)) - .filter(defendantDetails -> defendantDetails != null) + .filter(Objects::nonNull) .map(defendantDetails -> ListValue.builder() .value(defendantDetails) .build()) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 0bd99c9ef2..1d6770d6a0 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -306,70 +306,6 @@ void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); } - @Test - void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnown() { - // Given - AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .allDefendants(List.of( - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.YES) - .address(address) - .build()) - )) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) - .isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) - .isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) - .isEqualTo(address); - } - - @Test - void shouldDefaultAdditionalDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { - // Given - AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .allDefendants(List.of( - listValue(Party.builder() - .nameKnown(VerticalYesNo.YES) - .firstName("Defendant") - .lastName("One") - .build()), - listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()) - )) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) - .isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()) - .isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) - .isEqualTo(propertyAddress); - } - @Test void shouldSetEachGroundReasonInSummaryTab() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java new file mode 100644 index 0000000000..1faf7da604 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java @@ -0,0 +1,279 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.view.CaseTabView; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class AdditionalDefendantInformationTabDetailsBuilderTest { + + private AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; + + @BeforeEach + void setUp() { + additionalDefendantInformationTabDetailsBuilder = new AdditionalDefendantInformationTabDetailsBuilder(); + } + + @Test + void shouldSetAdditionalDefendantsInSummaryTabWhenThereIsMoreThanOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + String firstName = "Defendant2"; + String lastName = "Two"; + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName(firstName) + .lastName(lastName) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()) + .isEqualTo(firstName); + assertThat(additionalDefendants.getFirst().getValue().getLastName()) + .isEqualTo(lastName); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) + .isEqualTo(address); + } + + @Test + void shouldNotSetAdditionalDefendantsInSummaryTabWhenThereIsOnlyOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).isNull(); + } + + @Test + void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnownInSummaryTab() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) + .isEqualTo(address); + } + + @Test + void shouldDefaultAdditionalDefendantAddressForServiceToPropertyAddressWhenAddressNotKnownInSummaryTab() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getLastName()) + .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) + .isEqualTo(propertyAddress); + } + + @Test + void shouldSetAdditionalDefendantsInDetailsTabWhenThereIsMoreThanOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + String firstName = "Defendant2"; + String lastName = "Two"; + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName(firstName) + .lastName(lastName) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()) + .isEqualTo("Yes"); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()) + .isEqualTo(firstName); + assertThat(additionalDefendants.getFirst().getValue().getLastName()) + .isEqualTo(lastName); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()) + .isEqualTo("Yes"); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) + .isEqualTo(address); + } + + @Test + void shouldNotSetAdditionalDefendantsInDetailsTabWhenThereIsOnlyOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).isNull(); + } + + @Test + void shouldSetUnknownAdditionalDefendantNameToNullWhenNameNotKnownButAddressKnownInDetailsTab() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getLastName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()).isEqualTo(address); + } + + @Test + void shouldDefaultAdditionalDefendantAddressForServiceToNullWhenAddressNotKnownInDetailsTab() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getFirstName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getLastName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getAddressForService()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} From ffa9bd57fb091b228e3755cb05486da636717b24 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 08:33:45 +0100 Subject: [PATCH 081/138] HDPI-2983: add DefendantInformationTabDetailsBuilderTest --- .../pcs/ccd/view/CaseDetailsTabView.java | 2 +- ...DefendantInformationTabDetailsBuilder.java | 2 +- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 42 ---- ...ndantInformationTabDetailsBuilderTest.java | 14 ++ ...ndantInformationTabDetailsBuilderTest.java | 217 ++++++++++++++++++ 5 files changed, 233 insertions(+), 44 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilderTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index a1fb68448b..58d16e843c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -87,7 +87,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); DefendantInformationTabDetails defendantInformationTabDetails = - defendantInformationTabDetailsBuilder.createDetailedDefendantDetails(pcsCase); + defendantInformationTabDetailsBuilder.buildDetailedDefendantDetails(pcsCase); List> underlesseeMortgageTabDetailsList = buildUnderlesseeMortgageTabDetailsList(pcsCase); DemotionOfTenancyTabDetails demotionOfTenancyTabDetails = buildDemotionOfTenancyTabDetails(pcsCase); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java index 137785a7e7..4a438e57e0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java @@ -19,7 +19,7 @@ public DefendantInformationTabDetails buildSummaryDefendantOneDetails(PCSCase pc return createSummaryDefendantDetails(pcsCase.getAllDefendants().getFirst().getValue(), pcsCase); } - public DefendantInformationTabDetails createDetailedDefendantDetails(PCSCase pcsCase) { + public DefendantInformationTabDetails buildDetailedDefendantDetails(PCSCase pcsCase) { if (CollectionUtils.isEmpty(pcsCase.getAllDefendants())) { return null; } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 1d6770d6a0..0b7d63541f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -264,48 +264,6 @@ void shouldNotSetEmptySummarySections() { assertThat(summaryTab.getNoticeDetails()).isNull(); } - @Test - void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { - // Given - AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .allDefendants(List.of(listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.YES) - .address(address) - .build()))) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(address); - } - - @Test - void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnown() { - // Given - AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .allDefendants(List.of(listValue(Party.builder() - .nameKnown(VerticalYesNo.NO) - .addressKnown(VerticalYesNo.NO) - .build()))) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - } - @Test void shouldSetEachGroundReasonInSummaryTab() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java index 1faf7da604..e210ff7c8d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java @@ -52,10 +52,12 @@ void shouldSetAdditionalDefendantsInSummaryTabWhenThereIsMoreThanOneDefendant() // Then assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getFirstName()) .isEqualTo(firstName); assertThat(additionalDefendants.getFirst().getValue().getLastName()) .isEqualTo(lastName); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) .isEqualTo(address); } @@ -107,10 +109,12 @@ void shouldSetUnknownAdditionalDefendantNameWhenNameNotKnownButAddressKnownInSum // Then assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getFirstName()) .isEqualTo(CaseTabView.NAME_UNKNOWN); assertThat(additionalDefendants.getFirst().getValue().getLastName()) .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) .isEqualTo(address); } @@ -140,10 +144,12 @@ void shouldDefaultAdditionalDefendantAddressForServiceToPropertyAddressWhenAddre // Then assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getFirstName()) .isEqualTo(CaseTabView.NAME_UNKNOWN); assertThat(additionalDefendants.getFirst().getValue().getLastName()) .isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getAddressForService()) .isEqualTo(propertyAddress); } @@ -236,8 +242,12 @@ void shouldSetUnknownAdditionalDefendantNameToNullWhenNameNotKnownButAddressKnow // Then assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()) + .isEqualTo("No"); assertThat(additionalDefendants.getFirst().getValue().getFirstName()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getLastName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()) + .isEqualTo("Yes"); assertThat(additionalDefendants.getFirst().getValue().getAddressForService()).isEqualTo(address); } @@ -266,8 +276,12 @@ void shouldDefaultAdditionalDefendantAddressForServiceToNullWhenAddressNotKnownI // Then assertThat(additionalDefendants).hasSize(1); + assertThat(additionalDefendants.getFirst().getValue().getNameKnown()) + .isEqualTo("No"); assertThat(additionalDefendants.getFirst().getValue().getFirstName()).isNull(); assertThat(additionalDefendants.getFirst().getValue().getLastName()).isNull(); + assertThat(additionalDefendants.getFirst().getValue().getAddressKnown()) + .isEqualTo("No"); assertThat(additionalDefendants.getFirst().getValue().getAddressForService()).isNull(); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilderTest.java new file mode 100644 index 0000000000..237385d58e --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilderTest.java @@ -0,0 +1,217 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.view.CaseTabView; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DefendantInformationTabDetailsBuilderTest { + + private DefendantInformationTabDetailsBuilder defendantInformationTabDetailsBuilder; + + @BeforeEach + void setUp() { + defendantInformationTabDetailsBuilder = new DefendantInformationTabDetailsBuilder(); + } + + @Test + void shouldSetDefendantInSummaryTabWhenThereIsAtLeastOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + String firstName = "Defendant"; + String lastName = "One"; + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName(firstName) + .lastName(lastName) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildSummaryDefendantOneDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isNull(); + assertThat(defendantInformationTabDetails.getFirstName()).isEqualTo(firstName); + assertThat(defendantInformationTabDetails.getLastName()).isEqualTo(lastName); + assertThat(defendantInformationTabDetails.getAddressKnown()).isNull(); + assertThat(defendantInformationTabDetails.getAddressForService()).isEqualTo(address); + } + + @Test + void shouldNotSetDefendantInSummaryTabWhenThereIsNoDefendants() { + PCSCase pcsCase = PCSCase.builder().build(); + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildSummaryDefendantOneDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails).isNull(); + } + + @Test + void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnownInSummaryTab() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()))) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildSummaryDefendantOneDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isNull(); + assertThat(defendantInformationTabDetails.getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(defendantInformationTabDetails.getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(defendantInformationTabDetails.getAddressKnown()).isNull(); + assertThat(defendantInformationTabDetails.getAddressForService()).isEqualTo(address); + } + + @Test + void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnownInSummaryTab() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildSummaryDefendantOneDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isNull(); + assertThat(defendantInformationTabDetails.getFirstName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(defendantInformationTabDetails.getLastName()).isEqualTo(CaseTabView.NAME_UNKNOWN); + assertThat(defendantInformationTabDetails.getAddressKnown()).isNull(); + assertThat(defendantInformationTabDetails.getAddressForService()).isEqualTo(propertyAddress); + } + + @Test + void shouldSetDefendantInDetailsTabWhenThereIsAtLeastOneDefendant() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + String firstName = "Defendant"; + String lastName = "One"; + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName(firstName) + .lastName(lastName) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildDetailedDefendantDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isEqualTo("Yes"); + assertThat(defendantInformationTabDetails.getFirstName()).isEqualTo(firstName); + assertThat(defendantInformationTabDetails.getLastName()).isEqualTo(lastName); + assertThat(defendantInformationTabDetails.getAddressKnown()).isEqualTo("Yes"); + assertThat(defendantInformationTabDetails.getAddressForService()).isEqualTo(address); + } + + @Test + void shouldNotSetDefendantInDetailsTabWhenThereIsNoDefendants() { + PCSCase pcsCase = PCSCase.builder().build(); + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildDetailedDefendantDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails).isNull(); + } + + @Test + void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnownInDetailsTab() { + // Given + AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.YES) + .address(address) + .build()))) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildDetailedDefendantDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isEqualTo("No"); + assertThat(defendantInformationTabDetails.getFirstName()).isNull(); + assertThat(defendantInformationTabDetails.getLastName()).isNull(); + assertThat(defendantInformationTabDetails.getAddressKnown()).isEqualTo("Yes"); + assertThat(defendantInformationTabDetails.getAddressForService()).isEqualTo(address); + } + + @Test + void shouldDefaultDefendantAddressForServiceToPropertyAddressWhenAddressNotKnownInDetailsTab() { + // Given + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .allDefendants(List.of(listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()))) + .build(); + + // When + DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder + .buildDetailedDefendantDetails(pcsCase); + + // Then + assertThat(defendantInformationTabDetails.getNameKnown()).isEqualTo("No"); + assertThat(defendantInformationTabDetails.getFirstName()).isNull(); + assertThat(defendantInformationTabDetails.getLastName()).isNull(); + assertThat(defendantInformationTabDetails.getAddressKnown()).isEqualTo("No"); + assertThat(defendantInformationTabDetails.getAddressForService()).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} From c99cf628aa7fa052916981043a76348855198852 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 08:43:35 +0100 Subject: [PATCH 082/138] HDPI-2983: add ClaimantInformationTabDetailsBuilderTest --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 47 -------- ...imantInformationTabDetailsBuilderTest.java | 112 ++++++++++++++++++ 2 files changed, 112 insertions(+), 47 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilderTest.java diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 0b7d63541f..597ebe92e2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -192,53 +192,6 @@ void shouldDisplaySubmittedDateInGmtWhenBritishSummerTimeApplies() { assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 5:02:31PM"); } - @Test - void shouldSetSummaryClaimantNameFromOverriddenName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .isClaimantNameCorrect(VerticalYesNo.NO) - .overriddenClaimantName("Overridden claimant") - .build()) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Overridden claimant"); - } - - @Test - void shouldSetSummaryClaimantNameFromClaimantInformationName() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimantInformation(ClaimantInformation.builder() - .claimantName("Claimant information name") - .build()) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant information name"); - } - - @Test - void shouldSetSummaryClaimantNameFromAllClaimants() { - // Given - PCSCase pcsCase = PCSCase.builder() - .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Claimant party"); - } - @Test void shouldNotSetEmptySummarySections() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilderTest.java new file mode 100644 index 0000000000..9400490ba0 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimantInformationTabDetailsBuilderTest.java @@ -0,0 +1,112 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; +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.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ClaimantInformationTabDetailsBuilderTest { + + private ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; + + @BeforeEach + void setUp() { + claimantInformationTabDetailsBuilder = new ClaimantInformationTabDetailsBuilder(); + } + + @Test + void shouldSetSummaryClaimantNameFromFallbackName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .orgNameFound(YesOrNo.NO) + .fallbackClaimantName("Fallback claimant") + .build()) + .build(); + + // When + ClaimantInformationTabDetails claimantInformationTabDetails = + claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + + // Then + assertThat(claimantInformationTabDetails.getClaimantName()).isEqualTo("Fallback claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromOverriddenName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .isClaimantNameCorrect(VerticalYesNo.NO) + .overriddenClaimantName("Overridden claimant") + .build()) + .build(); + + // When + ClaimantInformationTabDetails claimantInformationTabDetails = + claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + + // Then + assertThat(claimantInformationTabDetails.getClaimantName()).isEqualTo("Overridden claimant"); + } + + @Test + void shouldSetSummaryClaimantNameFromClaimantInformationName() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimantInformation(ClaimantInformation.builder() + .claimantName("Claimant information name") + .build()) + .build(); + + // When + ClaimantInformationTabDetails claimantInformationTabDetails = + claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + + // Then + assertThat(claimantInformationTabDetails.getClaimantName()).isEqualTo("Claimant information name"); + } + + @Test + void shouldSetSummaryClaimantNameFromAllClaimants() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allClaimants(List.of(listValue(Party.builder().orgName("Claimant party").build()))) + .build(); + + // When + ClaimantInformationTabDetails claimantInformationTabDetails = + claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + + // Then + assertThat(claimantInformationTabDetails.getClaimantName()).isEqualTo("Claimant party"); + } + + @Test + void shouldReturnNullWithNoClaimantData() { + // Given + PCSCase pcsCase = PCSCase.builder().build(); + + // When + ClaimantInformationTabDetails claimantInformationTabDetails = + claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase); + + // Then + assertThat(claimantInformationTabDetails).isNull(); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} From 6ff1f2dbf6b6ca0c6c2713b49600d93ea87bba3b Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 09:31:20 +0100 Subject: [PATCH 083/138] HDPI-2983: add GroundsBuilderTest and ReasonsForPossessionTabDetailsBuilderTest --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 254 --------------- .../ccd/view/builder/GroundsBuilderTest.java | 98 ++++++ ...onsForPossessionTabDetailsBuilderTest.java | 291 ++++++++++++++++++ 3 files changed, 389 insertions(+), 254 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 597ebe92e2..2a838ea673 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -217,260 +217,6 @@ void shouldNotSetEmptySummarySections() { assertThat(summaryTab.getNoticeDetails()).isNull(); } - @Test - void shouldSetEachGroundReasonInSummaryTab() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder() - .label("Antisocial behaviour") - .reason("Antisocial reason") - .build()), - listValue(ClaimGroundSummary.builder() - .label("Premium paid in connection with mutual exchange (ground 6)") - .reason("Premium reason") - .build()), - listValue(ClaimGroundSummary.builder() - .label("Offence during a riot (ground 2ZA)") - .reason("Riot reason") - .build()), - listValue(ClaimGroundSummary.builder() - .label("Condition 1 of Section 84A of the Housing Act 1985") - .reason("Condition 1 reason") - .build()), - listValue(ClaimGroundSummary.builder() - .label("Landlord’s works (ground 10)") - .reason("Works reason") - .build()), - listValue(ClaimGroundSummary.builder() - .label("Housing association special circumstances accommodation (ground 14)") - .reason("Housing reason") - .build()) - )) - .build(); - - // When - ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); - - // Then - assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); - assertThat(reasons.getGround6()).isEqualTo("Premium reason"); - assertThat(reasons.getGround2ZA()).isEqualTo("Riot reason"); - assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); - assertThat(reasons.getGround10()).isEqualTo("Works reason"); - assertThat(reasons.getGround14()).isEqualTo("Housing reason"); - } - - @Test - void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - groundSummary("Antisocial behaviour", "Antisocial reason"), - groundSummary("Nuisance, annoyance, illegal or immoral use of the property (ground 2)", - "Nuisance reason"), - groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), - groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), - groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), - groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), - groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), - groundSummary("Landlord’s works (ground 10)", "Works reason") - )) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", - "Antisocial behaviour: " + String.join(", ", - "Condition 1 of Section 84A of the Housing Act 1985", - "Condition 2 of Section 84A of the Housing Act 1985", - "Condition 3 of Section 84A of the Housing Act 1985", - "Condition 4 of Section 84A of the Housing Act 1985", - "Condition 5 of Section 84A of the Housing Act 1985" - ), - "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", - "Landlord’s works (ground 10)" - )); - } - - @Test - void shouldGroupSection84AConditionsUnderAntisocialBehaviourWhenParentGroundIsMissing() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), - groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), - groundSummary("Landlord’s works (ground 10)", "Works reason") - )) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo(String.join("\n", - "Antisocial behaviour: " + String.join(", ", - "Condition 1 of Section 84A of the Housing Act 1985", - "Condition 2 of Section 84A of the Housing Act 1985" - ), - "Landlord’s works (ground 10)" - )); - } - - @Test - void shouldSetEachGroundNumberReasonInSummaryTab() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - groundSummary("Ground label (ground 1)", "Reason 1"), - groundSummary("Ground label (ground 2)", "Reason 2"), - groundSummary("Ground label (ground 2A)", "Reason 2A"), - groundSummary("Ground label (ground 2ZA)", "Reason 2ZA"), - groundSummary("Ground label (ground 3)", "Reason 3"), - groundSummary("Ground label (ground 4)", "Reason 4"), - groundSummary("Ground label (ground 5)", "Reason 5"), - groundSummary("Ground label (ground 6)", "Reason 6"), - groundSummary("Ground label (ground 7)", "Reason 7"), - groundSummary("Ground label (ground 7A)", "Reason 7A"), - groundSummary("Ground label (ground 7B)", "Reason 7B"), - groundSummary("Ground label (ground 8)", "Reason 8"), - groundSummary("Ground label (ground 9)", "Reason 9"), - groundSummary("Ground label (ground 10)", "Reason 10"), - groundSummary("Ground label (ground 10A)", "Reason 10A"), - groundSummary("Ground label (ground 11)", "Reason 11"), - groundSummary("Ground label (ground 12)", "Reason 12"), - groundSummary("Ground label (ground 13)", "Reason 13"), - groundSummary("Ground label (ground 14)", "Reason 14"), - groundSummary("Ground label (ground 14A)", "Reason 14A"), - groundSummary("Ground label (ground 14ZA)", "Reason 14ZA"), - groundSummary("Ground label (ground 15)", "Reason 15"), - groundSummary("Ground label (ground 15A)", "Reason 15A"), - groundSummary("Ground label (ground 16)", "Reason 16"), - groundSummary("Ground label (ground 17)", "Reason 17"), - groundSummary("Ground label (ground A)", "Reason A"), - groundSummary("Ground label (ground B)", "Reason B"), - groundSummary("Ground label (ground C)", "Reason C"), - groundSummary("Ground label (ground D)", "Reason D"), - groundSummary("Ground label (ground E)", "Reason E"), - groundSummary("Ground label (ground F)", "Reason F"), - groundSummary("Ground label (ground G)", "Reason G"), - groundSummary("Ground label (ground H)", "Reason H"), - groundSummary("Ground label (ground I)", "Reason I"), - groundSummary("Ground label (ground Z)", "Unmapped reason") - )) - .build(); - - // When - ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); - - // Then - assertThat(reasons.getGround1()).isEqualTo("Reason 1"); - assertThat(reasons.getGround2()).isEqualTo("Reason 2"); - assertThat(reasons.getGround2A()).isEqualTo("Reason 2A"); - assertThat(reasons.getGround2ZA()).isEqualTo("Reason 2ZA"); - assertThat(reasons.getGround3()).isEqualTo("Reason 3"); - assertThat(reasons.getGround4()).isEqualTo("Reason 4"); - assertThat(reasons.getGround5()).isEqualTo("Reason 5"); - assertThat(reasons.getGround6()).isEqualTo("Reason 6"); - assertThat(reasons.getGround7()).isEqualTo("Reason 7"); - assertThat(reasons.getGround7A()).isEqualTo("Reason 7A"); - assertThat(reasons.getGround7B()).isEqualTo("Reason 7B"); - assertThat(reasons.getGround8()).isEqualTo("Reason 8"); - assertThat(reasons.getGround9()).isEqualTo("Reason 9"); - assertThat(reasons.getGround10()).isEqualTo("Reason 10"); - assertThat(reasons.getGround10A()).isEqualTo("Reason 10A"); - assertThat(reasons.getGround11()).isEqualTo("Reason 11"); - assertThat(reasons.getGround12()).isEqualTo("Reason 12"); - assertThat(reasons.getGround13()).isEqualTo("Reason 13"); - assertThat(reasons.getGround14()).isEqualTo("Reason 14"); - assertThat(reasons.getGround14A()).isEqualTo("Reason 14A"); - assertThat(reasons.getGround14ZA()).isEqualTo("Reason 14ZA"); - assertThat(reasons.getGround15()).isEqualTo("Reason 15"); - assertThat(reasons.getGround15A()).isEqualTo("Reason 15A"); - assertThat(reasons.getGround16()).isEqualTo("Reason 16"); - assertThat(reasons.getGround17()).isEqualTo("Reason 17"); - assertThat(reasons.getGroundA()).isEqualTo("Reason A"); - assertThat(reasons.getGroundB()).isEqualTo("Reason B"); - assertThat(reasons.getGroundC()).isEqualTo("Reason C"); - assertThat(reasons.getGroundD()).isEqualTo("Reason D"); - assertThat(reasons.getGroundE()).isEqualTo("Reason E"); - assertThat(reasons.getGroundF()).isEqualTo("Reason F"); - assertThat(reasons.getGroundG()).isEqualTo("Reason G"); - assertThat(reasons.getGroundH()).isEqualTo("Reason H"); - assertThat(reasons.getGroundI()).isEqualTo("Reason I"); - } - - @Test - void shouldSetEachSectionReasonInSummaryTab() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - groundSummary("Ground label (section 157)", "Reason 157"), - groundSummary("Ground label (section 170)", "Reason 170"), - groundSummary("Ground label (section 178)", "Reason 178"), - groundSummary("Ground label (section 181)", "Reason 181"), - groundSummary("Ground label (section 186)", "Reason 186"), - groundSummary("Ground label (section 187)", "Reason 187"), - groundSummary("Ground label (section 191)", "Reason 191"), - groundSummary("Ground label (section 199)", "Reason 199"), - groundSummary("Ground label (section 999)", "Unmapped reason") - )) - .build(); - - // When - ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); - - // Then - assertThat(reasons.getSection157()).isEqualTo("Reason 157"); - assertThat(reasons.getSection170()).isEqualTo("Reason 170"); - assertThat(reasons.getSection178()).isEqualTo("Reason 178"); - assertThat(reasons.getSection181()).isEqualTo("Reason 181"); - assertThat(reasons.getSection186()).isEqualTo("Reason 186"); - assertThat(reasons.getSection187()).isEqualTo("Reason 187"); - assertThat(reasons.getSection191()).isEqualTo("Reason 191"); - assertThat(reasons.getSection199()).isEqualTo("Reason 199"); - } - - @Test - void shouldSetNonNumberedGroundReasonsInSummaryTab() { - // Given - PCSCase pcsCase = PCSCase.builder() - .claimGroundSummaries(List.of( - groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), - groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), - groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), - groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), - groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), - groundSummary("Antisocial behaviour", "Antisocial reason"), - groundSummary("Breach of the tenancy", "Breach reason"), - groundSummary("Absolute grounds", "Absolute reason"), - groundSummary("Other", "Other reason"), - groundSummary("Other grounds", "Other grounds reason"), - groundSummary("No grounds", "No grounds reason"), - groundSummary("Converted contract paragraph 25B(2) of Schedule 12", "Paragraph reason"), - groundSummary("Unmapped label", "Unmapped reason") - )) - .build(); - - // When - ReasonsForPossessionTabDetails reasons = underTest.buildSummaryTab(pcsCase).getReasonsForPossession(); - - // Then - assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); - assertThat(reasons.getCondition2OfSection84A()).isEqualTo("Condition 2 reason"); - assertThat(reasons.getCondition3OfSection84A()).isEqualTo("Condition 3 reason"); - assertThat(reasons.getCondition4OfSection84A()).isEqualTo("Condition 4 reason"); - assertThat(reasons.getCondition5OfSection84A()).isEqualTo("Condition 5 reason"); - assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); - assertThat(reasons.getBreachOfTheTenancy()).isEqualTo("Breach reason"); - assertThat(reasons.getAbsoluteGrounds()).isEqualTo("Absolute reason"); - assertThat(reasons.getOtherGrounds()).isEqualTo("Other grounds reason"); - assertThat(reasons.getNoGrounds()).isEqualTo("No grounds reason"); - assertThat(reasons.getParagraph25B2Schedule12()).isEqualTo("Paragraph reason"); - } - @Test void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java new file mode 100644 index 0000000000..f48541c6c1 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java @@ -0,0 +1,98 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GroundsBuilderTest { + + private GroundsBuilder groundsBuilder; + + @BeforeEach + void setUp() { + groundsBuilder = new GroundsBuilder(); + } + + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourInGrounds() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Nuisance reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + String grounds = groundsBuilder.getGrounds(pcsCase); + + // Then + assertThat(grounds).isEqualTo(String.join( + "\n", + "Antisocial behaviour: " + String.join( + ", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985", + "Condition 3 of Section 84A of the Housing Act 1985", + "Condition 4 of Section 84A of the Housing Act 1985", + "Condition 5 of Section 84A of the Housing Act 1985" + ), + "Nuisance, annoyance, illegal or immoral use of the property (ground 2)", + "Landlord’s works (ground 10)" + )); + } + + @Test + void shouldGroupSection84AConditionsUnderAntisocialBehaviourWhenParentGroundIsMissing() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + String grounds = groundsBuilder.getGrounds(pcsCase); + + // Then + assertThat(grounds).isEqualTo(String.join( + "\n", + "Antisocial behaviour: " + String.join( + ", ", + "Condition 1 of Section 84A of the Housing Act 1985", + "Condition 2 of Section 84A of the Housing Act 1985" + ), + "Landlord’s works (ground 10)" + )); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } + + + + private static ListValue groundSummary(String label, String reason) { + return listValue(ClaimGroundSummary.builder() + .label(label) + .reason(reason) + .build()); + } +} diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java new file mode 100644 index 0000000000..be62be4f24 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java @@ -0,0 +1,291 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ReasonsForPossessionTabDetailsBuilderTest { + + private ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + + @BeforeEach + void setUp() { + reasonsForPossessionTabDetailsBuilder = new ReasonsForPossessionTabDetailsBuilder(); + } + + @Test + void shouldSetEachGroundReason() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Antisocial behaviour") + .reason("Antisocial reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Premium paid in connection with mutual exchange (ground 6)") + .reason("Premium reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Offence during a riot (ground 2ZA)") + .reason("Riot reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Landlord’s works (ground 10)") + .reason("Works reason") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Housing association special circumstances accommodation (ground 14)") + .reason("Housing reason") + .build()) + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getGround6()).isEqualTo("Premium reason"); + assertThat(reasons.getGround2ZA()).isEqualTo("Riot reason"); + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getGround10()).isEqualTo("Works reason"); + assertThat(reasons.getGround14()).isEqualTo("Housing reason"); + } + + @Test + void shouldSetEachGroundNumberReason() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (ground 1)", "Reason 1"), + groundSummary("Ground label (ground 2)", "Reason 2"), + groundSummary("Ground label (ground 2A)", "Reason 2A"), + groundSummary("Ground label (ground 2ZA)", "Reason 2ZA"), + groundSummary("Ground label (ground 3)", "Reason 3"), + groundSummary("Ground label (ground 4)", "Reason 4"), + groundSummary("Ground label (ground 5)", "Reason 5"), + groundSummary("Ground label (ground 6)", "Reason 6"), + groundSummary("Ground label (ground 7)", "Reason 7"), + groundSummary("Ground label (ground 7A)", "Reason 7A"), + groundSummary("Ground label (ground 7B)", "Reason 7B"), + groundSummary("Ground label (ground 8)", "Reason 8"), + groundSummary("Ground label (ground 9)", "Reason 9"), + groundSummary("Ground label (ground 10)", "Reason 10"), + groundSummary("Ground label (ground 10A)", "Reason 10A"), + groundSummary("Ground label (ground 11)", "Reason 11"), + groundSummary("Ground label (ground 12)", "Reason 12"), + groundSummary("Ground label (ground 13)", "Reason 13"), + groundSummary("Ground label (ground 14)", "Reason 14"), + groundSummary("Ground label (ground 14A)", "Reason 14A"), + groundSummary("Ground label (ground 14ZA)", "Reason 14ZA"), + groundSummary("Ground label (ground 15)", "Reason 15"), + groundSummary("Ground label (ground 15A)", "Reason 15A"), + groundSummary("Ground label (ground 16)", "Reason 16"), + groundSummary("Ground label (ground 17)", "Reason 17"), + groundSummary("Ground label (ground A)", "Reason A"), + groundSummary("Ground label (ground B)", "Reason B"), + groundSummary("Ground label (ground C)", "Reason C"), + groundSummary("Ground label (ground D)", "Reason D"), + groundSummary("Ground label (ground E)", "Reason E"), + groundSummary("Ground label (ground F)", "Reason F"), + groundSummary("Ground label (ground G)", "Reason G"), + groundSummary("Ground label (ground H)", "Reason H"), + groundSummary("Ground label (ground I)", "Reason I"), + groundSummary("Ground label (ground Z)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getGround1()).isEqualTo("Reason 1"); + assertThat(reasons.getGround2()).isEqualTo("Reason 2"); + assertThat(reasons.getGround2A()).isEqualTo("Reason 2A"); + assertThat(reasons.getGround2ZA()).isEqualTo("Reason 2ZA"); + assertThat(reasons.getGround3()).isEqualTo("Reason 3"); + assertThat(reasons.getGround4()).isEqualTo("Reason 4"); + assertThat(reasons.getGround5()).isEqualTo("Reason 5"); + assertThat(reasons.getGround6()).isEqualTo("Reason 6"); + assertThat(reasons.getGround7()).isEqualTo("Reason 7"); + assertThat(reasons.getGround7A()).isEqualTo("Reason 7A"); + assertThat(reasons.getGround7B()).isEqualTo("Reason 7B"); + assertThat(reasons.getGround8()).isEqualTo("Reason 8"); + assertThat(reasons.getGround9()).isEqualTo("Reason 9"); + assertThat(reasons.getGround10()).isEqualTo("Reason 10"); + assertThat(reasons.getGround10A()).isEqualTo("Reason 10A"); + assertThat(reasons.getGround11()).isEqualTo("Reason 11"); + assertThat(reasons.getGround12()).isEqualTo("Reason 12"); + assertThat(reasons.getGround13()).isEqualTo("Reason 13"); + assertThat(reasons.getGround14()).isEqualTo("Reason 14"); + assertThat(reasons.getGround14A()).isEqualTo("Reason 14A"); + assertThat(reasons.getGround14ZA()).isEqualTo("Reason 14ZA"); + assertThat(reasons.getGround15()).isEqualTo("Reason 15"); + assertThat(reasons.getGround15A()).isEqualTo("Reason 15A"); + assertThat(reasons.getGround16()).isEqualTo("Reason 16"); + assertThat(reasons.getGround17()).isEqualTo("Reason 17"); + assertThat(reasons.getGroundA()).isEqualTo("Reason A"); + assertThat(reasons.getGroundB()).isEqualTo("Reason B"); + assertThat(reasons.getGroundC()).isEqualTo("Reason C"); + assertThat(reasons.getGroundD()).isEqualTo("Reason D"); + assertThat(reasons.getGroundE()).isEqualTo("Reason E"); + assertThat(reasons.getGroundF()).isEqualTo("Reason F"); + assertThat(reasons.getGroundG()).isEqualTo("Reason G"); + assertThat(reasons.getGroundH()).isEqualTo("Reason H"); + assertThat(reasons.getGroundI()).isEqualTo("Reason I"); + } + + @Test + void shouldSetEachSectionReason() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Ground label (section 157)", "Reason 157"), + groundSummary("Ground label (section 170)", "Reason 170"), + groundSummary("Ground label (section 178)", "Reason 178"), + groundSummary("Ground label (section 181)", "Reason 181"), + groundSummary("Ground label (section 186)", "Reason 186"), + groundSummary("Ground label (section 187)", "Reason 187"), + groundSummary("Ground label (section 191)", "Reason 191"), + groundSummary("Ground label (section 199)", "Reason 199"), + groundSummary("Ground label (section 999)", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getSection157()).isEqualTo("Reason 157"); + assertThat(reasons.getSection170()).isEqualTo("Reason 170"); + assertThat(reasons.getSection178()).isEqualTo("Reason 178"); + assertThat(reasons.getSection181()).isEqualTo("Reason 181"); + assertThat(reasons.getSection186()).isEqualTo("Reason 186"); + assertThat(reasons.getSection187()).isEqualTo("Reason 187"); + assertThat(reasons.getSection191()).isEqualTo("Reason 191"); + assertThat(reasons.getSection199()).isEqualTo("Reason 199"); + } + + @Test + void shouldSetNonNumberedGroundReasons() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason"), + groundSummary("Condition 2 of Section 84A of the Housing Act 1985", "Condition 2 reason"), + groundSummary("Condition 3 of Section 84A of the Housing Act 1985", "Condition 3 reason"), + groundSummary("Condition 4 of Section 84A of the Housing Act 1985", "Condition 4 reason"), + groundSummary("Condition 5 of Section 84A of the Housing Act 1985", "Condition 5 reason"), + groundSummary("Antisocial behaviour", "Antisocial reason"), + groundSummary("Breach of the tenancy", "Breach reason"), + groundSummary("Absolute grounds", "Absolute reason"), + groundSummary("Other", "Other reason"), + groundSummary("Other grounds", "Other grounds reason"), + groundSummary("No grounds", "No grounds reason"), + groundSummary("Converted contract paragraph 25B(2) of Schedule 12", "Paragraph reason"), + groundSummary("Unmapped label", "Unmapped reason") + )) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getCondition2OfSection84A()).isEqualTo("Condition 2 reason"); + assertThat(reasons.getCondition3OfSection84A()).isEqualTo("Condition 3 reason"); + assertThat(reasons.getCondition4OfSection84A()).isEqualTo("Condition 4 reason"); + assertThat(reasons.getCondition5OfSection84A()).isEqualTo("Condition 5 reason"); + assertThat(reasons.getAntisocialBehaviour()).isEqualTo("Antisocial reason"); + assertThat(reasons.getBreachOfTheTenancy()).isEqualTo("Breach reason"); + assertThat(reasons.getAbsoluteGrounds()).isEqualTo("Absolute reason"); + assertThat(reasons.getOtherGrounds()).isEqualTo("Other grounds reason"); + assertThat(reasons.getNoGrounds()).isEqualTo("No grounds reason"); + assertThat(reasons.getParagraph25B2Schedule12()).isEqualTo("Paragraph reason"); + } + + @Test + void shouldSetAdditionalReasonInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason") + )) + .additionalReasonsForPossession( + AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reason") + .build() + ) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getHasAdditionalReasons()).isNull(); + assertThat(reasons.getAdditionalReasonsForPossession()).isEqualTo("Additional reason"); + assertThat(reasons.getAdditionalReasonsDetails()).isNull(); + } + + @Test + void shouldSetAdditionalReasonInDetailsTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Condition 1 of Section 84A of the Housing Act 1985", "Condition 1 reason") + )) + .additionalReasonsForPossession( + AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reason") + .build() + ) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildDetailsReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getCondition1OfSection84A()).isEqualTo("Condition 1 reason"); + assertThat(reasons.getHasAdditionalReasons()).isEqualTo("Yes"); + assertThat(reasons.getAdditionalReasonsForPossession()).isNull(); + assertThat(reasons.getAdditionalReasonsDetails()).isEqualTo("Additional reason"); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } + + + + private static ListValue groundSummary(String label, String reason) { + return listValue(ClaimGroundSummary.builder() + .label(label) + .reason(reason) + .build()); + } +} From af237e9d3e42319e70cd1fb62c5cd35baa11cc3d Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 09:51:57 +0100 Subject: [PATCH 084/138] HDPI-2983: add RentArrearsTabDetailsBuilderTest --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 50 ------------- .../RentArrearsTabDetailsBuilderTest.java | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 50 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 2a838ea673..5bd30e547f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -217,56 +217,6 @@ void shouldNotSetEmptySummarySections() { assertThat(summaryTab.getNoticeDetails()).isNull(); } - @Test - void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .frequency(RentPaymentFrequency.WEEKLY) - .dailyCharge(new BigDecimal("1.50")) - .build()) - .build(); - - // When - RentArrearsTabDetails rentArrearsDetails = underTest.buildSummaryTab(pcsCase).getRentArrearsDetails(); - - // Then - assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); - assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); - } - - @Test - void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .formattedCalculatedDailyCharge("£2.34") - .build()) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£2.34"); - } - - @Test - void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { - // Given - PCSCase pcsCase = PCSCase.builder() - .rentDetails(RentDetails.builder() - .calculatedDailyCharge(new BigDecimal("3.40")) - .build()) - .build(); - - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - - // Then - assertThat(summaryTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£3.40"); - } - @Test void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { // Given diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java new file mode 100644 index 0000000000..acd8e84bf7 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java @@ -0,0 +1,72 @@ +package uk.gov.hmcts.reform.pcs.ccd.view.builder; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; + +import java.math.BigDecimal; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RentArrearsTabDetailsBuilderTest { + + private RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + + @BeforeEach + void setUp() { + rentArrearsTabDetailsBuilder = new RentArrearsTabDetailsBuilder(); + } + + @Test + void shouldSetRentArrearsDetailsFromStandardFrequencyAndDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .frequency(RentPaymentFrequency.WEEKLY) + .dailyCharge(new BigDecimal("1.50")) + .build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£1.50"); + } + + @Test + void shouldSetRentArrearsDetailsFromFormattedCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .formattedCalculatedDailyCharge("£2.34") + .build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£2.34"); + } + + @Test + void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder() + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£3.40"); + } +} From 5c68846decce1e5d10a45690c1d7a452c21dbc95 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 20 May 2026 09:55:41 +0100 Subject: [PATCH 085/138] HDPI-2978: Build Case Summary tab --- .../ccd/view/ClaimGroundSummaryBuilder.java | 110 ++++++++++-------- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 33 +++++- .../view/ClaimGroundSummaryBuilderTest.java | 13 ++- 3 files changed, 105 insertions(+), 51 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java index 50a7ca7242..86adadb10b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilder.java @@ -9,6 +9,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredRentArrearsGround; @@ -17,6 +18,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOtherGroundsForPossession; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.NoRentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; @@ -37,9 +39,51 @@ @Component public class ClaimGroundSummaryBuilder { + private static final Map> + ASSURED_DRAFT_REASON_LOOKUP = Map.ofEntries( + Map.entry(AssuredAdditionalOtherGround.OTHER, + ClaimGroundSummaryBuilder::getAssuredOtherGroundReason), + assuredReasonEntry(AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1, + RentArrearsGroundsReasons::getOwnerOccupierReason), + assuredReasonEntry(AssuredMandatoryGround.REPOSSESSION_GROUND2, + RentArrearsGroundsReasons::getRepossessionByLenderReason), + assuredReasonEntry(AssuredMandatoryGround.HOLIDAY_LET_GROUND3, + RentArrearsGroundsReasons::getHolidayLetReason), + assuredReasonEntry(AssuredMandatoryGround.STUDENT_LET_GROUND4, + RentArrearsGroundsReasons::getStudentLetReason), + assuredReasonEntry(AssuredMandatoryGround.MINISTER_RELIGION_GROUND5, + RentArrearsGroundsReasons::getMinisterOfReligionReason), + assuredReasonEntry(AssuredMandatoryGround.REDEVELOPMENT_GROUND6, + RentArrearsGroundsReasons::getRedevelopmentReason), + assuredReasonEntry(AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7, + RentArrearsGroundsReasons::getDeathOfTenantReason), + assuredReasonEntry(AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A, + RentArrearsGroundsReasons::getAntisocialBehaviourReason), + assuredReasonEntry(AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B, + RentArrearsGroundsReasons::getNoRightToRentReason), + assuredReasonEntry(AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9, + RentArrearsGroundsReasons::getSuitableAltAccommodationReason), + assuredReasonEntry(AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12, + RentArrearsGroundsReasons::getBreachOfTenancyConditionsReason), + assuredReasonEntry(AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13, + RentArrearsGroundsReasons::getPropertyDeteriorationReason), + assuredReasonEntry(AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14, + RentArrearsGroundsReasons::getNuisanceAnnoyanceReason), + assuredReasonEntry(AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A, + RentArrearsGroundsReasons::getDomesticViolenceReason), + assuredReasonEntry(AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA, + RentArrearsGroundsReasons::getOffenceDuringRiotReason), + assuredReasonEntry(AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15, + RentArrearsGroundsReasons::getFurnitureDeteriorationReason), + assuredReasonEntry(AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16, + RentArrearsGroundsReasons::getEmployeeOfLandlordReason), + assuredReasonEntry(AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17, + RentArrearsGroundsReasons::getTenancyByFalseStatementReason) + ); + private static final Map> SECURE_OR_FLEXIBLE_DRAFT_REASON_LOOKUP = Map.ofEntries( - draftReasonEntry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, + Map.entry(SecureAntisocialAdditionalGrounds.S84A_CONDITION_1, ClaimGroundSummaryBuilder::getSection84ACondition1Reason), secureOrFlexibleReasonEntry(SecureOrFlexibleDiscretionaryGrounds.RENT_ARREARS_OR_BREACH_OF_TENANCY, SecureOrFlexibleGroundsReasons::getBreachOfTenancyGround), @@ -134,6 +178,7 @@ private void addTenancyLicenceGrounds(List> summar Optional.ofNullable(draftCaseData.getNoRentArrearsGroundsOptions()).ifPresent(selected -> { addGrounds(summaries, selected.getMandatoryGrounds(), draftCaseData); addGrounds(summaries, selected.getDiscretionaryGrounds(), draftCaseData); + addGrounds(summaries, selected.getOtherGround(), draftCaseData); }); } } else if (isSecureOrFlexibleTenancy(tenancyType)) { @@ -183,6 +228,7 @@ private void addAssuredRentArrearsGrounds(List> su .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) .toList(), draftCaseData); } + addGrounds(summaries, selected.getAdditionalOtherGround(), draftCaseData); }); } @@ -258,51 +304,20 @@ private String getDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground } private String getAssuredDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { - RentArrearsGroundsReasons reasons = getRentArrearsGroundsReasons(draftCaseData); - - if (reasons == null) { - return null; - } + return Optional.ofNullable(ASSURED_DRAFT_REASON_LOOKUP.get(ground)) + .map(reasonAccessor -> reasonAccessor.apply(this, draftCaseData)) + .orElse(null); + } - if (ground == AssuredMandatoryGround.OWNER_OCCUPIER_GROUND1) { - return reasons.getOwnerOccupierReason(); - } else if (ground == AssuredMandatoryGround.REPOSSESSION_GROUND2) { - return reasons.getRepossessionByLenderReason(); - } else if (ground == AssuredMandatoryGround.HOLIDAY_LET_GROUND3) { - return reasons.getHolidayLetReason(); - } else if (ground == AssuredMandatoryGround.STUDENT_LET_GROUND4) { - return reasons.getStudentLetReason(); - } else if (ground == AssuredMandatoryGround.MINISTER_RELIGION_GROUND5) { - return reasons.getMinisterOfReligionReason(); - } else if (ground == AssuredMandatoryGround.REDEVELOPMENT_GROUND6) { - return reasons.getRedevelopmentReason(); - } else if (ground == AssuredMandatoryGround.DEATH_OF_TENANT_GROUND7) { - return reasons.getDeathOfTenantReason(); - } else if (ground == AssuredMandatoryGround.ANTISOCIAL_BEHAVIOUR_GROUND7A) { - return reasons.getAntisocialBehaviourReason(); - } else if (ground == AssuredMandatoryGround.NO_RIGHT_TO_RENT_GROUND7B) { - return reasons.getNoRightToRentReason(); - } else if (ground == AssuredDiscretionaryGround.ALTERNATIVE_ACCOMMODATION_GROUND9) { - return reasons.getSuitableAltAccommodationReason(); - } else if (ground == AssuredDiscretionaryGround.BREACH_TENANCY_GROUND12) { - return reasons.getBreachOfTenancyConditionsReason(); - } else if (ground == AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13) { - return reasons.getPropertyDeteriorationReason(); - } else if (ground == AssuredDiscretionaryGround.NUISANCE_ANNOYANCE_GROUND14) { - return reasons.getNuisanceAnnoyanceReason(); - } else if (ground == AssuredDiscretionaryGround.DOMESTIC_VIOLENCE_GROUND14A) { - return reasons.getDomesticViolenceReason(); - } else if (ground == AssuredDiscretionaryGround.OFFENCE_RIOT_GROUND14ZA) { - return reasons.getOffenceDuringRiotReason(); - } else if (ground == AssuredDiscretionaryGround.DETERIORATION_FURNITURE_GROUND15) { - return reasons.getFurnitureDeteriorationReason(); - } else if (ground == AssuredDiscretionaryGround.EMPLOYEE_LANDLORD_GROUND16) { - return reasons.getEmployeeOfLandlordReason(); - } else if (ground == AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17) { - return reasons.getTenancyByFalseStatementReason(); + private String getAssuredOtherGroundReason(PCSCase draftCaseData) { + RentArrearsGroundsReasons rentArrearsGroundsReasons = getRentArrearsGroundsReasons(draftCaseData); + if (rentArrearsGroundsReasons != null && rentArrearsGroundsReasons.getOtherGroundReason() != null) { + return rentArrearsGroundsReasons.getOtherGroundReason(); } - return null; + NoRentArrearsGroundsReasons noRentArrearsGroundsReasons = + draftCaseData.getNoRentArrearsGroundsReasons(); + return noRentArrearsGroundsReasons == null ? null : noRentArrearsGroundsReasons.getOtherGround(); } private String getIntroductoryDemotedOrOtherDraftReason(PCSCase draftCaseData, PossessionGroundEnum ground) { @@ -336,9 +351,12 @@ private String getSecureOrFlexibleDraftReason(PCSCase draftCaseData, PossessionG } private static Map.Entry> - draftReasonEntry(PossessionGroundEnum ground, - BiFunction reasonAccessor) { - return Map.entry(ground, reasonAccessor); + assuredReasonEntry(PossessionGroundEnum ground, + Function reasonAccessor) { + return Map.entry(ground, (builder, draftCaseData) -> Optional + .ofNullable(builder.getRentArrearsGroundsReasons(draftCaseData)) + .map(reasonAccessor) + .orElse(null)); } private static Map.Entry> diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 81ea7b3773..68166608be 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; @@ -27,6 +30,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -659,12 +663,18 @@ void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); } - @Test - void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { + @ParameterizedTest + @MethodSource("walesOccupationLicenceTypeLabelScenarios") + void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabelWhenEnglandTenancyDetailsAreUnavailable( + TenancyLicenceDetails tenancyLicenceDetails, + OccupationLicenceTypeWales occupationLicenceType, + String expectedAgreementType + ) { // Given PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(tenancyLicenceDetails) .occupationLicenceDetailsWales(OccupationLicenceDetailsWales.builder() - .occupationLicenceTypeWales(OccupationLicenceTypeWales.SECURE_CONTRACT) + .occupationLicenceTypeWales(occupationLicenceType) .licenceStartDate(LocalDate.of(2025, 5, 12)) .build()) .build(); @@ -673,7 +683,7 @@ void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); // Then - assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Secure contract"); + assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo(expectedAgreementType); assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("12/05/2025"); } @@ -695,6 +705,21 @@ void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); } + private static Stream walesOccupationLicenceTypeLabelScenarios() { + return Stream.of( + Arguments.of( + null, + OccupationLicenceTypeWales.SECURE_CONTRACT, + "Secure contract" + ), + Arguments.of( + TenancyLicenceDetails.builder().build(), + OccupationLicenceTypeWales.STANDARD_CONTRACT, + "Standard contract" + ) + ); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java index 957edca622..d3fca5f0b9 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/ClaimGroundSummaryBuilderTest.java @@ -12,6 +12,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalDiscretionaryGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalMandatoryGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredDiscretionaryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredMandatoryGround; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredNoArrearsPossessionGrounds; @@ -23,6 +24,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherNoGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.NoRentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.RentArrearsGroundsReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureAntisocialAdditionalGrounds; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.SecureOrFlexibleDiscretionaryGrounds; @@ -194,6 +196,7 @@ void shouldMapAllAssuredDraftGroundReasons() { .EMPLOYEE_LANDLORD_GROUND16, AssuredAdditionalDiscretionaryGrounds.FALSE_STATEMENT_GROUND17 )) + .additionalOtherGround(Set.of(AssuredAdditionalOtherGround.OTHER)) .build()) .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() .ownerOccupierReason("Owner reason") @@ -214,6 +217,7 @@ void shouldMapAllAssuredDraftGroundReasons() { .furnitureDeteriorationReason("Furniture reason") .employeeOfLandlordReason("Employee reason") .tenancyByFalseStatementReason("False statement reason") + .otherGroundReason("Other reason") .build()) .build(); @@ -246,6 +250,7 @@ void shouldMapAllAssuredDraftGroundReasons() { "Employee reason"); assertReason(summaries, AssuredDiscretionaryGround.FALSE_STATEMENT_GROUND17.getLabel(), "False statement reason"); + assertReason(summaries, AssuredAdditionalOtherGround.OTHER.getLabel(), "Other reason"); assertNoReason(summaries, AssuredMandatoryGround.SERIOUS_RENT_ARREARS_GROUND8.getLabel()); assertNoReason(summaries, AssuredDiscretionaryGround.RENT_ARREARS_GROUND10.getLabel()); assertNoReason(summaries, AssuredDiscretionaryGround.PERSISTENT_DELAY_GROUND11.getLabel()); @@ -372,11 +377,15 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { .discretionaryGrounds(Set.of( AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13 )) + .otherGround(Set.of(AssuredAdditionalOtherGround.OTHER)) .build()) .rentArrearsGroundsReasons(RentArrearsGroundsReasons.builder() .holidayLetReason("Holiday reason") .propertyDeteriorationReason("Deterioration reason") .build()) + .noRentArrearsGroundsReasons(NoRentArrearsGroundsReasons.builder() + .otherGround("Other reason") + .build()) .build(); // When @@ -389,11 +398,13 @@ void shouldBuildAssuredNoRentArrearsClaimGroundSummariesFromDraft() { .map(ClaimGroundSummary::getLabel) .containsExactlyInAnyOrder( AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), - AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel() + AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), + AssuredAdditionalOtherGround.OTHER.getLabel() ); assertReason(summaries, AssuredMandatoryGround.HOLIDAY_LET_GROUND3.getLabel(), "Holiday reason"); assertReason(summaries, AssuredDiscretionaryGround.DETERIORATION_PROPERTY_GROUND13.getLabel(), "Deterioration reason"); + assertReason(summaries, AssuredAdditionalOtherGround.OTHER.getLabel(), "Other reason"); } @Test From 566d991ad2021a3729d0914906365e2795fb3366 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 10:39:07 +0100 Subject: [PATCH 086/138] HDPI-2983: update CaseSummaryTabViewTest --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 119 ++++++++++++++++-- 1 file changed, 106 insertions(+), 13 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 5bd30e547f..4aee1b12e2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -1,8 +1,10 @@ package uk.gov.hmcts.reform.pcs.ccd.view; -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.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; @@ -18,6 +20,9 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; @@ -36,7 +41,9 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +@ExtendWith(MockitoExtension.class) public class CaseSummaryTabViewTest { @Mock @@ -57,20 +64,9 @@ public class CaseSummaryTabViewTest { @Mock private AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; + @InjectMocks private CaseSummaryTabView underTest; - @BeforeEach - void setUp() { - underTest = new CaseSummaryTabView( - groundsBuilder, - rentArrearsTabDetailsBuilder, - reasonsForPossessionTabDetailsBuilder, - claimantInformationTabDetailsBuilder, - defendantInformationTabDetailsBuilder, - additionalDefendantInformationTabDetailsBuilder - ); - } - @Test void shouldSetSummaryTabFields() { // Given @@ -137,6 +133,63 @@ void shouldSetSummaryTabFields() { .build()) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn( + "Rent arrears (ground 10)\n" + + "Antisocial behaviour: Condition 1 of Section 84A of the Housing Act 1985" + ); + + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn( + RentArrearsTabDetails.builder() + .rentAmount("£100") + .calculationFrequency("Every 4 weeks") + .dailyRate("£12.30") + .arrearsTotal("£450.75") + .judgmentRequested("Yes") + .build() + ); + + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn( + ReasonsForPossessionTabDetails.builder() + .ground10("Ground 10 reason") + .condition1OfSection84A("Condition 1 reason") + .additionalReasonsForPossession("Additional reasons") + .build() + ); + + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn( + ClaimantInformationTabDetails.builder() + .claimantName("Fallback claimant") + .build() + ); + + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn( + DefendantInformationTabDetails.builder() + .firstName("Defendant") + .lastName("One") + .addressForService(propertyAddress) + .build() + ); + + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn( + List.of( + listValue( + AdditionalDefendantInformationTabDetails.builder() + .firstName("Defendant") + .lastName("Two") + .addressForService(defendantAddress) + .build() + ), + listValue( + AdditionalDefendantInformationTabDetails.builder() + .firstName(CaseTabView.NAME_UNKNOWN) + .lastName(CaseTabView.NAME_UNKNOWN) + .addressForService(propertyAddress) + .build() + ) + ) + ); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); @@ -185,6 +238,14 @@ void shouldDisplaySubmittedDateInGmtWhenBritishSummerTimeApplies() { .dateSubmitted(LocalDateTime.of(2026, 7, 11, 17, 2, 31)) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn(null); + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn(null); + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn(null); + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn(null); + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn(null); + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn(null); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); @@ -202,6 +263,14 @@ void shouldNotSetEmptySummarySections() { .build()))) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn(null); + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn(null); + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn(null); + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn(null); + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn(null); + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn(null); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); @@ -226,6 +295,14 @@ void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { .build()) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn(null); + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn(null); + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn(null); + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn(null); + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn(null); + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn(null); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); @@ -244,6 +321,14 @@ void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabel() { .build()) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn(null); + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn(null); + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn(null); + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn(null); + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn(null); + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn(null); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); @@ -262,6 +347,14 @@ void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { .build()) .build(); + when(groundsBuilder.getGrounds(pcsCase)).thenReturn(null); + when(rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase)).thenReturn(null); + when(reasonsForPossessionTabDetailsBuilder.buildSummaryReasonsForPossession(pcsCase)).thenReturn(null); + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn(null); + when(defendantInformationTabDetailsBuilder.buildSummaryDefendantOneDetails(pcsCase)).thenReturn(null); + when(additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase)) + .thenReturn(null); + // When SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); From 8c59689a22e93882d3f86d4941be09a565d36c61 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 10:45:58 +0100 Subject: [PATCH 087/138] HDPI-2983: update CaseTypeTest and DraftCaseJsonMergerTest --- src/test/java/uk/gov/hmcts/reform/pcs/ccd/CaseTypeTest.java | 4 ++++ .../hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java | 1 + 2 files changed, 5 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/CaseTypeTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/CaseTypeTest.java index 131bf2efc9..fad9f29a59 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/CaseTypeTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/CaseTypeTest.java @@ -69,6 +69,7 @@ void shouldConfigureCaseTypeTabs() { final Tab.TabBuilder caseLinksTabBuilder = Tab.TabBuilder.builder(PCSCase.class, utils); final Tab.TabBuilder caseFileViewTabBuilder = Tab.TabBuilder.builder(PCSCase.class, utils); final Tab.TabBuilder casePartiesTabBuilder = Tab.TabBuilder.builder(PCSCase.class, utils); + final Tab.TabBuilder caseDetailsTabBuilder = Tab.TabBuilder.builder(PCSCase.class, utils); final Search.SearchBuilder searchBuilder = Search.SearchBuilder.builder(PCSCase.class, utils); final SearchCases.SearchCasesBuilder searchCasesBuilder = @@ -86,6 +87,7 @@ void shouldConfigureCaseTypeTabs() { when(builder.tab("caseLinks", "Linked Cases")).thenReturn(caseLinksTabBuilder); when(builder.tab("caseFileView", "Case File View")).thenReturn(caseFileViewTabBuilder); when(builder.tab("caseParties", "Case Parties")).thenReturn(casePartiesTabBuilder); + when(builder.tab("caseDetails", "Case Details")).thenReturn(caseDetailsTabBuilder); when(builder.categories(UserRole.PCS_SOLICITOR)) .thenReturn(CaseCategory.CaseCategoryBuilder.builder(UserRole.PCS_SOLICITOR)); @@ -99,6 +101,7 @@ void shouldConfigureCaseTypeTabs() { final Tab caseLinksTab = caseLinksTabBuilder.build(); final Tab casePartiesTab = casePartiesTabBuilder.build(); final Tab caseFileViewTab = caseFileViewTabBuilder.build(); + final Tab caseDetailsTab = caseDetailsTabBuilder.build(); // Then assertThat(nextStepsTab.getFields()).extracting(TabField::getId).contains("nextStepsMarkdown"); @@ -110,5 +113,6 @@ void shouldConfigureCaseTypeTabs() { .contains("LinkedCasesComponentLauncher!=\"\""); assertThat(caseFileViewTab.getFields().size()).isEqualTo(1); assertThat(casePartiesTab.getFields()).extracting(TabField::getId).contains("casePartiesTab_ClaimantDetails"); + assertThat(caseDetailsTab.getFields()).extracting(TabField::getId).contains("detailsTab_ClaimDetails"); } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java index 199fbeb5ea..23b418bd03 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/service/DraftCaseJsonMergerTest.java @@ -94,6 +94,7 @@ void shouldKeepExistingFieldsWhenMerging() throws JsonProcessingException { "enforcementOrder.rawWarrantDetails.vulnerablePeoplePresent", "enforcementOrder.rawWarrantDetails.vulnerableAdultsChildren", "summaryTab", + "caseDetailsTab", "casePartiesTab.claimantDetails.emailAddress", "casePartiesTab.claimantDetails.name", "casePartiesTab.claimantDetails.serviceAddress", From 23ca8a8165f10ead6ad16914132c873aa08b313a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 20 May 2026 12:26:56 +0100 Subject: [PATCH 088/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 68166608be..0d501be9a4 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -663,6 +663,26 @@ void shouldSetTenancyDetailsFromTenancyLicenceTypeLabel() { assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); } + @ParameterizedTest(name = "{0}") + @MethodSource("unavailableTenancyDetailsScenarios") + void shouldNotSetTenancyDetailsWhenNeitherEnglandNorWalesTenancyTypeIsAvailable( + String scenario, + TenancyLicenceDetails tenancyLicenceDetails, + OccupationLicenceDetailsWales occupationLicenceDetailsWales + ) { + // Given + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(tenancyLicenceDetails) + .occupationLicenceDetailsWales(occupationLicenceDetailsWales) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getTenancyDetails()).isNull(); + } + @ParameterizedTest @MethodSource("walesOccupationLicenceTypeLabelScenarios") void shouldSetTenancyDetailsFromWalesOccupationLicenceTypeLabelWhenEnglandTenancyDetailsAreUnavailable( @@ -705,6 +725,31 @@ void shouldSetTenancyDetailsFromWalesOtherOccupationLicenceType() { assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isNull(); } + private static Stream unavailableTenancyDetailsScenarios() { + return Stream.of( + Arguments.of( + "no England tenancy details and no Wales occupation licence details", + null, + null + ), + Arguments.of( + "England tenancy details do not have a type and no Wales occupation licence details", + TenancyLicenceDetails.builder().build(), + null + ), + Arguments.of( + "no England tenancy details and Wales occupation licence details do not have a type", + null, + OccupationLicenceDetailsWales.builder().build() + ), + Arguments.of( + "England tenancy details and Wales occupation licence details do not have a type", + TenancyLicenceDetails.builder().build(), + OccupationLicenceDetailsWales.builder().build() + ) + ); + } + private static Stream walesOccupationLicenceTypeLabelScenarios() { return Stream.of( Arguments.of( From 0002be42ba6cfdc477e304e82f2fabb8f30e599f Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 13:48:50 +0100 Subject: [PATCH 089/138] HDPI-2983: update CaseView tests and fix checkstyle --- .../pcs/ccd/view/CaseDetailsTabView.java | 26 +- .../reform/pcs/ccd/view/CaseTabView.java | 6 +- ...DefendantInformationTabDetailsBuilder.java | 18 +- .../builder/ClaimGroundSummaryBuilder.java | 2 +- ...DefendantInformationTabDetailsBuilder.java | 4 +- .../reform/pcs/ccd/view/CaseTabViewTest.java | 355 +++++++++++++++--- 6 files changed, 330 insertions(+), 81 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 58d16e843c..106225f1c7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -145,8 +145,8 @@ private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCa } TenancyLicenceDetails tenancyLicenceDetails = pcsCase.getTenancyLicenceDetails(); - TenancyLicenceType tenancyType = tenancyLicenceDetails != null ? - tenancyLicenceDetails.getTypeOfTenancyLicence() : null; + TenancyLicenceType tenancyType = tenancyLicenceDetails != null + ? tenancyLicenceDetails.getTypeOfTenancyLicence() : null; String otherGroundsDescription = ""; if (tenancyType == INTRODUCTORY_TENANCY || tenancyType == DEMOTED_TENANCY || tenancyType == OTHER) { @@ -242,7 +242,7 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { case EMAIL -> { LocalDateTime dateTime = noticeServedDetails.getNoticeEmailSentDateTime(); String emailAddress = noticeServedDetails.getNoticeEmailAddress(); - noticeTabDetails.setNoticeDate( dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); noticeTabDetails.setNoticeEmailAddress(emailAddress != null ? emailAddress : NO_ANSWER); } case OTHER_ELECTRONIC -> { @@ -268,7 +268,7 @@ private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { VerticalYesNo settlementAttempted = pcsCase.getSettlementAttempted(); return ActionsTakenTabDetails.builder() - .preactionProtocolFollowed(preactionProtocol != null ? preactionProtocol.getLabel() :NO_ANSWER) + .preactionProtocolFollowed(preactionProtocol != null ? preactionProtocol.getLabel() : NO_ANSWER) .mediationAttempted(mediationAttempted != null ? mediationAttempted.getLabel() : NO_ANSWER) .settlementAttempted(settlementAttempted != null ? settlementAttempted.getLabel() : NO_ANSWER) .build(); @@ -298,8 +298,8 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { private ApplicationsTabDetails buildApplicationsTabDetails(PCSCase pcsCase) { VerticalYesNo applicationWithClaim = pcsCase.getApplicationWithClaim(); - String planToMakeGeneralApplication = applicationWithClaim != null ? - applicationWithClaim.getLabel() : NO_ANSWER; + String planToMakeGeneralApplication = applicationWithClaim != null + ? applicationWithClaim.getLabel() : NO_ANSWER; return ApplicationsTabDetails.builder() .planToMakeGeneralApplication(planToMakeGeneralApplication) @@ -318,7 +318,7 @@ private AddressUK getClaimantAddress(PCSCase pcsCase) { if (!CollectionUtils.isEmpty(claimants)) { Party claimant = claimants.getFirst().getValue(); address = claimant.getAddress(); - } else if (claimantContactPreferences != null ) { + } else if (claimantContactPreferences != null) { YesOrNo orgAddressFound = claimantContactPreferences.getOrgAddressFound(); VerticalYesNo correctClaimantAddress = claimantContactPreferences.getIsCorrectClaimantContactAddress(); if (orgAddressFound == YesOrNo.YES && correctClaimantAddress == VerticalYesNo.YES) { @@ -352,8 +352,8 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase phoneNumber = claimant.getPhoneNumber(); } else if (claimantContactPreferences != null) { VerticalYesNo isCorrectClaimantContactEmail = claimantContactPreferences.getIsCorrectClaimantContactEmail(); - emailAddress = isCorrectClaimantContactEmail == VerticalYesNo.YES ? - claimantContactPreferences.getClaimantContactEmail() : + emailAddress = isCorrectClaimantContactEmail == VerticalYesNo.YES + ? claimantContactPreferences.getClaimantContactEmail() : claimantContactPreferences.getOverriddenClaimantContactEmail(); if (claimantContactPreferences.getClaimantProvidePhoneNumber() == VerticalYesNo.YES) { phoneNumber = claimantContactPreferences.getClaimantContactPhoneNumber(); @@ -420,8 +420,8 @@ private DemotionOfTenancyTabDetails buildDemotionOfTenancyTabDetails(PCSCase pcs Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); if ( - CollectionUtils.isEmpty(alternativesToPossessionSet) || - !alternativesToPossessionSet.contains(DEMOTION_OF_TENANCY) + CollectionUtils.isEmpty(alternativesToPossessionSet) + || !alternativesToPossessionSet.contains(DEMOTION_OF_TENANCY) ) { return null; } @@ -457,8 +457,8 @@ private DemotionOfTenancyTabDetails buildDemotionOfTenancyTabDetails(PCSCase pcs private SuspensionOfRightToBuyTabDetails buildSuspensionOfRightToBuyTabDetails(PCSCase pcsCase) { Set alternativesToPossessionSet = pcsCase.getAlternativesToPossession(); if ( - CollectionUtils.isEmpty(alternativesToPossessionSet) || - !alternativesToPossessionSet.contains(SUSPENSION_OF_RIGHT_TO_BUY) + CollectionUtils.isEmpty(alternativesToPossessionSet) + || !alternativesToPossessionSet.contains(SUSPENSION_OF_RIGHT_TO_BUY) ) { return null; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 47ba2bf980..3b0c69e346 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -62,9 +62,9 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { draftCaseData.getSuspensionOfRightToBuyDemotionOfTenancy(); if ( - suspensionOfRightToBuyDemotionOfTenancy != null && - !CollectionUtils.isEmpty(alternativesToPossessionSet) && - alternativesToPossessionSet.containsAll(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) + suspensionOfRightToBuyDemotionOfTenancy != null + && !CollectionUtils.isEmpty(alternativesToPossessionSet) + && alternativesToPossessionSet.containsAll(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) ) { DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); setDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy, demotionOfTenancy); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java index 847a3fe3f2..df98d5dc51 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java @@ -25,9 +25,10 @@ public List> buildSummaryAdd .map(ListValue::getValue) .map(defendant -> createAdditionalSummaryDefendantDetails(defendant, pcsCase)) .filter(Objects::nonNull) - .map(defendantDetails -> ListValue.builder() - .value(defendantDetails) - .build()) + .map(defendantDetails -> + ListValue.builder() + .value(defendantDetails) + .build()) .toList(); } @@ -42,9 +43,10 @@ public List> buildDetailedAd .map(ListValue::getValue) .map(defendant -> createAdditionalDetailedDefendantDetails(defendant, pcsCase)) .filter(Objects::nonNull) - .map(defendantDetails -> ListValue.builder() - .value(defendantDetails) - .build()) + .map(defendantDetails -> + ListValue.builder() + .value(defendantDetails) + .build()) .toList(); } @@ -70,8 +72,8 @@ private AdditionalDefendantInformationTabDetails createAdditionalDetailedDefenda AdditionalDefendantInformationTabDetails additionalDefendantInformationTabDetails = AdditionalDefendantInformationTabDetails.builder() - .nameKnown(nameKnown.getLabel()) - .addressKnown(addressKnown.getLabel()) + .nameKnown(nameKnown != null ? nameKnown.getLabel() : null) + .addressKnown(addressKnown != null ? addressKnown.getLabel() : null) .build(); if (nameKnown == VerticalYesNo.YES) { diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java index b0acda69fb..b280e5877c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ClaimGroundSummaryBuilder.java @@ -187,7 +187,7 @@ private void addAssuredRentArrearsGrounds(List> su .map(ground -> AssuredDiscretionaryGround.valueOf(ground.name())) .toList(), draftCaseData); } - if(!CollectionUtils.isEmpty(selected.getAdditionalOtherGround())) { + if (!CollectionUtils.isEmpty(selected.getAdditionalOtherGround())) { addGrounds(summaries, selected.getAdditionalOtherGround().stream() .map(ground -> AssuredAdditionalOtherGround.valueOf(ground.name())) .toList(), draftCaseData); diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java index 4a438e57e0..ed815d8bc8 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/DefendantInformationTabDetailsBuilder.java @@ -46,8 +46,8 @@ private DefendantInformationTabDetails createDetailedDefendantDetails(Party defe VerticalYesNo addressKnown = defendant.getAddressKnown(); DefendantInformationTabDetails defendantInformationTabDetails = DefendantInformationTabDetails.builder() - .nameKnown(nameKnown.getLabel()) - .addressKnown(addressKnown.getLabel()) + .nameKnown(nameKnown != null ? nameKnown.getLabel() : null) + .addressKnown(addressKnown != null ? addressKnown.getLabel() : null) .build(); if (nameKnown == VerticalYesNo.YES) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index c0e429ad7e..5f9d2dcba6 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -1,8 +1,8 @@ package uk.gov.hmcts.reform.pcs.ccd.view; -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.junit.jupiter.MockitoExtension; import org.mockito.Mock; import uk.gov.hmcts.ccd.sdk.type.AddressUK; @@ -10,10 +10,12 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; 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.UnderlesseeMortgageeDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.ClaimantTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.DefendantTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.summary.SummaryTab; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimGroundSummaryBuilder; @@ -21,13 +23,13 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) class CaseTabViewTest { - private CaseTabView underTest; - @Mock private ClaimGroundSummaryBuilder claimGroundSummaryBuilder; @@ -37,10 +39,8 @@ class CaseTabViewTest { @Mock private CaseDetailsTabView caseDetailsTabView; - @BeforeEach - void setUp() { - underTest = new CaseTabView(claimGroundSummaryBuilder, caseSummaryTabView, caseDetailsTabView); - } + @InjectMocks + private CaseTabView underTest; @Test void shouldSetClaimantDetailsInCasePartiesTab() { @@ -272,43 +272,41 @@ void shouldNotSetCasePartiesTabWithNoData() { } @Test - void shouldSetDraftSummaryTabFieldsUsingDraftDataOnly() { + void shouldSetTabFieldsUsingDraftDataOnly() { // Given - AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .build(); - PCSCase draftCaseData = PCSCase.builder() - .propertyAddress(propertyAddress) - .build(); + PCSCase draftCaseData = PCSCase.builder().build(); + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + PCSCase pcsCase = PCSCase.builder().build(); + // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); // Then SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(propertyAddress); - assertThat(summaryTab.getClaimantDetails()).isNull(); - assertThat(summaryTab.getDefendantDetails()).isNull(); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isNull(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); } @Test - void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { + void shouldSetDraftTabFieldsUsingDraftDefendantsAndGrounds() { // Given AddressUK submittedPropertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); AddressUK draftPropertyAddress = AddressUK.builder().postCode("E1 1AA").build(); AddressUK defendantOneAddress = AddressUK.builder().postCode("M1 1AA").build(); AddressUK additionalDefendantAddress = AddressUK.builder().postCode("B1 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(submittedPropertyAddress) - .allClaimants(List.of(listValue(Party.builder().orgName("Submitted claimant").build()))) - .claimGroundSummaries(List.of( - listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) - )) - .build(); PCSCase draftCaseData = PCSCase.builder() .propertyAddress(draftPropertyAddress) .allClaimants(List.of(listValue(Party.builder().orgName("Draft claimant").build()))) @@ -334,25 +332,51 @@ void shouldSetDraftSummaryTabFieldsUsingDraftDefendantsAndGrounds() { listValue(ClaimGroundSummary.builder().label("Draft ground").build()) ); + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(draftGrounds); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(submittedPropertyAddress) + .allClaimants(List.of(listValue(Party.builder().orgName("Submitted claimant").build()))) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder().label("Submitted ground").build()) + )) + .build(); + // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); // Then SummaryTab summaryTab = pcsCase.getSummaryTab(); - assertThat(summaryTab.getRepossessedPropertyAddress()).isEqualTo(draftPropertyAddress); - assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Draft claimant"); - assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Draft"); - assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("Defendant"); - assertThat(summaryTab.getDefendantDetails().getAddressForService()).isEqualTo(defendantOneAddress); - assertThat(summaryTab.getAdditionalDefendants()).hasSize(1); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Additional"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Defendant"); - assertThat(summaryTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) - .isEqualTo(additionalDefendantAddress); - assertThat(summaryTab.getGroundsForPossession().getGrounds()).isEqualTo("Draft ground"); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + assertThat(draftCaseData.getAllDefendants()).hasSize(2); + Party firstDefendant = draftCaseData.getAllDefendants().getFirst().getValue(); + Party secondDefendant = draftCaseData.getAllDefendants().getLast().getValue(); + assertThat(firstDefendant.getNameKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(firstDefendant.getFirstName()).isEqualTo("Draft"); + assertThat(firstDefendant.getLastName()).isEqualTo("Defendant"); + assertThat(firstDefendant.getAddressKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(firstDefendant.getAddress()).isEqualTo(defendantOneAddress); + assertThat(secondDefendant.getNameKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(secondDefendant.getFirstName()).isEqualTo("Additional"); + assertThat(secondDefendant.getLastName()).isEqualTo("Defendant"); + assertThat(secondDefendant.getAddressKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(secondDefendant.getAddress()).isEqualTo(additionalDefendantAddress); + assertThat(draftCaseData.getClaimGroundSummaries()).hasSize(1); + assertThat(draftCaseData.getClaimGroundSummaries().getFirst().getValue().getLabel()) + .isEqualTo("Draft ground"); } @Test @@ -360,9 +384,6 @@ void shouldSetDraftDefendantWhenNoAdditionalDefendantHasBeenSelected() { // Given AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); AddressUK defendantAddress = AddressUK.builder().postCode("M1 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .build(); PCSCase draftCaseData = PCSCase.builder() .propertyAddress(propertyAddress) .defendant1(DefendantDetails.builder() @@ -375,12 +396,31 @@ void shouldSetDraftDefendantWhenNoAdditionalDefendantHasBeenSelected() { .addAnotherDefendant(VerticalYesNo.NO) .build(); + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + assertThat(draftCaseData.getAllDefendants()).hasSize(1); Party defendant = draftCaseData.getAllDefendants().getFirst().getValue(); assertThat(defendant.getNameKnown()).isEqualTo(VerticalYesNo.YES); @@ -388,16 +428,12 @@ void shouldSetDraftDefendantWhenNoAdditionalDefendantHasBeenSelected() { assertThat(defendant.getLastName()).isEqualTo("Defendant"); assertThat(defendant.getAddressKnown()).isEqualTo(VerticalYesNo.YES); assertThat(defendant.getAddress()).isEqualTo(defendantAddress); - assertThat(pcsCase.getSummaryTab().getAdditionalDefendants()).isNull(); } @Test void shouldNotSetAdditionalDraftDefendantsWhenAdditionalDefendantListIsEmpty() { // Given AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .build(); PCSCase draftCaseData = PCSCase.builder() .propertyAddress(propertyAddress) .defendant1(DefendantDetails.builder() @@ -410,17 +446,35 @@ void shouldNotSetAdditionalDraftDefendantsWhenAdditionalDefendantListIsEmpty() { .additionalDefendants(List.of()) .build(); + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); assertThat(draftCaseData.getAllDefendants()).hasSize(1); - assertThat(pcsCase.getSummaryTab().getDefendantDetails().getFirstName()).isEqualTo("Only"); - assertThat(pcsCase.getSummaryTab().getDefendantDetails().getLastName()).isEqualTo("Defendant"); - assertThat(pcsCase.getSummaryTab().getDefendantDetails().getAddressForService()).isEqualTo(propertyAddress); - assertThat(pcsCase.getSummaryTab().getAdditionalDefendants()).isNull(); + Party defendant = draftCaseData.getAllDefendants().getFirst().getValue(); + assertThat(defendant.getFirstName()).isEqualTo("Only"); + assertThat(defendant.getLastName()).isEqualTo("Defendant"); + assertThat(defendant.getAddress()).isNull(); } @Test @@ -434,23 +488,216 @@ void shouldNotOverwriteExistingDraftDefendantsWhenDefendantOneIsMissing() { .lastName("Defendant") .build()) ); - PCSCase pcsCase = PCSCase.builder() - .propertyAddress(propertyAddress) - .build(); PCSCase draftCaseData = PCSCase.builder() .propertyAddress(propertyAddress) .allDefendants(existingDefendants) .build(); + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + PCSCase pcsCase = PCSCase.builder() + .propertyAddress(propertyAddress) + .build(); + // When underTest.setDraftCaseTabFields(pcsCase, draftCaseData); // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + assertThat(draftCaseData.getAllDefendants()).isSameAs(existingDefendants); - assertThat(pcsCase.getSummaryTab().getDefendantDetails().getFirstName()).isEqualTo("Existing"); - assertThat(pcsCase.getSummaryTab().getDefendantDetails().getLastName()).isEqualTo("Defendant"); + } + + @Test + void shouldSetDraftUnderlesseeOrMortgagePartiesWhenThereIsMoreThanOneParty() { + // Given + String name1 = "name1"; + AddressUK address1 = AddressUK.builder().build(); + UnderlesseeMortgageeDetails underlesseeMortgageeDetails1 = UnderlesseeMortgageeDetails.builder() + .nameKnown(VerticalYesNo.YES) + .name("name1") + .addressKnown(VerticalYesNo.YES) + .address(address1) + .build(); + + UnderlesseeMortgageeDetails underlesseeMortgageeDetails2 = UnderlesseeMortgageeDetails.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .underlesseeOrMortgagee1(underlesseeMortgageeDetails1) + .additionalUnderlesseeOrMortgagee(List.of(listValue(underlesseeMortgageeDetails2))) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + List> allUnderlesseeOrMortgagees = draftCaseData.getAllUnderlesseeOrMortgagees(); + assertThat(allUnderlesseeOrMortgagees).hasSize(2); + Party party1 = allUnderlesseeOrMortgagees.getFirst().getValue(); + assertThat(party1.getNameKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(party1.getOrgName()).isEqualTo(name1); + assertThat(party1.getAddressKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(party1.getAddress()).isEqualTo(address1); + + Party party2 = allUnderlesseeOrMortgagees.getLast().getValue(); + assertThat(party2.getNameKnown()).isEqualTo(VerticalYesNo.NO); + assertThat(party2.getOrgName()).isNull(); + assertThat(party2.getAddressKnown()).isEqualTo(VerticalYesNo.NO); + assertThat(party2.getAddress()).isNull(); + } + + @Test + void shouldSetDraftUnderlesseeOrMortgagePartiesWhenThereIsOnlyOneParty() { + // Given + String name1 = "name1"; + AddressUK address1 = AddressUK.builder().build(); + UnderlesseeMortgageeDetails underlesseeMortgageeDetails1 = UnderlesseeMortgageeDetails.builder() + .nameKnown(VerticalYesNo.YES) + .name("name1") + .addressKnown(VerticalYesNo.YES) + .address(address1) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .underlesseeOrMortgagee1(underlesseeMortgageeDetails1) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + List> allUnderlesseeOrMortgagees = draftCaseData.getAllUnderlesseeOrMortgagees(); + assertThat(allUnderlesseeOrMortgagees).hasSize(1); + Party party1 = allUnderlesseeOrMortgagees.getFirst().getValue(); + assertThat(party1.getNameKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(party1.getOrgName()).isEqualTo(name1); + assertThat(party1.getAddressKnown()).isEqualTo(VerticalYesNo.YES); + assertThat(party1.getAddress()).isEqualTo(address1); + } + + @Test + void shouldNotSetDraftUnderlesseeOrMortgagePartiesWhenThereIsNoParties() { + // Given + PCSCase draftCaseData = PCSCase.builder().build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + List> allUnderlesseeOrMortgagees = draftCaseData.getAllUnderlesseeOrMortgagees(); + assertThat(allUnderlesseeOrMortgagees).isNull(); + } + + @Test + void shouldNotSetDraftUnderlesseeOrMortgagePartiesWhenUnderlesseeMortgageeDetails1IsNotSet() { + // Given + UnderlesseeMortgageeDetails additionalUnderlesseeMortgageeDetails = UnderlesseeMortgageeDetails.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .additionalUnderlesseeOrMortgagee(List.of(listValue(additionalUnderlesseeMortgageeDetails))) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + List> allUnderlesseeOrMortgagees = draftCaseData.getAllUnderlesseeOrMortgagees(); + assertThat(allUnderlesseeOrMortgagees).isNull(); } private static ListValue listValue(T value) { From 243bf109862d697bc4b433f88af6afd92323923f Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 14:16:01 +0100 Subject: [PATCH 090/138] HDPI-2983: update RentArrearsTabDetails for case details tab and add submitted date --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 + .../domain/tabs/details/CaseDetailsTab.java | 3 ++ .../tabs/shared/RentArrearsTabDetails.java | 3 ++ .../pcs/ccd/view/CaseDetailsTabView.java | 42 +++++++++++++++---- .../reform/pcs/ccd/view/CaseTabViewTest.java | 4 +- 5 files changed, 43 insertions(+), 10 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 7ce3b88227..41ed6f7f11 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 @@ -161,6 +161,7 @@ private void buildCaseDetailsTab(ConfigBuilder builder .field("detailsTab_ClaimDetails") .field("detailsTab_PropertyAddress") .field("detailsTab_GroundsForPossessionDetails") + .field("detailsTab_DateClaimSubmitted") .field("detailsTab_TenancyLicenceDetails") .field("detailsTab_NoticeDetails") .field("detailsTab_ActionsTakenDetails") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 39ee20bc20..70c2bd15cb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -40,6 +40,9 @@ public class CaseDetailsTab { ) private GroundsForPossessionTabDetails groundsForPossessionDetails; + @CCD(label = "Date claim Submitted") + private String dateClaimSubmitted; + @CCD( label = "Tenancy, occupation contract or licence details" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 847874dcb9..13977299da 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -34,6 +34,9 @@ public class RentArrearsTabDetails { @CCD(label = "Rent statement") private List> rentStatement; + @CCD(label = "Rent statement") + private String rentStatementPlaceholder; + @CCD(label = "Rent arrears total at the time of claim issue") private String arrearsTotal; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 106225f1c7..a9492105d5 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -16,6 +16,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuy; import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; @@ -52,6 +53,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Locale; import java.util.Set; import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; @@ -66,7 +68,10 @@ public class CaseDetailsTabView { private static final String NO_ANSWER = " "; - private static final DateTimeFormatter PATTERN = DateTimeFormatter.ofPattern("d MMMM yyyy"); + private static final DateTimeFormatter DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); + private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); private final GroundsBuilder groundsBuilder; private final RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; @@ -93,6 +98,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { DemotionOfTenancyTabDetails demotionOfTenancyTabDetails = buildDemotionOfTenancyTabDetails(pcsCase); SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyTabDetails = buildSuspensionOfRightToBuyTabDetails(pcsCase); + String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted()); CaseDetailsTab caseDetailsTab = CaseDetailsTab.builder() .claimDetails(claimTabDetails) @@ -109,6 +115,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .mortgageDetails(underlesseeMortgageTabDetailsList) .demotionOfTenancyDetails(demotionOfTenancyTabDetails) .suspensionOfRightToBuyDetails(suspensionOfRightToBuyTabDetails) + .dateClaimSubmitted(dateSubmitted) .build(); if (claimantInformationTabDetails != null) { @@ -194,7 +201,7 @@ private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) return TenancyLicenceTabDetails.builder() .typeOfTenancyLicence(tenancyType != null ? tenancyType.getLabel() : NO_ANSWER) - .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(PATTERN) : NO_ANSWER) + .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(DATE_FORMATTER) : NO_ANSWER) .hasCopyOfTenancyLicence(hasTenancyLicence != null ? hasTenancyLicence.getLabel() : NO_ANSWER) .tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments()) .reasonsForNoTenancyLicenceDocuments(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments()) @@ -227,32 +234,32 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { switch (method) { case FIRST_CLASS_POST -> { LocalDate date = noticeServedDetails.getNoticePostedDate(); - noticeTabDetails.setNoticeDate(date != null ? date.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(date != null ? date.format(DATE_FORMATTER) : NO_ANSWER); } case DELIVERED_PERMITTED_PLACE -> { LocalDate date = noticeServedDetails.getNoticeDeliveredDate(); - noticeTabDetails.setNoticeDate(date != null ? date.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(date != null ? date.format(DATE_FORMATTER) : NO_ANSWER); } case PERSONALLY_HANDED -> { LocalDateTime dateTime = noticeServedDetails.getNoticeHandedOverDateTime(); String name = noticeServedDetails.getNoticePersonName(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); noticeTabDetails.setNoticePersonName(name != null ? name : NO_ANSWER); } case EMAIL -> { LocalDateTime dateTime = noticeServedDetails.getNoticeEmailSentDateTime(); String emailAddress = noticeServedDetails.getNoticeEmailAddress(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); noticeTabDetails.setNoticeEmailAddress(emailAddress != null ? emailAddress : NO_ANSWER); } case OTHER_ELECTRONIC -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherElectronicDateTime(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); } case OTHER -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); String explanation = noticeTabDetails.getNoticeOtherExplanation(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(PATTERN) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); noticeTabDetails.setNoticeOtherExplanation(explanation != null ? explanation : NO_ANSWER); } }; @@ -290,9 +297,20 @@ private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { .stepsToRecoverArrears(NO_ANSWER) .arrearsTotal(NO_ANSWER) .judgmentRequested(NO_ANSWER) + .rentStatementPlaceholder(NO_ANSWER) .build(); } + RentArrearsSection rentArrearsSection = pcsCase.getRentArrears(); + if (rentArrearsSection != null) { + rentArrearsTabDetails.setStepsToRecoverArrears(rentArrearsSection.getRecoveryAttemptDetails()); + rentArrearsTabDetails.setRentStatement(rentArrearsSection.getStatementDocuments()); + } else { + rentArrearsTabDetails.setStepsToRecoverArrears(NO_ANSWER); + rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); + } + + return rentArrearsTabDetails; } @@ -479,4 +497,12 @@ private SuspensionOfRightToBuyTabDetails buildSuspensionOfRightToBuyTabDetails(P .reasons(reason != null ? reason : NO_ANSWER) .build(); } + + private String formatSubmittedDate(LocalDateTime dateSubmitted) { + if (dateSubmitted == null) { + return null; + } + + return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index 5f9d2dcba6..ce7d5f3f73 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -528,7 +528,7 @@ void shouldSetDraftUnderlesseeOrMortgagePartiesWhenThereIsMoreThanOneParty() { AddressUK address1 = AddressUK.builder().build(); UnderlesseeMortgageeDetails underlesseeMortgageeDetails1 = UnderlesseeMortgageeDetails.builder() .nameKnown(VerticalYesNo.YES) - .name("name1") + .name(name1) .addressKnown(VerticalYesNo.YES) .address(address1) .build(); @@ -588,7 +588,7 @@ void shouldSetDraftUnderlesseeOrMortgagePartiesWhenThereIsOnlyOneParty() { AddressUK address1 = AddressUK.builder().build(); UnderlesseeMortgageeDetails underlesseeMortgageeDetails1 = UnderlesseeMortgageeDetails.builder() .nameKnown(VerticalYesNo.YES) - .name("name1") + .name(name1) .addressKnown(VerticalYesNo.YES) .address(address1) .build(); From 69605eaaa3f862dcc0cba821a65f8352b2c6eaef Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 15:25:06 +0100 Subject: [PATCH 091/138] HDPI-2983: fix RentArrearsTabDetails for case details tab --- .../tabs/shared/RentArrearsTabDetails.java | 3 + .../pcs/ccd/view/CaseDetailsTabView.java | 36 +--------- .../builder/RentArrearsTabDetailsBuilder.java | 70 +++++++++++++++++++ 3 files changed, 75 insertions(+), 34 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index 13977299da..fbfbc118d6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -31,6 +31,9 @@ public class RentArrearsTabDetails { @CCD(label = "Previous steps taken to recover rent arrears?") private String stepsToRecoverArrears; + @CCD(label = "Details of previous steps taken?") + private String stepsToRecoverArrearsDetails; + @CCD(label = "Rent statement") private List> rentStatement; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index a9492105d5..8235b47a9c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -86,7 +86,8 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase); NoticeTabDetails noticeTabDetails = buildNoticeTabDetails(pcsCase); ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase); - RentArrearsTabDetails rentArrearsTabDetails = buildRentArrearsTabDetails(pcsCase); + RentArrearsTabDetails rentArrearsTabDetails = + rentArrearsTabDetailsBuilder.buildDetailedRentArrearsTabDetails(pcsCase); ReasonsForPossessionTabDetails reasonsForPossessionTabDetails = reasonsForPossessionTabDetailsBuilder.buildDetailsReasonsForPossession(pcsCase); ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase); @@ -281,39 +282,6 @@ private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { .build(); } - private RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { - if (pcsCase.getShowRentSectionPage() != YesOrNo.YES) { - return null; - } - - RentArrearsTabDetails rentArrearsTabDetails = rentArrearsTabDetailsBuilder.buildRentArrearsTabDetails(pcsCase); - - if (rentArrearsTabDetails == null) { - return RentArrearsTabDetails.builder() - .rentAmount(NO_ANSWER) - .calculationFrequency(NO_ANSWER) - .frequency(NO_ANSWER) - .dailyRate(NO_ANSWER) - .stepsToRecoverArrears(NO_ANSWER) - .arrearsTotal(NO_ANSWER) - .judgmentRequested(NO_ANSWER) - .rentStatementPlaceholder(NO_ANSWER) - .build(); - } - - RentArrearsSection rentArrearsSection = pcsCase.getRentArrears(); - if (rentArrearsSection != null) { - rentArrearsTabDetails.setStepsToRecoverArrears(rentArrearsSection.getRecoveryAttemptDetails()); - rentArrearsTabDetails.setRentStatement(rentArrearsSection.getStatementDocuments()); - } else { - rentArrearsTabDetails.setStepsToRecoverArrears(NO_ANSWER); - rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); - } - - - return rentArrearsTabDetails; - } - private ApplicationsTabDetails buildApplicationsTabDetails(PCSCase pcsCase) { VerticalYesNo applicationWithClaim = pcsCase.getApplicationWithClaim(); String planToMakeGeneralApplication = applicationWithClaim != null diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java index c809d7a273..d53126dadb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.view.builder; 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.domain.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; @@ -13,6 +14,8 @@ @Component public class RentArrearsTabDetailsBuilder { + private static final String NO_ANSWER = " "; + public RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { RentDetails rentDetails = pcsCase.getRentDetails(); RentArrearsSection rentArrears = pcsCase.getRentArrears(); @@ -41,6 +44,65 @@ public RentArrearsTabDetails buildRentArrearsTabDetails(PCSCase pcsCase) { .build(); } + public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) { + if (pcsCase.getShowRentSectionPage() != YesOrNo.YES) { + return null; + } + + RentDetails rentDetails = pcsCase.getRentDetails(); + RentArrearsSection rentArrears = pcsCase.getRentArrears(); + + String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequencyDetailed(rentDetails); + String dailyRate = getDailyRate(rentDetails); + String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + + if (rentAmount == null + && calculationFrequency == null + && dailyRate == null + && arrearsTotal == null + && judgmentRequested == null) { + return RentArrearsTabDetails.builder() + .rentAmount(NO_ANSWER) + .calculationFrequency(NO_ANSWER) + .dailyRate(NO_ANSWER) + .stepsToRecoverArrears(NO_ANSWER) + .arrearsTotal(NO_ANSWER) + .judgmentRequested(NO_ANSWER) + .rentStatementPlaceholder(NO_ANSWER) + .build(); + } + + String frequency = null; + if (rentDetails != null && rentDetails.getFrequency() == RentPaymentFrequency.OTHER) { + frequency = rentDetails.getOtherFrequency(); + } + + RentArrearsSection rentArrearsSection = pcsCase.getRentArrears(); + + RentArrearsTabDetails rentArrearsTabDetails = RentArrearsTabDetails.builder() + .rentAmount(rentAmount) + .calculationFrequency(calculationFrequency) + .dailyRate(dailyRate) + .arrearsTotal(arrearsTotal) + .judgmentRequested(judgmentRequested) + .frequency(frequency) + .build(); + + if (rentArrearsSection != null) { + rentArrearsTabDetails.setStepsToRecoverArrears(rentArrearsSection.getRecoveryAttempted().getLabel()); + rentArrearsTabDetails.setStepsToRecoverArrearsDetails(rentArrearsSection.getRecoveryAttemptDetails()); + rentArrearsTabDetails.setRentStatement(rentArrearsSection.getStatementDocuments()); + } else { + rentArrearsTabDetails.setStepsToRecoverArrears(NO_ANSWER); + rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); + } + + return rentArrearsTabDetails; + } + private String getDailyRate(RentDetails rentDetails) { if (rentDetails == null) { return null; @@ -84,4 +146,12 @@ private String getRentCalculationFrequency(RentDetails rentDetails) { return rentDetails.getFrequency().getLabel(); } + + private String getRentCalculationFrequencyDetailed(RentDetails rentDetails) { + if (rentDetails == null || rentDetails.getFrequency() == null) { + return null; + } + + return rentDetails.getFrequency().getLabel(); + } } From 280e67a7f8e90173e6ba58d44f5c760cd3074099 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 20 May 2026 15:45:23 +0100 Subject: [PATCH 092/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabView.java | 9 +++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index bb4c3ad233..656ccdbf8b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -31,6 +31,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -39,6 +40,7 @@ import java.util.regex.Pattern; import static uk.gov.hmcts.ccd.sdk.type.YesOrNo.NO; +import static uk.gov.hmcts.reform.pcs.config.ClockConfiguration.UK_ZONE_ID; @Component public class CaseSummaryTabView { @@ -132,7 +134,12 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return null; } - return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + LocalDateTime ukDateSubmitted = dateSubmitted + .atZone(ZoneId.systemDefault()) + .withZoneSameInstant(UK_ZONE_ID) + .toLocalDateTime(); + + return ukDateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); } private ClaimantInformationTabDetails createSummaryClaimantTabDetails(PCSCase pcsCase) { diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 0d501be9a4..19267b5145 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -30,6 +30,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; +import java.util.TimeZone; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; @@ -164,6 +165,46 @@ void shouldDisplaySubmittedDateInGmtWhenBritishSummerTimeApplies() { assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 5:02:31PM"); } + @Test + void shouldDisplaySubmittedDateInUkTimeWhenServerTimezoneIsUtc() { + // Given + TimeZone originalTimeZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + PCSCase pcsCase = PCSCase.builder() + .dateSubmitted(LocalDateTime.of(2026, 7, 11, 17, 2, 31)) + .build(); + + try { + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 6:02:31PM"); + } finally { + TimeZone.setDefault(originalTimeZone); + } + } + + @Test + void shouldDisplaySubmittedDateInGmtOutsideBritishSummerTimeWhenServerTimezoneIsUtc() { + // Given + TimeZone originalTimeZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + PCSCase pcsCase = PCSCase.builder() + .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) + .build(); + + try { + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); + } finally { + TimeZone.setDefault(originalTimeZone); + } + } + @Test void shouldSetSummaryClaimantNameFromOverriddenName() { // Given From 76a30f8685e56e005395e05befc82e4b90be19fb Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 20 May 2026 16:11:42 +0100 Subject: [PATCH 093/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 19267b5145..a164621549 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -51,7 +51,7 @@ void shouldSetSummaryTabFields() { AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); PCSCase pcsCase = PCSCase.builder() .propertyAddress(propertyAddress) - .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) + .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) .claimGroundSummaries(List.of( listValue(ClaimGroundSummary.builder() .label("Rent arrears (ground 10)") @@ -125,7 +125,7 @@ void shouldSetSummaryTabFields() { .isEqualTo("Condition 1 reason"); assertThat(summaryTab.getReasonsForPossession().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); assertThat(summaryTab.getClaimantDetails().getClaimantName()).isEqualTo("Fallback claimant"); assertThat(summaryTab.getDefendantDetails().getFirstName()).isEqualTo("Defendant"); assertThat(summaryTab.getDefendantDetails().getLastName()).isEqualTo("One"); @@ -152,17 +152,23 @@ void shouldSetSummaryTabFields() { } @Test - void shouldDisplaySubmittedDateInGmtWhenBritishSummerTimeApplies() { + void shouldDisplaySubmittedDateInUkTimeWhenServerTimezoneIsUk() { // Given + TimeZone originalTimeZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); PCSCase pcsCase = PCSCase.builder() .dateSubmitted(LocalDateTime.of(2026, 7, 11, 17, 2, 31)) .build(); - // When - SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + try { + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); - // Then - assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 5:02:31PM"); + // Then + assertThat(summaryTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 5:02:31PM"); + } finally { + TimeZone.setDefault(originalTimeZone); + } } @Test From e50c5c7d02a94e15def0cc7433173630be6ddb9b Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 16:17:04 +0100 Subject: [PATCH 094/138] HDPI-2983: fix to view rent details and documents after submit in case details tab --- .../pcs/ccd/view/CaseDetailsTabView.java | 1 - .../pcs/ccd/view/NoticeOfPossessionView.java | 41 ++++++++++++++++++- .../reform/pcs/ccd/view/RentArrearsView.java | 41 ++++++++++++++++++- .../reform/pcs/ccd/view/RentDetailsView.java | 2 + .../pcs/ccd/view/TenancyLicenceView.java | 40 +++++++++++++++++- 5 files changed, 118 insertions(+), 7 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 8235b47a9c..cf4b40ec48 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -16,7 +16,6 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuy; import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionView.java index 274e159638..a18a129b74 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionView.java @@ -1,15 +1,20 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.WalesNoticeDetails; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.claim.NoticeOfPossessionEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.util.List; import java.util.Optional; @Component @@ -18,15 +23,20 @@ public class NoticeOfPossessionView { public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { getMainClaim(pcsCaseEntity) .map(ClaimEntity::getNoticeOfPossession) - .ifPresent(noticeOfPossession -> setNoticeOfPossessionFields(pcsCase, noticeOfPossession)); + .ifPresent(noticeOfPossession -> + setNoticeOfPossessionFields(pcsCase, noticeOfPossession, pcsCaseEntity)); } - private void setNoticeOfPossessionFields(PCSCase pcsCase, NoticeOfPossessionEntity noticeOfPossessionEntity) { + private void setNoticeOfPossessionFields(PCSCase pcsCase, NoticeOfPossessionEntity noticeOfPossessionEntity, + PcsCaseEntity pcsCaseEntity) { NoticeServedDetails noticeServedDetails = new NoticeServedDetails(); NoticeServiceMethod servingMethod = noticeOfPossessionEntity.getServingMethod(); noticeServedDetails.setNoticeServiceMethod(servingMethod); + List> documents = getNoticeStatement(pcsCaseEntity); + noticeServedDetails.setNoticeDocuments(documents); + if (pcsCase.getLegislativeCountry() == LegislativeCountry.WALES) { WalesNoticeDetails walesNoticeDetails = WalesNoticeDetails.builder() .noticeServed(noticeOfPossessionEntity.getNoticeServed()) @@ -72,4 +82,31 @@ private static Optional getMainClaim(PcsCaseEntity pcsCaseEntity) { .findFirst(); } + private static List> getNoticeStatement(PcsCaseEntity pcsCaseEntity) { + if (pcsCaseEntity.getDocuments().isEmpty()) { + return null; + } + + return pcsCaseEntity.getDocuments().stream() + .filter(NoticeOfPossessionView::isNoticeStatement) + .map(NoticeOfPossessionView::toDocument) + .toList(); + } + + private static boolean isNoticeStatement(DocumentEntity documentEntity) { + return documentEntity.getType() == DocumentType.NOTICE_FOR_SERVICE_OUT_OF_JURISDICTION; + } + + private static ListValue toDocument(DocumentEntity documentEntity) { + return ListValue.builder() + .value( + Document.builder() + .url(documentEntity.getUrl()) + .filename(documentEntity.getFileName()) + .binaryUrl(documentEntity.getBinaryUrl()) + .categoryId(documentEntity.getCategoryId()) + .build() + ).build(); + } + } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsView.java index 2dddb15f9b..f0597cda92 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsView.java @@ -1,11 +1,17 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.reform.pcs.ccd.domain.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.claim.RentArrearsEntity; + +import java.util.List; import java.util.Optional; @Component @@ -14,15 +20,19 @@ public class RentArrearsView { public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { getMainClaim(pcsCaseEntity) .map(ClaimEntity::getRentArrears) - .ifPresent(rentArrearsEntity -> setRentArrearsFields(pcsCase, rentArrearsEntity)); + .ifPresent(rentArrearsEntity -> + setRentArrearsFields(pcsCase, rentArrearsEntity, pcsCaseEntity)); } - private void setRentArrearsFields(PCSCase pcsCase, RentArrearsEntity rentArrearsEntity) { + private void setRentArrearsFields(PCSCase pcsCase, RentArrearsEntity rentArrearsEntity, + PcsCaseEntity pcsCaseEntity) { RentArrearsSection rentArrears = new RentArrearsSection(); + List> documents = getRentStatement(pcsCaseEntity); rentArrears.setTotal(rentArrearsEntity.getTotalRentArrears()); rentArrears.setRecoveryAttempted(rentArrearsEntity.getRecoveryAttempted()); rentArrears.setRecoveryAttemptDetails(rentArrearsEntity.getRecoveryAttemptDetails()); + rentArrears.setStatementDocuments(documents); pcsCase.setRentArrears(rentArrears); @@ -34,4 +44,31 @@ private static Optional getMainClaim(PcsCaseEntity pcsCaseEntity) { .findFirst(); } + private static List> getRentStatement(PcsCaseEntity pcsCaseEntity) { + if (pcsCaseEntity.getDocuments().isEmpty()) { + return null; + } + + return pcsCaseEntity.getDocuments().stream() + .filter(RentArrearsView::isRentStatement) + .map(RentArrearsView::toDocument) + .toList(); + } + + private static boolean isRentStatement(DocumentEntity documentEntity) { + return documentEntity.getType() == DocumentType.RENT_STATEMENT; + } + + private static ListValue toDocument(DocumentEntity documentEntity) { + return ListValue.builder() + .value( + Document.builder() + .url(documentEntity.getUrl()) + .filename(documentEntity.getFileName()) + .binaryUrl(documentEntity.getBinaryUrl()) + .categoryId(documentEntity.getCategoryId()) + .build() + ).build(); + } + } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java index 3e9d0ff21b..188805317f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.pcs.ccd.view; 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.domain.RentDetails; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; @@ -22,6 +23,7 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { .build(); pcsCase.setRentDetails(rentDetails); + pcsCase.setShowRentSectionPage(YesOrNo.YES); } } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceView.java index 615b2af92e..283d22d68f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceView.java @@ -1,16 +1,22 @@ package uk.gov.hmcts.reform.pcs.ccd.view; import org.springframework.stereotype.Component; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.CombinedLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.TenancyLicenceEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; +import java.util.List; + @Component public class TenancyLicenceView { @@ -24,11 +30,13 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { if (pcsCase.getLegislativeCountry() == LegislativeCountry.WALES) { setOccupationLicenceFields(pcsCase, tenancyLicence); } else { - setTenancyLicenceFields(pcsCase, tenancyLicence); + setTenancyLicenceFields(pcsCase, tenancyLicence, pcsCaseEntity); } } - private static void setTenancyLicenceFields(PCSCase pcsCase, TenancyLicenceEntity tenancyLicence) { + private static void setTenancyLicenceFields(PCSCase pcsCase, TenancyLicenceEntity tenancyLicence, + PcsCaseEntity pcsCaseEntity) { + List> documents = getTenancyLicenceDocument(pcsCaseEntity); CombinedLicenceType combinedLicenceType = tenancyLicence.getType(); TenancyLicenceDetails tenancyLicenceDetails = TenancyLicenceDetails.builder() .typeOfTenancyLicence(TenancyLicenceType.from(combinedLicenceType)) @@ -36,6 +44,7 @@ private static void setTenancyLicenceFields(PCSCase pcsCase, TenancyLicenceEntit .detailsOfOtherTypeOfTenancyLicence(tenancyLicence.getOtherTypeDetails()) .hasCopyOfTenancyLicence(tenancyLicence.getHasCopyOfTenancyLicence()) .reasonsForNoTenancyLicenceDocuments(tenancyLicence.getReasonsForNoTenancyLicence()) + .tenancyLicenceDocuments(documents) .build(); pcsCase.setTenancyLicenceDetails(tenancyLicenceDetails); @@ -53,4 +62,31 @@ private static void setOccupationLicenceFields(PCSCase pcsCase, TenancyLicenceEn pcsCase.setOccupationLicenceDetailsWales(occupationLicence); } + private static List> getTenancyLicenceDocument(PcsCaseEntity pcsCaseEntity) { + if (pcsCaseEntity.getDocuments().isEmpty()) { + return null; + } + + return pcsCaseEntity.getDocuments().stream() + .filter(TenancyLicenceView::isTenancyLicence) + .map(TenancyLicenceView::toDocument) + .toList(); + } + + private static boolean isTenancyLicence(DocumentEntity documentEntity) { + return documentEntity.getType() == DocumentType.TENANCY_LICENCE; + } + + private static ListValue toDocument(DocumentEntity documentEntity) { + return ListValue.builder() + .value( + Document.builder() + .url(documentEntity.getUrl()) + .filename(documentEntity.getFileName()) + .binaryUrl(documentEntity.getBinaryUrl()) + .categoryId(documentEntity.getCategoryId()) + .build() + ).build(); + } + } From 7b189158894ae7a0150317b29f218c1d1b446a14 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 18:30:31 +0100 Subject: [PATCH 095/138] HDPI-2983: fix null pointer exception --- .../builder/RentArrearsTabDetailsBuilder.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java index d53126dadb..4eb3df3cfd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java @@ -1,6 +1,9 @@ package uk.gov.hmcts.reform.pcs.ccd.view.builder; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; 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.RentArrearsSection; @@ -10,6 +13,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.math.BigDecimal; +import java.util.List; @Component public class RentArrearsTabDetailsBuilder { @@ -92,9 +96,18 @@ public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) .build(); if (rentArrearsSection != null) { - rentArrearsTabDetails.setStepsToRecoverArrears(rentArrearsSection.getRecoveryAttempted().getLabel()); - rentArrearsTabDetails.setStepsToRecoverArrearsDetails(rentArrearsSection.getRecoveryAttemptDetails()); - rentArrearsTabDetails.setRentStatement(rentArrearsSection.getStatementDocuments()); + VerticalYesNo recoveryAttempted = rentArrearsSection.getRecoveryAttempted(); + rentArrearsTabDetails + .setStepsToRecoverArrears(recoveryAttempted != null ? recoveryAttempted.getLabel() : NO_ANSWER); + String details = rentArrearsSection.getRecoveryAttemptDetails(); + rentArrearsTabDetails.setStepsToRecoverArrearsDetails(details != null ? details : NO_ANSWER); + List> documents = rentArrearsSection.getStatementDocuments(); + + if (CollectionUtils.isEmpty(documents)) { + rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); + } else { + rentArrearsTabDetails.setRentStatement(documents); + } } else { rentArrearsTabDetails.setStepsToRecoverArrears(NO_ANSWER); rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); From 83b3430979740456073674a7ea1ef2ed133a6a9d Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 18:48:02 +0100 Subject: [PATCH 096/138] HDPI-2983: update CaseTabViewTest --- .../reform/pcs/ccd/view/CaseTabView.java | 5 + .../reform/pcs/ccd/view/CaseTabViewTest.java | 191 ++++++++++++++++++ 2 files changed, 196 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java index 3b0c69e346..6ff8c8ae81 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java @@ -67,6 +67,11 @@ public void setDraftCaseTabFields(PCSCase pcsCase, PCSCase draftCaseData) { && alternativesToPossessionSet.containsAll(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) ) { DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + if (demotionOfTenancy == null) { + demotionOfTenancy = DemotionOfTenancy.builder().build(); + draftCaseData.setDemotionOfTenancy(demotionOfTenancy); + } + setDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy, demotionOfTenancy); draftCaseData.setSuspensionOfRightToBuy( buildSuspensionOfRightToBuyHousingAct(suspensionOfRightToBuyDemotionOfTenancy) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java index ce7d5f3f73..6550ee75ed 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabViewTest.java @@ -8,8 +8,13 @@ import uk.gov.hmcts.ccd.sdk.type.AddressUK; import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancy; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancyHousingAct; 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.SuspensionOfRightToBuy; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyDemotionOfTenancy; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; import uk.gov.hmcts.reform.pcs.ccd.domain.UnderlesseeMortgageeDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; @@ -21,11 +26,14 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; @ExtendWith(MockitoExtension.class) class CaseTabViewTest { @@ -700,6 +708,189 @@ void shouldNotSetDraftUnderlesseeOrMortgagePartiesWhenUnderlesseeMortgageeDetail assertThat(allUnderlesseeOrMortgagees).isNull(); } + @Test + void shouldSetSuspensionOfRightToBuyAndDemotionOfTenancyDraftDataWhenBothSelected() { + // Given + String suspensionReason = "Suspension reason"; + String demotionReason = "Demotion reason"; + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy = + SuspensionOfRightToBuyDemotionOfTenancy.builder() + .suspensionOfRightToBuyActs(SuspensionOfRightToBuyHousingAct.SECTION_6A_2) + .suspensionOrderReason(suspensionReason) + .demotionOfTenancyActs(DemotionOfTenancyHousingAct.SECTION_6A_2) + .demotionOrderReason(demotionReason) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .suspensionOfRightToBuyDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy) + .alternativesToPossession(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + SuspensionOfRightToBuy suspensionOfRightToBuy = draftCaseData.getSuspensionOfRightToBuy(); + assertThat(suspensionOfRightToBuy.getHousingAct()).isEqualTo(SuspensionOfRightToBuyHousingAct.SECTION_6A_2); + assertThat(suspensionOfRightToBuy.getReason()).isEqualTo(suspensionReason); + + DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + assertThat(demotionOfTenancy.getHousingAct()).isEqualTo(DemotionOfTenancyHousingAct.SECTION_6A_2); + assertThat(demotionOfTenancy.getReason()).isEqualTo(demotionReason); + } + + @Test + void shouldNotSetSuspensionOfRightToBuyAndDemotionOfTenancyDraftDataWhenOnlyDemotionSelected() { + // Given + String suspensionReason = "Suspension reason"; + String demotionReason = "Demotion reason"; + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy = + SuspensionOfRightToBuyDemotionOfTenancy.builder() + .suspensionOfRightToBuyActs(SuspensionOfRightToBuyHousingAct.SECTION_6A_2) + .suspensionOrderReason(suspensionReason) + .demotionOfTenancyActs(DemotionOfTenancyHousingAct.SECTION_6A_2) + .demotionOrderReason(demotionReason) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .suspensionOfRightToBuyDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy) + .alternativesToPossession(Set.of(DEMOTION_OF_TENANCY)) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + SuspensionOfRightToBuy suspensionOfRightToBuy = draftCaseData.getSuspensionOfRightToBuy(); + assertThat(suspensionOfRightToBuy).isNull(); + + DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + assertThat(demotionOfTenancy).isNull(); + } + + @Test + void shouldNotSetSuspensionOfRightToBuyAndDemotionOfTenancyDraftDataWhenOnlySuspensionSelected() { + // Given + String suspensionReason = "Suspension reason"; + String demotionReason = "Demotion reason"; + SuspensionOfRightToBuyDemotionOfTenancy suspensionOfRightToBuyDemotionOfTenancy = + SuspensionOfRightToBuyDemotionOfTenancy.builder() + .suspensionOfRightToBuyActs(SuspensionOfRightToBuyHousingAct.SECTION_6A_2) + .suspensionOrderReason(suspensionReason) + .demotionOfTenancyActs(DemotionOfTenancyHousingAct.SECTION_6A_2) + .demotionOrderReason(demotionReason) + .build(); + + PCSCase draftCaseData = PCSCase.builder() + .suspensionOfRightToBuyDemotionOfTenancy(suspensionOfRightToBuyDemotionOfTenancy) + .alternativesToPossession(Set.of(SUSPENSION_OF_RIGHT_TO_BUY)) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + SuspensionOfRightToBuy suspensionOfRightToBuy = draftCaseData.getSuspensionOfRightToBuy(); + assertThat(suspensionOfRightToBuy).isNull(); + + DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + assertThat(demotionOfTenancy).isNull(); + } + + @Test + void shouldNotSetSuspensionOfRightToBuyAndDemotionOfTenancyDraftDataWithNoData() { + // Given + PCSCase draftCaseData = PCSCase.builder() + .alternativesToPossession(Set.of(SUSPENSION_OF_RIGHT_TO_BUY, DEMOTION_OF_TENANCY)) + .build(); + + when(caseSummaryTabView.buildSummaryTab(draftCaseData)).thenReturn( + SummaryTab.builder().build() + ); + when(caseDetailsTabView.buildCaseDetailsTab(draftCaseData)).thenReturn( + CaseDetailsTab.builder().build() + ); + when(claimGroundSummaryBuilder.buildClaimGroundSummariesFromDraft(draftCaseData)).thenReturn(List.of()); + + PCSCase pcsCase = PCSCase.builder().build(); + + // When + underTest.setDraftCaseTabFields(pcsCase, draftCaseData); + + // Then + SummaryTab summaryTab = pcsCase.getSummaryTab(); + CaseDetailsTab caseDetailsTab = pcsCase.getCaseDetailsTab(); + assertThat(summaryTab).isNotNull(); + assertThat(caseDetailsTab).isNotNull(); + verify(caseSummaryTabView, times(1)).buildSummaryTab(draftCaseData); + verify(caseDetailsTabView, times(1)).buildCaseDetailsTab(draftCaseData); + verify(caseSummaryTabView, times(0)).buildSummaryTab(pcsCase); + verify(caseDetailsTabView, times(0)).buildCaseDetailsTab(pcsCase); + + SuspensionOfRightToBuy suspensionOfRightToBuy = draftCaseData.getSuspensionOfRightToBuy(); + assertThat(suspensionOfRightToBuy).isNull(); + + DemotionOfTenancy demotionOfTenancy = draftCaseData.getDemotionOfTenancy(); + assertThat(demotionOfTenancy).isNull(); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From b4bfe5d7853b6b8bb0dbe9b2da7bd32c4eacba5f Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 18:49:29 +0100 Subject: [PATCH 097/138] HDPI-2983: add placeholder for date submitted while case is in draft --- .../uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index cf4b40ec48..5fd7a9bb1d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -115,7 +115,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .mortgageDetails(underlesseeMortgageTabDetailsList) .demotionOfTenancyDetails(demotionOfTenancyTabDetails) .suspensionOfRightToBuyDetails(suspensionOfRightToBuyTabDetails) - .dateClaimSubmitted(dateSubmitted) + .dateClaimSubmitted(dateSubmitted != null ? dateSubmitted : NO_ANSWER) .build(); if (claimantInformationTabDetails != null) { From b1431a37e91e1cc4eedfbf479ebc4b442ef265a3 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 20 May 2026 19:44:33 +0100 Subject: [PATCH 098/138] HDPI-2983: update RentArrearsTabDetailsBuilderTest --- .../builder/RentArrearsTabDetailsBuilder.java | 69 ++++--- .../RentArrearsTabDetailsBuilderTest.java | 174 ++++++++++++++++++ 2 files changed, 207 insertions(+), 36 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java index 4eb3df3cfd..96c9ab0dbb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java @@ -53,56 +53,52 @@ public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) return null; } + String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null + ? NO_ANSWER : pcsCase.getArrearsJudgmentWanted().getLabel(); + + RentArrearsTabDetails rentArrearsTabDetails; RentDetails rentDetails = pcsCase.getRentDetails(); RentArrearsSection rentArrears = pcsCase.getRentArrears(); - String rentAmount = rentDetails == null ? null : formatMoney(rentDetails.getCurrentRent()); - String calculationFrequency = getRentCalculationFrequencyDetailed(rentDetails); - String dailyRate = getDailyRate(rentDetails); - String arrearsTotal = rentArrears == null ? null : formatMoney(rentArrears.getTotal()); - String judgmentRequested = pcsCase.getArrearsJudgmentWanted() == null - ? null : pcsCase.getArrearsJudgmentWanted().getLabel(); + if (rentDetails != null) { + String rentAmount = formatMoney(rentDetails.getCurrentRent()); + String calculationFrequency = getRentCalculationFrequencyDetailed(rentDetails); + String dailyRate = getDailyRate(rentDetails); - if (rentAmount == null - && calculationFrequency == null - && dailyRate == null - && arrearsTotal == null - && judgmentRequested == null) { - return RentArrearsTabDetails.builder() + String frequency = null; + if (rentDetails.getFrequency() == RentPaymentFrequency.OTHER) { + frequency = rentDetails.getOtherFrequency(); + } + + rentArrearsTabDetails = RentArrearsTabDetails.builder() + .rentAmount(rentAmount != null ? rentAmount : NO_ANSWER) + .calculationFrequency(calculationFrequency != null ? calculationFrequency : NO_ANSWER) + .dailyRate(dailyRate != null ? dailyRate : NO_ANSWER) + .judgmentRequested(judgmentRequested) + .frequency(frequency) + .build(); + } else { + rentArrearsTabDetails = RentArrearsTabDetails.builder() .rentAmount(NO_ANSWER) .calculationFrequency(NO_ANSWER) .dailyRate(NO_ANSWER) - .stepsToRecoverArrears(NO_ANSWER) - .arrearsTotal(NO_ANSWER) - .judgmentRequested(NO_ANSWER) - .rentStatementPlaceholder(NO_ANSWER) + .judgmentRequested(judgmentRequested) .build(); } - String frequency = null; - if (rentDetails != null && rentDetails.getFrequency() == RentPaymentFrequency.OTHER) { - frequency = rentDetails.getOtherFrequency(); - } - - RentArrearsSection rentArrearsSection = pcsCase.getRentArrears(); - - RentArrearsTabDetails rentArrearsTabDetails = RentArrearsTabDetails.builder() - .rentAmount(rentAmount) - .calculationFrequency(calculationFrequency) - .dailyRate(dailyRate) - .arrearsTotal(arrearsTotal) - .judgmentRequested(judgmentRequested) - .frequency(frequency) - .build(); - - if (rentArrearsSection != null) { - VerticalYesNo recoveryAttempted = rentArrearsSection.getRecoveryAttempted(); + if (rentArrears != null) { + VerticalYesNo recoveryAttempted = rentArrears.getRecoveryAttempted(); rentArrearsTabDetails .setStepsToRecoverArrears(recoveryAttempted != null ? recoveryAttempted.getLabel() : NO_ANSWER); - String details = rentArrearsSection.getRecoveryAttemptDetails(); + + String details = recoveryAttempted == VerticalYesNo.YES + ? rentArrears.getRecoveryAttemptDetails() : null; rentArrearsTabDetails.setStepsToRecoverArrearsDetails(details != null ? details : NO_ANSWER); - List> documents = rentArrearsSection.getStatementDocuments(); + String arrearsTotal = formatMoney(rentArrears.getTotal()); + rentArrearsTabDetails.setArrearsTotal(arrearsTotal != null ? arrearsTotal : NO_ANSWER); + + List> documents = rentArrears.getStatementDocuments(); if (CollectionUtils.isEmpty(documents)) { rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); } else { @@ -111,6 +107,7 @@ public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) } else { rentArrearsTabDetails.setStepsToRecoverArrears(NO_ANSWER); rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER); + rentArrearsTabDetails.setArrearsTotal(NO_ANSWER); } return rentArrearsTabDetails; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java index acd8e84bf7..747d76a6e9 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java @@ -2,12 +2,18 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import uk.gov.hmcts.ccd.sdk.type.Document; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +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.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; import java.math.BigDecimal; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -69,4 +75,172 @@ void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { // Then assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£3.40"); } + + @Test + void shouldBuildDetailedRentArrearsForCaseDetailsTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.YES) + .rentDetails( + RentDetails.builder() + .currentRent(new BigDecimal("4.00")) + .frequency(RentPaymentFrequency.WEEKLY) + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .rentArrears( + RentArrearsSection.builder() + .recoveryAttempted(VerticalYesNo.YES) + .recoveryAttemptDetails("recovery details") + .total(new BigDecimal("100.00")) + .statementDocuments( + List.of( + ListValue.builder() + .value(Document.builder().build()) + .build()) + ) + .build() + ) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getRentAmount()).isEqualTo("£4"); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); + assertThat(rentArrearsDetails.getFrequency()).isNull(); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£3.40"); + assertThat(rentArrearsDetails.getArrearsTotal()).isEqualTo("£100.00"); + assertThat(rentArrearsDetails.getStepsToRecoverArrears()).isEqualTo("Yes"); + assertThat(rentArrearsDetails.getStepsToRecoverArrearsDetails()).isEqualTo("recovery details"); + assertThat(rentArrearsDetails.getRentStatement()).hasSize(1); + assertThat(rentArrearsDetails.getRentStatementPlaceholder()).isNull(); + assertThat(rentArrearsDetails.getJudgmentRequested()).isEqualTo("Yes"); + } + + @Test + void shouldUsePlaceholderInDetailedRentArrearsWhenNoDocumentsUploaded() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.YES) + .rentDetails( + RentDetails.builder() + .currentRent(new BigDecimal("4.00")) + .frequency(RentPaymentFrequency.WEEKLY) + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .rentArrears( + RentArrearsSection.builder() + .recoveryAttempted(VerticalYesNo.YES) + .recoveryAttemptDetails("recovery details") + .total(new BigDecimal("100.00")) + .build() + ) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getRentStatement()).isNull(); + assertThat(rentArrearsDetails.getRentStatementPlaceholder()).isEqualTo(" "); + } + + @Test + void shouldSetFrequencyInDetailedRentArrearsWhenCalculationFrequencyIsOther() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.YES) + .rentDetails( + RentDetails.builder() + .currentRent(new BigDecimal("4.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Other frequency") + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .rentArrears( + RentArrearsSection.builder() + .recoveryAttempted(VerticalYesNo.YES) + .recoveryAttemptDetails("recovery details") + .total(new BigDecimal("100.00")) + .statementDocuments( + List.of( + ListValue.builder() + .value(Document.builder().build()) + .build()) + ) + .build() + ) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Other"); + assertThat(rentArrearsDetails.getFrequency()).isEqualTo("Other frequency"); + } + + @Test + void shouldUsePlaceholderInDetailedRentArrearsWhenRentDetailsIsNull() { + // Given + PCSCase pcsCase = PCSCase.builder().showRentSectionPage(YesOrNo.YES).build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getRentAmount()).isEqualTo(" "); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo(" "); + assertThat(rentArrearsDetails.getFrequency()).isNull(); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo(" "); + assertThat(rentArrearsDetails.getArrearsTotal()).isEqualTo(" "); + assertThat(rentArrearsDetails.getStepsToRecoverArrears()).isEqualTo(" "); + assertThat(rentArrearsDetails.getStepsToRecoverArrearsDetails()).isNull(); + assertThat(rentArrearsDetails.getRentStatement()).isNull(); + assertThat(rentArrearsDetails.getRentStatementPlaceholder()).isEqualTo(" "); + assertThat(rentArrearsDetails.getJudgmentRequested()).isEqualTo(" "); + } + + @Test + void shouldNotBuildDetailedRentArrearsWhenRentSectionPageIsNo() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.NO) + .rentDetails( + RentDetails.builder() + .currentRent(new BigDecimal("4.00")) + .frequency(RentPaymentFrequency.WEEKLY) + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .rentArrears( + RentArrearsSection.builder() + .recoveryAttempted(VerticalYesNo.YES) + .recoveryAttemptDetails("recovery details") + .total(new BigDecimal("100.00")) + .statementDocuments( + List.of( + ListValue.builder() + .value(Document.builder().build()) + .build()) + ) + .build() + ) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails).isNull(); + } } From baed0dd71b2578fea234c44bb57b365f4061b8eb Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 08:04:27 +0100 Subject: [PATCH 099/138] HDPI-2983: fix unit test --- .../pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java index 747d76a6e9..95282e40df 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java @@ -112,7 +112,7 @@ void shouldBuildDetailedRentArrearsForCaseDetailsTab() { assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Weekly"); assertThat(rentArrearsDetails.getFrequency()).isNull(); assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£3.40"); - assertThat(rentArrearsDetails.getArrearsTotal()).isEqualTo("£100.00"); + assertThat(rentArrearsDetails.getArrearsTotal()).isEqualTo("£100"); assertThat(rentArrearsDetails.getStepsToRecoverArrears()).isEqualTo("Yes"); assertThat(rentArrearsDetails.getStepsToRecoverArrearsDetails()).isEqualTo("recovery details"); assertThat(rentArrearsDetails.getRentStatement()).hasSize(1); From 4b5481578d1f9bebf379fbd4b14d29fb495f5bdc Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 08:23:22 +0100 Subject: [PATCH 100/138] HDPI-2983: update tests coverage in RentArrearsTabDetailsBuilderTest --- .../builder/RentArrearsTabDetailsBuilder.java | 7 +- .../RentArrearsTabDetailsBuilderTest.java | 91 +++++++++++++++++++ 2 files changed, 95 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java index 96c9ab0dbb..784207ef97 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java @@ -91,9 +91,10 @@ public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) rentArrearsTabDetails .setStepsToRecoverArrears(recoveryAttempted != null ? recoveryAttempted.getLabel() : NO_ANSWER); - String details = recoveryAttempted == VerticalYesNo.YES - ? rentArrears.getRecoveryAttemptDetails() : null; - rentArrearsTabDetails.setStepsToRecoverArrearsDetails(details != null ? details : NO_ANSWER); + if (recoveryAttempted == VerticalYesNo.YES) { + String details = rentArrears.getRecoveryAttemptDetails(); + rentArrearsTabDetails.setStepsToRecoverArrearsDetails(details != null ? details : NO_ANSWER); + } String arrearsTotal = formatMoney(rentArrears.getTotal()); rentArrearsTabDetails.setArrearsTotal(arrearsTotal != null ? arrearsTotal : NO_ANSWER); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java index 95282e40df..143510fa10 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilderTest.java @@ -76,6 +76,71 @@ void shouldSetRentArrearsDetailsFromCalculatedDailyCharge() { assertThat(rentArrearsDetails.getDailyRate()).isEqualTo("£3.40"); } + @Test + void shouldSetCalculationFrequencyInRentArrearsWhenFrequencyIsOther() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.YES) + .rentDetails( + RentDetails.builder() + .currentRent(new BigDecimal("4.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Other frequency") + .calculatedDailyCharge(new BigDecimal("3.40")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .rentArrears( + RentArrearsSection.builder() + .recoveryAttempted(VerticalYesNo.YES) + .recoveryAttemptDetails("recovery details") + .total(new BigDecimal("100.00")) + .statementDocuments( + List.of( + ListValue.builder() + .value(Document.builder().build()) + .build()) + ) + .build() + ) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo("Other frequency"); + } + + @Test + void shouldNotBuildRentArrearsWithNoRentArrears() { + // Given + PCSCase pcsCase = PCSCase.builder().build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails).isNull(); + } + + @Test + void shouldNotBuildRentArrearsWithRentArrearsDataNotSet() { + // Given + PCSCase pcsCase = PCSCase.builder() + .rentDetails(RentDetails.builder().build()) + .rentArrears(RentArrearsSection.builder().build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails).isNull(); + } + @Test void shouldBuildDetailedRentArrearsForCaseDetailsTab() { // Given @@ -243,4 +308,30 @@ void shouldNotBuildDetailedRentArrearsWhenRentSectionPageIsNo() { // Then assertThat(rentArrearsDetails).isNull(); } + + @Test + void shouldBuildDetailedRentArrearsWithPlaceholdersWhenRentArrearsDataNotSet() { + // Given + PCSCase pcsCase = PCSCase.builder() + .showRentSectionPage(YesOrNo.YES) + .rentDetails(RentDetails.builder().build()) + .rentArrears(RentArrearsSection.builder().build()) + .build(); + + // When + RentArrearsTabDetails rentArrearsDetails = rentArrearsTabDetailsBuilder + .buildDetailedRentArrearsTabDetails(pcsCase); + + // Then + assertThat(rentArrearsDetails.getRentAmount()).isEqualTo(" "); + assertThat(rentArrearsDetails.getCalculationFrequency()).isEqualTo(" "); + assertThat(rentArrearsDetails.getFrequency()).isNull(); + assertThat(rentArrearsDetails.getDailyRate()).isEqualTo(" "); + assertThat(rentArrearsDetails.getArrearsTotal()).isEqualTo(" "); + assertThat(rentArrearsDetails.getStepsToRecoverArrears()).isEqualTo(" "); + assertThat(rentArrearsDetails.getStepsToRecoverArrearsDetails()).isNull(); + assertThat(rentArrearsDetails.getRentStatement()).isNull(); + assertThat(rentArrearsDetails.getRentStatementPlaceholder()).isEqualTo(" "); + assertThat(rentArrearsDetails.getJudgmentRequested()).isEqualTo(" "); + } } From 6cc35a01f9128832cadf5a91c710719c127c1796 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 12:52:08 +0100 Subject: [PATCH 101/138] HDPI-2983: add CaseDetailsTabViewTest --- .../domain/tabs/details/CaseDetailsTab.java | 5 - .../pcs/ccd/view/CaseDetailsTabView.java | 34 +- .../pcs/ccd/view/CaseDetailsTabViewTest.java | 670 ++++++++++++++++++ 3 files changed, 703 insertions(+), 6 deletions(-) create mode 100644 src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 70c2bd15cb..719ccf0b53 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -98,11 +98,6 @@ public class CaseDetailsTab { ) private DefendantInformationTabDetails defendantInformationDetails; - @CCD( - label = "Defendant 1 address for service" - ) - private AddressUK defendantOneAddress; - @CCD( label = "Additional defendant" ) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 5fd7a9bb1d..b6f0c38f24 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -7,6 +7,7 @@ import uk.gov.hmcts.ccd.sdk.type.ListValue; import uk.gov.hmcts.ccd.sdk.type.YesOrNo; import uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantCircumstances; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantContactPreferences; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType; import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantCircumstances; @@ -28,6 +29,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ApplicationsTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimantCircumstancesTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ClaimantContactTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DefendantCircumstanceTabDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DemotionOfTenancyTabDetails; @@ -121,6 +123,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { if (claimantInformationTabDetails != null) { caseDetailsTab.setClaimantAddress(getClaimantAddress(pcsCase)); caseDetailsTab.setClaimantContactDetails(buildClaimantContactTabDetails(pcsCase)); + caseDetailsTab.setClaimantCircumstances(buildClaimantCircumstancesTabDetails(pcsCase)); } if (defendantInformationTabDetails != null) { @@ -258,7 +261,7 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { } case OTHER -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); - String explanation = noticeTabDetails.getNoticeOtherExplanation(); + String explanation = noticeServedDetails.getNoticeOtherExplanation(); noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); noticeTabDetails.setNoticeOtherExplanation(explanation != null ? explanation : NO_ANSWER); } @@ -273,9 +276,15 @@ private ActionsTakenTabDetails buildActionsTakenTabDetails(PCSCase pcsCase) { VerticalYesNo preactionProtocol = pcsCase.getPreActionProtocolCompleted(); VerticalYesNo mediationAttempted = pcsCase.getMediationAttempted(); VerticalYesNo settlementAttempted = pcsCase.getSettlementAttempted(); + String noPreactionExplanation = null; + + if (preactionProtocol == VerticalYesNo.NO) { + noPreactionExplanation = pcsCase.getPreActionProtocolIncompleteExplanation(); + } return ActionsTakenTabDetails.builder() .preactionProtocolFollowed(preactionProtocol != null ? preactionProtocol.getLabel() : NO_ANSWER) + .preActionProtocolIncompleteExplanation(noPreactionExplanation) .mediationAttempted(mediationAttempted != null ? mediationAttempted.getLabel() : NO_ANSWER) .settlementAttempted(settlementAttempted != null ? settlementAttempted.getLabel() : NO_ANSWER) .build(); @@ -352,6 +361,29 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase .build(); } + private ClaimantCircumstancesTabDetails buildClaimantCircumstancesTabDetails(PCSCase pcsCase) { + ClaimantCircumstances claimantCircumstances = pcsCase.getClaimantCircumstances(); + + if (claimantCircumstances == null) { + return ClaimantCircumstancesTabDetails.builder() + .claimantCircumstancesGiven(NO_ANSWER) + .build(); + } + VerticalYesNo claimantCircumstancesGiven = claimantCircumstances.getClaimantCircumstancesSelect(); + String claimantCircumstancesDetails = null; + + if (claimantCircumstancesGiven == VerticalYesNo.YES) { + claimantCircumstancesDetails = claimantCircumstances.getClaimantCircumstancesDetails(); + } + + return ClaimantCircumstancesTabDetails.builder() + .claimantCircumstancesGiven( + claimantCircumstancesGiven != null ? claimantCircumstancesGiven.getLabel() : NO_ANSWER + ) + .claimantCircumstancesDetails(claimantCircumstancesDetails) + .build(); + } + private DefendantCircumstanceTabDetails buildDefendantCircumstanceTabDetails(PCSCase pcsCase) { DefendantCircumstances defendantCircumstances = pcsCase.getDefendantCircumstances(); String circumstances = null; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java new file mode 100644 index 0000000000..b7fb331c19 --- /dev/null +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -0,0 +1,670 @@ +package uk.gov.hmcts.reform.pcs.ccd.view; + +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.AddressUK; +import uk.gov.hmcts.ccd.sdk.type.ListValue; +import uk.gov.hmcts.ccd.sdk.type.YesOrNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantCircumstances; +import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantContactPreferences; +import uk.gov.hmcts.reform.pcs.ccd.domain.DefendantCircumstances; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancy; +import uk.gov.hmcts.reform.pcs.ccd.domain.DemotionOfTenancyHousingAct; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; +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.RentArrearsSection; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuy; +import uk.gov.hmcts.reform.pcs.ccd.domain.SuspensionOfRightToBuyHousingAct; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.AssuredAdditionalOtherGround; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.ClaimGroundSummary; +import uk.gov.hmcts.reform.pcs.ccd.domain.grounds.IntroductoryDemotedOrOtherGrounds; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.CaseDetailsTab; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.AdditionalDefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ClaimantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.DefendantInformationTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.ReasonsForPossessionTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.shared.RentArrearsTabDetails; +import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringList; +import uk.gov.hmcts.reform.pcs.ccd.type.DynamicStringListElement; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.AdditionalDefendantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ClaimantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.DefendantInformationTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.DEMOTION_OF_TENANCY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.AlternativesToPossession.SUSPENSION_OF_RIGHT_TO_BUY; +import static uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantType.PROVIDER_OF_SOCIAL_HOUSING; + +@ExtendWith(MockitoExtension.class) +public class CaseDetailsTabViewTest { + + @Mock + private GroundsBuilder groundsBuilder; + + @Mock + private RentArrearsTabDetailsBuilder rentArrearsTabDetailsBuilder; + + @Mock + private ReasonsForPossessionTabDetailsBuilder reasonsForPossessionTabDetailsBuilder; + + @Mock + private ClaimantInformationTabDetailsBuilder claimantInformationTabDetailsBuilder; + + @Mock + private DefendantInformationTabDetailsBuilder defendantInformationTabDetailsBuilder; + + @Mock + private AdditionalDefendantInformationTabDetailsBuilder additionalDefendantInformationTabDetailsBuilder; + + @InjectMocks + private CaseDetailsTabView caseDetailsTabView; + + final private String NO_ANSWER = " "; + + @Test + void shouldSetCaseDetailsTabFields() { + AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); + AddressUK defendantAddress = AddressUK.builder().postCode("E1 1AA").build(); + AddressUK underlesseeAddress = AddressUK.builder().postCode("CV1 1DF").build(); + AddressUK claimantAddress = AddressUK.builder().postCode("L2 3RT").build(); + PCSCase pcsCase = PCSCase.builder() + .claimantType( + DynamicStringList.builder().value( + DynamicStringListElement.builder().code(PROVIDER_OF_SOCIAL_HOUSING.name()).build()) + .build()) + .claimAgainstTrespassers(VerticalYesNo.YES) + .propertyAddress(propertyAddress) + .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Rent arrears (ground 10)") + .reason("Ground 10 reason") + .code("ABSOLUTE_GROUNDS") + .build()), + listValue(ClaimGroundSummary.builder() + .label("Condition 1 of Section 84A of the Housing Act 1985") + .reason("Condition 1 reason") + .code("ABSOLUTE_GROUNDS") + .build()) + )) + .additionalReasonsForPossession(AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reasons") + .build()) + .allClaimants( + List.of(listValue( + Party.builder() + .orgName("Claimant") + .address(claimantAddress) + .emailAddress("claimant@email.com") + .phoneNumber("phone number") + .build() + )) + ) + .claimantCircumstances( + ClaimantCircumstances.builder() + .claimantCircumstancesSelect(VerticalYesNo.YES) + .claimantCircumstancesDetails("claimant circumstances") + .build() + ) + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .addressKnown(VerticalYesNo.YES) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("Two") + .addressKnown(VerticalYesNo.YES) + .address(defendantAddress) + .build()), + listValue(Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build()) + )) + .defendantCircumstances( + DefendantCircumstances.builder() + .hasDefendantCircumstancesInfo(VerticalYesNo.YES) + .defendantCircumstancesInfo("defendant circumstances") + .build() + ) + .rentDetails(RentDetails.builder() + .currentRent(new BigDecimal("100.00")) + .frequency(RentPaymentFrequency.OTHER) + .otherFrequency("Every 4 weeks") + .perDayCorrect(VerticalYesNo.NO) + .amendedDailyCharge(new BigDecimal("12.30")) + .build()) + .rentArrears(RentArrearsSection.builder() + .total(new BigDecimal("450.75")) + .build()) + .arrearsJudgmentWanted(VerticalYesNo.YES) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .hasCopyOfTenancyLicence(VerticalYesNo.NO) + .reasonsForNoTenancyLicenceDocuments("Reasons") + .build()) + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.EMAIL) + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .preActionProtocolCompleted(VerticalYesNo.NO) + .preActionProtocolIncompleteExplanation("preaction explanation") + .mediationAttempted(VerticalYesNo.YES) + .settlementAttempted(VerticalYesNo.YES) + .applicationWithClaim(VerticalYesNo.YES) + .allUnderlesseeOrMortgagees(List.of( + listValue( + Party.builder() + .nameKnown(VerticalYesNo.YES) + .orgName("underlessee name") + .addressKnown(VerticalYesNo.YES) + .address(underlesseeAddress) + .build() + ) + )) + .alternativesToPossession(Set.of(DEMOTION_OF_TENANCY, SUSPENSION_OF_RIGHT_TO_BUY)) + .demotionOfTenancy( + DemotionOfTenancy.builder() + .housingAct(DemotionOfTenancyHousingAct.SECTION_6A_2) + .statementOfExpressTermsServed(VerticalYesNo.YES) + .statementOfExpressTermsDetails("terms") + .reason("demotion reason") + .build() + ) + .suspensionOfRightToBuy( + SuspensionOfRightToBuy.builder() + .housingAct(SuspensionOfRightToBuyHousingAct.SECTION_6A_2) + .reason("suspension reason") + .build() + ) + .build(); + + when(groundsBuilder.getGrounds(pcsCase)).thenReturn( + "Rent arrears (ground 10)\n" + + "Antisocial behaviour: Condition 1 of Section 84A of the Housing Act 1985" + ); + + when(rentArrearsTabDetailsBuilder.buildDetailedRentArrearsTabDetails(pcsCase)).thenReturn( + RentArrearsTabDetails.builder() + .rentAmount("£100") + .calculationFrequency("Every 4 weeks") + .dailyRate("£12.30") + .arrearsTotal("£450.75") + .judgmentRequested("Yes") + .build() + ); + + when(reasonsForPossessionTabDetailsBuilder.buildDetailsReasonsForPossession(pcsCase)).thenReturn( + ReasonsForPossessionTabDetails.builder() + .ground10("Ground 10 reason") + .condition1OfSection84A("Condition 1 reason") + .additionalReasonsForPossession("Additional reasons") + .build() + ); + + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn( + ClaimantInformationTabDetails.builder() + .claimantName("Claimant") + .build() + ); + + when(defendantInformationTabDetailsBuilder.buildDetailedDefendantDetails(pcsCase)).thenReturn( + DefendantInformationTabDetails.builder() + .nameKnown("Yes") + .firstName("Defendant") + .lastName("One") + .addressKnown("Yes") + .addressForService(propertyAddress) + .build() + ); + + when(additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase)) + .thenReturn( + List.of( + listValue( + AdditionalDefendantInformationTabDetails.builder() + .nameKnown("Yes") + .firstName("Defendant") + .lastName("Two") + .addressKnown("Yes") + .addressForService(defendantAddress) + .build() + ), + listValue( + AdditionalDefendantInformationTabDetails.builder() + .nameKnown("No") + .addressKnown("No") + .build() + ) + ) + ); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + assertThat(caseDetailsTab.getPropertyAddress()).isEqualTo(propertyAddress); + assertThat(caseDetailsTab.getGroundsForPossessionDetails().getGrounds()) + .isEqualTo( + "Rent arrears (ground 10)\n" + + "Antisocial behaviour: Condition 1 of Section 84A of the Housing Act 1985" + ); + assertThat(caseDetailsTab.getReasonsForPossessionDetails().getGround10()) + .isEqualTo("Ground 10 reason"); + assertThat(caseDetailsTab.getReasonsForPossessionDetails().getCondition1OfSection84A()) + .isEqualTo("Condition 1 reason"); + assertThat(caseDetailsTab.getReasonsForPossessionDetails().getAdditionalReasonsForPossession()) + .isEqualTo("Additional reasons"); + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(caseDetailsTab.getClaimantInformation().getClaimantName()).isEqualTo("Claimant"); + assertThat(caseDetailsTab.getDefendantInformationDetails().getFirstName()).isEqualTo("Defendant"); + assertThat(caseDetailsTab.getDefendantInformationDetails().getLastName()).isEqualTo("One"); + assertThat(caseDetailsTab.getDefendantInformationDetails().getAddressForService()).isEqualTo(propertyAddress); + assertThat(caseDetailsTab.getAdditionalDefendants()).hasSize(2); + assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); + assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) + .isEqualTo(defendantAddress); + assertThat(caseDetailsTab.getAdditionalDefendants().get(1).getValue().getNameKnown()) + .isEqualTo("No"); + assertThat(caseDetailsTab.getAdditionalDefendants().get(1).getValue().getAddressKnown()) + .isEqualTo("No"); + assertThat(caseDetailsTab.getRentArrearsDetails().getRentAmount()).isEqualTo("£100"); + assertThat(caseDetailsTab.getRentArrearsDetails().getCalculationFrequency()).isEqualTo("Every 4 weeks"); + assertThat(caseDetailsTab.getRentArrearsDetails().getDailyRate()).isEqualTo("£12.30"); + assertThat(caseDetailsTab.getRentArrearsDetails().getArrearsTotal()).isEqualTo("£450.75"); + assertThat(caseDetailsTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTypeOfTenancyLicence()) + .isEqualTo("Other"); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDate()) + .isEqualTo("16 April 2024"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()) + .isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getHasCopyOfTenancyLicence()) + .isEqualTo("No"); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getReasonsForNoTenancyLicenceDocuments()) + .isEqualTo("Reasons"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()).isEqualTo("By email"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getApplicationsDetails().getPlanToMakeGeneralApplication()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getActionsTakenDetails().getPreactionProtocolFollowed()).isEqualTo("No"); + assertThat(caseDetailsTab.getActionsTakenDetails().getPreActionProtocolIncompleteExplanation()) + .isEqualTo("preaction explanation"); + assertThat(caseDetailsTab.getActionsTakenDetails().getMediationAttempted()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getActionsTakenDetails().getSettlementAttempted()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageDetails()).hasSize(1); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getNameKnown()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getName()) + .isEqualTo("underlessee name"); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddressKnown()) + .isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddress()) + .isEqualTo(underlesseeAddress); + assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getHousingAct()) + .isEqualTo(SuspensionOfRightToBuyHousingAct.SECTION_6A_2.getLabel()); + assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getReasons()) + .isEqualTo("suspension reason"); + assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getHousingAct()) + .isEqualTo(DemotionOfTenancyHousingAct.SECTION_6A_2.getLabel()); + assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getReasons()) + .isEqualTo("demotion reason"); + assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); + assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo("phone number"); + assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesDetails()) + .isEqualTo("claimant circumstances"); + assertThat(caseDetailsTab.getDefendantCircumstanceDetails().getDefendantCircumstancesGiven()) + .isEqualTo("Yes"); + assertThat(caseDetailsTab.getDefendantCircumstanceDetails().getDefendantCircumstances()) + .isEqualTo("defendant circumstances"); + } + + @Test + void shouldSetCaseDetailsTabFieldsWithNoData() { + PCSCase pcsCase = PCSCase.builder() + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + assertThat(caseDetailsTab.getPropertyAddress()).isNull(); + assertThat(caseDetailsTab.getGroundsForPossessionDetails().getGrounds()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getReasonsForPossessionDetails()).isNull(); + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantInformation()).isNull(); + assertThat(caseDetailsTab.getDefendantInformationDetails()).isNull(); + assertThat(caseDetailsTab.getAdditionalDefendants()).isNull(); + assertThat(caseDetailsTab.getRentArrearsDetails()).isNull(); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTypeOfTenancyLicence()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDate()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getHasCopyOfTenancyLicence()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getReasonsForNoTenancyLicenceDocuments()) + .isNull(); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getApplicationsDetails().getPlanToMakeGeneralApplication()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getActionsTakenDetails().getPreactionProtocolFollowed()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getActionsTakenDetails().getPreActionProtocolIncompleteExplanation()) + .isNull(); + assertThat(caseDetailsTab.getActionsTakenDetails().getMediationAttempted()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getActionsTakenDetails().getSettlementAttempted()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getMortgageDetails()).isNull(); + assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails()).isNull(); + assertThat(caseDetailsTab.getDemotionOfTenancyDetails()).isNull(); + assertThat(caseDetailsTab.getClaimantCircumstances()).isNull(); + assertThat(caseDetailsTab.getDefendantCircumstanceDetails()).isNull(); + assertThat(caseDetailsTab.getClaimantContactDetails()).isNull(); + assertThat(caseDetailsTab.getClaimantAddress()).isNull(); + } + + @Test + void shouldSetPlaceholderValuesIfOnlyAlternativesToPossessionIsSet() { + // Given + PCSCase pcsCase = PCSCase.builder() + .alternativesToPossession(Set.of(DEMOTION_OF_TENANCY, SUSPENSION_OF_RIGHT_TO_BUY)) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getHousingAct()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getReasons()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getHousingAct()) + .isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getReasons()) + .isEqualTo(NO_ANSWER); + } + + @Test + void shouldSetOtherGroundsDescriptionAssuredTenancy() { + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .hasCopyOfTenancyLicence(VerticalYesNo.NO) + .reasonsForNoTenancyLicenceDocuments("Reasons") + .build()) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Other") + .reason("Other reason") + .description("description") + .code(AssuredAdditionalOtherGround.OTHER.name()) + .build()) + )) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + assertThat(caseDetailsTab.getGroundsForPossessionDetails().getOtherGroundsDescription()) + .isEqualTo("description"); + } + + @Test + void shouldSetOtherGroundsDescriptionOtherTenancy() { + PCSCase pcsCase = PCSCase.builder() + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .hasCopyOfTenancyLicence(VerticalYesNo.NO) + .reasonsForNoTenancyLicenceDocuments("Reasons") + .build()) + .claimGroundSummaries(List.of( + listValue(ClaimGroundSummary.builder() + .label("Other") + .reason("Other reason") + .description("description") + .code(IntroductoryDemotedOrOtherGrounds.OTHER.name()) + .build()) + )) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getGroundsForPossessionDetails().getOtherGroundsDescription()) + .isEqualTo("description"); + } + + @Test + void shouldUseClaimantContactPreferencesIfAllClaimantsIsNotSet() { + // Given + AddressUK claimantAddress = AddressUK.builder().postCode("L2 3RT").build(); + PCSCase pcsCase = PCSCase.builder() + .claimantContactPreferences( + ClaimantContactPreferences.builder() + .orgAddressFound(YesOrNo.YES) + .isCorrectClaimantContactAddress(VerticalYesNo.YES) + .organisationAddress(claimantAddress) + .isCorrectClaimantContactEmail(VerticalYesNo.YES) + .claimantContactEmail("claimant@email.com") + .claimantProvidePhoneNumber(VerticalYesNo.YES) + .claimantContactPhoneNumber("phone number") + .build() + ) + .build(); + + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn( + ClaimantInformationTabDetails.builder() + .claimantName("Claimant") + .build() + ); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); + assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo("phone number"); + } + + @Test + void shouldUseOverwrittenAddressAndEmail() { + // Given + AddressUK claimantAddress = AddressUK.builder().postCode("L2 3RT").build(); + PCSCase pcsCase = PCSCase.builder() + .claimantContactPreferences( + ClaimantContactPreferences.builder() + .orgAddressFound(YesOrNo.YES) + .isCorrectClaimantContactAddress(VerticalYesNo.NO) + .overriddenClaimantContactAddress(claimantAddress) + .isCorrectClaimantContactEmail(VerticalYesNo.NO) + .overriddenClaimantContactEmail("claimant@email.com") + .claimantProvidePhoneNumber(VerticalYesNo.NO) + .claimantContactPhoneNumber("phone number") + .build() + ) + .build(); + + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn( + ClaimantInformationTabDetails.builder() + .claimantName("Claimant") + .build() + ); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); + assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(NO_ANSWER); + } + + @Test + void shouldUsePlaceholderValuesIfClaimantDetailsIsNotSet() { + PCSCase pcsCase = PCSCase.builder().build(); + + when(claimantInformationTabDetailsBuilder.createSummaryClaimantTabDetails(pcsCase)).thenReturn( + ClaimantInformationTabDetails.builder() + .claimantName("Claimant") + .build() + ); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getClaimantAddress().getAddressLine1()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantAddress().getPostTown()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantAddress().getCountry()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantAddress().getPostCode()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesDetails()).isNull(); + } + + @Test + void shouldSetNoticeDetailsForFirstClassPost() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.FIRST_CLASS_POST) + .noticePostedDate(LocalDate.of(2026, 5, 11)) + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) + .isEqualTo(NoticeServiceMethod.FIRST_CLASS_POST.getLabel()); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + } + + @Test + void shouldSetNoticeDetailsForPermittedPlace() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.DELIVERED_PERMITTED_PLACE) + .noticeDeliveredDate(LocalDate.of(2026, 5, 11)) + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) + .isEqualTo(NoticeServiceMethod.DELIVERED_PERMITTED_PLACE.getLabel()); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + } + + @Test + void shouldSetNoticeDetailsForPersonallyHanded() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.PERSONALLY_HANDED) + .noticeHandedOverDateTime(LocalDateTime.of(2026, 5, 11, 9, 0, 0)) + .noticePersonName("Notice name") + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) + .isEqualTo(NoticeServiceMethod.PERSONALLY_HANDED.getLabel()); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticePersonName()).isEqualTo("Notice name"); + } + + @Test + void shouldSetNoticeDetailsForOtherElectronic() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.OTHER_ELECTRONIC) + .noticeOtherElectronicDateTime(LocalDateTime.of(2026, 5, 11, 9, 0, 0)) + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) + .isEqualTo(NoticeServiceMethod.OTHER_ELECTRONIC.getLabel()); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + } + + @Test + void shouldSetNoticeDetailsForOther() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServed(YesOrNo.YES) + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.OTHER) + .noticeOtherDateTime(LocalDateTime.of(2026, 5, 11, 9, 0, 0)) + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) + .isEqualTo(NoticeServiceMethod.OTHER.getLabel()); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + } + + private static ListValue listValue(T value) { + return ListValue.builder() + .value(value) + .build(); + } +} From d4a6e852e9ad674b604b338ad9a2b1e51102c097 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 13:02:48 +0100 Subject: [PATCH 102/138] HDPI-2983: update view tests --- .../ccd/view/NoticeOfPossessionViewTest.java | 27 +++++++++++++++++++ .../pcs/ccd/view/RentArrearsViewTest.java | 10 +++++++ .../pcs/ccd/view/RentDetailsViewTest.java | 2 ++ .../pcs/ccd/view/TenancyLicenceViewTest.java | 11 ++++++++ 4 files changed, 50 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionViewTest.java index 72e376005b..3d1d503c9c 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/NoticeOfPossessionViewTest.java @@ -8,10 +8,12 @@ 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.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.WalesNoticeDetails; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.claim.NoticeOfPossessionEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; @@ -258,4 +260,29 @@ void shouldSetNoticeServedDateAndDetailsForOther() { assertThat(noticeServedDetails.getNoticeOtherExplanation()).isEqualTo(otherExplanation); } + @Test + void shouldSetNoticeDocumentIfPresent() { + // Given + LocalDate postedDate = mock(LocalDate.class); + when(noticeOfPossessionEntity.getServingMethod()).thenReturn(FIRST_CLASS_POST); + when(noticeOfPossessionEntity.getNoticeDate()).thenReturn(postedDate); + when(pcsCaseEntity.getDocuments()).thenReturn( + List.of( + DocumentEntity.builder() + .type(DocumentType.NOTICE_FOR_SERVICE_OUT_OF_JURISDICTION) + .build() + ) + ); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + verify(pcsCase).setNoticeServedDetails(noticeServedDetailsCaptor.capture()); + + NoticeServedDetails noticeServedDetails = noticeServedDetailsCaptor.getValue(); + assertThat(noticeServedDetails.getNoticeServiceMethod()).isEqualTo(FIRST_CLASS_POST); + assertThat(noticeServedDetails.getNoticePostedDate()).isSameAs(postedDate); + assertThat(noticeServedDetails.getNoticeDocuments()).hasSize(1); + } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsViewTest.java index bd1e036153..fc75a92453 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentArrearsViewTest.java @@ -6,10 +6,12 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import uk.gov.hmcts.reform.pcs.ccd.domain.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.RentArrearsSection; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.claim.RentArrearsEntity; @@ -80,6 +82,13 @@ void shouldSetRentArrearsFields() { when(rentArrearsEntity.getArrearsJudgmentWanted()).thenReturn(VerticalYesNo.YES); when(rentArrearsEntity.getRecoveryAttempted()).thenReturn(VerticalYesNo.YES); when(rentArrearsEntity.getRecoveryAttemptDetails()).thenReturn(details); + when(pcsCaseEntity.getDocuments()).thenReturn( + List.of( + DocumentEntity.builder() + .type(DocumentType.RENT_STATEMENT) + .build() + ) + ); // When underTest.setCaseFields(pcsCase, pcsCaseEntity); @@ -93,6 +102,7 @@ void shouldSetRentArrearsFields() { assertThat(rentArrears.getTotal()).isEqualTo(totalRentArrears); assertThat(rentArrears.getRecoveryAttempted()).isEqualTo(VerticalYesNo.YES); assertThat(rentArrears.getRecoveryAttemptDetails()).isEqualTo(details); + assertThat(rentArrears.getStatementDocuments()).hasSize(1); verify(pcsCase).setArrearsJudgmentWanted(VerticalYesNo.YES); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java index 8da11d7874..bde8e4111a 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java @@ -6,6 +6,7 @@ import org.mockito.ArgumentCaptor; 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.RentDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.RentPaymentFrequency; @@ -73,6 +74,7 @@ void shouldSetRentDetailsFields() { = ArgumentCaptor.forClass(RentDetails.class); verify(pcsCase).setRentDetails(rentDetailsCaptor.capture()); + verify(pcsCase).setShowRentSectionPage(YesOrNo.YES); RentDetails rentDetails = rentDetailsCaptor.getValue(); assertThat(rentDetails.getCurrentRent()).isEqualTo(rentAmount); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceViewTest.java index 4db5afb0bc..5709495c3b 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/TenancyLicenceViewTest.java @@ -7,17 +7,20 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import uk.gov.hmcts.reform.pcs.ccd.domain.CombinedLicenceType; +import uk.gov.hmcts.reform.pcs.ccd.domain.DocumentType; import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceDetails; import uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType; import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceDetailsWales; import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; +import uk.gov.hmcts.reform.pcs.ccd.entity.DocumentEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.TenancyLicenceEntity; import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; import java.time.LocalDate; +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -70,6 +73,13 @@ void shouldSetTenancyLicenceFieldsForNonWales() { when(tenancyLicenceEntity.getStartDate()).thenReturn(tenancyStartDate); when(tenancyLicenceEntity.getHasCopyOfTenancyLicence()).thenReturn(hasCopyOfTenancyLicence); when(tenancyLicenceEntity.getReasonsForNoTenancyLicence()).thenReturn(reasonsForNoTenancyLicence); + when(pcsCaseEntity.getDocuments()).thenReturn( + List.of( + DocumentEntity.builder() + .type(DocumentType.TENANCY_LICENCE) + .build() + ) + ); // When underTest.setCaseFields(pcsCase, pcsCaseEntity); @@ -88,6 +98,7 @@ void shouldSetTenancyLicenceFieldsForNonWales() { assertThat(tenancyLicenceDetails.getHasCopyOfTenancyLicence()).isEqualTo(hasCopyOfTenancyLicence); assertThat(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments()) .isEqualTo(reasonsForNoTenancyLicence); + assertThat(tenancyLicenceDetails.getTenancyLicenceDocuments()).hasSize(1); } @Test From 0c440cb7df43687e771cd7f83048654c4ff3b34c Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 13:14:40 +0100 Subject: [PATCH 103/138] HDPI-2983: fix styling --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 - .../tabs/details/ActionsTakenTabDetails.java | 16 +--- .../tabs/details/ApplicationsTabDetails.java | 4 +- .../domain/tabs/details/CaseDetailsTab.java | 76 +++++-------------- .../domain/tabs/details/ClaimTabDetails.java | 8 +- .../ClaimantCircumstancesTabDetails.java | 8 +- .../details/ClaimantContactTabDetails.java | 8 +- .../DefendantCircumstanceTabDetails.java | 4 +- .../details/DemotionOfTenancyTabDetails.java | 8 +- .../domain/tabs/details/NoticeTabDetails.java | 36 +++------ .../SuspensionOfRightToBuyTabDetails.java | 8 +- .../details/TenancyLicenceTabDetails.java | 20 ++--- ...lesseeOrMortgageInformationTabDetails.java | 16 +--- .../GroundsForPossessionTabDetails.java | 4 +- .../pcs/ccd/view/CaseDetailsTabViewTest.java | 55 +++++++------- 15 files changed, 82 insertions(+), 190 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 41ed6f7f11..c717b18adb 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 @@ -183,7 +183,6 @@ private void buildCaseDetailsTab(ConfigBuilder builder "### Defendant Details" ) .field("detailsTab_DefendantInformationDetails") - .field("detailsTab_DefendantOneAddress") .field("detailsTab_AdditionalDefendants") .field("detailsTab_DefendantCircumstanceDetails") .label( diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java index 7f2d7d9359..6cd15b8342 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ActionsTakenTabDetails.java @@ -12,23 +12,15 @@ @AllArgsConstructor public class ActionsTakenTabDetails { - @CCD( - label = "Pre-action protocol followed?" - ) + @CCD(label = "Pre-action protocol followed?") private String preactionProtocolFollowed; - @CCD( - label = "Explain why you have not followed the pre-action protocol" - ) + @CCD(label = "Explain why you have not followed the pre-action protocol") private String preActionProtocolIncompleteExplanation; - @CCD( - label = "Mediation attempted?" - ) + @CCD(label = "Mediation attempted?") private String mediationAttempted; - @CCD( - label = "Settlement attempted?" - ) + @CCD(label = "Settlement attempted?") private String settlementAttempted; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java index 60a04e070b..d72ec86ecd 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ApplicationsTabDetails.java @@ -12,8 +12,6 @@ @AllArgsConstructor public class ApplicationsTabDetails { - @CCD( - label = "Are you planning to make an application at the same time as your claim?" - ) + @CCD(label = "Are you planning to make an application at the same time as your claim?") private String planToMakeGeneralApplication; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 719ccf0b53..57fa4aeb45 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -25,101 +25,63 @@ @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) public class CaseDetailsTab { - @CCD( - label = "Claim details" - ) + @CCD(label = "Claim details") private ClaimTabDetails claimDetails; - @CCD( - label = "Address of property to be repossessed" - ) + @CCD(label = "Address of property to be repossessed") private AddressUK propertyAddress; - @CCD( - label = "Grounds for possession" - ) + @CCD(label = "Grounds for possession") private GroundsForPossessionTabDetails groundsForPossessionDetails; @CCD(label = "Date claim Submitted") private String dateClaimSubmitted; - @CCD( - label = "Tenancy, occupation contract or licence details" - ) + @CCD(label = "Tenancy, occupation contract or licence details") private TenancyLicenceTabDetails tenancyLicenceDetails; - @CCD( - label = "Notice details" - ) + @CCD(label = "Notice details") private NoticeTabDetails noticeDetails; - @CCD( - label = "Actions already taken" - ) + @CCD(label = "Actions already taken") private ActionsTakenTabDetails actionsTakenDetails; - @CCD( - label = "Details of rent arrears" - ) + @CCD(label = "Details of rent arrears") private RentArrearsTabDetails rentArrearsDetails; - @CCD( - label = "Reasons for possession" - ) + @CCD(label = "Reasons for possession") private ReasonsForPossessionTabDetails reasonsForPossessionDetails; - @CCD( - label = "Applications" - ) + @CCD(label = "Applications") private ApplicationsTabDetails applicationsDetails; - @CCD( - label = "Claimant" - ) + @CCD(label = "Claimant") private ClaimantInformationTabDetails claimantInformation; - @CCD( - label = "Claimant address for service" - ) + @CCD(label = "Claimant address for service") private AddressUK claimantAddress; - @CCD( - label = "Claimant contact details" - ) + @CCD(label = "Claimant contact details") private ClaimantContactTabDetails claimantContactDetails; - @CCD( - label = "Claimant circumstances" - ) + @CCD(label = "Claimant circumstances") private ClaimantCircumstancesTabDetails claimantCircumstances; - @CCD( - label = "Defendant 1" - ) + @CCD(label = "Defendant 1") private DefendantInformationTabDetails defendantInformationDetails; - @CCD( - label = "Additional defendant" - ) + @CCD(label = "Additional defendant") private List> additionalDefendants; - @CCD( - label = "Defendant’ circumstances" - ) + @CCD(label = "Defendant’ circumstances") private DefendantCircumstanceTabDetails defendantCircumstanceDetails; - @CCD( - label = "Underlessee or mortgagee" - ) + @CCD(label = "Underlessee or mortgagee") private List> mortgageDetails; - @CCD( - label = "Demotion of tenancy claim" - ) + @CCD(label = "Demotion of tenancy claim") private DemotionOfTenancyTabDetails demotionOfTenancyDetails; - @CCD( - label = "SuspensionOfRightToBuyTabDetails" - ) + @CCD(label = "SuspensionOfRightToBuyTabDetails") private SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyDetails; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java index e9a34c7775..24b45af39b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java @@ -11,13 +11,9 @@ @NoArgsConstructor @AllArgsConstructor public class ClaimTabDetails { - @CCD( - label = "Claimant type" - ) + @CCD(label = "Claimant type") private String claimantType; - @CCD( - label = "Claim against trespassers?" - ) + @CCD(label = "Claim against trespassers?") private String trespassClaim; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java index 96e382fc01..3cc4465dec 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java @@ -12,13 +12,9 @@ @AllArgsConstructor public class ClaimantCircumstancesTabDetails { - @CCD( - label = "Is there any information you’d like to provide about ${claimantNamePossessiveForm} circumstances?" - ) + @CCD(label = "Is there any information you’d like to provide about ${claimantNamePossessiveForm} circumstances?") private String claimantCircumstancesGiven; - @CCD( - label = "Claimant circumstances" - ) + @CCD(label = "Claimant circumstances") private String claimantCircumstancesDetails; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java index d69182c578..b64453df3b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java @@ -13,13 +13,9 @@ @AllArgsConstructor public class ClaimantContactTabDetails { - @CCD ( - label = "Email address for notifications" - ) + @CCD (label = "Email address for notifications") private String emailAddress; - @CCD ( - label = "Contact phone number" - ) + @CCD (label = "Contact phone number") private String phoneNumber; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java index 5c172d44dc..d33229e7c0 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java @@ -18,8 +18,6 @@ public class DefendantCircumstanceTabDetails { ) private String defendantCircumstancesGiven; - @CCD( - label = "Defendants’ circumstances" - ) + @CCD(label = "Defendants’ circumstances") private String defendantCircumstances; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java index 761692f837..d8d0255fdb 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DemotionOfTenancyTabDetails.java @@ -23,13 +23,9 @@ public class DemotionOfTenancyTabDetails { ) private String statementOfExpressTermsServed; - @CCD( - label = "Details of terms" - ) + @CCD(label = "Details of terms") private String terms; - @CCD( - label = "Reasons for requesting a demotion of tenancy order" - ) + @CCD(label = "Reasons for requesting a demotion of tenancy order") private String reasons; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java index 77f665dff1..bc601b71d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java @@ -16,48 +16,30 @@ @AllArgsConstructor public class NoticeTabDetails { - @CCD( - label = "Has notice been served?" - ) + @CCD(label = "Has notice been served?") private String noticeServed; - @CCD( - label = "Date and time notice served (if applicable)" - ) + @CCD(label = "Date and time notice served (if applicable)") private String noticeDate; - @CCD( - label = "Method of service" - ) + @CCD(label = "Method of service") private String noticeMethod; - @CCD( - label = "Name of person document was left with" - ) + @CCD(label = "Name of person document was left with") private String noticePersonName; - @CCD( - label = "Email address the document sent to" - ) + @CCD(label = "Email address the document sent to") private String noticeEmailAddress; - @CCD( - label = "Explain what the other means were" - ) + @CCD(label = "Explain what the other means were") private String noticeOtherExplanation; - @CCD( - label = "Are you able to upload a copy of the notice you served?" - ) + @CCD(label = "Are you able to upload a copy of the notice you served?") private String noticeUploaded; - @CCD( - label = "Notice or certificate of service" - ) + @CCD(label = "Notice or certificate of service") private List> noticeDocuments; - @CCD( - label = "Details of why you cannot upload a copy" - ) + @CCD(label = "Details of why you cannot upload a copy") private String reasonsForNoNoticeDocument; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java index 4543248063..d0aa356cbf 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/SuspensionOfRightToBuyTabDetails.java @@ -12,13 +12,9 @@ @AllArgsConstructor public class SuspensionOfRightToBuyTabDetails { - @CCD( - label = "Section of the Housing Act suspension of right to buy claim made under" - ) + @CCD(label = "Section of the Housing Act suspension of right to buy claim made under") private String housingAct; - @CCD( - label = "Reasons for requesting suspension of right to buy order" - ) + @CCD(label = "Reasons for requesting suspension of right to buy order") private String reasons; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java index f16ec9b525..f32c4fe5af 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java @@ -16,28 +16,18 @@ @AllArgsConstructor public class TenancyLicenceTabDetails { - @CCD( - label = "Tenancy, occupation contract or licence agreement type" - ) + @CCD(label = "Tenancy, occupation contract or licence agreement type") private String typeOfTenancyLicence; - @CCD( - label = "Tenancy, occupation contract or licence start date" - ) + @CCD(label = "Tenancy, occupation contract or licence start date") private String tenancyLicenceDate; - @CCD( - label = "Do you have a copy of the tenancy or licence agreement?" - ) + @CCD(label = "Do you have a copy of the tenancy or licence agreement?") private String hasCopyOfTenancyLicence; - @CCD( - label = "Details of why you do not have a copy" - ) + @CCD(label = "Details of why you do not have a copy") private String reasonsForNoTenancyLicenceDocuments; - @CCD( - label = "Tenancy, occupation contract or licence agreement" - ) + @CCD(label = "Tenancy, occupation contract or licence agreement") private List> tenancyLicenceDocuments; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index 07e4dec3bb..421023b59d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -13,23 +13,15 @@ @AllArgsConstructor public class UnderlesseeOrMortgageInformationTabDetails { - @CCD( - label = "Underlessee or mortgagee’s address for name known?" - ) + @CCD(label = "Underlessee or mortgagee’s address for name known?") private String nameKnown; - @CCD( - label = "Name" - ) + @CCD(label = "Name") private String name; - @CCD( - label = "Underlessee or mortgagee’s address for service known?" - ) + @CCD(label = "Underlessee or mortgagee’s address for service known?") private String addressKnown; - @CCD( - label = "Underlessee or mortgagee correspondence address" - ) + @CCD(label = "Underlessee or mortgagee correspondence address") private AddressUK address; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java index 226748a42b..4aabe89729 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/GroundsForPossessionTabDetails.java @@ -17,8 +17,6 @@ public class GroundsForPossessionTabDetails { @CCD(label = "Grounds", typeOverride = TextArea) private String grounds; - @CCD( - label = "Description of other grounds" - ) + @CCD(label = "Description of other grounds") private String otherGroundsDescription; } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index b7fb331c19..e24232d02d 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -59,6 +59,8 @@ @ExtendWith(MockitoExtension.class) public class CaseDetailsTabViewTest { + private final String noAnswer = " "; + @Mock private GroundsBuilder groundsBuilder; @@ -80,8 +82,6 @@ public class CaseDetailsTabViewTest { @InjectMocks private CaseDetailsTabView caseDetailsTabView; - final private String NO_ANSWER = " "; - @Test void shouldSetCaseDetailsTabFields() { AddressUK propertyAddress = AddressUK.builder().postCode("SW1A 1AA").build(); @@ -288,7 +288,8 @@ void shouldSetCaseDetailsTabFields() { assertThat(caseDetailsTab.getDefendantInformationDetails().getLastName()).isEqualTo("One"); assertThat(caseDetailsTab.getDefendantInformationDetails().getAddressForService()).isEqualTo(propertyAddress); assertThat(caseDetailsTab.getAdditionalDefendants()).hasSize(2); - assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getFirstName()).isEqualTo("Defendant"); + assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getFirstName()) + .isEqualTo("Defendant"); assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getLastName()).isEqualTo("Two"); assertThat(caseDetailsTab.getAdditionalDefendants().getFirst().getValue().getAddressForService()) .isEqualTo(defendantAddress); @@ -357,31 +358,31 @@ void shouldSetCaseDetailsTabFieldsWithNoData() { CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); assertThat(caseDetailsTab.getPropertyAddress()).isNull(); - assertThat(caseDetailsTab.getGroundsForPossessionDetails().getGrounds()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getGroundsForPossessionDetails().getGrounds()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getReasonsForPossessionDetails()).isNull(); - assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getClaimantInformation()).isNull(); assertThat(caseDetailsTab.getDefendantInformationDetails()).isNull(); assertThat(caseDetailsTab.getAdditionalDefendants()).isNull(); assertThat(caseDetailsTab.getRentArrearsDetails()).isNull(); assertThat(caseDetailsTab.getTenancyLicenceDetails().getTypeOfTenancyLicence()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDate()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getTenancyLicenceDetails().getHasCopyOfTenancyLicence()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getTenancyLicenceDetails().getReasonsForNoTenancyLicenceDocuments()) .isNull(); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getApplicationsDetails().getPlanToMakeGeneralApplication()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getActionsTakenDetails().getPreactionProtocolFollowed()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getApplicationsDetails().getPlanToMakeGeneralApplication()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getActionsTakenDetails().getPreactionProtocolFollowed()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getActionsTakenDetails().getPreActionProtocolIncompleteExplanation()) .isNull(); - assertThat(caseDetailsTab.getActionsTakenDetails().getMediationAttempted()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getActionsTakenDetails().getSettlementAttempted()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getActionsTakenDetails().getMediationAttempted()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getActionsTakenDetails().getSettlementAttempted()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getMortgageDetails()).isNull(); assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails()).isNull(); assertThat(caseDetailsTab.getDemotionOfTenancyDetails()).isNull(); @@ -403,13 +404,13 @@ void shouldSetPlaceholderValuesIfOnlyAlternativesToPossessionIsSet() { // Then assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getHousingAct()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getReasons()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getHousingAct()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); assertThat(caseDetailsTab.getDemotionOfTenancyDetails().getReasons()) - .isEqualTo(NO_ANSWER); + .isEqualTo(noAnswer); } @Test @@ -528,7 +529,7 @@ void shouldUseOverwrittenAddressAndEmail() { // Then assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); - assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(noAnswer); } @Test @@ -545,13 +546,13 @@ void shouldUsePlaceholderValuesIfClaimantDetailsIsNotSet() { CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); // Then - assertThat(caseDetailsTab.getClaimantAddress().getAddressLine1()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantAddress().getPostTown()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantAddress().getCountry()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantAddress().getPostCode()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(NO_ANSWER); - assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo(NO_ANSWER); + assertThat(caseDetailsTab.getClaimantAddress().getAddressLine1()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantAddress().getPostTown()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantAddress().getCountry()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantAddress().getPostCode()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesDetails()).isNull(); } From f5341ee6705b9e9f6a66ecdbc231cbd3de8d15bb Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 13:31:47 +0100 Subject: [PATCH 104/138] HDPI-2983: add timezone to submitted date --- .../hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index b6f0c38f24..8a1fb37816 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -52,6 +52,7 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Locale; @@ -63,6 +64,7 @@ import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.DEMOTED_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.INTRODUCTORY_TENANCY; import static uk.gov.hmcts.reform.pcs.ccd.domain.TenancyLicenceType.OTHER; +import static uk.gov.hmcts.reform.pcs.config.ClockConfiguration.UK_ZONE_ID; @AllArgsConstructor @Component @@ -502,6 +504,11 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { return null; } - return dateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + LocalDateTime ukDateSubmitted = dateSubmitted + .atZone(ZoneId.systemDefault()) + .withZoneSameInstant(UK_ZONE_ID) + .toLocalDateTime(); + + return ukDateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); } } From 4252f2c731cd6706c3791191015bf416b84a6886 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 13:45:57 +0100 Subject: [PATCH 105/138] HDPI-2983: add timezone tests --- .../pcs/ccd/view/CaseDetailsTabViewTest.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index e24232d02d..ca02e60878 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -49,6 +49,7 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Set; +import java.util.TimeZone; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.when; @@ -95,7 +96,7 @@ void shouldSetCaseDetailsTabFields() { .build()) .claimAgainstTrespassers(VerticalYesNo.YES) .propertyAddress(propertyAddress) - .dateSubmitted(LocalDateTime.of(2026, 5, 11, 17, 2, 31)) + .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) .claimGroundSummaries(List.of( listValue(ClaimGroundSummary.builder() .label("Rent arrears (ground 10)") @@ -282,7 +283,7 @@ void shouldSetCaseDetailsTabFields() { .isEqualTo("Condition 1 reason"); assertThat(caseDetailsTab.getReasonsForPossessionDetails().getAdditionalReasonsForPossession()) .isEqualTo("Additional reasons"); - assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo("11 May 2026, 5:02:31PM"); + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); assertThat(caseDetailsTab.getClaimantInformation().getClaimantName()).isEqualTo("Claimant"); assertThat(caseDetailsTab.getDefendantInformationDetails().getFirstName()).isEqualTo("Defendant"); assertThat(caseDetailsTab.getDefendantInformationDetails().getLastName()).isEqualTo("One"); @@ -663,6 +664,46 @@ void shouldSetNoticeDetailsForOther() { assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); } + @Test + void shouldDisplaySubmittedDateInUkTimeWhenServerTimezoneIsUtc() { + // Given + TimeZone originalTimeZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + PCSCase pcsCase = PCSCase.builder() + .dateSubmitted(LocalDateTime.of(2026, 7, 11, 17, 2, 31)) + .build(); + + try { + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo("11 July 2026, 6:02:31PM"); + } finally { + TimeZone.setDefault(originalTimeZone); + } + } + + @Test + void shouldDisplaySubmittedDateInGmtOutsideBritishSummerTimeWhenServerTimezoneIsUtc() { + // Given + TimeZone originalTimeZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + PCSCase pcsCase = PCSCase.builder() + .dateSubmitted(LocalDateTime.of(2026, 1, 11, 17, 2, 31)) + .build(); + + try { + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getDateClaimSubmitted()).isEqualTo("11 January 2026, 5:02:31PM"); + } finally { + TimeZone.setDefault(originalTimeZone); + } + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From ad5ec2656a19b14d3d93f300ec5466b968146a55 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 15:42:44 +0100 Subject: [PATCH 106/138] HDPI-2983: address review comments --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 16 ++++++++-------- .../ccd/domain/tabs/details/CaseDetailsTab.java | 4 ++-- .../tabs/details/ClaimantContactTabDetails.java | 7 +++++-- .../tabs/shared/RentArrearsTabDetails.java | 2 +- .../reform/pcs/ccd/view/CaseDetailsTabView.java | 13 ++++++++++--- .../pcs/ccd/view/CaseDetailsTabViewTest.java | 7 +++++-- 6 files changed, 31 insertions(+), 18 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 c717b18adb..24da7bdc54 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,6 +74,14 @@ public void configure(final ConfigBuilder builder) { .label("nextStepsMarkdownLabel", null, "${nextStepsMarkdown}") .field("nextStepsMarkdown", NEVER_SHOW); + buildCasePartiesTab(builder); + + buildCaseDetailsTab(builder); + + builder.tab("caseFileView", "Case File View") + .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) + .field(PCSCase::getCaseFileView, null, "#ARGUMENT(CaseFileView)"); + buildSummaryTab(builder); builder.tab("CaseHistory", "History") @@ -89,19 +97,11 @@ public void configure(final ConfigBuilder builder) { .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) .field("waysToPay"); - builder.tab("caseFileView", "Case File View") - .showCondition(ShowConditions.stateNotEquals(AWAITING_SUBMISSION_TO_HMCTS)) - .field(PCSCase::getCaseFileView, null, "#ARGUMENT(CaseFileView)"); - - buildCaseDetailsTab(builder); - builder.tab("caseLinks", "Linked Cases") .forRoles(UserRole.PCS_SOLICITOR) .field(PCSCase::getLinkedCasesComponentLauncher, null, "#ARGUMENT(LinkedCases)") .field(PCSCase::getCaseLinks, "LinkedCasesComponentLauncher!=\"\"", "#ARGUMENT(LinkedCases)"); - buildCasePartiesTab(builder); - configureCaseFileCategories(builder); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 57fa4aeb45..70dd5050ba 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -73,7 +73,7 @@ public class CaseDetailsTab { @CCD(label = "Additional defendant") private List> additionalDefendants; - @CCD(label = "Defendant’ circumstances") + @CCD(label = "Defendants’ circumstances") private DefendantCircumstanceTabDetails defendantCircumstanceDetails; @CCD(label = "Underlessee or mortgagee") @@ -82,6 +82,6 @@ public class CaseDetailsTab { @CCD(label = "Demotion of tenancy claim") private DemotionOfTenancyTabDetails demotionOfTenancyDetails; - @CCD(label = "SuspensionOfRightToBuyTabDetails") + @CCD(label = "Suspension of right to buy") private SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyDetails; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java index b64453df3b..d5f7f90525 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantContactTabDetails.java @@ -13,9 +13,12 @@ @AllArgsConstructor public class ClaimantContactTabDetails { - @CCD (label = "Email address for notifications") + @CCD(label = "Email address for notifications") private String emailAddress; - @CCD (label = "Contact phone number") + @CCD(label = "Do you want to provide a phone number for urgent updates about your case?") + private String phoneNumberProvided; + + @CCD(label = "Contact phone number") private String phoneNumber; } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java index fbfbc118d6..3647a3ac52 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/RentArrearsTabDetails.java @@ -31,7 +31,7 @@ public class RentArrearsTabDetails { @CCD(label = "Previous steps taken to recover rent arrears?") private String stepsToRecoverArrears; - @CCD(label = "Details of previous steps taken?") + @CCD(label = "Details of previous steps taken") private String stepsToRecoverArrearsDetails; @CCD(label = "Rent statement") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 8a1fb37816..4ca0d0d0ac 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -341,17 +341,23 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase ClaimantContactPreferences claimantContactPreferences = pcsCase.getClaimantContactPreferences(); String emailAddress = null; String phoneNumber = null; + VerticalYesNo phoneNumberProvided = null; if (!CollectionUtils.isEmpty(claimants)) { Party claimant = claimants.getFirst().getValue(); emailAddress = claimant.getEmailAddress(); - phoneNumber = claimant.getPhoneNumber(); + phoneNumberProvided = claimant.getPhoneNumberProvided(); + + if (phoneNumberProvided == VerticalYesNo.YES) { + phoneNumber = claimant.getPhoneNumber(); + } } else if (claimantContactPreferences != null) { VerticalYesNo isCorrectClaimantContactEmail = claimantContactPreferences.getIsCorrectClaimantContactEmail(); emailAddress = isCorrectClaimantContactEmail == VerticalYesNo.YES ? claimantContactPreferences.getClaimantContactEmail() : claimantContactPreferences.getOverriddenClaimantContactEmail(); - if (claimantContactPreferences.getClaimantProvidePhoneNumber() == VerticalYesNo.YES) { + phoneNumberProvided = claimantContactPreferences.getClaimantProvidePhoneNumber(); + if (phoneNumberProvided == VerticalYesNo.YES) { phoneNumber = claimantContactPreferences.getClaimantContactPhoneNumber(); } } @@ -359,7 +365,8 @@ private ClaimantContactTabDetails buildClaimantContactTabDetails(PCSCase pcsCase return ClaimantContactTabDetails.builder() .emailAddress(emailAddress != null ? emailAddress : NO_ANSWER) - .phoneNumber(phoneNumber != null ? phoneNumber : NO_ANSWER) + .phoneNumberProvided(phoneNumberProvided != null ? phoneNumberProvided.getLabel() : NO_ANSWER) + .phoneNumber(phoneNumber) .build(); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index ca02e60878..91f72a30ed 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -119,6 +119,7 @@ void shouldSetCaseDetailsTabFields() { .orgName("Claimant") .address(claimantAddress) .emailAddress("claimant@email.com") + .phoneNumberProvided(VerticalYesNo.YES) .phoneNumber("phone number") .build() )) @@ -340,6 +341,7 @@ void shouldSetCaseDetailsTabFields() { .isEqualTo("demotion reason"); assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumberProvided()).isEqualTo("Yes"); assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo("phone number"); assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo("Yes"); assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesDetails()) @@ -530,7 +532,7 @@ void shouldUseOverwrittenAddressAndEmail() { // Then assertThat(caseDetailsTab.getClaimantAddress()).isEqualTo(claimantAddress); assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo("claimant@email.com"); - assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumberProvided()).isEqualTo("No"); } @Test @@ -552,7 +554,8 @@ void shouldUsePlaceholderValuesIfClaimantDetailsIsNotSet() { assertThat(caseDetailsTab.getClaimantAddress().getCountry()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getClaimantAddress().getPostCode()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getClaimantContactDetails().getEmailAddress()).isEqualTo(noAnswer); - assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumberProvided()).isEqualTo(noAnswer); + assertThat(caseDetailsTab.getClaimantContactDetails().getPhoneNumber()).isNull(); assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesGiven()).isEqualTo(noAnswer); assertThat(caseDetailsTab.getClaimantCircumstances().getClaimantCircumstancesDetails()).isNull(); } From 332ed3650c1d56e9b687120c3ea1dd9e5561cfa5 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 16:29:19 +0100 Subject: [PATCH 107/138] HDPI-2983: fix label --- .../details/UnderlesseeOrMortgageInformationTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index 421023b59d..e2eca83fd6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -13,7 +13,7 @@ @AllArgsConstructor public class UnderlesseeOrMortgageInformationTabDetails { - @CCD(label = "Underlessee or mortgagee’s address for name known?") + @CCD(label = "Underlessee or mortgagee’s name known?") private String nameKnown; @CCD(label = "Name") From 0a44c928d0ebd16ed27c1a6615accb3acd981695 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 21 May 2026 17:08:19 +0100 Subject: [PATCH 108/138] HDPI-2983: fix label --- .../details/UnderlesseeOrMortgageInformationTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index e2eca83fd6..811d24d8b6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -22,6 +22,6 @@ public class UnderlesseeOrMortgageInformationTabDetails { @CCD(label = "Underlessee or mortgagee’s address for service known?") private String addressKnown; - @CCD(label = "Underlessee or mortgagee correspondence address") + @CCD(label = "Underlessee or mortgagee address for service address") private AddressUK address; } From ff146b0710b113dab471f370b53feaa4b0cf93a6 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 07:15:03 +0100 Subject: [PATCH 109/138] HDPI-2983: add NoticeOtherElectronicDetails --- .../reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java | 3 +++ .../uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java | 2 ++ .../gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java index bc601b71d7..5b45cc34e6 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/NoticeTabDetails.java @@ -31,6 +31,9 @@ public class NoticeTabDetails { @CCD(label = "Email address the document sent to") private String noticeEmailAddress; + @CCD(label = "Details of how notice was served") + private String noticeOtherElectronicDetails; + @CCD(label = "Explain what the other means were") private String noticeOtherExplanation; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 4ca0d0d0ac..94fd6766d7 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -259,7 +259,9 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { } case OTHER_ELECTRONIC -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherElectronicDateTime(); + String details = noticeServedDetails.getNoticeOtherElectronicMethodExplanation(); noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); + noticeTabDetails.setNoticeOtherElectronicDetails(details != null ? details : NO_ANSWER); } case OTHER -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index 91f72a30ed..bc3b7d54d3 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -633,6 +633,7 @@ void shouldSetNoticeDetailsForOtherElectronic() { .noticeServedDetails(NoticeServedDetails.builder() .noticeServiceMethod(NoticeServiceMethod.OTHER_ELECTRONIC) .noticeOtherElectronicDateTime(LocalDateTime.of(2026, 5, 11, 9, 0, 0)) + .noticeOtherElectronicMethodExplanation("explanation") .build()) .build(); @@ -644,6 +645,8 @@ void shouldSetNoticeDetailsForOtherElectronic() { .isEqualTo(NoticeServiceMethod.OTHER_ELECTRONIC.getLabel()); assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeOtherElectronicDetails()) + .isEqualTo("explanation"); } @Test From 1d9f9778c7e1939973776118478f360238f668b3 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 09:09:50 +0100 Subject: [PATCH 110/138] HDPI-2983: update trespass claim label --- .../reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java index 24b45af39b..50f2a9a78e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimTabDetails.java @@ -14,6 +14,6 @@ public class ClaimTabDetails { @CCD(label = "Claimant type") private String claimantType; - @CCD(label = "Claim against trespassers?") + @CCD(label = "Is your claim a trespass claim?") private String trespassClaim; } From 86ecd122854376ec6d06fcb0eb8a7584ee6e2e27 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 10:46:13 +0100 Subject: [PATCH 111/138] HDPI-2983: update AdditionalDefendantInformationTabDetailsBuilderTest --- ...DefendantInformationTabDetailsBuilder.java | 4 ++ ...ndantInformationTabDetailsBuilderTest.java | 46 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java index df98d5dc51..408b6d7d4e 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilder.java @@ -70,6 +70,10 @@ private AdditionalDefendantInformationTabDetails createAdditionalDetailedDefenda VerticalYesNo nameKnown = defendant.getNameKnown(); VerticalYesNo addressKnown = defendant.getAddressKnown(); + if (nameKnown == null && addressKnown == null) { + return null; + } + AdditionalDefendantInformationTabDetails additionalDefendantInformationTabDetails = AdditionalDefendantInformationTabDetails.builder() .nameKnown(nameKnown != null ? nameKnown.getLabel() : null) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java index e210ff7c8d..c9f251690f 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/AdditionalDefendantInformationTabDetailsBuilderTest.java @@ -65,7 +65,6 @@ void shouldSetAdditionalDefendantsInSummaryTabWhenThereIsMoreThanOneDefendant() @Test void shouldNotSetAdditionalDefendantsInSummaryTabWhenThereIsOnlyOneDefendant() { // Given - AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); PCSCase pcsCase = PCSCase.builder() .allDefendants(List.of( listValue(Party.builder() @@ -198,7 +197,6 @@ void shouldSetAdditionalDefendantsInDetailsTabWhenThereIsMoreThanOneDefendant() @Test void shouldNotSetAdditionalDefendantsInDetailsTabWhenThereIsOnlyOneDefendant() { // Given - AddressUK address = AddressUK.builder().postCode("SW1A 1AA").build(); PCSCase pcsCase = PCSCase.builder() .allDefendants(List.of( listValue(Party.builder() @@ -285,6 +283,50 @@ void shouldDefaultAdditionalDefendantAddressForServiceToNullWhenAddressNotKnownI assertThat(additionalDefendants.getFirst().getValue().getAddressForService()).isNull(); } + @Test + void shouldReturnEmptyListWhenAdditionalDefendantsHaveNullDataInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder().build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildSummaryAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).isEmpty(); + } + + @Test + void shouldReturnEmptyListWhenAdditionalDefendantsHaveNullDataInDetailsTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .allDefendants(List.of( + listValue(Party.builder() + .nameKnown(VerticalYesNo.YES) + .firstName("Defendant") + .lastName("One") + .build()), + listValue(Party.builder().build()) + )) + .build(); + + // When + List> additionalDefendants = + additionalDefendantInformationTabDetailsBuilder.buildDetailedAdditionalDefendantsDetails(pcsCase); + + // Then + assertThat(additionalDefendants).isEmpty(); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From 69ebee00b00b84cd4643b8f4311446ab94172b7c Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 10:53:01 +0100 Subject: [PATCH 112/138] HDPI-2983: update GroundsBuilderTest --- .../ccd/view/builder/GroundsBuilderTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java index f48541c6c1..67c0fa1cd2 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/GroundsBuilderTest.java @@ -81,6 +81,33 @@ void shouldGroupSection84AConditionsUnderAntisocialBehaviourWhenParentGroundIsMi )); } + @Test + void shouldNotReturnSection84AConditionsIfNotPresent() { + // Given + PCSCase pcsCase = PCSCase.builder() + .claimGroundSummaries(List.of( + groundSummary("Landlord’s works (ground 10)", "Works reason") + )) + .build(); + + // When + String grounds = groundsBuilder.getGrounds(pcsCase); + + // Then + assertThat(grounds).isEqualTo("Landlord’s works (ground 10)"); + } + + @Test + void shouldReturnNullWhenThereAreNoGroundSummaries() { + PCSCase pcsCase = PCSCase.builder().build(); + + // When + String grounds = groundsBuilder.getGrounds(pcsCase); + + // Then + assertThat(grounds).isNull(); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From 6b245f32c77f3c93a3cfcb1b890a6e43e7a2ed67 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 11:07:54 +0100 Subject: [PATCH 113/138] HDPI-2983: update ReasonsForPossessionTabDetailsBuilderTest --- ...onsForPossessionTabDetailsBuilderTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java index be62be4f24..492b1eeb5c 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/ReasonsForPossessionTabDetailsBuilderTest.java @@ -274,6 +274,53 @@ void shouldSetAdditionalReasonInDetailsTab() { assertThat(reasons.getAdditionalReasonsDetails()).isEqualTo("Additional reason"); } + @Test + void shouldReturnNullWhenThereIsNoClaimSummariesInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder().build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons).isNull(); + } + + @Test + void shouldReturnNullWhenThereIsNoClaimSummariesInDetailsTab() { + // Given + PCSCase pcsCase = PCSCase.builder().build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildDetailsReasonsForPossession(pcsCase); + + // Then + assertThat(reasons).isNull(); + } + + @Test + void shouldReturnReasonForPossessionDetailsWhenThereIsOnlyAdditionalReasonsInSummaryTab() { + // Given + PCSCase pcsCase = PCSCase.builder() + .additionalReasonsForPossession( + AdditionalReasons.builder() + .hasReasons(VerticalYesNo.YES) + .reasons("Additional reason") + .build() + ) + .build(); + + // When + ReasonsForPossessionTabDetails reasons = reasonsForPossessionTabDetailsBuilder + .buildSummaryReasonsForPossession(pcsCase); + + // Then + assertThat(reasons.getAdditionalReasonsForPossession()).isEqualTo("Additional reason"); + assertThat(reasons.getAdditionalReasonsDetails()).isNull(); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From 8938936c5553e7b87fc2d16859b18adc04a617eb Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 22 May 2026 17:32:51 +0100 Subject: [PATCH 114/138] HDPI-2983: update claimantCircumstancesGiven label --- .../domain/tabs/details/ClaimantCircumstancesTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java index 3cc4465dec..7ed611a683 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java @@ -12,7 +12,7 @@ @AllArgsConstructor public class ClaimantCircumstancesTabDetails { - @CCD(label = "Is there any information you’d like to provide about ${claimantNamePossessiveForm} circumstances?") + @CCD(label = "Is there any information you’d like to provide about the claimant's circumstances?") private String claimantCircumstancesGiven; @CCD(label = "Claimant circumstances") From e74fcc0ae7e2f4ab34bf23ea21453cba4f7629ca Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 26 May 2026 12:01:56 +0100 Subject: [PATCH 115/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V104__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V101__add_claim_submitted_date.sql => V104__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V101__add_claim_submitted_date.sql b/src/main/resources/db/migration/V104__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V101__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V104__add_claim_submitted_date.sql From bae170e33a28265da0bd2bb3b0aa77fcf0b32a22 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 26 May 2026 12:03:56 +0100 Subject: [PATCH 116/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/PCSCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 348db02a19..67e7722c43 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 @@ -650,5 +650,5 @@ public class PCSCase { label = "Note", typeOverride = Collection, typeParameterOverride = "CaseNote") - private List> caseNotes; + List> caseNotes; } From 783fb9bada85a85fb737048684de28a1c135b52d Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 26 May 2026 12:26:53 +0100 Subject: [PATCH 117/138] HDPI-2978: Build Case Summary tab --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/PCSCaseView.java | 1 - 1 file changed, 1 deletion(-) 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 4541f941b3..cba0c5b212 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 @@ -146,7 +146,6 @@ private PCSCase getSubmittedCase(long caseReference) { genAppsView.setCaseFields(pcsCase, pcsCaseEntity); caseLinkView.setCaseFields(pcsCase, pcsCaseEntity); caseNoteView.setCaseFields(pcsCase, pcsCaseEntity); - caseTabView.setCaseTabFields(pcsCase); return pcsCase; } From 7498b477283907fc157dd06dd96676c438a9f4f4 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 26 May 2026 12:30:31 +0100 Subject: [PATCH 118/138] HDPI-2983: fix apostrophes --- .../domain/tabs/details/ClaimantCircumstancesTabDetails.java | 2 +- .../domain/tabs/details/DefendantCircumstanceTabDetails.java | 2 +- .../tabs/shared/AdditionalDefendantInformationTabDetails.java | 4 ++-- .../domain/tabs/shared/DefendantInformationTabDetails.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java index 7ed611a683..f838fb7894 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/ClaimantCircumstancesTabDetails.java @@ -12,7 +12,7 @@ @AllArgsConstructor public class ClaimantCircumstancesTabDetails { - @CCD(label = "Is there any information you’d like to provide about the claimant's circumstances?") + @CCD(label = "Is there any information you’d like to provide about the claimant’s circumstances?") private String claimantCircumstancesGiven; @CCD(label = "Claimant circumstances") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java index d33229e7c0..6b0342d18b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java @@ -13,7 +13,7 @@ public class DefendantCircumstanceTabDetails { @CCD( - label = "Is there any information you're required to provide, or you want to provide, " + label = "Is there any information you’re required to provide, or you want to provide, " + "about the defendants’ circumstances?" ) private String defendantCircumstancesGiven; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index b7ad6d5744..a69b6daa75 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -13,7 +13,7 @@ @AllArgsConstructor public class AdditionalDefendantInformationTabDetails { - @CCD(label = "Additional defendant's name known?") + @CCD(label = "Additional defendant’s name known?") private String nameKnown; @CCD(label = "First name") @@ -22,7 +22,7 @@ public class AdditionalDefendantInformationTabDetails { @CCD(label = "Last name") private String lastName; - @CCD(label = "Additional defendant's correspondence address known") + @CCD(label = "Additional defendant’s correspondence address known") private String addressKnown; @CCD(label = "Additional defendant address for service") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index f252079557..7f5fa7488f 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -13,7 +13,7 @@ @AllArgsConstructor public class DefendantInformationTabDetails { - @CCD(label = "Defendant 1's name known?") + @CCD(label = "Defendant 1’s name known?") private String nameKnown; @CCD(label = "First name") @@ -22,7 +22,7 @@ public class DefendantInformationTabDetails { @CCD(label = "Last name") private String lastName; - @CCD(label = "Defendant 1's correspondence address known") + @CCD(label = "Defendant 1’s correspondence address known") private String addressKnown; @CCD(label = "Defendant 1 address for service") From 583a97ad164ffc82f36455eae18ce4f8dfb0d8ca Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Tue, 26 May 2026 19:46:39 +0100 Subject: [PATCH 119/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V105__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V104__add_claim_submitted_date.sql => V105__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V104__add_claim_submitted_date.sql b/src/main/resources/db/migration/V105__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V104__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V105__add_claim_submitted_date.sql From cb544d6afe8fc527c9367398c48d76c494aeb4c5 Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 27 May 2026 11:21:44 +0100 Subject: [PATCH 120/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabView.java | 59 ++++++++++++- .../pcs/ccd/view/CaseSummaryTabViewTest.java | 83 ++++++++++++++++++- 2 files changed, 139 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 656ccdbf8b..8247f37053 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -8,6 +8,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.RentArrearsSection; @@ -30,6 +31,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.wales.OccupationLicenceTypeWales; import java.math.BigDecimal; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -46,6 +48,8 @@ public class CaseSummaryTabView { private static final DateTimeFormatter SUMMARY_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + private static final DateTimeFormatter SUMMARY_DATE_TIME_FORMATTER = + DateTimeFormatter.ofPattern("dd/MM/yyyy, h:mm:ssa", Locale.UK); private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); private static final Pattern GROUND_REFERENCE_PATTERN = @@ -464,16 +468,67 @@ private String getOccupationLicenceStartDate(OccupationLicenceDetailsWales occup private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { NoticeServedDetails noticeServedDetails = pcsCase.getNoticeServedDetails(); + String noticeServedDate = getNoticeServedDate(noticeServedDetails); - if (noticeServedDetails == null || noticeServedDetails.getNoticeEmailSentDateTime() == null) { + if (noticeServedDate == null) { return null; } return NoticeTabDetails.builder() - .noticeServedDate(noticeServedDetails.getNoticeEmailSentDateTime().format(SUMMARY_DATE_FORMATTER)) + .noticeServedDate(noticeServedDate) .build(); } + private String getNoticeServedDate(NoticeServedDetails noticeServedDetails) { + if (noticeServedDetails == null) { + return null; + } + + NoticeServiceMethod noticeServiceMethod = noticeServedDetails.getNoticeServiceMethod(); + if (noticeServiceMethod == null) { + return getAnyNoticeServedDate(noticeServedDetails); + } + + return switch (noticeServiceMethod) { + case FIRST_CLASS_POST -> formatSummaryDate(noticeServedDetails.getNoticePostedDate()); + case DELIVERED_PERMITTED_PLACE -> formatSummaryDate(noticeServedDetails.getNoticeDeliveredDate()); + case PERSONALLY_HANDED -> formatSummaryDateTime(noticeServedDetails.getNoticeHandedOverDateTime()); + case EMAIL -> formatSummaryDateTime(noticeServedDetails.getNoticeEmailSentDateTime()); + case OTHER_ELECTRONIC -> formatSummaryDateTime(noticeServedDetails.getNoticeOtherElectronicDateTime()); + case OTHER -> formatSummaryDateTime(noticeServedDetails.getNoticeOtherDateTime()); + }; + } + + private String getAnyNoticeServedDate(NoticeServedDetails noticeServedDetails) { + if (noticeServedDetails.getNoticePostedDate() != null) { + return formatSummaryDate(noticeServedDetails.getNoticePostedDate()); + } else if (noticeServedDetails.getNoticeDeliveredDate() != null) { + return formatSummaryDate(noticeServedDetails.getNoticeDeliveredDate()); + } else if (noticeServedDetails.getNoticeHandedOverDateTime() != null) { + return formatSummaryDateTime(noticeServedDetails.getNoticeHandedOverDateTime()); + } else if (noticeServedDetails.getNoticeEmailSentDateTime() != null) { + return formatSummaryDateTime(noticeServedDetails.getNoticeEmailSentDateTime()); + } else if (noticeServedDetails.getNoticeOtherElectronicDateTime() != null) { + return formatSummaryDateTime(noticeServedDetails.getNoticeOtherElectronicDateTime()); + } else if (noticeServedDetails.getNoticeOtherDateTime() != null) { + return formatSummaryDateTime(noticeServedDetails.getNoticeOtherDateTime()); + } + + return null; + } + + private String formatSummaryDate(LocalDate date) { + return date == null ? null : date.format(SUMMARY_DATE_FORMATTER); + } + + private String formatSummaryDateTime(LocalDateTime dateTime) { + if (dateTime == null) { + return null; + } + + return dateTime.format(SUMMARY_DATE_TIME_FORMATTER).replace("am", "AM").replace("pm", "PM"); + } + private String getRentCalculationFrequency(RentDetails rentDetails) { if (rentDetails == null || rentDetails.getFrequency() == null) { return null; diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index a164621549..72fa0571c0 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -11,6 +11,7 @@ import uk.gov.hmcts.reform.pcs.ccd.domain.AdditionalReasons; import uk.gov.hmcts.reform.pcs.ccd.domain.ClaimantInformation; import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails; +import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod; 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.RentArrearsSection; @@ -106,6 +107,7 @@ void shouldSetSummaryTabFields() { .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) .build()) .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.EMAIL) .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) .build()) .build(); @@ -148,7 +150,7 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); - assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026, 5:02PM"); } @Test @@ -283,6 +285,38 @@ void shouldNotSetEmptySummarySections() { assertThat(summaryTab.getNoticeDetails()).isNull(); } + @ParameterizedTest + @MethodSource("noticeServedDateScenarios") + void shouldSetNoticeServedDateFromSelectedNoticeServiceMethod(NoticeServedDetails noticeServedDetails, + String expectedNoticeServedDate) { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServedDetails(noticeServedDetails) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo(expectedNoticeServedDate); + } + + @Test + void shouldNotSetNoticeDetailsWhenSelectedNoticeServiceMethodHasNoDate() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServedDetails(NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.OTHER) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + @Test void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { // Given @@ -812,6 +846,53 @@ private static Stream walesOccupationLicenceTypeLabelScenarios() { ); } + private static Stream noticeServedDateScenarios() { + return Stream.of( + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.FIRST_CLASS_POST) + .noticePostedDate(LocalDate.of(2026, 5, 11)) + .build(), + "11/05/2026" + ), + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.DELIVERED_PERMITTED_PLACE) + .noticeDeliveredDate(LocalDate.of(2026, 5, 12)) + .build(), + "12/05/2026" + ), + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.PERSONALLY_HANDED) + .noticeHandedOverDateTime(LocalDateTime.of(2026, 5, 13, 9, 30)) + .build(), + "13/05/2026, 9:30AM" + ), + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.EMAIL) + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 14, 17, 2)) + .build(), + "14/05/2026, 5:02PM" + ), + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.OTHER_ELECTRONIC) + .noticeOtherElectronicDateTime(LocalDateTime.of(2026, 5, 15, 10, 15)) + .build(), + "15/05/2026, 10:15AM" + ), + Arguments.of( + NoticeServedDetails.builder() + .noticeServiceMethod(NoticeServiceMethod.OTHER) + .noticeOtherDateTime(LocalDateTime.of(2026, 5, 16, 18, 45)) + .build(), + "16/05/2026, 6:45PM" + ) + ); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From dc02c85facc15ad306ccc0ad755499ed266f539a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 27 May 2026 11:32:42 +0100 Subject: [PATCH 121/138] HDPI-2978: Build Case Summary tab --- .../reform/pcs/ccd/view/CaseSummaryTabViewTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index 72fa0571c0..aa1ea6c861 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -150,7 +150,7 @@ void shouldSetSummaryTabFields() { assertThat(summaryTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); assertThat(summaryTab.getTenancyDetails().getAgreementType()).isEqualTo("Licence details"); assertThat(summaryTab.getTenancyDetails().getAgreementStartDate()).isEqualTo("16/04/2024"); - assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026, 5:02PM"); + assertThat(summaryTab.getNoticeDetails().getNoticeServedDate()).isEqualTo("11/05/2026, 5:02:00PM"); } @Test @@ -867,28 +867,28 @@ private static Stream noticeServedDateScenarios() { .noticeServiceMethod(NoticeServiceMethod.PERSONALLY_HANDED) .noticeHandedOverDateTime(LocalDateTime.of(2026, 5, 13, 9, 30)) .build(), - "13/05/2026, 9:30AM" + "13/05/2026, 9:30:00AM" ), Arguments.of( NoticeServedDetails.builder() .noticeServiceMethod(NoticeServiceMethod.EMAIL) .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 14, 17, 2)) .build(), - "14/05/2026, 5:02PM" + "14/05/2026, 5:02:00PM" ), Arguments.of( NoticeServedDetails.builder() .noticeServiceMethod(NoticeServiceMethod.OTHER_ELECTRONIC) .noticeOtherElectronicDateTime(LocalDateTime.of(2026, 5, 15, 10, 15)) .build(), - "15/05/2026, 10:15AM" + "15/05/2026, 10:15:00AM" ), Arguments.of( NoticeServedDetails.builder() .noticeServiceMethod(NoticeServiceMethod.OTHER) .noticeOtherDateTime(LocalDateTime.of(2026, 5, 16, 18, 45)) .build(), - "16/05/2026, 6:45PM" + "16/05/2026, 6:45:00PM" ) ); } From 1422a945aa7de7f75c0dc008c330cf7ed289bf8a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Wed, 27 May 2026 12:08:23 +0100 Subject: [PATCH 122/138] HDPI-2978: Build Case Summary tab --- .../pcs/ccd/view/CaseSummaryTabView.java | 20 +------------------ .../pcs/ccd/view/CaseSummaryTabViewTest.java | 16 +++++++++++++++ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java index 8247f37053..b612c0ecec 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabView.java @@ -486,7 +486,7 @@ private String getNoticeServedDate(NoticeServedDetails noticeServedDetails) { NoticeServiceMethod noticeServiceMethod = noticeServedDetails.getNoticeServiceMethod(); if (noticeServiceMethod == null) { - return getAnyNoticeServedDate(noticeServedDetails); + return null; } return switch (noticeServiceMethod) { @@ -499,24 +499,6 @@ private String getNoticeServedDate(NoticeServedDetails noticeServedDetails) { }; } - private String getAnyNoticeServedDate(NoticeServedDetails noticeServedDetails) { - if (noticeServedDetails.getNoticePostedDate() != null) { - return formatSummaryDate(noticeServedDetails.getNoticePostedDate()); - } else if (noticeServedDetails.getNoticeDeliveredDate() != null) { - return formatSummaryDate(noticeServedDetails.getNoticeDeliveredDate()); - } else if (noticeServedDetails.getNoticeHandedOverDateTime() != null) { - return formatSummaryDateTime(noticeServedDetails.getNoticeHandedOverDateTime()); - } else if (noticeServedDetails.getNoticeEmailSentDateTime() != null) { - return formatSummaryDateTime(noticeServedDetails.getNoticeEmailSentDateTime()); - } else if (noticeServedDetails.getNoticeOtherElectronicDateTime() != null) { - return formatSummaryDateTime(noticeServedDetails.getNoticeOtherElectronicDateTime()); - } else if (noticeServedDetails.getNoticeOtherDateTime() != null) { - return formatSummaryDateTime(noticeServedDetails.getNoticeOtherDateTime()); - } - - return null; - } - private String formatSummaryDate(LocalDate date) { return date == null ? null : date.format(SUMMARY_DATE_FORMATTER); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java index aa1ea6c861..1935a23b67 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseSummaryTabViewTest.java @@ -317,6 +317,22 @@ void shouldNotSetNoticeDetailsWhenSelectedNoticeServiceMethodHasNoDate() { assertThat(summaryTab.getNoticeDetails()).isNull(); } + @Test + void shouldNotSetNoticeDetailsWhenNoticeServiceMethodIsMissing() { + // Given + PCSCase pcsCase = PCSCase.builder() + .noticeServedDetails(NoticeServedDetails.builder() + .noticeEmailSentDateTime(LocalDateTime.of(2026, 5, 11, 17, 2)) + .build()) + .build(); + + // When + SummaryTab summaryTab = underTest.buildSummaryTab(pcsCase); + + // Then + assertThat(summaryTab.getNoticeDetails()).isNull(); + } + @Test void shouldSetUnknownDefendantNameWhenNameNotKnownButAddressKnown() { // Given From fe28621c56ffefd012354d6ede31bf422fe57725 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 28 May 2026 08:43:37 +0100 Subject: [PATCH 123/138] HDPI-2983: change correspondence address to service address --- .../tabs/shared/AdditionalDefendantInformationTabDetails.java | 2 +- .../ccd/domain/tabs/shared/DefendantInformationTabDetails.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java index a69b6daa75..34659b519d 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/AdditionalDefendantInformationTabDetails.java @@ -22,7 +22,7 @@ public class AdditionalDefendantInformationTabDetails { @CCD(label = "Last name") private String lastName; - @CCD(label = "Additional defendant’s correspondence address known") + @CCD(label = "Additional defendant’s address for service known?") private String addressKnown; @CCD(label = "Additional defendant address for service") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java index 7f5fa7488f..c305590664 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/shared/DefendantInformationTabDetails.java @@ -22,7 +22,7 @@ public class DefendantInformationTabDetails { @CCD(label = "Last name") private String lastName; - @CCD(label = "Defendant 1’s correspondence address known") + @CCD(label = "Defendant 1’s address for service known?") private String addressKnown; @CCD(label = "Defendant 1 address for service") From 4b7f1d6c5018791ba708f783189c3711911f22fc Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Thu, 28 May 2026 09:08:10 +0100 Subject: [PATCH 124/138] HDPI-2983: use add time to notice details date in case details tab --- .../reform/pcs/ccd/view/CaseDetailsTabView.java | 16 ++++++++++------ .../pcs/ccd/view/CaseDetailsTabViewTest.java | 10 +++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 94fd6766d7..68bf15568a 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -73,7 +73,7 @@ public class CaseDetailsTabView { private static final String NO_ANSWER = " "; private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); - private static final DateTimeFormatter SUBMITTED_DATE_FORMATTER = + private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("d MMMM yyyy, h:mm:ssa", Locale.UK); private final GroundsBuilder groundsBuilder; @@ -248,25 +248,25 @@ private NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) { case PERSONALLY_HANDED -> { LocalDateTime dateTime = noticeServedDetails.getNoticeHandedOverDateTime(); String name = noticeServedDetails.getNoticePersonName(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? formatDateTime(dateTime) : NO_ANSWER); noticeTabDetails.setNoticePersonName(name != null ? name : NO_ANSWER); } case EMAIL -> { LocalDateTime dateTime = noticeServedDetails.getNoticeEmailSentDateTime(); String emailAddress = noticeServedDetails.getNoticeEmailAddress(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? formatDateTime(dateTime) : NO_ANSWER); noticeTabDetails.setNoticeEmailAddress(emailAddress != null ? emailAddress : NO_ANSWER); } case OTHER_ELECTRONIC -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherElectronicDateTime(); String details = noticeServedDetails.getNoticeOtherElectronicMethodExplanation(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? formatDateTime(dateTime) : NO_ANSWER); noticeTabDetails.setNoticeOtherElectronicDetails(details != null ? details : NO_ANSWER); } case OTHER -> { LocalDateTime dateTime = noticeServedDetails.getNoticeOtherDateTime(); String explanation = noticeServedDetails.getNoticeOtherExplanation(); - noticeTabDetails.setNoticeDate(dateTime != null ? dateTime.format(DATE_FORMATTER) : NO_ANSWER); + noticeTabDetails.setNoticeDate(dateTime != null ? formatDateTime(dateTime) : NO_ANSWER); noticeTabDetails.setNoticeOtherExplanation(explanation != null ? explanation : NO_ANSWER); } }; @@ -518,6 +518,10 @@ private String formatSubmittedDate(LocalDateTime dateSubmitted) { .withZoneSameInstant(UK_ZONE_ID) .toLocalDateTime(); - return ukDateSubmitted.format(SUBMITTED_DATE_FORMATTER).replace("am", "AM").replace("pm", "PM"); + return formatDateTime(ukDateSubmitted); + } + + private String formatDateTime(LocalDateTime localDateTime) { + return localDateTime.format(DATE_TIME_FORMATTER).replace("am", "AM").replace("pm", "PM"); } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index bc3b7d54d3..82786167e4 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -309,14 +309,14 @@ void shouldSetCaseDetailsTabFields() { assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDate()) .isEqualTo("16 April 2024"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()) - .isEqualTo("11 May 2026"); + .isEqualTo("11 May 2026, 5:02:00PM"); assertThat(caseDetailsTab.getTenancyLicenceDetails().getHasCopyOfTenancyLicence()) .isEqualTo("No"); assertThat(caseDetailsTab.getTenancyLicenceDetails().getReasonsForNoTenancyLicenceDocuments()) .isEqualTo("Reasons"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()).isEqualTo("By email"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026, 5:02:00PM"); assertThat(caseDetailsTab.getApplicationsDetails().getPlanToMakeGeneralApplication()).isEqualTo("Yes"); assertThat(caseDetailsTab.getActionsTakenDetails().getPreactionProtocolFollowed()).isEqualTo("No"); assertThat(caseDetailsTab.getActionsTakenDetails().getPreActionProtocolIncompleteExplanation()) @@ -621,7 +621,7 @@ void shouldSetNoticeDetailsForPersonallyHanded() { assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) .isEqualTo(NoticeServiceMethod.PERSONALLY_HANDED.getLabel()); assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026, 9:00:00AM"); assertThat(caseDetailsTab.getNoticeDetails().getNoticePersonName()).isEqualTo("Notice name"); } @@ -644,7 +644,7 @@ void shouldSetNoticeDetailsForOtherElectronic() { assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) .isEqualTo(NoticeServiceMethod.OTHER_ELECTRONIC.getLabel()); assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026, 9:00:00AM"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeOtherElectronicDetails()) .isEqualTo("explanation"); } @@ -667,7 +667,7 @@ void shouldSetNoticeDetailsForOther() { assertThat(caseDetailsTab.getNoticeDetails().getNoticeMethod()) .isEqualTo(NoticeServiceMethod.OTHER.getLabel()); assertThat(caseDetailsTab.getNoticeDetails().getNoticeServed()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026"); + assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()).isEqualTo("11 May 2026, 9:00:00AM"); } @Test From 60d6059a9b0bcde08de5984784785e3f2216a02d Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 28 May 2026 09:20:11 +0100 Subject: [PATCH 125/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V106__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V105__add_claim_submitted_date.sql => V106__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V105__add_claim_submitted_date.sql b/src/main/resources/db/migration/V106__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V105__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V106__add_claim_submitted_date.sql From 16da8a4bacb6429797f90844133987fdddc45f6c Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Thu, 28 May 2026 09:45:04 +0100 Subject: [PATCH 126/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V107__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V106__add_claim_submitted_date.sql => V107__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V106__add_claim_submitted_date.sql b/src/main/resources/db/migration/V107__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V106__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V107__add_claim_submitted_date.sql From 6584dc8fac99955f7ba5c83870e9359e686c453e Mon Sep 17 00:00:00 2001 From: srinijg Date: Thu, 28 May 2026 17:43:04 +0100 Subject: [PATCH 127/138] Hdpi 2978 automation (#1881) Co-authored-by: gmmagruder Co-authored-by: guygrewal77 Co-authored-by: Gabrielle Magruder <51362727+gmmagruder@users.noreply.github.com> Co-authored-by: guygrewal77 <163517291+guygrewal77@users.noreply.github.com> --- src/e2eTest/config/global-setup.config.ts | 1 + .../data/api-data/submitCase.api.data.ts | 127 ++++++++++++++++++ src/e2eTest/data/page-data/home.page.data.ts | 1 + src/e2eTest/tests/caseTabs.spec.ts | 82 ++++++++++- .../tests/createCase.saveResume.spec.ts | 7 - src/e2eTest/tests/createCase.spec.ts | 14 -- src/e2eTest/tests/createCaseWales.spec.ts | 7 - .../custom-actions/createCase.action.ts | 121 ++++++++++++++++- .../custom-actions/createCaseAPI.action.ts | 4 +- .../custom-actions/linkSolicitorAPI.action.ts | 2 +- src/e2eTest/utils/common/string.utils.ts | 45 +++++++ src/e2eTest/utils/registry/action.registry.ts | 1 + 12 files changed, 375 insertions(+), 37 deletions(-) diff --git a/src/e2eTest/config/global-setup.config.ts b/src/e2eTest/config/global-setup.config.ts index 94c61a53f4..d120300346 100644 --- a/src/e2eTest/config/global-setup.config.ts +++ b/src/e2eTest/config/global-setup.config.ts @@ -20,6 +20,7 @@ function applyPlaywrightServiceUrls(): void { process.env.IDAM_WEB_URL ||= `https://idam-api.${e}.platform.hmcts.net`; process.env.IDAM_TESTING_SUPPORT_URL ||= `https://idam-testing-support-api.${e}.platform.hmcts.net`; process.env.S2S_URL ||= `http://rpe-service-auth-provider-${e}.service.core-compute-${e}.internal/testing-support/lease`; + process.env.CASE_API_URL ||= `http://pcs-api-${e}.service.core-compute-${e}.internal`; } else { // preview, empty ENVIRONMENT, etc.: AAT IdAM/S2S (same as Jenkinsfile_CNP defaults). MANAGE_CASE / data-store from Jenkins or exports. process.env.IDAM_WEB_URL ||= 'https://idam-api.aat.platform.hmcts.net'; diff --git a/src/e2eTest/data/api-data/submitCase.api.data.ts b/src/e2eTest/data/api-data/submitCase.api.data.ts index 857c66bb1a..4bc610e049 100644 --- a/src/e2eTest/data/api-data/submitCase.api.data.ts +++ b/src/e2eTest/data/api-data/submitCase.api.data.ts @@ -360,6 +360,133 @@ export const submitCaseApiData = { languageUsed: 'ENGLISH', completionNextStep: 'SUBMIT_AND_PAY_NOW' }, + submitCasePayloadCaseSummary: { + legislativeCountry: 'England', + orgNameFound: 'Yes', + claimantType: { + value: { + code: 'PROVIDER_OF_SOCIAL_HOUSING', + label: 'Registered provider of social housing or local authority' + }, + list_items: [ + { + code: 'PRIVATE_LANDLORD', + label: 'Private landlord' + }, + { + code: 'PROVIDER_OF_SOCIAL_HOUSING', + label: 'Registered provider of social housing or local authority' + }, + { + code: 'MORTGAGE_LENDER', + label: 'Mortgage lender' + }, + { + code: 'OTHER', + label: 'Other' + } + ], + valueCode: 'PROVIDER_OF_SOCIAL_HOUSING' + }, + claimAgainstTrespassers: 'NO', + claimantName: 'Possession Claims Solicitor Org', + isClaimantNameCorrect: 'YES', + claimantContactEmail: 'pcs-solicitor1@test.com', + isCorrectClaimantContactEmail: 'YES', + orgAddressFound: "Yes", + organisationAddress: { + AddressLine1: 'Ministry Of Justice', + AddressLine2: 'Seventh Floor 102 Petty France', + PostTown: 'London', + PostCode: 'SW1H 9AJ', + Country: 'United Kingdom' + }, + formattedClaimantContactAddress: 'Ministry Of Justice
Seventh Floor 102 Petty France
London
SW1H 9AJ', + isCorrectClaimantContactAddress: 'YES', + claimantProvidePhoneNumber: 'YES', + claimantContactPhoneNumber: '04469172429', + defendant1: { + nameKnown: 'YES', + addressKnown: 'YES', + addressSameAsPossession: 'NO', + correspondenceAddress: { + AddressLine1: '6 Second Avenue', + AddressLine2: 'Oxford Street', + AddressLine3: "", + PostTown: 'London', + County: '', + Country: 'United Kingdom', + PostCode: 'W3 7RX' + }, + firstName: 'John', + lastName: 'Doe', + }, + addAnotherDefendant: 'NO', + additionalDefendants: [ + { + value: { + nameKnown: 'NO', + addressKnown: 'NO', + addressSameAsPossession: 'NO' + }, + id: null + }, + { + value: { + nameKnown: 'NO', + addressKnown: 'NO', + addressSameAsPossession: 'NO' + }, + id: null + }, + ], + tenancy_TypeOfTenancyLicence: 'DEMOTED_TENANCY', + tenancy_TenancyLicenceDate: '2020-10-02', + tenancy_HasCopyOfTenancyLicence: 'NO', + tenancy_ReasonsForNoTenancyLicenceDocuments: 'tet', + showIntroductoryDemotedOtherGroundReasonPage: 'Yes', + introGrounds_HasIntroductoryDemotedOtherGroundsForPossession: 'YES', + introGrounds_IntroductoryDemotedOrOtherGrounds: ['RENT_ARREARS'], + noGrounds: 'text no grounds', + preActionProtocolCompleted: 'NO', + preActionProtocolIncompleteExplanation: 'preAction protocol completed', + mediationAttempted: 'NO', + settlementAttempted: 'NO', + noticeServed: 'YES', + notice_NoticePostedDate: '2025-11-10', + notice_NoticeDocuments: [], + notice_NoticeServiceMethod: 'EMAIL', + notice_NoticeEmailAddress: 'test@gmail.com', + notice_NoticeEmailSentDateTime: '2025-12-11T14:22:59', + rentDetails_CurrentRent: '125000', + rentDetails_Frequency: 'MONTHLY', + rentDetails_CalculatedDailyCharge: '3285', + rentArrears_Total: '23999', + rentArrears_RecoveryAttempted: 'NO', + arrearsJudgmentWanted: 'NO', + claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', + claimantCircumstancesSelect: 'NO', + hasDefendantCircumstancesInfo: 'NO', + suspensionOfRTB_ShowHousingActsPage: 'No', + demotionOfTenancy_ShowHousingActsPage: 'No', + suspensionToBuyDemotionOfTenancyPages: 'No', + alternativesToPossession: [], + additionalReasonsForPossession: { + hasReasons: 'NO', + reasons: null + }, + hasUnderlesseeOrMortgagee: 'NO', + wantToUploadDocuments: 'NO', + applicationWithClaim: 'NO', + languageUsed: 'ENGLISH', + completionNextStep: 'SUBMIT_AND_PAY_NOW', + statementOfTruth: { + completedBy: 'CLAIMANT', + fullNameParty: 'fg', + positionParty: 'fg', + agreementClaimant: ['BELIEVE_TRUE'], + }, + }, submitCasePayloadDefault: { legislativeCountry: 'England', claimantType: { diff --git a/src/e2eTest/data/page-data/home.page.data.ts b/src/e2eTest/data/page-data/home.page.data.ts index 6e1d820ae2..cd5ebf0c71 100644 --- a/src/e2eTest/data/page-data/home.page.data.ts +++ b/src/e2eTest/data/page-data/home.page.data.ts @@ -7,5 +7,6 @@ export const home = findCaseTab: 'Find case', caseParties: 'Case Parties', caseNotes: 'Notes', + caseSummary: 'Summary', signOutButton: 'Sign out' } diff --git a/src/e2eTest/tests/caseTabs.spec.ts b/src/e2eTest/tests/caseTabs.spec.ts index 071bfeffa5..1f3ad6d563 100644 --- a/src/e2eTest/tests/caseTabs.spec.ts +++ b/src/e2eTest/tests/caseTabs.spec.ts @@ -10,11 +10,17 @@ import { addCaseNote } from '@data/page-data-figma'; import { checkYourAnswersCaseNote } from '@data/page-data/checkYourAnswersCaseNote.page.data'; import { getCurrentBSTTime } from '@utils/common/string.utils'; -test.beforeEach(async ({ page }) => { +test.beforeEach(async ({ page }, testInfo) => { initializeExecutor(page); - await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); - await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseTab }); - await performAction('fetchCurrentUserAPI'); + if (testInfo.title.includes('Summary')) { + await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); + await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseSummary }); + await performAction('fetchCurrentUserAPI'); + } else { + await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); + await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseTab }); + await performAction('fetchCurrentUserAPI'); + } await performAction('navigateToUrl', `${process.env.MANAGE_CASE_BASE_URL}/cases/case-details/PCS/${getCaseTypeId()}/${process.env.CASE_NUMBER}#Summary`); await expect(async () => { await page.waitForURL(`${process.env.MANAGE_CASE_BASE_URL}/**/**/**/**/**#Summary`); @@ -59,7 +65,7 @@ test.describe('[Case tabs - England Journey] @nightly', async () => { "text": checkYourAnswersCaseNote.header, "elementType": "subHeading" }); - + await performAction('clickButton', checkYourAnswersCaseNote.submitNote); await performValidation('bannerAlert', 'Case #.* has been updated with event: Add a case note'); await performAction('clickTab', home.caseNotes); @@ -70,4 +76,70 @@ test.describe('[Case tabs - England Journey] @nightly', async () => { }); }); + test('Case tabs - Summary tab test @MAC @regression', async () => { + await performAction('clickTab', home.caseSummary); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Address of property', + table: 'Address of property to be repossessed' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Claimant details', + table: 'Claimant' + }); + + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Defendant details', + table: 'Defendant 1' + }); + + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Grounds of possession', + table: 'Grounds for possession' + }); + + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Rent arrears', + table: 'Details of rent arrears' + }); + + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Tenancy and Occupation', + table: 'Tenancy, occupation contract or licence details' + }); + + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseSummary.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseSummary.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseSummary, + section: 'Notice', + table: 'Notice details' + }); + + }); + }); diff --git a/src/e2eTest/tests/createCase.saveResume.spec.ts b/src/e2eTest/tests/createCase.saveResume.spec.ts index c73c3ebe5f..3a29d55315 100644 --- a/src/e2eTest/tests/createCase.saveResume.spec.ts +++ b/src/e2eTest/tests/createCase.saveResume.spec.ts @@ -197,13 +197,6 @@ test.describe('[Create Case - With resume claim options] @nightly @MAC', async ( await performAction('clickButton', checkYourAnswers.submitClaim); await performAction('payClaimFee'); await performValidation('bannerAlert', 'Case #.* has been updated with event: Make a claim'); - await performValidations( - 'address info not null', - ['formLabelValue', propertyDetails.buildingAndStreetLabel], - ['formLabelValue', propertyDetails.townOrCityLabel], - ['formLabelValue', propertyDetails.postcodeZipcodeLabel], - ['formLabelValue', propertyDetails.countryLabel], - ) }); test('England - Resume without saved options - Secure tenancy - No Rent Arrears @MAC', async () => { diff --git a/src/e2eTest/tests/createCase.spec.ts b/src/e2eTest/tests/createCase.spec.ts index 64bfe07225..6f4208d042 100644 --- a/src/e2eTest/tests/createCase.spec.ts +++ b/src/e2eTest/tests/createCase.spec.ts @@ -187,13 +187,6 @@ test.describe('[Create Case - England] @nightly', async () => { await performAction('clickButton', checkYourAnswers.submitClaim); await performAction('payClaimFee'); await performValidation('bannerAlert', 'Case #.* has been updated with event: Make a claim'); - await performValidations( - 'address info not null', - ['formLabelValue', propertyDetails.buildingAndStreetLabel], - ['formLabelValue', propertyDetails.townOrCityLabel], - ['formLabelValue', propertyDetails.postcodeZipcodeLabel], - ['formLabelValue', propertyDetails.countryLabel], - ) }); //This test must be run only in the Nightly jobs as it contains an exhaustive test sceanrio for 'Upload additional documents' page @@ -318,13 +311,6 @@ test.describe('[Create Case - England] @nightly', async () => { await performAction('clickButton', checkYourAnswers.submitClaim); await performAction('payClaimFee',{clickLink: true}); await performValidation('bannerAlert', 'Case #.* has been updated with event: Make a claim'); - await performValidations( - 'address info not null', - ['formLabelValue', propertyDetails.buildingAndStreetLabel], - ['formLabelValue', propertyDetails.townOrCityLabel], - ['formLabelValue', propertyDetails.postcodeZipcodeLabel], - ['formLabelValue', propertyDetails.countryLabel], - ) }); test('England - Assured tenancy with No Rent arrears @MAC', async () => { diff --git a/src/e2eTest/tests/createCaseWales.spec.ts b/src/e2eTest/tests/createCaseWales.spec.ts index af444763bb..f91cacda0e 100644 --- a/src/e2eTest/tests/createCaseWales.spec.ts +++ b/src/e2eTest/tests/createCaseWales.spec.ts @@ -604,13 +604,6 @@ test.describe('[Create Case - Wales] @nightly', async () => { await performAction('clickButton', checkYourAnswers.submitClaim); await performAction('payClaimFee'); await performValidation('bannerAlert', 'Case #.* has been updated with event: Make a claim'); - await performValidations( - 'address info not null', - ['formLabelValue', propertyDetails.buildingAndStreetLabel], - ['formLabelValue', propertyDetails.townOrCityLabel], - ['formLabelValue', propertyDetails.postcodeZipcodeLabel], - ['formLabelValue', propertyDetails.countryLabel], - ) }); test('Wales - Standard contract - No Rent arrears @MAC', async () => { diff --git a/src/e2eTest/utils/actions/custom-actions/createCase.action.ts b/src/e2eTest/utils/actions/custom-actions/createCase.action.ts index c6bb756128..08d63b090f 100644 --- a/src/e2eTest/utils/actions/custom-actions/createCase.action.ts +++ b/src/e2eTest/utils/actions/custom-actions/createCase.action.ts @@ -55,7 +55,8 @@ import { import {MEDIUM_TIMEOUT, VERY_LONG_TIMEOUT} from 'playwright.config'; import {compareMaps} from '@utils/common/compareMaps.util'; import {caseInfo} from './createCaseAPI.action'; -import { createCaseApiData } from '@data/api-data'; +import {createCaseApiData} from '@data/api-data'; +import {formatCurrency, formatDate, formatDateTime, formatText, formatWord} from '@utils/common/string.utils'; export let caseNumber: string; export let claimantsName: string; export let addressInfo: { buildingStreet: string; townCity: string; engOrWalPostcode: string }; @@ -83,7 +84,7 @@ export class CreateCaseAction implements IAction { ['selectJurisdictionCaseTypeEvent', () => this.selectJurisdictionCaseTypeEvent(page)], ['enterTestAddressManually', () => this.enterTestAddressManually(page, fieldName as actionRecord)], ['selectClaimType', () => this.selectClaimType(fieldName)], - ['selectClaimantName', () => this.selectClaimantName(page,fieldName)], + ['selectClaimantName', () => this.selectClaimantName(page, fieldName)], ['selectContactPreferences', () => this.selectContactPreferences(fieldName as actionRecord)], ['selectRentArrearsPossessionGround', () => this.selectRentArrearsPossessionGround(fieldName as actionRecord)], ['selectGroundsForPossession', () => this.selectGroundsForPossession(fieldName as actionRecord)], @@ -125,6 +126,7 @@ export class CreateCaseAction implements IAction { ['validateClaimantDetails', () => this.validateClaimantDetails(page, fieldName as actionRecord)], ['addCaseNotes', () => this.addCaseNotes(fieldName as actionRecord)], ['validateCaseNotesDetails', () => this.validateCaseNotesDetails(page, fieldName as actionRecord)], + ['validateCaseSummaryDetails', () => this.validateCaseSummaryDetails(page, fieldName as actionRecord)], ]); const actionToPerform = actionsMap.get(action); if (!actionToPerform) throw new Error(`No action found for '${action}'`); @@ -1040,6 +1042,121 @@ export class CreateCaseAction implements IAction { } + private async validateCaseSummaryDetails(page: Page, caseSummarySection: actionRecord) { + + let caseSummary = new Map(); + let submitPayLoad = caseSummarySection.submitPayload as Record; + let createPayLoad = caseSummarySection.createPayload as Record; + + switch (caseSummarySection.section) { + case 'Defendant details': + if (submitPayLoad.defendant1.nameKnown === 'YES') { + caseSummary.set(`First name`, submitPayLoad.defendant1.firstName); + caseSummary.set(`Last name`, submitPayLoad.defendant1.lastName); + } + if (submitPayLoad.defendant1.addressKnown === 'YES' && submitPayLoad.defendant1.addressSameAsPossession === 'YES') { + const address = submitPayLoad.formattedClaimantContactAddress.split('
'); + caseSummary.set(`Building and Street`, address[0]); + caseSummary.set(`Address Line 2`, address[1]); + caseSummary.set(`Town or City`, address[2]); + caseSummary.set(`Postcode/Zipcode`, address[3]); + caseSummary.set('Country', 'United Kingdom') + + } else if (submitPayLoad.defendant1.addressKnown === 'YES' && submitPayLoad.defendant1.addressSameAsPossession === 'NO') { + caseSummary.set(`Building and Street`, submitPayLoad.defendant1.correspondenceAddress.AddressLine1); + caseSummary.set(`Address Line 2`, submitPayLoad.defendant1.correspondenceAddress.AddressLine2); + caseSummary.set(`Town or City`, submitPayLoad.defendant1.correspondenceAddress.PostTown); + caseSummary.set(`Postcode/Zipcode`, submitPayLoad.defendant1.correspondenceAddress.PostCode); + caseSummary.set('Country', 'United Kingdom') + } + break; + + case 'Address of property': + caseSummary.set(`Building and Street`, createPayLoad.propertyAddress.AddressLine1); + caseSummary.set(`Address Line 2`, createPayLoad.propertyAddress.AddressLine2); + caseSummary.set(`Town or City`, createPayLoad.propertyAddress.PostTown); + caseSummary.set(`Postcode/Zipcode`, createPayLoad.propertyAddress.PostCode); + caseSummary.set('Country', createPayLoad.propertyAddress.Country); + break; + + case 'Claimant details': + caseSummary.set(`Claimant name`, submitPayLoad.claimantName); + break; + + case 'Tenancy and Occupation': + caseSummary.set(`Tenancy, occupation contract or licence agreement type`, (submitPayLoad.tenancy_TypeOfTenancyLicence) + .toLowerCase() + .replace(/_/g, " ") + .replace(/^\w/, (c: string) => c.toUpperCase()) + ); + caseSummary.set(`Tenancy, occupation contract or licence agreement start date`, formatDate(submitPayLoad.tenancy_TenancyLicenceDate)); + break; + + case 'Grounds of possession': + if (submitPayLoad.introGrounds_HasIntroductoryDemotedOtherGroundsForPossession === 'YES') { + caseSummary.set(`Grounds`, formatText(submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds[0])); + }; + break; + + case 'Rent arrears': + caseSummary.set(`Rent amount`, formatCurrency(submitPayLoad.rentDetails_CurrentRent)); + caseSummary.set(`How rent is calculated`, formatWord(submitPayLoad.rentDetails_Frequency)); + caseSummary.set(`Daily rate`, formatCurrency(submitPayLoad.rentDetails_CalculatedDailyCharge)); + caseSummary.set(`Rent arrears total at the time of claim issue`, formatCurrency(submitPayLoad.rentArrears_Total)); + caseSummary.set(`Judgment requested for the outstanding arrears?`, formatWord(submitPayLoad.arrearsJudgmentWanted)); + break; + + case 'Notice': + + const serviceMethod = submitPayLoad.notice_NoticeServiceMethod; + + const dateServed = + serviceMethod === 'FIRST_CLASS_POST' + ? submitPayLoad.notice_NoticePostedDate + : serviceMethod === 'EMAIL' + ? submitPayLoad.notice_NoticeEmailSentDateTime + : null; + + if (dateServed) { + const formattedDate = + serviceMethod === 'FIRST_CLASS_POST' + ? formatDate(dateServed) + : formatDateTime(dateServed); + + caseSummary.set('Date notice was served', formattedDate); + } + + break; + + default: + break; + }; + + await this.caseTabTableData(page, caseSummarySection.table as string); + + const misMatchMap = compareMaps(caseSummary, caseTabMap, { + name1: 'CaseSummary', + name2: 'CaseSummaryTab', + }) + + if (misMatchMap.size > 0) { + console.log(`\n❌ Differences found: ${misMatchMap.size}`); + for (const [key, val] of misMatchMap) { + const expectedValue = val.a === undefined ? '' : String(val.a); + const actualValue = val.b === undefined ? '' : String(val.b); + console.log('============================================================'); + console.log(`• key: "${String(key)}" → Expected: ${expectedValue} | Actual: ${actualValue}`); + } + console.log(`\n********** END OF FAILURE LIST. ***************`); + throw new Error(`Case Summary validations failed for ${misMatchMap.size} ${misMatchMap.size === 1 ? 'item' : 'items'}`); + } else { + console.log(`\n✅ Case Summary VALIDATION for section ${caseSummarySection.section} PASSED!\n`); + } + + caseTabMap.clear(); + + } + private async caseTabTableData(page: Page, table: string) { const tables = page.locator(`//span[text()="${table}"]/ancestor::div[1]/child::table[@aria-describedby="complex field table"]`); diff --git a/src/e2eTest/utils/actions/custom-actions/createCaseAPI.action.ts b/src/e2eTest/utils/actions/custom-actions/createCaseAPI.action.ts index 9b3b5c11a6..31a1d3756d 100644 --- a/src/e2eTest/utils/actions/custom-actions/createCaseAPI.action.ts +++ b/src/e2eTest/utils/actions/custom-actions/createCaseAPI.action.ts @@ -173,18 +173,20 @@ export class CreateCaseAPIAction implements IAction { private async getCaseAPI(): Promise { const getCaseApi = Axios.create(createCaseEventTokenApiData.createCaseEventTokenApiInstance()); - process.env.CREATE_EVENT_TOKEN = (await getCaseApi.get(createCaseEventTokenApiData.createCaseEventTokenApiEndPoint)).data.token; + //process.env.CREATE_EVENT_TOKEN = (await getCaseApi.get(createCaseEventTokenApiData.createCaseEventTokenApiEndPoint)).data.token; try { const createResponse = await getCaseApi.get(getCaseApiData.getCaseApiEndPoint()); await this.generateSolicitorAccessToken(); const allDefendants = createResponse.data.data.allDefendants; const defendantIds = allDefendants.map((d: any) => d.id); + if (defendantIds.length === 0) throw new Error(`No Defendants ID retrieved and the status is ${createResponse.status}`); for (const defendantId of defendantIds) { process.env.Defendant_ID = defendantId; await performAction('linkSolicitorAPI'); } + console.log(`\n✅ GET DEFENDANT ID SUCCESSFUL : STATUS ${createResponse.status}`); } catch (error: any) { const status = error?.response?.status; diff --git a/src/e2eTest/utils/actions/custom-actions/linkSolicitorAPI.action.ts b/src/e2eTest/utils/actions/custom-actions/linkSolicitorAPI.action.ts index c3f534f60b..e84fc4573e 100644 --- a/src/e2eTest/utils/actions/custom-actions/linkSolicitorAPI.action.ts +++ b/src/e2eTest/utils/actions/custom-actions/linkSolicitorAPI.action.ts @@ -64,4 +64,4 @@ export class LinkSolicitorAPIAction implements IAction { } } } -} \ No newline at end of file +} diff --git a/src/e2eTest/utils/common/string.utils.ts b/src/e2eTest/utils/common/string.utils.ts index fd298713de..13f7d3d398 100644 --- a/src/e2eTest/utils/common/string.utils.ts +++ b/src/e2eTest/utils/common/string.utils.ts @@ -48,3 +48,48 @@ export function getCurrentBSTTime(): string { return formatted.replace(/am|pm/, (match) => match.toUpperCase()); } +/* convert YYY-MM-DD to DD/MM/YYYY format */ +export function formatDate(dateStr: string): string { + const date = new Date(dateStr); + return date.toLocaleDateString("en-GB"); +} + +/* convert string for ex RENT_ARREARS to Rent arrears */ +export function formatText(input: string): string { + return input + .toLowerCase() + .replace(/_/g, " ") + .replace(/^\w/, c => c.toUpperCase()); +} + +/* covert string 100000 to £1000 */ +export function formatCurrency(value: string): string { + const numberValue = Number(value) / 100; + return `£${numberValue}`; +} + +/* convert EXAMPLE to Example */ +export function formatWord(input: string): string { + return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); +} + +/* convert date and time 2025-12-11T14:20:59 to 11/12/2025, 2:20:59PM */ +export function formatDateTime(dateStr: string): string { + const date = new Date(dateStr); + + const day = String(date.getDate()).padStart(2, '0'); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const year = date.getFullYear(); + + let hours = date.getHours(); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + + const ampm = hours >= 12 ? 'PM' : 'AM'; + + hours = hours % 12; + hours = hours === 0 ? 12 : hours; // convert 0 → 12 + + return `${day}/${month}/${year}, ${hours}:${minutes}:${seconds}${ampm}`; +} + diff --git a/src/e2eTest/utils/registry/action.registry.ts b/src/e2eTest/utils/registry/action.registry.ts index 047415f6c5..630d298272 100644 --- a/src/e2eTest/utils/registry/action.registry.ts +++ b/src/e2eTest/utils/registry/action.registry.ts @@ -104,6 +104,7 @@ export class ActionRegistry { ['validateDefendantDetails', new CreateCaseAction()], ['validateClaimantDetails', new CreateCaseAction()], ['validateCaseNotesDetails', new CreateCaseAction()], + ['validateCaseSummaryDetails', new CreateCaseAction()], ['addCaseNotes', new CreateCaseAction()], ['selectPaymentTypePBA', new FeeAndPayAction()], ['selectPaymentByCard', new FeeAndPayAction()], From c02b6db6f9d7b2813561bf70083e7353859ae406 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Fri, 29 May 2026 00:08:35 +0100 Subject: [PATCH 128/138] HDPI-2983: fix wording --- .../details/UnderlesseeOrMortgageInformationTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java index 811d24d8b6..ac72220f17 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/UnderlesseeOrMortgageInformationTabDetails.java @@ -22,6 +22,6 @@ public class UnderlesseeOrMortgageInformationTabDetails { @CCD(label = "Underlessee or mortgagee’s address for service known?") private String addressKnown; - @CCD(label = "Underlessee or mortgagee address for service address") + @CCD(label = "Underlessee or mortgagee address for service") private AddressUK address; } From f468b5b7580d401bb9e4fad1cfbd301a63f6199a Mon Sep 17 00:00:00 2001 From: sadmanrahman Date: Fri, 29 May 2026 09:34:03 +0100 Subject: [PATCH 129/138] HDPI-2978: Build Case Summary tab --- ...laim_submitted_date.sql => V108__add_claim_submitted_date.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V107__add_claim_submitted_date.sql => V108__add_claim_submitted_date.sql} (100%) diff --git a/src/main/resources/db/migration/V107__add_claim_submitted_date.sql b/src/main/resources/db/migration/V108__add_claim_submitted_date.sql similarity index 100% rename from src/main/resources/db/migration/V107__add_claim_submitted_date.sql rename to src/main/resources/db/migration/V108__add_claim_submitted_date.sql From c70e4c2e2453b15b38885d81735265b9c5febd23 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 09:37:14 +0100 Subject: [PATCH 130/138] HDPI-2983: fix rent details viewable on submit with no data bug --- .../reform/pcs/ccd/view/RentDetailsView.java | 8 +++++++- .../pcs/ccd/view/RentDetailsViewTest.java | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java index 188805317f..630a9fe184 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsView.java @@ -7,6 +7,8 @@ import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; import uk.gov.hmcts.reform.pcs.ccd.entity.TenancyLicenceEntity; +import java.math.BigDecimal; + @Component public class RentDetailsView { @@ -14,6 +16,11 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { TenancyLicenceEntity tenancyLicence = pcsCaseEntity.getTenancyLicence(); if (tenancyLicence != null) { + BigDecimal rentAmount = tenancyLicence.getRentAmount(); + if (rentAmount != null) { + pcsCase.setShowRentSectionPage(YesOrNo.YES); + } + RentDetails rentDetails = RentDetails.builder() .currentRent(tenancyLicence.getRentAmount()) .frequency(tenancyLicence.getRentFrequency()) @@ -23,7 +30,6 @@ public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { .build(); pcsCase.setRentDetails(rentDetails); - pcsCase.setShowRentSectionPage(YesOrNo.YES); } } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java index bde8e4111a..d5e61026bd 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/RentDetailsViewTest.java @@ -17,7 +17,9 @@ import java.math.BigDecimal; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; @@ -84,4 +86,21 @@ void shouldSetRentDetailsFields() { assertThat(rentDetails.getPerDayCorrect()).isEqualTo(VerticalYesNo.NO); } + @Test + void shouldNotSetShowRentSectionPageIfRentAmountIsNull() { + // Given + TenancyLicenceEntity tenancyLicenceEntity = mock(TenancyLicenceEntity.class); + when(pcsCaseEntity.getTenancyLicence()).thenReturn(tenancyLicenceEntity); + + // When + underTest.setCaseFields(pcsCase, pcsCaseEntity); + + // Then + ArgumentCaptor rentDetailsCaptor + = ArgumentCaptor.forClass(RentDetails.class); + + verify(pcsCase).setRentDetails(rentDetailsCaptor.capture()); + verify(pcsCase, times(0)).setShowRentSectionPage(any()); + } + } From dfc80551f61754d1c910495d4bc6323b4194c044 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 11:42:30 +0100 Subject: [PATCH 131/138] HDPI-2983: fix table name --- .../reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 70dd5050ba..309f8b2c5b 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -73,7 +73,7 @@ public class CaseDetailsTab { @CCD(label = "Additional defendant") private List> additionalDefendants; - @CCD(label = "Defendants’ circumstances") + @CCD(label = "Defendant circumstances") private DefendantCircumstanceTabDetails defendantCircumstanceDetails; @CCD(label = "Underlessee or mortgagee") From 1ec2d15a3187adfdf62599c68a388893eb7bc206 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 11:45:34 +0100 Subject: [PATCH 132/138] HDPI-2983: fix defendantCircumstances details --- .../domain/tabs/details/DefendantCircumstanceTabDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java index 6b0342d18b..f7413df9ca 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/DefendantCircumstanceTabDetails.java @@ -18,6 +18,6 @@ public class DefendantCircumstanceTabDetails { ) private String defendantCircumstancesGiven; - @CCD(label = "Defendants’ circumstances") + @CCD(label = "Details of defendants’ circumstances") private String defendantCircumstances; } From 58bbe6debb33f2e0a642382fa5d477d6f68a9cee Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 13:13:54 +0100 Subject: [PATCH 133/138] HDPI-2983: fix suspensionOfRightToBuyDetails label --- .../reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index 309f8b2c5b..a3f37e1e53 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -82,6 +82,6 @@ public class CaseDetailsTab { @CCD(label = "Demotion of tenancy claim") private DemotionOfTenancyTabDetails demotionOfTenancyDetails; - @CCD(label = "Suspension of right to buy") + @CCD(label = "Suspension of right to buy claim") private SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyDetails; } From 6e576179285c374baf4752c8ed24069ee17da482 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 16:12:50 +0100 Subject: [PATCH 134/138] HDPI-2983: move first mortgage party into own table and put rest in additional list --- .../domain/tabs/details/CaseDetailsTab.java | 5 +- .../pcs/ccd/view/CaseDetailsTabView.java | 45 ++++++++++++----- .../pcs/ccd/view/CaseDetailsTabViewTest.java | 50 +++++++++++++++++-- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java index a3f37e1e53..9219f99823 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/CaseDetailsTab.java @@ -76,7 +76,10 @@ public class CaseDetailsTab { @CCD(label = "Defendant circumstances") private DefendantCircumstanceTabDetails defendantCircumstanceDetails; - @CCD(label = "Underlessee or mortgagee") + @CCD(label = "Underlessee or mortgagee 1") + private UnderlesseeOrMortgageInformationTabDetails mortgageOneDetails; + + @CCD(label = "Additional underlessee or mortgagee") private List> mortgageDetails; @CCD(label = "Demotion of tenancy claim") diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 68bf15568a..1cd3f20fb1 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -97,8 +97,8 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { ClaimantInformationTabDetails claimantInformationTabDetails = buildClaimantInformationTabDetails(pcsCase); DefendantInformationTabDetails defendantInformationTabDetails = defendantInformationTabDetailsBuilder.buildDetailedDefendantDetails(pcsCase); - List> underlesseeMortgageTabDetailsList = - buildUnderlesseeMortgageTabDetailsList(pcsCase); + UnderlesseeOrMortgageInformationTabDetails underlesseeMortgageOneTabDetails = + buildUnderlesseeOrMortgageOneInformationTabDetails(pcsCase); DemotionOfTenancyTabDetails demotionOfTenancyTabDetails = buildDemotionOfTenancyTabDetails(pcsCase); SuspensionOfRightToBuyTabDetails suspensionOfRightToBuyTabDetails = buildSuspensionOfRightToBuyTabDetails(pcsCase); @@ -116,7 +116,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { .applicationsDetails(applicationsTabDetails) .claimantInformation(claimantInformationTabDetails) .defendantInformationDetails(defendantInformationTabDetails) - .mortgageDetails(underlesseeMortgageTabDetailsList) + .mortgageOneDetails(underlesseeMortgageOneTabDetails) .demotionOfTenancyDetails(demotionOfTenancyTabDetails) .suspensionOfRightToBuyDetails(suspensionOfRightToBuyTabDetails) .dateClaimSubmitted(dateSubmitted != null ? dateSubmitted : NO_ANSWER) @@ -134,6 +134,13 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) { caseDetailsTab.setAdditionalDefendants(additionalDefendantInformationTabDetails); caseDetailsTab.setDefendantCircumstanceDetails(buildDefendantCircumstanceTabDetails(pcsCase)); } + + if (underlesseeMortgageOneTabDetails != null) { + List> underlesseeMortgageTabDetailsList = + buildUnderlesseeMortgageTabDetailsList(pcsCase); + caseDetailsTab.setMortgageDetails(underlesseeMortgageTabDetailsList); + } + return caseDetailsTab; } @@ -412,7 +419,7 @@ private DefendantCircumstanceTabDetails buildDefendantCircumstanceTabDetails(PCS .build(); } - private List> buildUnderlesseeMortgageTabDetailsList( + private UnderlesseeOrMortgageInformationTabDetails buildUnderlesseeOrMortgageOneInformationTabDetails( PCSCase pcsCase ) { List> underlesseeMortgageParties = pcsCase.getAllUnderlesseeOrMortgagees(); @@ -420,12 +427,26 @@ private List> buildUnderle return null; } + return buildUnderlesseeMortgageTabDetails(underlesseeMortgageParties.getFirst()); + } + + private List> buildUnderlesseeMortgageTabDetailsList( + PCSCase pcsCase + ) { + List> underlesseeMortgageParties = pcsCase.getAllUnderlesseeOrMortgagees(); + if (CollectionUtils.isEmpty(underlesseeMortgageParties) || underlesseeMortgageParties.size() < 2) { + return null; + } + return underlesseeMortgageParties.stream() + .skip(1) .map(this::buildUnderlesseeMortgageTabDetails) - .toList(); + .map(details -> + ListValue.builder().value(details).build() + ).toList(); } - private ListValue buildUnderlesseeMortgageTabDetails( + private UnderlesseeOrMortgageInformationTabDetails buildUnderlesseeMortgageTabDetails( ListValue underlesseeMortgageePartyListValue ) { Party underlesseeMortgageeParty = underlesseeMortgageePartyListValue.getValue(); @@ -434,13 +455,11 @@ private ListValue buildUnderlesseeMo VerticalYesNo addressKnown = underlesseeMortgageeParty.getAddressKnown(); AddressUK address = addressKnown == VerticalYesNo.YES ? underlesseeMortgageeParty.getAddress() : null; - return ListValue.builder() - .value(UnderlesseeOrMortgageInformationTabDetails.builder() - .nameKnown(nameKnown.getLabel()) - .name(name) - .addressKnown(addressKnown.getLabel()) - .address(address) - .build()) + return UnderlesseeOrMortgageInformationTabDetails.builder() + .nameKnown(nameKnown.getLabel()) + .name(name) + .addressKnown(addressKnown.getLabel()) + .address(address) .build(); } diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index 82786167e4..3d5544c076 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -190,6 +190,12 @@ void shouldSetCaseDetailsTabFields() { .addressKnown(VerticalYesNo.YES) .address(underlesseeAddress) .build() + ), + listValue( + Party.builder() + .nameKnown(VerticalYesNo.NO) + .addressKnown(VerticalYesNo.NO) + .build() ) )) .alternativesToPossession(Set.of(DEMOTION_OF_TENANCY, SUSPENSION_OF_RIGHT_TO_BUY)) @@ -323,14 +329,18 @@ void shouldSetCaseDetailsTabFields() { .isEqualTo("preaction explanation"); assertThat(caseDetailsTab.getActionsTakenDetails().getMediationAttempted()).isEqualTo("Yes"); assertThat(caseDetailsTab.getActionsTakenDetails().getSettlementAttempted()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getMortgageDetails()).hasSize(1); - assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getNameKnown()).isEqualTo("Yes"); - assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getName()) + assertThat(caseDetailsTab.getMortgageOneDetails().getNameKnown()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageOneDetails().getName()) .isEqualTo("underlessee name"); - assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddressKnown()) + assertThat(caseDetailsTab.getMortgageOneDetails().getAddressKnown()) .isEqualTo("Yes"); - assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddress()) + assertThat(caseDetailsTab.getMortgageOneDetails().getAddress()) .isEqualTo(underlesseeAddress); + assertThat(caseDetailsTab.getMortgageDetails()).hasSize(1); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getNameKnown()).isEqualTo("No"); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getName()).isNull(); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddressKnown()).isEqualTo("No"); + assertThat(caseDetailsTab.getMortgageDetails().getFirst().getValue().getAddress()).isNull(); assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getHousingAct()) .isEqualTo(SuspensionOfRightToBuyHousingAct.SECTION_6A_2.getLabel()); assertThat(caseDetailsTab.getSuspensionOfRightToBuyDetails().getReasons()) @@ -395,6 +405,36 @@ void shouldSetCaseDetailsTabFieldsWithNoData() { assertThat(caseDetailsTab.getClaimantAddress()).isNull(); } + @Test + void shouldHandleOneUnderlesseeOrMortgageParty() { + AddressUK underlesseeAddress = AddressUK.builder().postCode("CV1 1DF").build(); + PCSCase pcsCase = PCSCase.builder() + .allUnderlesseeOrMortgagees(List.of( + listValue( + Party.builder() + .nameKnown(VerticalYesNo.YES) + .orgName("underlessee name") + .addressKnown(VerticalYesNo.YES) + .address(underlesseeAddress) + .build() + ) + )) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getMortgageDetails()).isNull(); + assertThat(caseDetailsTab.getMortgageOneDetails().getNameKnown()).isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageOneDetails().getName()) + .isEqualTo("underlessee name"); + assertThat(caseDetailsTab.getMortgageOneDetails().getAddressKnown()) + .isEqualTo("Yes"); + assertThat(caseDetailsTab.getMortgageOneDetails().getAddress()) + .isEqualTo(underlesseeAddress); + } + @Test void shouldSetPlaceholderValuesIfOnlyAlternativesToPossessionIsSet() { // Given From d50614d632b42889b839512b7e58e2f42b810c43 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Tue, 2 Jun 2026 16:49:51 +0100 Subject: [PATCH 135/138] HDPI-2983: display detailsTab_MortgageDetails --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 1 + 1 file changed, 1 insertion(+) 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 8b0815bebc..64388cdd59 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 @@ -209,6 +209,7 @@ private void buildCaseDetailsTab(ConfigBuilder builder "detailsTab_MortgageDetails!=\"\"", "### Underlessee or mortgagee entitled to claim relief against forfeiture" ) + .field("detailsTab_MortgageOneDetails") .field("detailsTab_MortgageDetails") .label( "Demotion of tenancy", From 1cc34844fbc98dfc9161f869ea1678b157f3cb5d Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 3 Jun 2026 15:08:03 +0100 Subject: [PATCH 136/138] HDPI-2983: change headers and add tenancy type other description --- .../uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 12 +++++----- .../details/TenancyLicenceTabDetails.java | 3 +++ .../pcs/ccd/view/CaseDetailsTabView.java | 3 +++ .../pcs/ccd/view/CaseDetailsTabViewTest.java | 24 +++++++++++++++++++ 4 files changed, 36 insertions(+), 6 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 64388cdd59..e829ee0c6c 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 @@ -176,7 +176,7 @@ private void buildSummaryTab(ConfigBuilder builder) { private void buildCaseDetailsTab(ConfigBuilder builder) { builder.tab("caseDetails", "Case Details") - .label("Case details", null, "### Case details") + .label("Case details", null, "## Case details") .field("detailsTab_ClaimDetails") .field("detailsTab_PropertyAddress") .field("detailsTab_GroundsForPossessionDetails") @@ -190,7 +190,7 @@ private void buildCaseDetailsTab(ConfigBuilder builder .label( "Claimant Details", "detailsTab_ClaimantInformation!=\"\"", - "### Claimant Details" + "## Claimant Details" ) .field("detailsTab_ClaimantInformation") .field("detailsTab_ClaimantAddress") @@ -199,7 +199,7 @@ private void buildCaseDetailsTab(ConfigBuilder builder .label( "Defendant Details", "detailsTab_DefendantInformationDetails!=\"\"", - "### Defendant Details" + "## Defendant Details" ) .field("detailsTab_DefendantInformationDetails") .field("detailsTab_AdditionalDefendants") @@ -207,20 +207,20 @@ private void buildCaseDetailsTab(ConfigBuilder builder .label( "Underlessee or mortgagee", "detailsTab_MortgageDetails!=\"\"", - "### Underlessee or mortgagee entitled to claim relief against forfeiture" + "## Underlessee or mortgagee entitled to claim relief against forfeiture" ) .field("detailsTab_MortgageOneDetails") .field("detailsTab_MortgageDetails") .label( "Demotion of tenancy", "detailsTab_DemotionOfTenancyDetails!=\"\"", - "### Demotion of tenancy" + "## Demotion of tenancy" ) .field("detailsTab_DemotionOfTenancyDetails") .label( "Suspension of right to buy", "detailsTab_SuspensionOfRightToBuyDetails!=\"\"", - "### Suspension of right to buy" + "## Suspension of right to buy" ) .field("detailsTab_SuspensionOfRightToBuyDetails"); } diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java index f32c4fe5af..407e639e86 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/tabs/details/TenancyLicenceTabDetails.java @@ -19,6 +19,9 @@ public class TenancyLicenceTabDetails { @CCD(label = "Tenancy, occupation contract or licence agreement type") private String typeOfTenancyLicence; + @CCD(label = "Description of contract type") + private String tenancyLicenceDescription; + @CCD(label = "Tenancy, occupation contract or licence start date") private String tenancyLicenceDate; diff --git a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java index 1cd3f20fb1..96eac4901c 100644 --- a/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java +++ b/src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java @@ -213,6 +213,9 @@ private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) return TenancyLicenceTabDetails.builder() .typeOfTenancyLicence(tenancyType != null ? tenancyType.getLabel() : NO_ANSWER) + .tenancyLicenceDescription( + tenancyType == OTHER ? tenancyLicenceDetails.getDetailsOfOtherTypeOfTenancyLicence() : null + ) .tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(DATE_FORMATTER) : NO_ANSWER) .hasCopyOfTenancyLicence(hasTenancyLicence != null ? hasTenancyLicence.getLabel() : NO_ANSWER) .tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments()) diff --git a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java index 3d5544c076..25f2bc4da1 100644 --- a/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java +++ b/src/test/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabViewTest.java @@ -43,6 +43,7 @@ import uk.gov.hmcts.reform.pcs.ccd.view.builder.GroundsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.ReasonsForPossessionTabDetailsBuilder; import uk.gov.hmcts.reform.pcs.ccd.view.builder.RentArrearsTabDetailsBuilder; +import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry; import java.math.BigDecimal; import java.time.LocalDate; @@ -168,6 +169,7 @@ void shouldSetCaseDetailsTabFields() { .arrearsJudgmentWanted(VerticalYesNo.YES) .tenancyLicenceDetails(TenancyLicenceDetails.builder() .typeOfTenancyLicence(TenancyLicenceType.OTHER) + .detailsOfOtherTypeOfTenancyLicence("other tenancy details") .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) .hasCopyOfTenancyLicence(VerticalYesNo.NO) .reasonsForNoTenancyLicenceDocuments("Reasons") @@ -312,6 +314,8 @@ void shouldSetCaseDetailsTabFields() { assertThat(caseDetailsTab.getRentArrearsDetails().getJudgmentRequested()).isEqualTo("Yes"); assertThat(caseDetailsTab.getTenancyLicenceDetails().getTypeOfTenancyLicence()) .isEqualTo("Other"); + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDescription()) + .isEqualTo("other tenancy details"); assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDate()) .isEqualTo("16 April 2024"); assertThat(caseDetailsTab.getNoticeDetails().getNoticeDate()) @@ -750,6 +754,26 @@ void shouldDisplaySubmittedDateInGmtOutsideBritishSummerTimeWhenServerTimezoneIs } } + @Test + void shouldNotSetTenancyLicenceDescriptionWhenTenancyTypeIsNotOther() { + // Given + PCSCase pcsCase = PCSCase.builder() + .legislativeCountry(LegislativeCountry.ENGLAND) + .tenancyLicenceDetails(TenancyLicenceDetails.builder() + .typeOfTenancyLicence(TenancyLicenceType.ASSURED_TENANCY) + .tenancyLicenceDate(LocalDate.of(2024, 4, 16)) + .hasCopyOfTenancyLicence(VerticalYesNo.NO) + .reasonsForNoTenancyLicenceDocuments("Reasons") + .build()) + .build(); + + // When + CaseDetailsTab caseDetailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase); + + // Then + assertThat(caseDetailsTab.getTenancyLicenceDetails().getTenancyLicenceDescription()).isNull(); + } + private static ListValue listValue(T value) { return ListValue.builder() .value(value) From 27b44e37b00668ef6ef8a37966b2d9826b21b142 Mon Sep 17 00:00:00 2001 From: gmmagruder Date: Wed, 3 Jun 2026 16:45:29 +0100 Subject: [PATCH 137/138] HDPI-2983: make Case details h1 --- src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e829ee0c6c..ee0b2fd446 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 @@ -176,7 +176,7 @@ private void buildSummaryTab(ConfigBuilder builder) { private void buildCaseDetailsTab(ConfigBuilder builder) { builder.tab("caseDetails", "Case Details") - .label("Case details", null, "## Case details") + .label("Case details", null, "# Case details") .field("detailsTab_ClaimDetails") .field("detailsTab_PropertyAddress") .field("detailsTab_GroundsForPossessionDetails") From 7efd9aa43b84f418cd8494b5917b0030e7dbe19a Mon Sep 17 00:00:00 2001 From: srinijg Date: Wed, 3 Jun 2026 19:03:17 +0100 Subject: [PATCH 138/138] Hddpi 2983 automation (#1923) --- .../data/api-data/submitCase.api.data.ts | 170 +++++++++++++++- src/e2eTest/data/page-data/home.page.data.ts | 1 + src/e2eTest/tests/caseTabs.spec.ts | 152 +++++++++++++++ .../custom-actions/createCase.action.ts | 184 ++++++++++++++++-- src/e2eTest/utils/common/string.utils.ts | 20 +- src/e2eTest/utils/controller.ts | 19 +- src/e2eTest/utils/registry/action.registry.ts | 2 +- 7 files changed, 522 insertions(+), 26 deletions(-) diff --git a/src/e2eTest/data/api-data/submitCase.api.data.ts b/src/e2eTest/data/api-data/submitCase.api.data.ts index 4bc610e049..b3fbae2a46 100644 --- a/src/e2eTest/data/api-data/submitCase.api.data.ts +++ b/src/e2eTest/data/api-data/submitCase.api.data.ts @@ -284,7 +284,7 @@ export const submitCaseApiData = { isClaimantNameCorrect: 'YES', claimantContactEmail: 'pcs-solicitor1@test.com', isCorrectClaimantContactEmail: 'YES', - orgAddressFound: "Yes", + orgAddressFound: 'Yes', organisationAddress: { AddressLine1: 'Ministry Of Justice', AddressLine2: 'Seventh Floor 102 Petty France', @@ -303,7 +303,7 @@ export const submitCaseApiData = { correspondenceAddress: { AddressLine1: '6 Second Avenue', AddressLine2: 'Oxford Street', - AddressLine3: "", + AddressLine3: '', PostTown: 'London', County: '', Country: 'United Kingdom', @@ -393,7 +393,7 @@ export const submitCaseApiData = { isClaimantNameCorrect: 'YES', claimantContactEmail: 'pcs-solicitor1@test.com', isCorrectClaimantContactEmail: 'YES', - orgAddressFound: "Yes", + orgAddressFound: 'Yes', organisationAddress: { AddressLine1: 'Ministry Of Justice', AddressLine2: 'Seventh Floor 102 Petty France', @@ -412,7 +412,7 @@ export const submitCaseApiData = { correspondenceAddress: { AddressLine1: '6 Second Avenue', AddressLine2: 'Oxford Street', - AddressLine3: "", + AddressLine3: '', PostTown: 'London', County: '', Country: 'United Kingdom', @@ -463,7 +463,7 @@ export const submitCaseApiData = { rentDetails_CalculatedDailyCharge: '3285', rentArrears_Total: '23999', rentArrears_RecoveryAttempted: 'NO', - arrearsJudgmentWanted: 'NO', + arrearsJudgmentWanted: 'NO', claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', claimantCircumstancesSelect: 'NO', hasDefendantCircumstancesInfo: 'NO', @@ -487,6 +487,164 @@ export const submitCaseApiData = { agreementClaimant: ['BELIEVE_TRUE'], }, }, + submitCasePayloadCaseDetails: { + legislativeCountry: 'England', + orgNameFound: 'Yes', + claimantType: { + value: { + code: 'PROVIDER_OF_SOCIAL_HOUSING', + label: 'Registered provider of social housing or local authority' + }, + list_items: [ + { + code: 'PRIVATE_LANDLORD', + label: 'Private landlord' + }, + { + code: 'PROVIDER_OF_SOCIAL_HOUSING', + label: 'Registered provider of social housing or local authority' + }, + { + code: 'MORTGAGE_LENDER', + label: 'Mortgage lender' + }, + { + code: 'OTHER', + label: 'Other' + } + ], + valueCode: 'PROVIDER_OF_SOCIAL_HOUSING' + }, + claimAgainstTrespassers: 'NO', + claimantName: 'Possession Claims Solicitor Org', + isClaimantNameCorrect: 'YES', + claimantContactEmail: 'pcs-solicitor1@test.com', + isCorrectClaimantContactEmail: 'YES', + orgAddressFound: 'Yes', + organisationAddress: { + AddressLine1: 'Ministry Of Justice', + AddressLine2: 'Seventh Floor 102 Petty France', + PostTown: 'London', + PostCode: 'SW1H 9AJ', + Country: 'United Kingdom' + }, + formattedClaimantContactAddress: 'Ministry Of Justice
Seventh Floor 102 Petty France
London
SW1H 9AJ', + isCorrectClaimantContactAddress: 'YES', + claimantProvidePhoneNumber: 'YES', + claimantContactPhoneNumber: '04469172429', + defendant1: { + nameKnown: 'YES', + addressKnown: 'YES', + addressSameAsPossession: 'NO', + correspondenceAddress: { + AddressLine1: '6 Second Avenue', + AddressLine2: 'Oxford Street', + AddressLine3: '', + PostTown: 'London', + County: '', + Country: 'United Kingdom', + PostCode: 'W3 7RX' + }, + firstName: 'John', + lastName: 'Doe', + }, + addAnotherDefendant: 'NO', + additionalDefendants: [ + { + value: { + nameKnown: 'NO', + addressKnown: 'NO', + addressSameAsPossession: 'NO' + }, + id: null + }, + { + value: { + nameKnown: 'NO', + addressKnown: 'NO', + addressSameAsPossession: 'NO' + }, + id: null + }, + ], + tenancy_TypeOfTenancyLicence: 'DEMOTED_TENANCY', + tenancy_TenancyLicenceDate: '2020-10-02', + tenancy_HasCopyOfTenancyLicence: 'NO', + tenancy_ReasonsForNoTenancyLicenceDocuments: 'user input no tenancy documents', + showIntroductoryDemotedOtherGroundReasonPage: 'Yes', + introGrounds_HasIntroductoryDemotedOtherGroundsForPossession: 'YES', + introGrounds_IntroductoryDemotedOrOtherGrounds: ['RENT_ARREARS', 'ANTI_SOCIAL','BREACH_OF_THE_TENANCY','ABSOLUTE_GROUNDS'], + antiSocialBehaviourGround: 'Antisocial behaviour test input', + breachOfTheTenancyGround: 'breach of tenancy test data', + absoluteGrounds: 'absolute grounds test data', + rentDetails_CurrentRent: '125000', + rentDetails_Frequency: 'WEEKLY', + rentDetails_CalculatedDailyCharge: '1429', + rentArrears_StatementDocuments: [ + { + id: '77d43175-cf1f-4feb-885f-0a0c454391c2', + value: { + document_url: 'http://dm-store-aat.service.core-compute-aat.internal/documents/fee16b4c-b9f2-4697-8f5e-10db5c51e056', + document_binary_url: 'http://dm-store-aat.service.core-compute-aat.internal/documents/fee16b4c-b9f2-4697-8f5e-10db5c51e056/binary', + document_filename: 'rentStatement.pdf', + } + } + ], + rentArrears_Total: '23999', + rentArrears_RecoveryAttempted: 'NO', + arrearsJudgmentWanted: 'YES', + preActionProtocolCompleted: 'YES', + mediationAttempted: 'YES', + settlementAttempted: 'YES', + noticeServed: 'YES', + notice_NoticePostedDate: '2025-11-10', + notice_NoticeDocuments: [], + notice_NoticeServiceMethod: 'FIRST_CLASS_POST', + claimantNamePossessiveForm: 'Possession Claims Solicitor Org’s', + claimantCircumstancesSelect: 'YES', + claimantCircumstancesDetails: 'claimant circumstances test data', + hasDefendantCircumstancesInfo: 'YES', + defendantCircumstancesInfo: 'User Input Defendants circumstances', + suspensionOfRTB_ShowHousingActsPage: 'No', + demotionOfTenancy_ShowHousingActsPage: 'Yes', + suspensionToBuyDemotionOfTenancyPages: 'No', + alternativesToPossession: ['DEMOTION_OF_TENANCY','SUSPENSION_OF_RIGHT_TO_BUY'], + suspensionOfRightToBuyActs: 'SECTION_6A_2', + demotionOfTenancyActs: 'SECTION_82A_2', + demotionOfTenancy_StatementOfExpressTermsServed: 'YES', + demotionOfTenancy_StatementOfExpressTermsDetails: 'User input terms', + demotionOrderReason: 'demotion reasons test data', + suspensionOrderReason: 'suspension of order reason', + additionalReasonsForPossession: { + hasReasons: 'YES', + reasons: 'User input for additional reasons' + }, + hasUnderlesseeOrMortgagee: 'YES', + underlesseeOrMortgagee1: { + nameKnown: 'YES', + name: 'peter', + addressKnown: 'YES', + address: { + AddressLine1: '4 Second Avenue', + AddressLine2: 'Whirlpool Street', + AddressLine3: '', + PostTown: 'London', + County: '', + Country: 'United Kingdom', + PostCode: 'W3 7RX' + } + }, + wantToUploadDocuments: 'NO', + applicationWithClaim: 'NO', + languageUsed: 'ENGLISH', + completionNextStep: 'SUBMIT_AND_PAY_NOW', + statementOfTruth: { + completedBy: 'CLAIMANT', + fullNameParty: 'fg', + positionParty: 'fg', + agreementClaimant: ['BELIEVE_TRUE'], + }, + }, submitCasePayloadDefault: { legislativeCountry: 'England', claimantType: { @@ -594,4 +752,4 @@ export const submitCaseApiData = { submitCaseApiEndPoint: () => `/cases/${process.env.CASE_NUMBER}/events`, -}; +}; \ No newline at end of file diff --git a/src/e2eTest/data/page-data/home.page.data.ts b/src/e2eTest/data/page-data/home.page.data.ts index cd5ebf0c71..4b794b0c5f 100644 --- a/src/e2eTest/data/page-data/home.page.data.ts +++ b/src/e2eTest/data/page-data/home.page.data.ts @@ -8,5 +8,6 @@ export const home = caseParties: 'Case Parties', caseNotes: 'Notes', caseSummary: 'Summary', + caseDetails: 'Case Details', signOutButton: 'Sign out' } diff --git a/src/e2eTest/tests/caseTabs.spec.ts b/src/e2eTest/tests/caseTabs.spec.ts index 1f3ad6d563..f5476d51a9 100644 --- a/src/e2eTest/tests/caseTabs.spec.ts +++ b/src/e2eTest/tests/caseTabs.spec.ts @@ -16,6 +16,10 @@ test.beforeEach(async ({ page }, testInfo) => { await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseSummary }); await performAction('fetchCurrentUserAPI'); + } else if (testInfo.title.includes('Details')) { + await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); + await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseDetails }); + await performAction('fetchCurrentUserAPI'); } else { await performAction('createCaseAPI', { data: createCaseApiData.createCasePayload }); await performAction('submitCaseAPI', { data: submitCaseApiData.submitCasePayloadCaseTab }); @@ -142,4 +146,152 @@ test.describe('[Case tabs - England Journey] @nightly', async () => { }); + test('Case tabs - Case Details tab test @MAC @regression', async () => { + await performAction('clickTab', home.caseDetails); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Claim details', + table: 'Claim details' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Address of property', + table: 'Address of property to be repossessed' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Claimant details', + table: 'Claimant' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Claimant address', + table: 'Claimant address for service' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Claimant contact details', + table: 'Claimant contact details' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Claimant circumstances', + table: 'Claimant circumstances' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Defendant Case details', + table: 'Defendant 1' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Defendant circumstances', + table: 'Defendant circumstances' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Grounds of possession', + table: 'Grounds for possession' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Rent arrears Case details', + table: 'Details of rent arrears' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Tenancy and Occupation Case details', + table: 'Tenancy, occupation contract or licence details' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Notice Case details', + table: 'Notice details' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Actions taken', + table: 'Actions already taken' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Reasons for possession', + table: 'Reasons for possession' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Applications', + table: 'Applications' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Demotion of tenancy', + table: 'Demotion of tenancy claim' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Suspension of right to buy', + table: 'Suspension of right to buy claim' + }); + await performAction('validateCaseSummaryDetails', { + defendant1NameKnown: submitCaseApiData.submitCasePayloadCaseDetails.defendant1.nameKnown, + additionalDefendants: submitCaseApiData.submitCasePayloadCaseDetails.addAnotherDefendant, + createPayload: createCaseApiData.createCasePayload, + submitPayload: submitCaseApiData.submitCasePayloadCaseDetails, + section: 'Underlessee or mortgagee', + table: 'Underlessee or mortgagee 1' + }); + + }); }); diff --git a/src/e2eTest/utils/actions/custom-actions/createCase.action.ts b/src/e2eTest/utils/actions/custom-actions/createCase.action.ts index 08d63b090f..52e3771cf3 100644 --- a/src/e2eTest/utils/actions/custom-actions/createCase.action.ts +++ b/src/e2eTest/utils/actions/custom-actions/createCase.action.ts @@ -1047,7 +1047,7 @@ export class CreateCaseAction implements IAction { let caseSummary = new Map(); let submitPayLoad = caseSummarySection.submitPayload as Record; let createPayLoad = caseSummarySection.createPayload as Record; - + switch (caseSummarySection.section) { case 'Defendant details': if (submitPayLoad.defendant1.nameKnown === 'YES') { @@ -1071,6 +1071,37 @@ export class CreateCaseAction implements IAction { } break; + case 'Defendant Case details': + caseSummary.set(`Defendant 1’s name known?`, formatWord(submitPayLoad.defendant1.nameKnown)); + caseSummary.set(`First name`, submitPayLoad.defendant1.firstName); + caseSummary.set(`Last name`, submitPayLoad.defendant1.lastName); + + if (submitPayLoad.defendant1.addressKnown === 'YES' && submitPayLoad.defendant1.addressSameAsPossession === 'YES') { + const address = submitPayLoad.formattedClaimantContactAddress.split('
'); + caseSummary.set(`Defendant 1’s address for service known?`, formatWord(submitPayLoad.defendant1.addressKnown)); + caseSummary.set(`Building and Street`, address[0]); + caseSummary.set(`Address Line 2`, address[1]); + caseSummary.set(`Town or City`, address[2]); + caseSummary.set(`Postcode/Zipcode`, address[3]); + caseSummary.set('Country', 'United Kingdom') + + } else if (submitPayLoad.defendant1.addressKnown === 'YES' && submitPayLoad.defendant1.addressSameAsPossession === 'NO') { + caseSummary.set(`Defendant 1’s address for service known?`, formatWord(submitPayLoad.defendant1.addressKnown)); + caseSummary.set(`Building and Street`, submitPayLoad.defendant1.correspondenceAddress.AddressLine1); + caseSummary.set(`Address Line 2`, submitPayLoad.defendant1.correspondenceAddress.AddressLine2); + caseSummary.set(`Town or City`, submitPayLoad.defendant1.correspondenceAddress.PostTown); + caseSummary.set(`Postcode/Zipcode`, submitPayLoad.defendant1.correspondenceAddress.PostCode); + caseSummary.set('Country', 'United Kingdom') + } + break; + + case 'Defendant circumstances': + caseSummary.set(`Is there any information you’re required to provide, or you want to provide, about the defendants’ circumstances?`, formatWord(submitPayLoad.hasDefendantCircumstancesInfo)); + if (submitPayLoad.hasDefendantCircumstancesInfo === 'YES') { + caseSummary.set(`Details of defendants’ circumstances`, submitPayLoad.defendantCircumstancesInfo); + } + break; + case 'Address of property': caseSummary.set(`Building and Street`, createPayLoad.propertyAddress.AddressLine1); caseSummary.set(`Address Line 2`, createPayLoad.propertyAddress.AddressLine2); @@ -1083,18 +1114,54 @@ export class CreateCaseAction implements IAction { caseSummary.set(`Claimant name`, submitPayLoad.claimantName); break; + case 'Claimant address': + caseSummary.set(`Building and Street`, submitPayLoad.organisationAddress.AddressLine1); + caseSummary.set(`Address Line 2`, submitPayLoad.organisationAddress.AddressLine2); + caseSummary.set(`Town or City`, submitPayLoad.organisationAddress.PostTown); + caseSummary.set(`Postcode/Zipcode`, submitPayLoad.organisationAddress.PostCode); + caseSummary.set('Country', submitPayLoad.organisationAddress.Country); + break; + + case 'Claimant contact details': + caseSummary.set(`Email address for notifications`, submitPayLoad.claimantContactEmail); + caseSummary.set(`Do you want to provide a phone number for urgent updates about your case?`, formatWord(submitPayLoad.claimantProvidePhoneNumber)); + caseSummary.set(`Contact phone number`, submitPayLoad.claimantContactPhoneNumber); + break; + + case 'Claimant circumstances': + caseSummary.set(`Is there any information you’d like to provide about the claimant’s circumstances?`, formatWord(submitPayLoad.claimantCircumstancesSelect)); + if (submitPayLoad.claimantCircumstancesSelect === 'YES') { + caseSummary.set(`Claimant circumstances`, submitPayLoad.claimantCircumstancesDetails); + } + break; + case 'Tenancy and Occupation': caseSummary.set(`Tenancy, occupation contract or licence agreement type`, (submitPayLoad.tenancy_TypeOfTenancyLicence) .toLowerCase() .replace(/_/g, " ") .replace(/^\w/, (c: string) => c.toUpperCase()) ); - caseSummary.set(`Tenancy, occupation contract or licence agreement start date`, formatDate(submitPayLoad.tenancy_TenancyLicenceDate)); + caseSummary.set(`Tenancy, occupation contract or licence agreement start date`, formatDate(submitPayLoad.tenancy_TenancyLicenceDate, 'DD/MM/YYYY')); + break; + + case 'Tenancy and Occupation Case details': + caseSummary.set(`Tenancy, occupation contract or licence agreement type`, (submitPayLoad.tenancy_TypeOfTenancyLicence) + .toLowerCase() + .replace(/_/g, " ") + .replace(/^\w/, (c: string) => c.toUpperCase()) + ); + caseSummary.set(`Tenancy, occupation contract or licence start date`, formatDate(submitPayLoad.tenancy_TenancyLicenceDate, 'DD/MONTH/YYYY')); + caseSummary.set(`Do you have a copy of the tenancy or licence agreement?`, formatWord(submitPayLoad.tenancy_HasCopyOfTenancyLicence)); + caseSummary.set(`Details of why you do not have a copy`, submitPayLoad.tenancy_ReasonsForNoTenancyLicenceDocuments); break; case 'Grounds of possession': if (submitPayLoad.introGrounds_HasIntroductoryDemotedOtherGroundsForPossession === 'YES') { - caseSummary.set(`Grounds`, formatText(submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds[0])); + caseSummary.set(`Grounds`, submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds.map(formatText). + map((item: string) => + item === "Anti social" ? "Antisocial behaviour" : item + ) + .join(',')); }; break; @@ -1106,10 +1173,18 @@ export class CreateCaseAction implements IAction { caseSummary.set(`Judgment requested for the outstanding arrears?`, formatWord(submitPayLoad.arrearsJudgmentWanted)); break; - case 'Notice': + case 'Rent arrears Case details': + caseSummary.set(`Rent amount`, formatCurrency(submitPayLoad.rentDetails_CurrentRent)); + caseSummary.set(`How rent is calculated`, formatWord(submitPayLoad.rentDetails_Frequency)); + caseSummary.set(`Daily rate`, formatCurrency(submitPayLoad.rentDetails_CalculatedDailyCharge)); + caseSummary.set(`Previous steps taken to recover rent arrears?`, formatWord(submitPayLoad.rentArrears_RecoveryAttempted)); + caseSummary.set(`Rent statement`, submitPayLoad.rentArrears_StatementDocuments?.[0]?.value?.document_filename); + caseSummary.set(`Rent arrears total at the time of claim issue`, formatCurrency(submitPayLoad.rentArrears_Total)); + caseSummary.set(`Judgment requested for the outstanding arrears?`, formatWord(submitPayLoad.arrearsJudgmentWanted)); + break; + case 'Notice': const serviceMethod = submitPayLoad.notice_NoticeServiceMethod; - const dateServed = serviceMethod === 'FIRST_CLASS_POST' ? submitPayLoad.notice_NoticePostedDate @@ -1120,12 +1195,99 @@ export class CreateCaseAction implements IAction { if (dateServed) { const formattedDate = serviceMethod === 'FIRST_CLASS_POST' - ? formatDate(dateServed) + ? formatDate(dateServed,'DD/MM/YYYY') : formatDateTime(dateServed); caseSummary.set('Date notice was served', formattedDate); } + break; + + case 'Notice Case details': + const serviceMethodCaseDetails = submitPayLoad.notice_NoticeServiceMethod; + const dateServedCaseDetails = + serviceMethodCaseDetails === 'FIRST_CLASS_POST' + ? submitPayLoad.notice_NoticePostedDate + : serviceMethodCaseDetails === 'EMAIL' + ? submitPayLoad.notice_NoticeEmailSentDateTime + : null; + const methodOfService = serviceMethodCaseDetails === 'FIRST_CLASS_POST' ? 'By first class post or other service which provides for delivery on the next business day' : serviceMethodCaseDetails === 'EMAIL' ? 'By Email' : null; + caseSummary.set('Has notice been served?',formatWord(submitPayLoad.noticeServed)); + caseSummary.set('Method of service', methodOfService as string); + + if (dateServedCaseDetails) { + const formattedDate = + serviceMethodCaseDetails === 'FIRST_CLASS_POST' + ? formatDate(dateServedCaseDetails, 'DD/MONTH/YYYY') + : formatDateTime(dateServedCaseDetails); + + caseSummary.set('Date and time notice served (if applicable)', formattedDate); + } + break; + + case 'Claim details': + caseSummary.set(`Claimant type`, submitPayLoad.claimantType.value.label); + caseSummary.set(`Is your claim a trespass claim?`, formatWord(submitPayLoad.claimAgainstTrespassers)); + break; + case 'Actions taken': + caseSummary.set(`Pre-action protocol followed?`, formatWord(submitPayLoad.preActionProtocolCompleted)); + caseSummary.set(`Mediation attempted?`, formatWord(submitPayLoad.mediationAttempted)); + caseSummary.set(`Settlement attempted?`, formatWord(submitPayLoad.settlementAttempted)); + break; + + case 'Reasons for possession': + if (submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds?.includes('ANTI_SOCIAL')) { + caseSummary.set(`Reasons for claiming possession under Antisocial behaviour`, submitPayLoad.antiSocialBehaviourGround); + } + if (submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds?.includes('BREACH_OF_THE_TENANCY')) { + caseSummary.set(`Reasons for claiming possession under Breach of the tenancy`, submitPayLoad.breachOfTheTenancyGround); + } + if (submitPayLoad.introGrounds_IntroductoryDemotedOrOtherGrounds?.includes('ABSOLUTE_GROUNDS')) { + caseSummary.set(`Reasons for claiming possession under Absolute grounds`, submitPayLoad.absoluteGrounds); + } + caseSummary.set(`Do you have any additional reasons for possession?`, formatWord(submitPayLoad.additionalReasonsForPossession.hasReasons)); + if (submitPayLoad.additionalReasonsForPossession.hasReasons === 'YES') { + caseSummary.set(`Details of additional reasons`, formatWord(submitPayLoad.additionalReasonsForPossession.reasons)); + } + break; + + case 'Applications': + caseSummary.set(`Are you planning to make an application at the same time as your claim?`, formatWord(submitPayLoad.applicationWithClaim)); + break; + + case 'Demotion of tenancy': + if (submitPayLoad.alternativesToPossession?.includes('DEMOTION_OF_TENANCY')) { + const sectionOfHousingAct = submitPayLoad.demotionOfTenancyActs === 'SECTION_82A_2' ? 'Section 82A(2) of the Housing Act 1985' : 'Section 6A(2) of the Housing Act 1988'; + caseSummary.set(`Section of the Housing Act demotion of tenancy claim made under`, sectionOfHousingAct); + caseSummary.set(`Have you served the defendants with a statement of the express terms which will apply to the demoted tenancy?`, formatWord(submitPayLoad.demotionOfTenancy_StatementOfExpressTermsServed)); + if (submitPayLoad.demotionOfTenancy_StatementOfExpressTermsServed === 'YES') { + caseSummary.set(`Details of terms`, submitPayLoad.demotionOfTenancy_StatementOfExpressTermsDetails) + } + caseSummary.set(`Reasons for requesting a demotion of tenancy order`, submitPayLoad.demotionOrderReason) + } + break; + + case 'Suspension of right to buy': + if (submitPayLoad.alternativesToPossession?.includes('SUSPENSION_OF_RIGHT_TO_BUY')) { + const sectionOfHousingActSuspension = submitPayLoad.suspensionOfRightToBuyActs === 'SECTION_82A_2' ? 'Section 82A(2) of the Housing Act 1985' : 'Section 6A(2) of the Housing Act 1988'; + caseSummary.set(`Section of the Housing Act suspension of right to buy claim made under`, sectionOfHousingActSuspension); + caseSummary.set(`Reasons for requesting suspension of right to buy order`, submitPayLoad.suspensionOrderReason) + } + break; + + case 'Underlessee or mortgagee': + if (submitPayLoad.hasUnderlesseeOrMortgagee === 'YES') { + caseSummary.set(`Underlessee or mortgagee’s name known?`, formatWord(submitPayLoad.underlesseeOrMortgagee1.nameKnown)); + caseSummary.set(`Name`, submitPayLoad.underlesseeOrMortgagee1.nameKnown === 'YES' ? submitPayLoad.underlesseeOrMortgagee1.name : ''); + caseSummary.set(`Underlessee or mortgagee’s address for service known?`, formatWord(submitPayLoad.underlesseeOrMortgagee1.addressKnown)); + if (submitPayLoad.underlesseeOrMortgagee1.addressKnown === 'YES') { + caseSummary.set(`Building and Street`, submitPayLoad.underlesseeOrMortgagee1.address.AddressLine1); + caseSummary.set(`Address Line 2`, submitPayLoad.underlesseeOrMortgagee1.address.AddressLine2); + caseSummary.set(`Town or City`, submitPayLoad.underlesseeOrMortgagee1.address.PostTown); + caseSummary.set(`Postcode/Zipcode`, submitPayLoad.underlesseeOrMortgagee1.address.PostCode); + caseSummary.set('Country', submitPayLoad.underlesseeOrMortgagee1.address.Country); + } + } break; default: @@ -1135,8 +1297,8 @@ export class CreateCaseAction implements IAction { await this.caseTabTableData(page, caseSummarySection.table as string); const misMatchMap = compareMaps(caseSummary, caseTabMap, { - name1: 'CaseSummary', - name2: 'CaseSummaryTab', + name1: `${caseSummarySection.section}`, + name2: 'CaseSummaryDetailsTab', }) if (misMatchMap.size > 0) { @@ -1148,9 +1310,9 @@ export class CreateCaseAction implements IAction { console.log(`• key: "${String(key)}" → Expected: ${expectedValue} | Actual: ${actualValue}`); } console.log(`\n********** END OF FAILURE LIST. ***************`); - throw new Error(`Case Summary validations failed for ${misMatchMap.size} ${misMatchMap.size === 1 ? 'item' : 'items'}`); + throw new Error(`Case Summary/Details validations failed for ${misMatchMap.size} ${misMatchMap.size === 1 ? 'item' : 'items'} in "${caseSummarySection.section}" section`); } else { - console.log(`\n✅ Case Summary VALIDATION for section ${caseSummarySection.section} PASSED!\n`); + console.log(`\n✅ Case Summary/Details VALIDATION for section "${caseSummarySection.section}" PASSED!\n`); } caseTabMap.clear(); @@ -1193,4 +1355,4 @@ export class CreateCaseAction implements IAction { } } }; -} +} \ No newline at end of file diff --git a/src/e2eTest/utils/common/string.utils.ts b/src/e2eTest/utils/common/string.utils.ts index 13f7d3d398..c2ee19a98e 100644 --- a/src/e2eTest/utils/common/string.utils.ts +++ b/src/e2eTest/utils/common/string.utils.ts @@ -48,10 +48,23 @@ export function getCurrentBSTTime(): string { return formatted.replace(/am|pm/, (match) => match.toUpperCase()); } -/* convert YYY-MM-DD to DD/MM/YYYY format */ -export function formatDate(dateStr: string): string { +/* convert YYY-MM-DD to DD/MM/YYYY format or DD MONTH YYYY */ +export function formatDate(dateStr: string, formatType: string): string { + const date = new Date(dateStr); - return date.toLocaleDateString("en-GB"); + let finalDate: string = ''; + if (formatType === 'DD/MM/YYYY') { + finalDate = date.toLocaleDateString("en-GB"); + } else if (formatType === 'DD/MONTH/YYYY') { + + const day = date.getDate(); + const month = date.toLocaleString("en-GB", { month: "long" }); + const year = date.getFullYear(); + + finalDate = `${day} ${month} ${year}`; + } + return finalDate; + } /* convert string for ex RENT_ARREARS to Rent arrears */ @@ -92,4 +105,3 @@ export function formatDateTime(dateStr: string): string { return `${day}/${month}/${year}, ${hours}:${minutes}:${seconds}${ampm}`; } - diff --git a/src/e2eTest/utils/controller.ts b/src/e2eTest/utils/controller.ts index 42b456c543..6c9f2281d5 100644 --- a/src/e2eTest/utils/controller.ts +++ b/src/e2eTest/utils/controller.ts @@ -55,10 +55,10 @@ async function validatePageIfNavigated(action: string): Promise { await performValidation('autoValidatePageContent'); try { await test.step("Running Accessibility Scan", async () => { - await new AxeUtils(executor.page).audit({ - exclude: axe_Exclusions, - }); + await new AxeUtils(executor.page).audit({ + exclude: axe_Exclusions, }); + }); } catch (error) { const errorMessage = String((error as Error).message || error).toLowerCase(); if (errorMessage.includes('execution context was destroyed') || @@ -73,7 +73,7 @@ async function validatePageIfNavigated(action: string): Promise { } function captureDataForCYA(action: string, fieldName?: actionData | actionRecord, value?: actionData | actionRecord): void { - if (action === 'selectClaimantType' || action ==='addCaseNotes') { + if (action === 'selectClaimantType' || action === 'addCaseNotes') { captureDataForCYAPage = true; } @@ -97,8 +97,19 @@ export async function performAction(action: string, fieldName?: actionData | act const obj = fieldName as Record; displayValue = { ...obj, password: '*'.repeat(String(obj.password).length) }; displayFieldName = displayValue; + } else if (typeof fieldName === 'object' && fieldName !== null && Object.keys(fieldName).some(key => key.includes('Payload'))) { + const obj = fieldName as Record; + displayValue = Object.fromEntries( + Object.entries(obj).map(([key, value]) => + key.includes('Payload') + ? [key, 'Payload is Input'] + : [key, value] + ) + ); + displayFieldName = displayValue; } + const stepText = `${action}${displayFieldName !== undefined ? ` - ${typeof displayFieldName === 'object' ? readValuesFromInputObjects(displayFieldName) : displayFieldName}` : ''}${displayValue !== undefined ? ` with value '${typeof displayValue === 'object' ? readValuesFromInputObjects(displayValue) : displayValue}'` : ''}`; await test.step(stepText, async () => { await actionInstance.execute(executor.page, action, fieldName, value); diff --git a/src/e2eTest/utils/registry/action.registry.ts b/src/e2eTest/utils/registry/action.registry.ts index 268b8987f3..44121fcfd6 100644 --- a/src/e2eTest/utils/registry/action.registry.ts +++ b/src/e2eTest/utils/registry/action.registry.ts @@ -136,4 +136,4 @@ export class ActionRegistry { static getAvailableActions(): string[] { return Array.from(this.actions.keys()); } -} +} \ No newline at end of file