From c9fc2107eb1ee79119386216b2b5610f956ada2b Mon Sep 17 00:00:00 2001 From: "Chak Shing, Lo" Date: Thu, 28 Nov 2024 14:42:47 +0000 Subject: [PATCH 01/20] Revert "Roll back DFPL 2546 (#5746)" This reverts commit afee2046fe0deb2db830660e3277513b8ab8eb7c. --- .../others/changeOtherToRespondent.json | 41 +++++++++++------- .../respondents/amendRespondents.json | 41 +++++++++++------- .../respondents/enterRespondents.json | 43 +++++++++++-------- .../CareSupervision/2_Others.json | 37 ++++++++++------ .../CareSupervision/2_RespondentParty.json | 17 ++++++-- .../CareSupervision/HearingBooking.json | 3 +- .../CareSupervision/IsAddressKnowList.json | 23 ++++++++++ .../fpl/controllers/ChangeFromOtherUtils.java | 13 +++--- .../OthersControllerAboutToSubmitTest.java | 7 +-- ...ControllerChangeFromOtherMidEventTest.java | 5 ++- .../fpl/controllers/OthersController.java | 2 +- .../fpl/controllers/RespondentController.java | 16 ++++++- .../reform/fpl/enums/IsAddressKnowType.java | 15 +++++++ .../uk/gov/hmcts/reform/fpl/model/Other.java | 12 +----- .../hmcts/reform/fpl/model/Respondent.java | 4 +- .../reform/fpl/model/RespondentParty.java | 10 ++--- .../reform/fpl/service/OthersService.java | 35 ++++++++------- .../reform/fpl/service/RespondentService.java | 35 +++++++++------ .../respondent/RespondentValidator.java | 4 +- .../reform/ccd/model/RespondentPartyTest.java | 4 +- ...lacementEventsHandlerNotificationTest.java | 6 +-- .../reform/fpl/service/OthersServiceTest.java | 25 ++++++++--- .../fpl/service/RespondentServiceTest.java | 24 ++++++++--- .../fpl/service/SendDocumentServiceTest.java | 9 ++-- .../respondent/RespondentValidatorTest.java | 8 ++-- 25 files changed, 289 insertions(+), 150 deletions(-) create mode 100644 ccd-definition/FixedLists/CareSupervision/IsAddressKnowList.json create mode 100644 service/src/main/java/uk/gov/hmcts/reform/fpl/enums/IsAddressKnowType.java diff --git a/ccd-definition/CaseEventToComplexTypes/others/changeOtherToRespondent.json b/ccd-definition/CaseEventToComplexTypes/others/changeOtherToRespondent.json index dd166386f71..cdb2b719465 100644 --- a/ccd-definition/CaseEventToComplexTypes/others/changeOtherToRespondent.json +++ b/ccd-definition/CaseEventToComplexTypes/others/changeOtherToRespondent.json @@ -56,11 +56,20 @@ "DisplayContext": "MANDATORY" }, { + "LiveFrom": "01/01/2017", "ID": "ChangeOtherToRespondent", "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", - "ListElementCode": "party.address", + "ListElementCode": "party.addressAutoConfidentialLabel", "FieldDisplayOrder": 7, + "DisplayContext": "OPTIONAL" + }, + { + "ID": "ChangeOtherToRespondent", + "CaseEventID": "changeOtherToRespondent", + "CaseFieldID": "transformedRespondent", + "ListElementCode": "party.address", + "FieldDisplayOrder": 8, "DisplayContext": "MANDATORY" }, { @@ -117,7 +126,7 @@ "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", "ListElementCode": "party.telephoneNumber", - "FieldDisplayOrder": 8, + "FieldDisplayOrder": 9, "DisplayContext": "OPTIONAL" }, { @@ -139,33 +148,33 @@ "ID": "ChangeOtherToRespondent", "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", - "ListElementCode": "party.relationshipLabel", - "FieldDisplayOrder": 9, - "DisplayContext": "READONLY", - "FieldShowCondition": "party!=\"SHOW_LABEL\"" + "ListElementCode": "party.contactDetailsHidden", + "FieldDisplayOrder": 10, + "DisplayContext": "OPTIONAL" }, { "ID": "ChangeOtherToRespondent", "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", - "ListElementCode": "party.relationshipToChild", - "FieldDisplayOrder": 10, + "ListElementCode": "party.contactDetailsHiddenReason", + "FieldDisplayOrder": 11, "DisplayContext": "OPTIONAL" }, { "ID": "ChangeOtherToRespondent", "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", - "ListElementCode": "party.contactDetailsHidden", - "FieldDisplayOrder": 11, - "DisplayContext": "OPTIONAL" + "ListElementCode": "party.relationshipLabel", + "FieldDisplayOrder": 12, + "DisplayContext": "READONLY", + "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, { "ID": "ChangeOtherToRespondent", "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", - "ListElementCode": "party.contactDetailsHiddenReason", - "FieldDisplayOrder": 12, + "ListElementCode": "party.relationshipToChild", + "FieldDisplayOrder": 13, "DisplayContext": "OPTIONAL" }, { @@ -173,7 +182,7 @@ "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", "ListElementCode": "party.proceedingsLabel", - "FieldDisplayOrder": 13, + "FieldDisplayOrder": 14, "DisplayContext": "READONLY", "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, @@ -182,7 +191,7 @@ "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", "ListElementCode": "party.litigationIssues", - "FieldDisplayOrder": 14, + "FieldDisplayOrder": 15, "DisplayContext": "OPTIONAL" }, { @@ -190,7 +199,7 @@ "CaseEventID": "changeOtherToRespondent", "CaseFieldID": "transformedRespondent", "ListElementCode": "party.litigationIssuesDetails", - "FieldDisplayOrder": 15, + "FieldDisplayOrder": 16, "DisplayContext": "OPTIONAL" }, { diff --git a/ccd-definition/CaseEventToComplexTypes/respondents/amendRespondents.json b/ccd-definition/CaseEventToComplexTypes/respondents/amendRespondents.json index 7e5d6d1bc9b..faacef250d4 100644 --- a/ccd-definition/CaseEventToComplexTypes/respondents/amendRespondents.json +++ b/ccd-definition/CaseEventToComplexTypes/respondents/amendRespondents.json @@ -67,8 +67,17 @@ "ID": "AmendRespondents", "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.address", + "ListElementCode": "party.addressAutoConfidentialLabel", "FieldDisplayOrder": 7, + "DisplayContext": "OPTIONAL" + }, + { + "LiveFrom": "01/01/2017", + "ID": "AmendRespondents", + "CaseEventID": "amendRespondents", + "CaseFieldID": "respondents1", + "ListElementCode": "party.address", + "FieldDisplayOrder": 8, "DisplayContext": "MANDATORY" }, { @@ -126,7 +135,7 @@ "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.telephoneNumber", - "FieldDisplayOrder": 8, + "FieldDisplayOrder": 9, "DisplayContext": "OPTIONAL" }, { @@ -151,18 +160,17 @@ "ID": "AmendRespondents", "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.relationshipLabel", - "FieldDisplayOrder": 9, - "DisplayContext": "READONLY", - "FieldShowCondition": "party!=\"SHOW_LABEL\"" + "ListElementCode": "party.contactDetailsHidden", + "FieldDisplayOrder": 10, + "DisplayContext": "OPTIONAL" }, { "LiveFrom": "01/01/2017", "ID": "AmendRespondents", "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.relationshipToChild", - "FieldDisplayOrder": 10, + "ListElementCode": "party.contactDetailsHiddenReason", + "FieldDisplayOrder": 11, "DisplayContext": "OPTIONAL" }, { @@ -170,17 +178,18 @@ "ID": "AmendRespondents", "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.contactDetailsHidden", - "FieldDisplayOrder": 11, - "DisplayContext": "OPTIONAL" + "ListElementCode": "party.relationshipLabel", + "FieldDisplayOrder": 12, + "DisplayContext": "READONLY", + "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, { "LiveFrom": "01/01/2017", "ID": "AmendRespondents", "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.contactDetailsHiddenReason", - "FieldDisplayOrder": 12, + "ListElementCode": "party.relationshipToChild", + "FieldDisplayOrder": 13, "DisplayContext": "OPTIONAL" }, { @@ -189,7 +198,7 @@ "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.proceedingsLabel", - "FieldDisplayOrder": 13, + "FieldDisplayOrder": 14, "DisplayContext": "READONLY", "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, @@ -199,7 +208,7 @@ "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.litigationIssues", - "FieldDisplayOrder": 14, + "FieldDisplayOrder": 15, "DisplayContext": "OPTIONAL" }, { @@ -208,7 +217,7 @@ "CaseEventID": "amendRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.litigationIssuesDetails", - "FieldDisplayOrder": 15, + "FieldDisplayOrder": 16, "DisplayContext": "OPTIONAL" }, { diff --git a/ccd-definition/CaseEventToComplexTypes/respondents/enterRespondents.json b/ccd-definition/CaseEventToComplexTypes/respondents/enterRespondents.json index 47903376eee..022437ebe0b 100644 --- a/ccd-definition/CaseEventToComplexTypes/respondents/enterRespondents.json +++ b/ccd-definition/CaseEventToComplexTypes/respondents/enterRespondents.json @@ -69,8 +69,17 @@ "ID": "EnterRespondents", "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.address", + "ListElementCode": "party.addressAutoConfidentialLabel", "FieldDisplayOrder": 7, + "DisplayContext": "OPTIONAL" + }, + { + "LiveFrom": "01/01/2017", + "ID": "EnterRespondents", + "CaseEventID": "enterRespondents", + "CaseFieldID": "respondents1", + "ListElementCode": "party.address", + "FieldDisplayOrder": 8, "DisplayContext": "MANDATORY" }, { @@ -128,7 +137,7 @@ "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.telephoneNumber", - "FieldDisplayOrder": 8, + "FieldDisplayOrder": 9, "DisplayContext": "OPTIONAL" }, { @@ -153,19 +162,17 @@ "ID": "EnterRespondents", "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.relationshipLabel", - "FieldDisplayOrder": 9, - "DisplayContext": "READONLY", - "FieldShowCondition": "party!=\"SHOW_LABEL\"" + "ListElementCode": "party.contactDetailsHidden", + "FieldDisplayOrder": 10, + "DisplayContext": "OPTIONAL" }, { "LiveFrom": "01/01/2017", "ID": "EnterRespondents", "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.relationshipToChild", - "EventElementLabel": "*What is the respondent's relationship to the child or children in this case?", - "FieldDisplayOrder": 10, + "ListElementCode": "party.contactDetailsHiddenReason", + "FieldDisplayOrder": 11, "DisplayContext": "OPTIONAL" }, { @@ -173,17 +180,19 @@ "ID": "EnterRespondents", "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.contactDetailsHidden", - "FieldDisplayOrder": 11, - "DisplayContext": "OPTIONAL" + "ListElementCode": "party.relationshipLabel", + "FieldDisplayOrder": 12, + "DisplayContext": "READONLY", + "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, { "LiveFrom": "01/01/2017", "ID": "EnterRespondents", "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", - "ListElementCode": "party.contactDetailsHiddenReason", - "FieldDisplayOrder": 12, + "ListElementCode": "party.relationshipToChild", + "EventElementLabel": "*What is the respondent's relationship to the child or children in this case?", + "FieldDisplayOrder": 13, "DisplayContext": "OPTIONAL" }, { @@ -192,7 +201,7 @@ "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.proceedingsLabel", - "FieldDisplayOrder": 13, + "FieldDisplayOrder": 14, "DisplayContext": "READONLY", "FieldShowCondition": "party!=\"SHOW_LABEL\"" }, @@ -202,7 +211,7 @@ "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.litigationIssues", - "FieldDisplayOrder": 14, + "FieldDisplayOrder": 15, "DisplayContext": "OPTIONAL" }, { @@ -211,7 +220,7 @@ "CaseEventID": "enterRespondents", "CaseFieldID": "respondents1", "ListElementCode": "party.litigationIssuesDetails", - "FieldDisplayOrder": 15, + "FieldDisplayOrder": 16, "DisplayContext": "OPTIONAL" }, { diff --git a/ccd-definition/ComplexTypes/CareSupervision/2_Others.json b/ccd-definition/ComplexTypes/CareSupervision/2_Others.json index bcc5219244b..4a625b86274 100644 --- a/ccd-definition/ComplexTypes/CareSupervision/2_Others.json +++ b/ccd-definition/ComplexTypes/CareSupervision/2_Others.json @@ -47,10 +47,20 @@ "LiveFrom": "01/01/2017", "ID": "Others", "ListElementCode": "addressKnow", - "FieldType": "YesOrNo", + "FieldType": "FixedRadioList", + "FieldTypeParameter": "IsAddressKnowList", "ElementLabel": "*Current address known?", "SecurityClassification": "Public" }, + { + "LiveFrom": "01/01/2017", + "ID": "Others", + "ListElementCode": "addressAutoConfidentialLabel", + "FieldType": "Label", + "ElementLabel": "## This address is automatically made confidential", + "SecurityClassification": "Public", + "FieldShowCondition": "addressKnow=\"LIVE_IN_REFUGE\"" + }, { "LiveFrom": "01/01/2017", "ID": "Others", @@ -58,7 +68,7 @@ "FieldType": "AddressUK", "ElementLabel": "Current address", "SecurityClassification": "Public", - "FieldShowCondition": "addressKnow=\"Yes\"" + "FieldShowCondition": "addressKnow=\"Yes\" OR addressKnow=\"LIVE_IN_REFUGE\"" }, { "LiveFrom": "01/01/2017", @@ -79,22 +89,14 @@ "Max": "24", "SecurityClassification": "Public" }, - { - "LiveFrom": "01/01/2017", - "ID": "Others", - "ListElementCode": "childInformation", - "FieldType": "TextArea", - "ElementLabel": "What is this person's relationship to the child or children in this case?", - "HintText": "Include: the name of the child or children, this person's relationship to them and whether this person has parental responsibility", - "SecurityClassification": "Public" - }, { "LiveFrom": "01/01/2017", "ID": "Others", "ListElementCode": "detailsHidden", "FieldType": "YesOrNo", "ElementLabel": "Do you need contact details hidden from other parties?", - "SecurityClassification": "Public" + "SecurityClassification": "Public", + "FieldShowCondition": "addressKnow!=\"LIVE_IN_REFUGE\"" }, { "LiveFrom": "01/01/2017", @@ -102,7 +104,16 @@ "ListElementCode": "detailsHiddenReason", "FieldType": "TextArea", "ElementLabel": "Give reason", - "FieldShowCondition": "detailsHidden=\"Yes\"", + "FieldShowCondition": "detailsHidden=\"Yes\" AND addressKnow!=\"LIVE_IN_REFUGE\"", + "SecurityClassification": "Public" + }, + { + "LiveFrom": "01/01/2017", + "ID": "Others", + "ListElementCode": "childInformation", + "FieldType": "TextArea", + "ElementLabel": "What is this person's relationship to the child or children in this case?", + "HintText": "Include: the name of the child or children, this person's relationship to them and whether this person has parental responsibility", "SecurityClassification": "Public" }, { diff --git a/ccd-definition/ComplexTypes/CareSupervision/2_RespondentParty.json b/ccd-definition/ComplexTypes/CareSupervision/2_RespondentParty.json index a7b929fe021..ea92e60b601 100644 --- a/ccd-definition/ComplexTypes/CareSupervision/2_RespondentParty.json +++ b/ccd-definition/ComplexTypes/CareSupervision/2_RespondentParty.json @@ -74,10 +74,20 @@ "LiveFrom": "01/01/2017", "ID": "RespondentParty", "ListElementCode": "addressKnow", - "FieldType": "YesOrNo", + "FieldType": "FixedRadioList", + "FieldTypeParameter": "IsAddressKnowList", "ElementLabel": "*Current address known?", "SecurityClassification": "Public" }, + { + "LiveFrom": "01/01/2017", + "ID": "RespondentParty", + "ListElementCode": "addressAutoConfidentialLabel", + "FieldType": "Label", + "ElementLabel": "## This address is automatically made confidential", + "SecurityClassification": "Public", + "FieldShowCondition": "addressKnow=\"LIVE_IN_REFUGE\"" + }, { "LiveFrom": "01/01/2017", "ID": "RespondentParty", @@ -85,7 +95,7 @@ "FieldType": "AddressUK", "ElementLabel": "Current address", "SecurityClassification": "Public", - "FieldShowCondition": "addressKnow=\"Yes\"" + "FieldShowCondition": "addressKnow=\"Yes\" OR addressKnow=\"LIVE_IN_REFUGE\"" }, { "LiveFrom": "01/01/2017", @@ -129,6 +139,7 @@ "ListElementCode": "contactDetailsHidden", "FieldType": "YesOrNo", "ElementLabel": "Do you need contact details hidden from other parties?", + "FieldShowCondition": "addressKnow!=\"LIVE_IN_REFUGE\"", "SecurityClassification": "Public" }, { @@ -137,7 +148,7 @@ "ListElementCode": "contactDetailsHiddenReason", "FieldType": "TextArea", "ElementLabel": "Give reason", - "FieldShowCondition": "contactDetailsHidden=\"Yes\"", + "FieldShowCondition": "contactDetailsHidden=\"Yes\" AND addressKnow!=\"LIVE_IN_REFUGE\"", "SecurityClassification": "Public" }, { diff --git a/ccd-definition/ComplexTypes/CareSupervision/HearingBooking.json b/ccd-definition/ComplexTypes/CareSupervision/HearingBooking.json index 1e1388f032f..3c78da9d75e 100644 --- a/ccd-definition/ComplexTypes/CareSupervision/HearingBooking.json +++ b/ccd-definition/ComplexTypes/CareSupervision/HearingBooking.json @@ -361,7 +361,8 @@ "FieldTypeParameter": "Others", "ElementLabel": " ", "SecurityClassification": "Public", - "FieldShowCondition": "type = \"DO NOT SHOW\"" + "FieldShowCondition": "type = \"DO NOT SHOW\"", + "Searchable": "N" }, { "LiveFrom": "01/01/2017", diff --git a/ccd-definition/FixedLists/CareSupervision/IsAddressKnowList.json b/ccd-definition/FixedLists/CareSupervision/IsAddressKnowList.json new file mode 100644 index 00000000000..5ab2631e41a --- /dev/null +++ b/ccd-definition/FixedLists/CareSupervision/IsAddressKnowList.json @@ -0,0 +1,23 @@ +[ + { + "LiveFrom": "01/01/2017", + "ID": "IsAddressKnowList", + "ListElementCode": "Yes", + "ListElement": "Yes", + "DisplayOrder": 0 + }, + { + "LiveFrom": "01/01/2017", + "ID": "IsAddressKnowList", + "ListElementCode": "No", + "ListElement": "No", + "DisplayOrder": 1 + }, + { + "LiveFrom": "01/01/2017", + "ID": "IsAddressKnowList", + "ListElementCode": "LIVE_IN_REFUGE", + "ListElement": "They are living in a refuge", + "DisplayOrder": 2 + } +] diff --git a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/ChangeFromOtherUtils.java b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/ChangeFromOtherUtils.java index 7de4546e221..e02273db0e5 100644 --- a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/ChangeFromOtherUtils.java +++ b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/ChangeFromOtherUtils.java @@ -1,5 +1,6 @@ package uk.gov.hmcts.reform.fpl.controllers; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.RepresentativeRole; import uk.gov.hmcts.reform.fpl.enums.YesNo; import uk.gov.hmcts.reform.fpl.model.Address; @@ -121,7 +122,7 @@ public static List> prepareConfidentialRespondentsFromRespon e -> element(e.getId(), Respondent.builder() .party(RespondentParty.builder() .firstName(e.getValue().getParty().getFirstName()) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .address(buildHiddenAddress(e.getValue().getParty().getFirstName())) .telephoneNumber(Telephone.builder().telephoneNumber("777777777").build()) .build()) @@ -154,7 +155,7 @@ public static Respondent prepareExpectedTransformedConfidentialRespondent() { return Respondent.builder() .party(RespondentParty.builder() .firstName("Johnny") - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .address(buildHiddenAddress("Converting")) .telephoneNumber(Telephone.builder().telephoneNumber("123456789").build()) .build()) @@ -165,7 +166,7 @@ public static Respondent prepareExpectedExistingConfidentialRespondent(int seqNo return Respondent.builder() .party(RespondentParty.builder() .firstName(String.format("existing respondent %s", seqNo)) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .address(buildHiddenAddress(String.format("existing respondent %s", seqNo))) .telephoneNumber(Telephone.builder().telephoneNumber("777777777").build()) .build()) @@ -186,7 +187,7 @@ public static Respondent prepareTransformedRespondentTestingData(boolean contact .firstName("Johnny") .telephoneNumber(Telephone.builder().telephoneNumber("123456789").build()) .address(buildHiddenAddress("Converting")) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .contactDetailsHidden(YesNo.from(contactDetailsHidden).getValue()) .build()) .legalRepresentation("No") @@ -200,7 +201,7 @@ public static Respondent prepareExpectedTransformedRespondent(boolean contactDea .telephoneNumber(contactDeatilsHidden ? null : Telephone.builder() .telephoneNumber("123456789").build()) .address(contactDeatilsHidden ? null : buildHiddenAddress("Converting")) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .contactDetailsHidden(YesNo.from(contactDeatilsHidden).getValue()) .build()) .legalRepresentation("No") @@ -281,7 +282,7 @@ public static List prepareRespondentsTestingData(int numberOfRespond .telephoneNumber("777777777") .build()) .address(respondentDetailsHidden ? null : buildHiddenAddress("" + j)) - .addressKnow(YesNo.from(respondentDetailsHidden).getValue()) + .addressKnow(respondentDetailsHidden ? IsAddressKnowType.YES : IsAddressKnowType.NO) .contactDetailsHidden(YesNo.from(respondentDetailsHidden).getValue()) .build()) .legalRepresentation("No") diff --git a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/OthersControllerAboutToSubmitTest.java b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/OthersControllerAboutToSubmitTest.java index 32940b45bf1..3bc84934725 100644 --- a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/OthersControllerAboutToSubmitTest.java +++ b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/OthersControllerAboutToSubmitTest.java @@ -5,6 +5,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CaseDetails; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.model.Address; import uk.gov.hmcts.reform.fpl.model.CaseData; import uk.gov.hmcts.reform.fpl.model.Other; @@ -110,7 +111,7 @@ private Other other() { .name("other") .address(Address.builder().addressLine1("506 Abbey Lane").build()) .telephone("01227 123456") - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .detailsHidden("Yes") .build(); } @@ -118,7 +119,7 @@ private Other other() { private Other otherWithDetailsRemoved() { return Other.builder() .name("other") - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .detailsHidden("Yes") .build(); } @@ -137,7 +138,7 @@ private List> additionalOthersWithoutAddress() { .name("additional other") .address(Address.builder().addressLine1("101 London Road").build()) .telephone("07122 123456") - .addressKnow("No") + .addressKnow(IsAddressKnowType.NO) .detailsHidden("Yes") .build())); } diff --git a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/RespondentControllerChangeFromOtherMidEventTest.java b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/RespondentControllerChangeFromOtherMidEventTest.java index abb5ba58dcd..389b7401a30 100644 --- a/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/RespondentControllerChangeFromOtherMidEventTest.java +++ b/service/src/integrationTest/java/uk/gov/hmcts/reform/fpl/controllers/RespondentControllerChangeFromOtherMidEventTest.java @@ -11,6 +11,7 @@ import org.springframework.boot.test.mock.mockito.MockBean; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CaseDetails; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.UserRole; import uk.gov.hmcts.reform.fpl.model.Address; import uk.gov.hmcts.reform.fpl.model.CaseData; @@ -96,7 +97,7 @@ private static Stream shouldPopulateTransformedRespondentSource() { .county("Some county") .country("UK") .build()) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .dateOfBirth(LocalDate.of(2005, Month.JUNE, 4)) .firstName("Kyle Stafford") .placeOfBirth("Newry") @@ -117,7 +118,7 @@ private static Stream shouldPopulateTransformedRespondentSource() { .county("Some county") .country("UK") .build()) - .addressKnow("Yes") + .addressKnow(IsAddressKnowType.YES) .dateOfBirth(LocalDate.of(2002, Month.FEBRUARY, 5)) .firstName("Sarah Simpson") .placeOfBirth("Craigavon") diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/OthersController.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/OthersController.java index 97d8687ad96..2c64eeaa131 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/OthersController.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/OthersController.java @@ -43,7 +43,7 @@ public AboutToStartOrSubmitCallbackResponse handleAboutToStart(@RequestBody Call @PostMapping("/about-to-submit") public AboutToStartOrSubmitCallbackResponse handleAboutToSubmit(@RequestBody CallbackRequest callbackRequest) { CaseDetails caseDetails = callbackRequest.getCaseDetails(); - Others updatedOthers = othersService.removeAddressOrAddressNotKnowReason(getCaseData(caseDetails)); + Others updatedOthers = othersService.consolidateAndRemoveHiddenFields(getCaseData(caseDetails)); caseDetails.getData().put(OTHERS, updatedOthers); CaseData caseData = getCaseData(caseDetails); diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/RespondentController.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/RespondentController.java index 558290dad96..80faee5ee36 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/RespondentController.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/controllers/RespondentController.java @@ -10,6 +10,8 @@ import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; import uk.gov.hmcts.reform.ccd.client.model.CaseDetails; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; +import uk.gov.hmcts.reform.fpl.enums.YesNo; import uk.gov.hmcts.reform.fpl.events.AfterSubmissionCaseDataUpdated; import uk.gov.hmcts.reform.fpl.events.RespondentsUpdated; import uk.gov.hmcts.reform.fpl.model.CaseData; @@ -87,7 +89,8 @@ public AboutToStartOrSubmitCallbackResponse handleMidEvent(@RequestBody Callback CaseData caseData = getCaseData(caseDetails); CaseData caseDataBefore = getCaseDataBefore(callbackRequest); - caseDetails.getData().put(RESPONDENTS_KEY, respondentService.removeHiddenFields(caseData.getRespondents1())); + caseDetails.getData().put(RESPONDENTS_KEY, + respondentService.consolidateAndRemoveHiddenFields(caseData.getRespondents1())); List errors = respondentValidator.validate(caseData, caseDataBefore); return respond(caseDetails, errors); @@ -105,7 +108,7 @@ private void prepareNewRespondents(CaseDetails caseDetails, CaseData caseData, C caseData.getAllRespondents(), oldRespondents ); - newRespondents = respondentService.removeHiddenFields(newRespondents); + newRespondents = respondentService.consolidateAndRemoveHiddenFields(newRespondents); newRespondents = representableCounselUpdater.updateLegalCounsel( oldRespondents, newRespondents, caseData.getAllChildren() @@ -236,6 +239,15 @@ private void addTransformedRespondentToRespondents(CaseDetails caseDetails, Case UUID newRespondentId) { OtherToRespondentEventData eventData = caseData.getOtherToRespondentEventData(); Respondent transformedRespondent = eventData.getTransformedRespondent(); + if (IsAddressKnowType.LIVE_IN_REFUGE.equals(transformedRespondent.getParty().getAddressKnow())) { + transformedRespondent = transformedRespondent.toBuilder() + .party(transformedRespondent.getParty().toBuilder() + .contactDetailsHidden(YesNo.YES.getValue()) + .contactDetailsHiddenReason(null) + .build()) + .build(); + } + List> newRespondents = confidentialDetailsService.prepareCollection( caseData.getAllRespondents(), caseData.getConfidentialRespondents(), expandCollection()); newRespondents.add(element(newRespondentId, transformedRespondent)); diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/enums/IsAddressKnowType.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/enums/IsAddressKnowType.java new file mode 100644 index 00000000000..15ea3b26a63 --- /dev/null +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/enums/IsAddressKnowType.java @@ -0,0 +1,15 @@ +package uk.gov.hmcts.reform.fpl.enums; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum IsAddressKnowType { + @JsonProperty("Yes") + YES, + @JsonProperty("No") + NO, + LIVE_IN_REFUGE; +} diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Other.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Other.java index edeb848bcc9..845d2669039 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Other.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Other.java @@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode; import org.apache.commons.lang3.ObjectUtils; import uk.gov.hmcts.reform.fpl.enums.AddressNotKnowReason; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.PartyType; import uk.gov.hmcts.reform.fpl.model.common.Element; import uk.gov.hmcts.reform.fpl.model.common.EmailAddress; @@ -47,7 +48,7 @@ public class Other implements Representable, ConfidentialParty { private final String detailsHiddenReason; private List> representedBy; private final String addressNotKnowReason; - private final String addressKnow; + private final IsAddressKnowType addressKnow; public List> getRepresentedBy() { if (this.representedBy == null) { @@ -158,13 +159,4 @@ public boolean isDeceasedOrNFA() { return AddressNotKnowReason.DECEASED.getType().equals(addressNotKnowReason) || AddressNotKnowReason.NO_FIXED_ABODE.getType().equals(addressNotKnowReason); } - - public Other removeAddress() { - return this.toBuilder().address(null).build(); - } - - public Other removeAddressNotKnowReason() { - return this.toBuilder().addressNotKnowReason(null).build(); - } - } diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Respondent.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Respondent.java index 4a1c028464c..c35d9f6d6b5 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Respondent.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/Respondent.java @@ -8,7 +8,7 @@ import lombok.Data; import lombok.extern.jackson.Jacksonized; import uk.gov.hmcts.reform.fpl.enums.AddressNotKnowReason; -import uk.gov.hmcts.reform.fpl.enums.YesNo; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.model.common.Element; import uk.gov.hmcts.reform.fpl.model.common.Party; import uk.gov.hmcts.reform.fpl.model.interfaces.ConfidentialParty; @@ -115,7 +115,7 @@ public static Respondent expandCollection() { @JsonIgnore public boolean isDeceasedOrNFA() { - return isNotEmpty(party) && YesNo.NO.getValue().equals(party.getAddressKnow()) + return isNotEmpty(party) && IsAddressKnowType.NO.equals(party.getAddressKnow()) && (AddressNotKnowReason.DECEASED.getType().equals(party.getAddressNotKnowReason()) || AddressNotKnowReason.NO_FIXED_ABODE.getType().equals(party.getAddressNotKnowReason())); } diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/RespondentParty.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/RespondentParty.java index bf89d28282e..810689f29c8 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/model/RespondentParty.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/model/RespondentParty.java @@ -9,8 +9,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.lang3.StringUtils; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.PartyType; -import uk.gov.hmcts.reform.fpl.enums.YesNo; import uk.gov.hmcts.reform.fpl.model.common.EmailAddress; import uk.gov.hmcts.reform.fpl.model.common.Party; import uk.gov.hmcts.reform.fpl.model.common.Telephone; @@ -32,7 +32,7 @@ public final class RespondentParty extends Party { private final String litigationIssues; private final String litigationIssuesDetails; private final String addressNotKnowReason; - private final String addressKnow; + private final IsAddressKnowType addressKnow; @Override @@ -72,7 +72,7 @@ public RespondentParty(String partyId, String contactDetailsHiddenReason, String litigationIssues, String litigationIssuesDetails, - String addressNotKnowReason, String addressKnow) { + String addressNotKnowReason, IsAddressKnowType addressKnow) { super(partyId, partyType, firstName, lastName, organisationName, dateOfBirth, address, email, telephoneNumber); this.gender = gender; @@ -91,11 +91,11 @@ public RespondentParty(String partyId, public static class RespondentPartyBuilder { } - public String getAddressKnow() { + public IsAddressKnowType getAddressKnow() { if (addressKnow != null) { return addressKnow; } return this.address != null && StringUtils.isNotBlank(this.address.getAddressLine1()) - ? YesNo.YES.getValue() : null; + ? IsAddressKnowType.YES : null; } } diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/OthersService.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/OthersService.java index 24e19fbe1ae..1ba4890388b 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/OthersService.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/OthersService.java @@ -1,6 +1,7 @@ package uk.gov.hmcts.reform.fpl.service; import org.springframework.stereotype.Service; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.YesNo; import uk.gov.hmcts.reform.fpl.model.CaseData; import uk.gov.hmcts.reform.fpl.model.Other; @@ -182,20 +183,24 @@ private boolean otherExists(Others others) { return others != null && (others.getFirstOther() != null || others.getAdditionalOthers() != null); } - public Others removeAddressOrAddressNotKnowReason(CaseData caseData) { - List> updatedOthers = new ArrayList<>(); - - caseData.getAllOthers().forEach(element -> { - Other other = element.getValue(); - if (!isNull(other.getAddressKnow())) { - updatedOthers.add(other.getAddressKnow().equals(YesNo.NO.getValue()) - ? element(element.getId(), other.removeAddress()) - : element(element.getId(), other.removeAddressNotKnowReason())); - } else { - updatedOthers.add(element); - } - }); - - return Others.from(updatedOthers); + public Others consolidateAndRemoveHiddenFields(CaseData caseData) { + return Others.from(caseData.getAllOthers().stream() + .map(otherElement -> { + Other other = otherElement.getValue(); + if (!isNull(other.getAddressKnow())) { + Other.OtherBuilder builder = other.toBuilder(); + if (IsAddressKnowType.NO.equals(other.getAddressKnow())) { + builder = builder.address(null); + } else { + builder = builder.addressNotKnowReason(null); + } + + if (IsAddressKnowType.LIVE_IN_REFUGE.equals(other.getAddressKnow())) { + builder = builder.detailsHidden(YesNo.YES.getValue()); + } + return element(otherElement.getId(), builder.build()); + } + return otherElement; + }).toList()); } } diff --git a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/RespondentService.java b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/RespondentService.java index c5fad3a78e0..f993860d3ec 100644 --- a/service/src/main/java/uk/gov/hmcts/reform/fpl/service/RespondentService.java +++ b/service/src/main/java/uk/gov/hmcts/reform/fpl/service/RespondentService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.ccd.model.ChangeOrganisationRequest; import uk.gov.hmcts.reform.ccd.model.Organisation; +import uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType; import uk.gov.hmcts.reform.fpl.enums.SolicitorRole; import uk.gov.hmcts.reform.fpl.model.Address; import uk.gov.hmcts.reform.fpl.model.CaseData; @@ -38,6 +39,7 @@ import static org.apache.commons.lang3.ObjectUtils.isEmpty; import static org.apache.commons.lang3.ObjectUtils.isNotEmpty; import static uk.gov.hmcts.reform.ccd.model.ChangeOrganisationApprovalStatus.APPROVED; +import static uk.gov.hmcts.reform.fpl.enums.IsAddressKnowType.LIVE_IN_REFUGE; import static uk.gov.hmcts.reform.fpl.enums.YesNo.NO; import static uk.gov.hmcts.reform.fpl.enums.YesNo.YES; import static uk.gov.hmcts.reform.fpl.utils.ElementUtils.element; @@ -80,7 +82,7 @@ public List> persistRepresentativesRelationship(List