Skip to content

Commit

Permalink
DFPL-2639: Move living situation (+ details) to the confidential tab (#…
Browse files Browse the repository at this point in the history
…5796)

Co-authored-by: prabhamuthu15 <[email protected]>
  • Loading branch information
DanCatchpole and prabhamuthu15 authored Jan 6, 2025
1 parent 8810d75 commit 0da2a55
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
29 changes: 22 additions & 7 deletions service/src/main/java/uk/gov/hmcts/reform/fpl/model/Child.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static java.util.UUID.randomUUID;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import static org.apache.commons.lang3.ObjectUtils.isEmpty;

@Data
@Builder(toBuilder = true)
Expand Down Expand Up @@ -49,6 +50,8 @@ public Party toParty() {
public Child extractConfidentialDetails() {
return this.toBuilder()
.party(ChildParty.builder()
.livingSituation(this.party.getLivingSituation())
.livingSituationDetails(this.party.getLivingSituationDetails())
.firstName(this.party.getFirstName())
.lastName(this.party.getLastName())
.address(this.party.getAddress())
Expand All @@ -61,21 +64,33 @@ public Child extractConfidentialDetails() {

@Override
public Child addConfidentialDetails(Party party) {
ChildParty.ChildPartyBuilder partyBuilder = this.getParty().toBuilder()
.firstName(party.getFirstName())
.lastName(party.getLastName())
.address(party.getAddress())
.telephoneNumber(party.getTelephoneNumber())
.email(party.getEmail());

// Do not nullify old data that may not have been moved over prior to DFPL-2639
if (!isEmpty(((ChildParty) party).getLivingSituation())) {
partyBuilder.livingSituation(((ChildParty) party).getLivingSituation());
}

if (!isEmpty(((ChildParty) party).getLivingSituationDetails())) {
partyBuilder.livingSituationDetails(((ChildParty) party).getLivingSituationDetails());
}

return this.toBuilder()
.party(this.getParty().toBuilder()
.firstName(party.getFirstName())
.lastName(party.getLastName())
.address(party.getAddress())
.telephoneNumber(party.getTelephoneNumber())
.email(party.getEmail())
.build())
.party(partyBuilder.build())
.build();
}

@Override
public Child removeConfidentialDetails() {
return this.toBuilder()
.party(this.party.toBuilder()
.livingSituation(null)
.livingSituationDetails(null)
.address(null)
.telephoneNumber(null)
.email(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ void shouldRemoveConfidentialDetailsFromCaseDetailsWhenNoConfidentialDetails() {
assertThat(caseDetails.getData()).isEmpty();
}

@Test
void shouldNotOverrideOldDataIfLivingDetailsNotHiddenYet() {
Element<Child> originalChild = childWithRemovedConfidentialFieldsWithLivingSituation(ID);
Element<Child> confDetails = childWithConfidentialFieldsAndShowAddressButNoLivingSituation(ID);
CaseData caseData = CaseData.builder()
.children1(List.of(originalChild))
.confidentialChildren(List.of(confDetails))
.build();

List<Element<Child>> updatedChildren = service.prepareCollection(caseData.getAllChildren(),
caseData.getConfidentialChildren(), Child.expandCollection());

assertThat(updatedChildren.get(0).getValue().getParty())
.extracting("livingSituation", "livingSituationDetails")
.containsExactly("Living with parents", "Details here");
}

private ChildParty.ChildPartyBuilder baseChildBuilder(String detailsHidden) {
return ChildParty.builder()
Expand All @@ -205,12 +221,34 @@ private Element<Child> childWithRemovedConfidentialFields(UUID id) {
.build());
}

private Element<Child> childWithRemovedConfidentialFieldsWithLivingSituation(UUID id) {
// Prior to DFPL-2639, living situation + details were not confidential
return element(id, Child.builder()
.party(baseChildBuilder(CONFIDENTIAL)
.livingSituation("Living with parents")
.livingSituationDetails("Details here")
.build())
.build());
}

private Element<Child> childWithConfidentialFieldsAndShowAddressButNoLivingSituation(UUID id) {
return element(id, Child.builder()
.party(baseChildBuilder(NO_VALUE)
.email(EmailAddress.builder().email("[email protected]").build())
.address(Address.builder().addressLine1("Address Line 1").build())
.telephoneNumber(Telephone.builder().telephoneNumber("01227 831393").build())
.showAddressInConfidentialTab("Yes")
.build())
.build());
}

private Element<Child> childWithConfidentialFields(UUID id, String detailsHidden) {
return element(id, Child.builder()
.party(baseChildBuilder(detailsHidden)
.email(EmailAddress.builder().email("[email protected]").build())
.address(Address.builder().addressLine1("Address Line 1").build())
.telephoneNumber(Telephone.builder().telephoneNumber("01227 831393").build())
.livingSituation("Living in a refuge")
.build())
.build());
}
Expand All @@ -222,6 +260,7 @@ private Element<Child> childWithConfidentialFieldsAndShowAddress() {
.address(Address.builder().addressLine1("Address Line 1").build())
.telephoneNumber(Telephone.builder().telephoneNumber("01227 831393").build())
.showAddressInConfidentialTab("Yes")
.livingSituation("Living in a refuge")
.build())
.build());
}
Expand Down

0 comments on commit 0da2a55

Please sign in to comment.