From 6a276fc21170f76343d4e538f578318b45558373 Mon Sep 17 00:00:00 2001 From: sherlynkhaw Date: Fri, 10 Nov 2023 16:27:37 +0000 Subject: [PATCH] CIV-9993 Hearing party MCI (#3285) * Added new ManageContactInformation callback handler and event and whitelisted it within the AllowedFlowState service. * Added new ManageContactInformation callback handler and event and whitelisted it within the AllowedFlowState service. * CIV-9992 add options for manage contact information * revert accidental commit * add utils test * update utils test * add test scenarios for handler * update handler tests * add IDs to party options * changed name of some variables * added chosenpartytype and chosenpartyid to determine what to show on page 2, wip on applicant/defendant pages * adding tests ManageContactInformationUtilsTest * changed some keys, updated tests * experts and witnesses form wip * show experts on ui * make id fields public * Cherry picked the 3 main commits from CIV-3216 Added partyID to dq witness and expert objects. Enabled the initialisation on party Ids in DQ witnesses and experts and copied partyIDs into their relative case level counterparts Moved changes behind hmc toggle Fixed duplicate append call * Updated experts and witnesses to have mappings * changed utils class back to static and removed mocks * Fixed witnesses * fixed litigation friend * fixed capability to delete all experts/witnesses and add new expert/witnesses when never existed before * postcode * removed unnecessary lines and imports * fixed data going missing for applicant 1 for party id * fixed claim details tab * added ccd data store image in charts * fixed test * Update values.preview.template.yaml --------- Co-authored-by: GarethLancaster <31533575+Gareth40342@users.noreply.github.com> Co-authored-by: sankaviv1 Co-authored-by: Gareth Lancaster <90632240+Gareth40343@users.noreply.github.com> Co-authored-by: TurkingtonL Co-authored-by: sankaviv1 <95748224+sankaviv1@users.noreply.github.com> Co-authored-by: AhsanZX97 --- ...nageContactInformationCallbackHandler.java | 325 +++++++++- .../reform/civil/model/CaseDataParent.java | 10 +- .../reform/civil/model/UpdateDetailsForm.java | 16 +- .../civil/model/UpdatePartyDetailsForm.java | 16 + .../utils/ManageContactInformationUtils.java | 230 ++++++- ...ContactInformationCallbackHandlerTest.java | 577 +++++++++++++++++- .../civil/sampledata/CaseDataBuilder.java | 4 +- .../ManageContactInformationUtilsTest.java | 256 +++++++- 8 files changed, 1362 insertions(+), 72 deletions(-) create mode 100644 src/main/java/uk/gov/hmcts/reform/civil/model/UpdatePartyDetailsForm.java diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java index 9183d1089c3..f7570b2557a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandler.java @@ -6,37 +6,74 @@ import org.springframework.stereotype.Service; import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse; import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse; +import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse; import uk.gov.hmcts.reform.civil.callback.Callback; import uk.gov.hmcts.reform.civil.callback.CallbackException; import uk.gov.hmcts.reform.civil.callback.CallbackHandler; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario; +import uk.gov.hmcts.reform.civil.enums.YesOrNo; +import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; import uk.gov.hmcts.reform.civil.model.CaseData; +import uk.gov.hmcts.reform.civil.model.LitigationFriend; +import uk.gov.hmcts.reform.civil.model.Party; import uk.gov.hmcts.reform.civil.model.UpdateDetailsForm; +import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicList; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; +import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.dq.Expert; +import uk.gov.hmcts.reform.civil.model.dq.Witness; import uk.gov.hmcts.reform.civil.service.CoreCaseUserService; import uk.gov.hmcts.reform.civil.service.UserService; +import uk.gov.hmcts.reform.civil.validation.PostcodeValidator; import uk.gov.hmcts.reform.idam.client.models.UserInfo; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; - +import static java.lang.String.format; +import static java.util.Optional.ofNullable; import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_CONTACT_INFORMATION; +import static uk.gov.hmcts.reform.civil.enums.CaseCategory.SPEC_CLAIM; import static uk.gov.hmcts.reform.civil.enums.CaseState.AWAITING_APPLICANT_INTENTION; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP; import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; +import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.addApplicantExpertAndWitnessFlagsStructure; +import static uk.gov.hmcts.reform.civil.utils.CaseFlagUtils.addRespondentDQPartiesFlagStructure; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_WITNESSES_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addApplicant1Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addApplicantOptions2v1; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendant1Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendant2Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendantOptions1v2SameSolicitor; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.appendUserAndType; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapExpertsToUpdatePartyDetailsForm; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQExperts; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQWitnesses; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapWitnessesToUpdatePartyDetailsForm; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isApplicantSolicitor; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isRespondentSolicitorOne; import static uk.gov.hmcts.reform.civil.utils.UserRoleUtils.isRespondentSolicitorTwo; @@ -47,6 +84,9 @@ public class ManageContactInformationCallbackHandler extends CallbackHandler { private static final String INVALID_CASE_STATE_ERROR = "You will be able run the manage contact information " + "event once the claimant has responded."; + private static final String CHECK_LITIGATION_FRIEND_ERROR_TITLE = "Check the litigation friend's details"; + private static final String CHECK_LITIGATION_FRIEND_ERROR = "After making these changes, please ensure that the " + + "litigation friend's contact information is also up to date."; private static final List ADMIN_ROLES = List.of( "caseworker-civil-admin"); private static final List EVENTS = List.of( @@ -56,13 +96,17 @@ public class ManageContactInformationCallbackHandler extends CallbackHandler { private final CoreCaseUserService coreCaseUserService; private final UserService userService; private final ObjectMapper objectMapper; + private final CaseDetailsConverter caseDetailsConverter; + private final PostcodeValidator postcodeValidator; @Override protected Map callbacks() { return new ImmutableMap.Builder() - .put(callbackKey(ABOUT_TO_START), this::validateUserCanTriggerEvent) - .put(callbackKey(ABOUT_TO_SUBMIT), this::emptyCallbackResponse) - .put(callbackKey(SUBMITTED), this::emptyCallbackResponse) + .put(callbackKey(ABOUT_TO_START), this::prepareEvent) + .put(callbackKey(MID, "show-party-field"), this::showPartyField) + .put(callbackKey(MID, "show-warning"), this::showWarning) + .put(callbackKey(ABOUT_TO_SUBMIT), this::submitChanges) + .put(callbackKey(SUBMITTED), this::buildConfirmation) .build(); } @@ -71,7 +115,8 @@ public List handledEvents() { return EVENTS; } - private CallbackResponse validateUserCanTriggerEvent(CallbackParams callbackParams) { + private CallbackResponse prepareEvent(CallbackParams callbackParams) { + //TODO: 1v2DS/SS -> LR to show LR org 1/2 dependning on MP CaseData caseData = callbackParams.getCaseData(); String authToken = callbackParams.getParams().get(BEARER_TOKEN).toString(); @@ -146,6 +191,276 @@ private CallbackResponse validateUserCanTriggerEvent(CallbackParams callbackPara .build(); } + private List> prepareExperts(String partyId, CaseData caseData) { + if (partyId.equals(CLAIMANT_ONE_EXPERTS_ID)) { + return mapExpertsToUpdatePartyDetailsForm(caseData.getApplicant1DQ().getExperts().getDetails()); + } else if (partyId.equals(DEFENDANT_ONE_EXPERTS_ID)) { + return mapExpertsToUpdatePartyDetailsForm(caseData.getRespondent1DQ().getExperts().getDetails()); + } else if (partyId.equals(DEFENDANT_TWO_EXPERTS_ID)) { + return mapExpertsToUpdatePartyDetailsForm(caseData.getRespondent2DQ().getExperts().getDetails()); + } + return Collections.emptyList(); + } + + private List> prepareWitnesses(String partyId, CaseData caseData) { + if (partyId.equals(CLAIMANT_ONE_WITNESSES_ID)) { + return mapWitnessesToUpdatePartyDetailsForm(caseData.getApplicant1DQ().getWitnesses().getDetails()); + } else if (partyId.equals(DEFENDANT_ONE_WITNESSES_ID)) { + return mapWitnessesToUpdatePartyDetailsForm(caseData.getRespondent1DQ().getWitnesses().getDetails()); + } else if (partyId.equals(DEFENDANT_TWO_WITNESSES_ID)) { + return mapWitnessesToUpdatePartyDetailsForm(caseData.getRespondent2DQ().getWitnesses().getDetails()); + } + return Collections.emptyList(); + } + + private String getPostCode(String partyChosen, CaseData caseData) { + switch (partyChosen) { + case CLAIMANT_ONE_ID: { + return getPartyPostCode(caseData.getApplicant1()); + } + case CLAIMANT_TWO_ID: { + return getPartyPostCode(caseData.getApplicant2()); + } + case DEFENDANT_ONE_ID: { + return getPartyPostCode(caseData.getRespondent1()); + } + case DEFENDANT_TWO_ID: { + return getPartyPostCode(caseData.getRespondent2()); + } + case CLAIMANT_ONE_LITIGATION_FRIEND_ID: { + return getPartyPostCode(caseData.getApplicant1LitigationFriend()); + } + case CLAIMANT_TWO_LITIGATION_FRIEND_ID: { + return getPartyPostCode(caseData.getApplicant2LitigationFriend()); + } + case DEFENDANT_ONE_LITIGATION_FRIEND_ID: { + return getPartyPostCode(caseData.getRespondent1LitigationFriend()); + } + case DEFENDANT_TWO_LITIGATION_FRIEND_ID: { + return getPartyPostCode(caseData.getRespondent2LitigationFriend()); + } + default: { + return null; + } + } + } + + private String getPartyPostCode(Party party) { + return party.getPrimaryAddress().getPostCode(); + } + + private String getPartyPostCode(LitigationFriend party) { + return party.getPrimaryAddress().getPostCode(); + } + + private CallbackResponse showWarning(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + CaseData.CaseDataBuilder caseDataBuilder = caseData.toBuilder(); + String partyChosen = caseData.getUpdateDetailsForm().getPartyChosen().getValue().getCode(); + ArrayList warnings = new ArrayList<>(); + List errors = new ArrayList<>(); + + if (partyHasLitigationFriend(partyChosen, caseData)) { + warnings.add(CHECK_LITIGATION_FRIEND_ERROR_TITLE); + warnings.add(CHECK_LITIGATION_FRIEND_ERROR); + } + + if (SPEC_CLAIM.equals(caseData.getCaseAccessCategory())) { + errors = postcodeValidator.validate(getPostCode(partyChosen, caseData)); + } + + return AboutToStartOrSubmitCallbackResponse.builder() + .data(caseDataBuilder.build().toMap(objectMapper)) + .warnings(warnings) + .errors(errors) + .build(); + } + + private Boolean partyHasLitigationFriend(String partyChosen, CaseData caseData) { + if (hasLitigationFriend(CLAIMANT_ONE_ID, partyChosen, caseData.getApplicant1LitigationFriendRequired()) + || hasLitigationFriend(CLAIMANT_TWO_ID, partyChosen, caseData.getApplicant2LitigationFriendRequired()) + || hasLitigationFriend(DEFENDANT_ONE_ID, partyChosen, caseData.getRespondent1LitigationFriend()) + || hasLitigationFriend(DEFENDANT_TWO_ID, partyChosen, caseData.getRespondent2LitigationFriend()) + ) { + return true; + } + return false; + } + + private Boolean hasLitigationFriend(String id, String partyChosen, YesOrNo litigationFriend) { + return id.equals(partyChosen) && YES.equals(litigationFriend); + } + + private Boolean hasLitigationFriend(String id, String partyChosen, LitigationFriend litigationFriend) { + return id.equals(partyChosen) && litigationFriend != null; + } + + private CallbackResponse showPartyField(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + CaseData.CaseDataBuilder builder = caseData.toBuilder(); + + String partyChosen = caseData.getUpdateDetailsForm().getPartyChosen().getValue().getCode(); + String partyChosenType = null; + + if (isParty(partyChosen) || isLitigationFriend(partyChosen)) { + // Party fields are empty in this mid event, this is a workaround + CaseData oldCaseData = caseDetailsConverter.toCaseData(callbackParams.getRequest().getCaseDetailsBefore()); + String authToken = callbackParams.getParams().get(BEARER_TOKEN).toString(); + boolean isAdmin = isAdmin(authToken); + partyChosenType = appendUserAndType(partyChosen, oldCaseData, isAdmin); + } + + UpdateDetailsForm.UpdateDetailsFormBuilder formBuilder = caseData.getUpdateDetailsForm().toBuilder() + .partyChosenId(partyChosen) + .partyChosenType(partyChosenType) + .updateExpertsDetailsForm(prepareExperts(partyChosen, caseData)) + .updateWitnessesDetailsForm(prepareWitnesses(partyChosen, caseData)) + .build().toBuilder(); + + builder.updateDetailsForm(formBuilder.build()); + + return AboutToStartOrSubmitCallbackResponse.builder() + .data(builder.build().toMap(objectMapper)) + .build(); + } + + private Boolean isParty(String partyChosen) { + return CLAIMANT_ONE_ID.equals(partyChosen) + || CLAIMANT_TWO_ID.equals(partyChosen) + || DEFENDANT_ONE_ID.equals(partyChosen) + || DEFENDANT_TWO_ID.equals(partyChosen); + } + + private Boolean isLitigationFriend(String partyChosen) { + return CLAIMANT_ONE_LITIGATION_FRIEND_ID.equals(partyChosen) + || CLAIMANT_TWO_LITIGATION_FRIEND_ID.equals(partyChosen) + || DEFENDANT_ONE_LITIGATION_FRIEND_ID.equals(partyChosen) + || DEFENDANT_TWO_LITIGATION_FRIEND_ID.equals(partyChosen); + } + + private CallbackResponse submitChanges(CallbackParams callbackParams) { + CaseData caseData = callbackParams.getCaseData(); + CaseData.CaseDataBuilder builder = caseData.toBuilder(); + + updateExperts(caseData.getUpdateDetailsForm().getPartyChosenId(), caseData, builder); + updateWitnesses(caseData.getUpdateDetailsForm().getPartyChosenId(), caseData, builder); + + // clear updateDetailsForm + builder.updateDetailsForm(UpdateDetailsForm.builder().manageContactDetailsEventUsed(YES).build()); + + // update claim details tab + updateClaimDetailsTab(caseData, builder); + + return AboutToStartOrSubmitCallbackResponse.builder() + .data(builder.build().toMap(objectMapper)) + .build(); + } + + private void updateClaimDetailsTab(CaseData caseData, CaseData.CaseDataBuilder builder) { + builder.respondent1DetailsForClaimDetailsTab(caseData.getRespondent1().toBuilder().flags(null).build()); + + if (ofNullable(caseData.getRespondent2()).isPresent()) { + builder.respondent2DetailsForClaimDetailsTab(caseData.getRespondent2().toBuilder().flags(null).build()); + } + } + + // wip can't be tested yet because need to get ids from new ticket: CIV-10382 + // have to delete experts (yes/no etc) if the experts are removed, same as witnesses + + private void updateExperts(String partyId, CaseData caseData, CaseData.CaseDataBuilder builder) { + List> formData = caseData.getUpdateDetailsForm().getUpdateExpertsDetailsForm(); + List> mappedExperts; + + if (partyId.equals(CLAIMANT_ONE_EXPERTS_ID)) { + mappedExperts = mapUpdatePartyDetailsFormToDQExperts( + caseData.getApplicant1DQ().getApplicant1DQExperts().getDetails(), formData); + builder.applicant1DQ(caseData.getApplicant1DQ().toBuilder() + .applicant1DQExperts( + caseData.getApplicant1DQ().getApplicant1DQExperts().toBuilder() + .expertRequired(mappedExperts.size() >= 1 ? YES : NO) + .details(mappedExperts) + .build()) + .build()); + addApplicantExpertAndWitnessFlagsStructure(builder, caseData); + //TODO: need to add it to top level party object + } else if (partyId.equals(DEFENDANT_ONE_EXPERTS_ID)) { + mappedExperts = mapUpdatePartyDetailsFormToDQExperts( + caseData.getRespondent1DQ().getRespondent1DQExperts().getDetails(), formData); + builder.respondent1DQ(caseData.getRespondent1DQ().toBuilder() + .respondent1DQExperts( + caseData.getRespondent1DQ().getRespondent1DQExperts().toBuilder() + .expertRequired(mappedExperts.size() >= 1 ? YES : NO) + .details(mappedExperts) + .build()) + .build()); + addRespondentDQPartiesFlagStructure(builder, caseData); + //TODO: need to add it to top level party object + } else if (partyId.equals(DEFENDANT_TWO_EXPERTS_ID)) { + mappedExperts = mapUpdatePartyDetailsFormToDQExperts( + caseData.getRespondent2DQ().getRespondent2DQExperts().getDetails(), formData); + builder.respondent2DQ(caseData.getRespondent2DQ().toBuilder() + .respondent2DQExperts( + caseData.getRespondent2DQ().getRespondent2DQExperts().toBuilder() + .expertRequired(mappedExperts.size() >= 1 ? YES : NO) + .details(mappedExperts) + .build()) + .build()); + addRespondentDQPartiesFlagStructure(builder, caseData); + //TODO: need to add it to top level party object + } + + } + + private void updateWitnesses(String partyId, CaseData caseData, CaseData.CaseDataBuilder builder) { + List> formData = caseData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm(); + List> mappedWitnesses; + + if (partyId.equals(CLAIMANT_ONE_WITNESSES_ID)) { + mappedWitnesses = mapUpdatePartyDetailsFormToDQWitnesses( + caseData.getApplicant1DQ().getApplicant1DQWitnesses().getDetails(), formData); + builder.applicant1DQ(caseData.getApplicant1DQ().toBuilder() + .applicant1DQWitnesses( + caseData.getApplicant1DQ().getApplicant1DQWitnesses().toBuilder() + .witnessesToAppear(mappedWitnesses.size() >= 1 ? YES : NO) + .details(mappedWitnesses) + .build()) + .build()); + addApplicantExpertAndWitnessFlagsStructure(builder, caseData); + //TODO: need to add it to top level party object + } else if (partyId.equals(DEFENDANT_ONE_WITNESSES_ID)) { + mappedWitnesses = mapUpdatePartyDetailsFormToDQWitnesses( + caseData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails(), formData); + builder.respondent1DQ(caseData.getRespondent1DQ().toBuilder() + .respondent1DQWitnesses( + caseData.getRespondent1DQ().getRespondent1DQWitnesses().toBuilder() + .witnessesToAppear(mappedWitnesses.size() >= 1 ? YES : NO) + .details(mappedWitnesses) + .build()) + .build()); + addRespondentDQPartiesFlagStructure(builder, caseData); + //TODO: need to add it to top level party object + } else if (partyId.equals(DEFENDANT_TWO_WITNESSES_ID)) { + mappedWitnesses = mapUpdatePartyDetailsFormToDQWitnesses( + caseData.getRespondent2DQ().getRespondent2DQWitnesses().getDetails(), formData); + builder.respondent2DQ(caseData.getRespondent2DQ().toBuilder() + .respondent2DQWitnesses( + caseData.getRespondent2DQ().getRespondent2DQWitnesses().toBuilder() + .witnessesToAppear(mappedWitnesses.size() >= 1 ? YES : NO) + .details(mappedWitnesses) + .build()) + .build()); + addRespondentDQPartiesFlagStructure(builder, caseData); + //TODO: need to add it to top level party object + } + } + + private SubmittedCallbackResponse buildConfirmation(CallbackParams callbackParams) { + return SubmittedCallbackResponse.builder() + .confirmationHeader(format("# Contact information changed")) + .confirmationBody(format("### What happens next\nAny changes made to contact details have been updated in the Claim Details tab.")) + .build(); + } + private boolean isAwaitingClaimantIntention(CaseData caseData) { return caseData.getCcdState().equals(AWAITING_APPLICANT_INTENTION); } diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java index e5b1329495e..7d2a5546ce9 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java @@ -534,9 +534,13 @@ public boolean isApplicantNotRepresented() { private final List> applicantWitnesses; private final List> respondent1Witnesses; private final List> respondent2Witnesses; - private final List> applicantSolOrgIndividuals; - private final List> respondent1SolOrgIndividuals; - private final List> applicant1SolOrgIndividuals; + private final List> applicant1LRIndividuals; + private final List> respondent1LRIndividuals; + private final List> respondent2LRIndividuals; + private final List> applicant1OrgIndividuals; + private final List> applicant2OrgIndividuals; + private final List> respondent1OrgIndividuals; + private final List> respondent2OrgIndividuals; private List disposalHearingDisclosureOfDocumentsDJToggle; private List disposalHearingWitnessOfFactDJToggle; diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/UpdateDetailsForm.java b/src/main/java/uk/gov/hmcts/reform/civil/model/UpdateDetailsForm.java index 82f48651bb7..33b489f1fec 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/model/UpdateDetailsForm.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/UpdateDetailsForm.java @@ -1,6 +1,5 @@ package uk.gov.hmcts.reform.civil.model; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -11,17 +10,18 @@ import java.util.List; @Data -@Builder +@Builder(toBuilder = true) @NoArgsConstructor @AllArgsConstructor public class UpdateDetailsForm { - @JsonProperty("partyChosen") private DynamicList partyChosen; - - @JsonProperty("additionalUnavailableDates") - private List> additionalUnavailableDates; - - @JsonProperty("hidePartyChoice") + private String partyChosenId; + private String partyChosenType; private YesOrNo hidePartyChoice; + private List> additionalUnavailableDates; + private List> updateExpertsDetailsForm; + private List> updateWitnessesDetailsForm; + private YesOrNo manageContactDetailsEventUsed; } + diff --git a/src/main/java/uk/gov/hmcts/reform/civil/model/UpdatePartyDetailsForm.java b/src/main/java/uk/gov/hmcts/reform/civil/model/UpdatePartyDetailsForm.java new file mode 100644 index 00000000000..5955d276a92 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/reform/civil/model/UpdatePartyDetailsForm.java @@ -0,0 +1,16 @@ +package uk.gov.hmcts.reform.civil.model; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder(toBuilder = true) +public class UpdatePartyDetailsForm { + + private String firstName; + private String lastName; + private String phoneNumber; + private String emailAddress; + private String partyId; + private String fieldOfExpertise; +} diff --git a/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java b/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java index 5967810fb19..83ff6136dd6 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtils.java @@ -2,16 +2,22 @@ import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; +import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.dq.Expert; import uk.gov.hmcts.reform.civil.model.dq.Experts; +import uk.gov.hmcts.reform.civil.model.dq.Witness; import uk.gov.hmcts.reform.civil.model.dq.Witnesses; - +import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; - import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY; import static uk.gov.hmcts.reform.civil.model.Party.Type.ORGANISATION; import static uk.gov.hmcts.reform.civil.model.common.DynamicListElement.dynamicElementFromCode; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; public class ManageContactInformationUtils { @@ -34,30 +40,30 @@ private ManageContactInformationUtils() { private static final String ORG_INDIVIDUALS = "Individuals attending for the organisation"; private static final String LEGAL_REP_INDIVIDUALS = "Individuals attending for the legal representative"; - private static final String CLAIMANT_ONE_ID = "CLAIMANT_1"; - private static final String CLAIMANT_ONE_LITIGATION_FRIEND_ID = "CLAIMANT_1_LITIGATIONFRIEND"; - private static final String CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSSOLICITORORG"; - private static final String CLAIMANT_ONE_ORG_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSORG"; - private static final String CLAIMANT_ONE_WITNESSES_ID = "CLAIMANT_1_WITNESSES"; - private static final String CLAIMANT_ONE_EXPERTS_ID = "CLAIMANT_1_EXPERTS"; - - private static final String CLAIMANT_TWO_ID = "CLAIMANT_2"; - private static final String CLAIMANT_TWO_LITIGATION_FRIEND_ID = "CLAIMANT_2_LITIGATIONFRIEND"; - private static final String CLAIMANT_TWO_ORG_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSORG"; - - private static final String DEFENDANT_ONE_ID = "DEFENDANT_1"; - private static final String DEFENDANT_ONE_LITIGATION_FRIEND_ID = "DEFENDANT_1_LITIGATIONFRIEND"; - private static final String DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_1_INDIVIDUALSSOLICITORORG"; - private static final String DEFENDANT_ONE_ORG_INDIVIDUALS_ID = "DEFENDANT_1_INDIVIDUALSORG"; - private static final String DEFENDANT_ONE_WITNESSES_ID = "DEFENDANT_1_WITNESSES"; - private static final String DEFENDANT_ONE_EXPERTS_ID = "DEFENDANT_1_EXPERTS"; - - private static final String DEFENDANT_TWO_ID = "DEFENDANT_2"; - private static final String DEFENDANT_TWO_LITIGATION_FRIEND_ID = "DEFENDANT_2_LITIGATIONFRIEND"; - private static final String DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_2_INDIVIDUALSSOLICITORORG"; - private static final String DEFENDANT_TWO_ORG_INDIVIDUALS_ID = "DEFENDANT_2_INDIVIDUALSORG"; - private static final String DEFENDANT_TWO_WITNESSES_ID = "DEFENDANT_2_WITNESSES"; - private static final String DEFENDANT_TWO_EXPERTS_ID = "DEFENDANT_2_EXPERTS"; + public static final String CLAIMANT_ONE_ID = "CLAIMANT_1"; + public static final String CLAIMANT_ONE_LITIGATION_FRIEND_ID = "CLAIMANT_1_LITIGATION_FRIEND"; + public static final String CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "CLAIMANT_1_LR_INDIVIDUALS"; + public static final String CLAIMANT_ONE_ORG_INDIVIDUALS_ID = "CLAIMANT_1_ORGANISATION_INDIVIDUALS"; + public static final String CLAIMANT_ONE_WITNESSES_ID = "CLAIMANT_1_WITNESSES"; + public static final String CLAIMANT_ONE_EXPERTS_ID = "CLAIMANT_1_EXPERTS"; + + public static final String CLAIMANT_TWO_ID = "CLAIMANT_2"; + public static final String CLAIMANT_TWO_LITIGATION_FRIEND_ID = "CLAIMANT_2_LITIGATION_FRIEND"; + public static final String CLAIMANT_TWO_ORG_INDIVIDUALS_ID = "CLAIMANT_2_ORGANISATION_INDIVIDUALS"; + + public static final String DEFENDANT_ONE_ID = "DEFENDANT_1"; + public static final String DEFENDANT_ONE_LITIGATION_FRIEND_ID = "DEFENDANT_1_LITIGATION_FRIEND"; + public static final String DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_1_LR_INDIVIDUALS"; + public static final String DEFENDANT_ONE_ORG_INDIVIDUALS_ID = "DEFENDANT_1_ORGANISATION_INDIVIDUALS"; + public static final String DEFENDANT_ONE_WITNESSES_ID = "DEFENDANT_1_WITNESSES"; + public static final String DEFENDANT_ONE_EXPERTS_ID = "DEFENDANT_1_EXPERTS"; + + public static final String DEFENDANT_TWO_ID = "DEFENDANT_2"; + public static final String DEFENDANT_TWO_LITIGATION_FRIEND_ID = "DEFENDANT_2_LITIGATION_FRIEND"; + public static final String DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_2_LR_INDIVIDUALS"; + public static final String DEFENDANT_TWO_ORG_INDIVIDUALS_ID = "DEFENDANT_2_ORGANISATION_INDIVIDUALS"; + public static final String DEFENDANT_TWO_WITNESSES_ID = "DEFENDANT_2_WITNESSES"; + public static final String DEFENDANT_TWO_EXPERTS_ID = "DEFENDANT_2_EXPERTS"; public static void addApplicant1Options(List list, CaseData caseData, boolean isAdmin) { addApplicant1PartyOptions(list, caseData); @@ -95,6 +101,178 @@ public static void addDefendant2Options(List list, CaseData addDefendant2ExpertsAndWitnesses(list, caseData, isAdmin); } + public static String appendUserAndType(String partyChosen, CaseData caseData, boolean isAdmin) { + String user = isAdmin ? "ADMIN" : "LR"; + + switch (partyChosen) { + case (CLAIMANT_ONE_ID): { + return formatId(partyChosen, user, caseData.getApplicant1()); + } + case(CLAIMANT_TWO_ID): { + return formatId(partyChosen, user, caseData.getApplicant2()); + } + case (DEFENDANT_ONE_ID): { + return formatId(partyChosen, user, caseData.getRespondent1()); + } + case(DEFENDANT_TWO_ID): { + return formatId(partyChosen, user, caseData.getRespondent2()); + } + case(CLAIMANT_ONE_LITIGATION_FRIEND_ID): + case(CLAIMANT_TWO_LITIGATION_FRIEND_ID): + case(DEFENDANT_ONE_LITIGATION_FRIEND_ID): + case(DEFENDANT_TWO_LITIGATION_FRIEND_ID): { + return formatId(partyChosen, user); + } + default: { + throw new IllegalArgumentException("Manage Contact Information party chosen ID does not exist"); + } + } + } + + public static List> mapExpertsToUpdatePartyDetailsForm(List> experts) { + List> newExperts = new ArrayList<>(); + + if (experts != null) { + for (Element party : experts) { + Expert expert = party.getValue(); + newExperts.addAll(wrapElements(UpdatePartyDetailsForm.builder() + .firstName(expert.getFirstName()) + .lastName(expert.getLastName()) + .emailAddress(expert.getEmailAddress()) + .phoneNumber(expert.getPhoneNumber()) + .fieldOfExpertise(expert.getFieldOfExpertise()) + .partyId(expert.getPartyID()) //this will need to be added in new ticket + .build())); + } + } + return newExperts; + } + + public static List> mapUpdatePartyDetailsFormToDQExperts(List> existingDQExperts, List> formExperts) { + List> newExperts = new ArrayList<>(); + List experts = unwrapElements(existingDQExperts); + + if (formExperts != null) { + for (Element form : formExperts) { + UpdatePartyDetailsForm formExpert = form.getValue(); + + Expert dqExpert = experts.stream() + .filter(e -> e.getPartyID().equals(formExpert.getPartyId())) + .findFirst() + .orElse(null); + + if (dqExpert != null && dqExpert.getPartyID() != null) { + // if id already exists in dq + newExperts.addAll(wrapElements(dqExpert.toBuilder() + .firstName(formExpert.getFirstName()) + .lastName(formExpert.getLastName()) + .emailAddress(formExpert.getEmailAddress()) + .phoneNumber(formExpert.getPhoneNumber()) + .fieldOfExpertise(formExpert.getFieldOfExpertise()) + .build())); + } else { + // if id doesn't exist in dq means it is a newly added expert + newExperts.addAll(wrapElements(Expert.builder() + .firstName(formExpert.getFirstName()) + .lastName(formExpert.getLastName()) + .emailAddress(formExpert.getEmailAddress()) + .phoneNumber(formExpert.getPhoneNumber()) + .fieldOfExpertise(formExpert.getFieldOfExpertise()) + .dateAdded(LocalDate.now()) + .eventAdded("Manage Contact Information Event") + .partyID(null) //CIV-10382 + .build())); + // Replace above to this in CIV-10382 + // newExperts.addAll(wrapElements(appendWithNewPartyIds(Expert.builder() + // .firstName(formExpert.getFirstName()) + // .lastName(formExpert.getLastName()) + // .emailAddress(formExpert.getEmailAddress()) + // .phoneNumber(formExpert.getPhoneNumber()) + // .fieldOfExpertise(formExpert.getFieldOfExpertise()) + // .dateAdded(LocalDate.now()) + // .eventAdded("Manage Contact Information Event") + // .build()))); + } + } + } + + return newExperts; + } + + public static List> mapWitnessesToUpdatePartyDetailsForm(List> witnesses) { + List> newWitnesses = new ArrayList<>(); + + if (witnesses != null) { + for (Element party : witnesses) { + Witness witness = party.getValue(); + newWitnesses.addAll(wrapElements(UpdatePartyDetailsForm.builder() + .firstName(witness.getFirstName()) + .lastName(witness.getLastName()) + .emailAddress(witness.getEmailAddress()) + .phoneNumber(witness.getPhoneNumber()) + .partyId(witness.getPartyID()) + .build())); + } + } + return newWitnesses; + } + + public static List> mapUpdatePartyDetailsFormToDQWitnesses(List> existingDQWitnesses, List> formWitnesses) { + List> newWitnesses = new ArrayList<>(); + List witnesses = unwrapElements(existingDQWitnesses); + + if (formWitnesses != null) { + for (Element form : formWitnesses) { + UpdatePartyDetailsForm formWitness = form.getValue(); + + Witness dqWitness = witnesses.stream() + .filter(w -> w.getPartyID().equals(formWitness.getPartyId())) + .findFirst() + .orElse(null); + + // if id already exists in dq + if (dqWitness != null && dqWitness.getPartyID() != null) { + newWitnesses.addAll(wrapElements(dqWitness.toBuilder() + .firstName(formWitness.getFirstName()) + .lastName(formWitness.getLastName()) + .emailAddress(formWitness.getEmailAddress()) + .phoneNumber(formWitness.getPhoneNumber()) + .build())); + } else { + // if id doesn't exist in dq means it is a newly added witness + newWitnesses.addAll(wrapElements(Witness.builder() + .firstName(formWitness.getFirstName()) + .lastName(formWitness.getLastName()) + .emailAddress(formWitness.getEmailAddress()) + .phoneNumber(formWitness.getPhoneNumber()) + .dateAdded(LocalDate.now()) + .eventAdded("Manage Contact Information Event") + .partyID(null) //CIV-10382 + .build())); + // Replace above to this in CIV-10382 + // newWitnesses.addAll(wrapElements(appendWithNewPartyIds(Witness.builder() + // .firstName(formWitness.getFirstName()) + // .lastName(formWitness.getLastName()) + // .emailAddress(formWitness.getEmailAddress()) + // .phoneNumber(formWitness.getPhoneNumber()) + // .dateAdded(LocalDate.now()) + // .eventAdded("Manage Contact Information Event") + // .build()))); + } + } + } + + return newWitnesses; + } + + private static String formatId(String partyChosen, String isAdmin, Party party) { + return String.format("%s_%s_%s", partyChosen, isAdmin, party.getType().toString()); + } + + private static String formatId(String partyChosen, String isAdmin) { + return String.format("%s_%s", partyChosen, isAdmin); + } + private static void addApplicant1PartyOptions(List list, CaseData caseData) { // applicant 1 party name list.add(dynamicElementFromCode(CLAIMANT_ONE_ID, diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java index 832084cce8f..de083369ffa 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/ManageContactInformationCallbackHandlerTest.java @@ -4,40 +4,79 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; 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.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CallbackType; +import uk.gov.hmcts.reform.civil.enums.CaseCategory; import uk.gov.hmcts.reform.civil.enums.CaseState; import uk.gov.hmcts.reform.civil.enums.RespondentResponseType; import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest; import uk.gov.hmcts.reform.civil.helpers.CaseDetailsConverter; +import uk.gov.hmcts.reform.civil.model.Address; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.UpdateDetailsForm; +import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; +import uk.gov.hmcts.reform.civil.model.common.DynamicList; +import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; +import uk.gov.hmcts.reform.civil.model.common.Element; +import uk.gov.hmcts.reform.civil.model.dq.Applicant1DQ; +import uk.gov.hmcts.reform.civil.model.dq.Expert; +import uk.gov.hmcts.reform.civil.model.dq.Experts; +import uk.gov.hmcts.reform.civil.model.dq.Respondent1DQ; +import uk.gov.hmcts.reform.civil.model.dq.Respondent2DQ; +import uk.gov.hmcts.reform.civil.model.dq.Witness; +import uk.gov.hmcts.reform.civil.model.dq.Witnesses; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; import uk.gov.hmcts.reform.civil.service.CoreCaseUserService; +import uk.gov.hmcts.reform.civil.validation.PostcodeValidator; import uk.gov.hmcts.reform.idam.client.models.UserInfo; - +import java.time.LocalDate; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.when; import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT; -import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED; +import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID; +import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY; +import static uk.gov.hmcts.reform.civil.model.Party.Type.INDIVIDUAL; import static uk.gov.hmcts.reform.civil.utils.DynamicListUtils.listFromDynamicList; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_WITNESSES_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_EXPERTS_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_WITNESSES_ID; @SpringBootTest(classes = { ManageContactInformationCallbackHandler.class, JacksonAutoConfiguration.class, - CaseDetailsConverter.class + CaseDetailsConverter.class, + PostcodeValidator.class }) class ManageContactInformationCallbackHandlerTest extends BaseCallbackHandlerTest { @@ -50,6 +89,12 @@ class ManageContactInformationCallbackHandlerTest extends BaseCallbackHandlerTes @MockBean private CoreCaseUserService coreCaseUserService; + @MockBean + private CaseDetailsConverter caseDetailsConverter; + + @MockBean + private PostcodeValidator postcodeValidator; + private static final UserInfo ADMIN_USER = UserInfo.builder() .roles(List.of("caseworker-civil-admin")) .uid("uid") @@ -664,31 +709,537 @@ void shouldReturnExpectedList_WhenInvokedFor1v2DifferentSolicitorAsRespondentSol @Nested class AboutToSubmit { + UpdatePartyDetailsForm party; + Expert dqExpert; + Expert expectedExpert1; + Witness dqWitness; + Witness expectedWitness1; + + @BeforeEach + void setup() { + party = UpdatePartyDetailsForm.builder().firstName("First").lastName("Name").build(); + dqExpert = Expert.builder().partyID("id").firstName("dq").lastName("dq").build(); + expectedExpert1 = dqExpert.builder().firstName("First").lastName("Name") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) + .partyID(null) //change this for CIV-10382 + .build(); + dqWitness = Witness.builder().firstName("dq").lastName("dq").partyID("id").build(); + expectedWitness1 = Witness.builder().firstName("First").lastName("Name") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) + .partyID(null).build(); // CIV-10382 + } @Test - void shouldReturnExpectedResponse_WhenAboutToSubmitIsInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); + void shouldUpdateApplicantOneExperts() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(CLAIMANT_ONE_EXPERTS_ID) + .build()) + .build()) + .partyChosenId(CLAIMANT_ONE_EXPERTS_ID) + .updateExpertsDetailsForm(wrapElements(party)) + .build()) + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQExperts(Experts.builder().details(wrapElements(dqExpert)).build()) + .build()) + .build(); CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); - assertEquals(AboutToStartOrSubmitCallbackResponse.builder().build(), response); + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); } - } - @Nested - class Submitted { + @Test + void shouldUpdateDefendantOneExperts() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_ONE_EXPERTS_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_ONE_EXPERTS_ID) + .updateExpertsDetailsForm(wrapElements(party)) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQExperts(Experts.builder().details(wrapElements(dqExpert)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + } @Test - void shouldReturnExpectedResponse_WhenSubmittedIsInvoked() { - CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build(); - CallbackParams params = callbackParamsOf(caseData, SUBMITTED); + void shouldUpdateDefendantTwoExperts() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_TWO_EXPERTS_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_TWO_EXPERTS_ID) + .updateExpertsDetailsForm(wrapElements(party)) + .build()) + .respondent2DQ(Respondent2DQ.builder() + .respondent2DQExperts(Experts.builder().details(wrapElements(dqExpert)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler .handle(params); - assertEquals(AboutToStartOrSubmitCallbackResponse.builder().build(), response); + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent2DQ().getRespondent2DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + } + + @Test + void shouldUpdateApplicantOneWitnesses() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(CLAIMANT_ONE_WITNESSES_ID) + .build()) + .build()) + .partyChosenId(CLAIMANT_ONE_WITNESSES_ID) + .updateWitnessesDetailsForm(wrapElements(party)) + .build()) + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQWitnesses(Witnesses.builder().details(wrapElements(dqWitness)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + } + + @Test + void shouldUpdateDefendantOneWitnesses() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_ONE_WITNESSES_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_ONE_WITNESSES_ID) + .updateWitnessesDetailsForm(wrapElements(party)) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQWitnesses(Witnesses.builder().details(wrapElements(dqWitness)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + } + + @Test + void shouldUpdateDefendantTwoWitnesses() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_TWO_WITNESSES_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_TWO_WITNESSES_ID) + .updateWitnessesDetailsForm(wrapElements(party)) + .build()) + .respondent2DQ(Respondent2DQ.builder() + .respondent2DQWitnesses(Witnesses.builder().details(wrapElements(dqWitness)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent2DQ().getRespondent2DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + } + + @Test + void addingExpertWhenNoneExisted() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(CLAIMANT_ONE_EXPERTS_ID) + .build()) + .build()) + .partyChosenId(CLAIMANT_ONE_EXPERTS_ID) + .updateExpertsDetailsForm(wrapElements(party)) + .build()) + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQExperts(Experts.builder() + .expertRequired(NO) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQExperts().getDetails()).get(0)).isEqualTo(expectedExpert1); + assertThat(updatedData.getApplicant1DQ().getApplicant1DQExperts().getExpertRequired()).isEqualTo(YES); + } + + @Test + void removingAllExperts() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(CLAIMANT_ONE_EXPERTS_ID) + .build()) + .build()) + .partyChosenId(CLAIMANT_ONE_EXPERTS_ID) + .updateExpertsDetailsForm(null) + .build()) + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQExperts(Experts.builder() + .expertRequired(YES) + .details(wrapElements(dqExpert)).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getApplicant1DQ().getApplicant1DQExperts().getDetails())).isEmpty(); + assertThat(updatedData.getApplicant1DQ().getApplicant1DQExperts().getExpertRequired()).isEqualTo(NO); + } + + @Test + void addingWitnessWhenNoneExisted() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_ONE_WITNESSES_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_ONE_WITNESSES_ID) + .updateWitnessesDetailsForm(wrapElements(party)) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQWitnesses(Witnesses.builder().witnessesToAppear(NO).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails()).get(0)).isEqualTo(expectedWitness1); + assertThat(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getWitnessesToAppear()).isEqualTo(YES); + } + + @Test + void removingAllWitnesses() { + CaseData caseData = CaseDataBuilder.builder() + .atStateApplicantRespondToDefenceAndProceed() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(DEFENDANT_ONE_WITNESSES_ID) + .build()) + .build()) + .partyChosenId(DEFENDANT_ONE_WITNESSES_ID) + .updateWitnessesDetailsForm(null) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQWitnesses(Witnesses.builder() + .details(wrapElements(dqWitness)) + .witnessesToAppear(YES).build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + + AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler + .handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(unwrapElements(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getDetails())).isEmpty(); + assertThat(updatedData.getRespondent1DQ().getRespondent1DQWitnesses().getWitnessesToAppear()).isEqualTo(NO); + } + } + + @Nested + class MidShowWarning { + private static final String PAGE_ID = "show-warning"; + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_ID, CLAIMANT_TWO_ID, DEFENDANT_ONE_ID, DEFENDANT_TWO_ID}) + void shouldReturnWarning(String partyChosenId) { + String errorTitle = "Check the litigation friend's details"; + String errorMessage = "After making these changes, please ensure that the " + + "litigation friend's contact information is also up to date."; + + CaseData caseData = CaseDataBuilder.builder() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .addApplicant1LitigationFriend() + .addApplicant2LitigationFriend() + .addRespondent1LitigationFriend() + .addRespondent2LitigationFriend() + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getWarnings()).contains(errorTitle); + assertThat(response.getWarnings()).contains(errorMessage); + } + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_ID, CLAIMANT_TWO_ID, DEFENDANT_ONE_ID, DEFENDANT_TWO_ID, DEFENDANT_ONE_LITIGATION_FRIEND_ID}) + void shouldNotReturnWarning(String partyChosenId) { + CaseData caseData = CaseDataBuilder.builder() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .build(); + + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + assertThat(response.getWarnings()).isEmpty(); + } + + @Test + void shouldReturnPostcodeError() { + given(postcodeValidator.validate(any())).willReturn(List.of("Please enter Postcode")); + + CaseData caseData = CaseDataBuilder.builder() + .caseAccessCategory(CaseCategory.SPEC_CLAIM) + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(CLAIMANT_ONE_ID) + .build()) + .build()) + .build()) + .applicant1(Party.builder() + .type(INDIVIDUAL) + .primaryAddress(Address.builder() + .postCode(null) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + assertThat(response.getErrors()).isNotNull(); + assertEquals(1, response.getErrors().size()); + assertEquals("Please enter Postcode", response.getErrors().get(0)); + } + } + + @Nested + class MidShowPartyField { + private static final String PAGE_ID = "show-party-field"; + + @Test + void shouldPopulatePartyChosenId() { + CaseData caseData = CaseDataBuilder.builder() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code("CODE") + .build()) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenId()).isEqualTo("CODE"); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenType()).isEqualTo(null); + assertThat(updatedData.getUpdateDetailsForm().getUpdateExpertsDetailsForm()).isEmpty(); + assertThat(updatedData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm()).isEmpty(); + } + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_ID, CLAIMANT_TWO_ID, DEFENDANT_ONE_ID, DEFENDANT_TWO_ID}) + void shouldPopulatePartyType(String partyChosenId) { + when(userService.getUserInfo(anyString())).thenReturn(ADMIN_USER); + CaseData caseDataBefore = CaseDataBuilder.builder() + .applicant1(Party.builder().type(INDIVIDUAL).build()) + .applicant2(Party.builder().type(INDIVIDUAL).build()) + .respondent1(Party.builder().type(INDIVIDUAL).build()) + .respondent2(Party.builder().type(INDIVIDUAL).build()) + .buildClaimIssuedPaymentCaseData(); + given(caseDetailsConverter.toCaseData(any(CaseDetails.class))).willReturn(caseDataBefore); + + CaseData caseData = CaseDataBuilder.builder() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenId()).isEqualTo(partyChosenId); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenType()).isEqualTo(partyChosenId + "_ADMIN_INDIVIDUAL"); + assertThat(updatedData.getUpdateDetailsForm().getUpdateExpertsDetailsForm()).isEmpty(); + assertThat(updatedData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm()).isEmpty(); + } + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_LITIGATION_FRIEND_ID, CLAIMANT_TWO_LITIGATION_FRIEND_ID, DEFENDANT_ONE_LITIGATION_FRIEND_ID, DEFENDANT_TWO_LITIGATION_FRIEND_ID}) + void shouldPopulatePartyTypeForLitigationFriend(String partyChosenId) { + when(userService.getUserInfo(anyString())).thenReturn(LEGAL_REP_USER); + CaseData caseDataBefore = CaseDataBuilder.builder() + .applicant1(Party.builder().type(INDIVIDUAL).build()) + .applicant2(Party.builder().type(INDIVIDUAL).build()) + .respondent1(Party.builder().type(INDIVIDUAL).build()) + .respondent2(Party.builder().type(INDIVIDUAL).build()) + .buildClaimIssuedPaymentCaseData(); + given(caseDetailsConverter.toCaseData(any(CaseDetails.class))).willReturn(caseDataBefore); + + CaseData caseData = CaseDataBuilder.builder() + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenId()).isEqualTo(partyChosenId); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenType()).isEqualTo(partyChosenId + "_LR"); + assertThat(updatedData.getUpdateDetailsForm().getUpdateExpertsDetailsForm()).isEmpty(); + assertThat(updatedData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm()).isEmpty(); + } + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_EXPERTS_ID, DEFENDANT_ONE_EXPERTS_ID, DEFENDANT_TWO_EXPERTS_ID}) + void shouldPopulateExperts(String partyChosenId) { + when(userService.getUserInfo(anyString())).thenReturn(ADMIN_USER); + Expert expert = Expert.builder().firstName("First").lastName("Name").partyID("id").build(); + UpdatePartyDetailsForm party = UpdatePartyDetailsForm.builder().firstName("First").lastName("Name") + .partyId("id").build(); + List> form = wrapElements(party); + + CaseData caseData = CaseDataBuilder.builder() + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQExperts(Experts.builder().details(wrapElements(expert)).build()) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQExperts(Experts.builder().details(wrapElements(expert)).build()) + .build()) + .respondent2DQ(Respondent2DQ.builder() + .respondent2DQExperts(Experts.builder().details(wrapElements(expert)).build()) + .build()) + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenId()).isEqualTo(partyChosenId); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenType()).isEqualTo(null); + assertThat(updatedData.getUpdateDetailsForm().getUpdateExpertsDetailsForm()).isEqualTo(form); + assertThat(updatedData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm()).isEmpty(); + + } + + @ParameterizedTest + @ValueSource(strings = {CLAIMANT_ONE_WITNESSES_ID, DEFENDANT_ONE_WITNESSES_ID, DEFENDANT_TWO_WITNESSES_ID}) + void shouldPopulateWitnesses(String partyChosenId) { + Witness witness = Witness.builder().firstName("First").lastName("Name").partyID("id").build(); + UpdatePartyDetailsForm party = UpdatePartyDetailsForm.builder().firstName("First").lastName("Name") + .partyId("id").build(); + List> form = wrapElements(party); + + CaseData caseData = CaseDataBuilder.builder() + .applicant1DQ(Applicant1DQ.builder() + .applicant1DQWitnesses(Witnesses.builder().details(wrapElements(witness)).build()) + .build()) + .respondent1DQ(Respondent1DQ.builder() + .respondent1DQWitnesses(Witnesses.builder().details(wrapElements(witness)).build()) + .build()) + .respondent2DQ(Respondent2DQ.builder() + .respondent2DQWitnesses(Witnesses.builder().details(wrapElements(witness)).build()) + .build()) + .updateDetailsForm(UpdateDetailsForm.builder() + .partyChosen(DynamicList.builder() + .value(DynamicListElement.builder() + .code(partyChosenId) + .build()) + .build()) + .build()) + .build(); + CallbackParams params = callbackParamsOf(caseData, MID, PAGE_ID); + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenId()).isEqualTo(partyChosenId); + assertThat(updatedData.getUpdateDetailsForm().getPartyChosenType()).isEqualTo(null); + assertThat(updatedData.getUpdateDetailsForm().getUpdateExpertsDetailsForm()).isEmpty(); + assertThat(updatedData.getUpdateDetailsForm().getUpdateWitnessesDetailsForm()).isEqualTo(form); + } } } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java index f6b96b180f4..4b2a4a05581 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/sampledata/CaseDataBuilder.java @@ -6076,8 +6076,8 @@ public CaseDataBuilder claimantUserDetails(IdamUserDetails claimantUserDetails) return this; } - public CaseDataBuilder updateDetailsForm(UpdateDetailsForm additionalDates) { - this.updateDetailsForm = additionalDates; + public CaseDataBuilder updateDetailsForm(UpdateDetailsForm form) { + this.updateDetailsForm = form; return this; } diff --git a/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java b/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java index f8fc3f207cb..ac5effba420 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/utils/ManageContactInformationUtilsTest.java @@ -1,11 +1,16 @@ package uk.gov.hmcts.reform.civil.utils; +import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import uk.gov.hmcts.reform.civil.model.CaseData; import uk.gov.hmcts.reform.civil.model.Party; +import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm; import uk.gov.hmcts.reform.civil.model.common.DynamicListElement; +import uk.gov.hmcts.reform.civil.model.dq.Expert; +import uk.gov.hmcts.reform.civil.model.dq.Witness; import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; - +import java.math.BigDecimal; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; @@ -14,13 +19,26 @@ import static uk.gov.hmcts.reform.civil.enums.RespondentResponseType.FULL_DEFENCE; import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES; import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY; +import static uk.gov.hmcts.reform.civil.model.Party.Type.INDIVIDUAL; import static uk.gov.hmcts.reform.civil.model.Party.Type.ORGANISATION; +import static uk.gov.hmcts.reform.civil.model.Party.Type.SOLE_TRADER; import static uk.gov.hmcts.reform.civil.model.common.DynamicListElement.dynamicElementFromCode; +import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_ONE_LITIGATION_FRIEND_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.CLAIMANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_ONE_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_ID; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.DEFENDANT_TWO_LITIGATION_FRIEND_ID; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addApplicant1Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addApplicantOptions2v1; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendant1Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendant2Options; import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.addDefendantOptions1v2SameSolicitor; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.appendUserAndType; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapExpertsToUpdatePartyDetailsForm; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQExperts; +import static uk.gov.hmcts.reform.civil.utils.ManageContactInformationUtils.mapUpdatePartyDetailsFormToDQWitnesses; class ManageContactInformationUtilsTest { @@ -246,11 +264,219 @@ void shouldAddCorrectOptions_forDefendant1v2SameSolicitorAsAdmin() { assertThat(options).isEqualTo(expectedDefendants1v2SameSolicitorOptions(true, true)); } + @Test + void shouldMapExpertsToUpdatePartyDetailsForm() { + Expert expert1 = Expert.builder().firstName("First").lastName("Name").partyID("id").eventAdded("event").build(); + Expert expert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") + .phoneNumber("1").emailAddress("email").partyID("id2").build(); + UpdatePartyDetailsForm party = UpdatePartyDetailsForm.builder().firstName("First").lastName("Name") + .partyId("id").build(); + UpdatePartyDetailsForm party2 = UpdatePartyDetailsForm.builder().firstName("Second").lastName("expert") + .fieldOfExpertise("field").phoneNumber("1").emailAddress("email").partyId("id2").build(); + + assertThat(mapExpertsToUpdatePartyDetailsForm(wrapElements(expert1, expert2))) + .isEqualTo(wrapElements(party, party2)); + } + + @Test + void shouldMapExpertsToUpdatePartyDetailsForm_ifEmpty() { + assertThat(mapExpertsToUpdatePartyDetailsForm(null)).isEqualTo(new ArrayList<>()); + } + + @Nested + class MapToDQExperts { + UpdatePartyDetailsForm party = UpdatePartyDetailsForm.builder().firstName("Lewis").lastName("John") + .partyId("id").build(); + UpdatePartyDetailsForm party2 = UpdatePartyDetailsForm.builder().firstName("Second").lastName("expert") + .fieldOfExpertise("field").phoneNumber("1").emailAddress("expertemail").partyId("id2").build(); + + LocalDate date = LocalDate.of(2020, 3, 20); + + Expert expert1 = Expert.builder().firstName("First").lastName("Name").partyID("id").eventAdded("event") + .dateAdded(date).estimatedCost(BigDecimal.valueOf(10000)).build(); + Expert expert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") + .eventAdded("event").dateAdded(date).phoneNumber("1").emailAddress("email").partyID("id2").build(); + + @Test + void shouldEditExperts() { + Expert expectedExpert1 = Expert.builder().firstName("Lewis").lastName("John").partyID("id") + .eventAdded("event").dateAdded(date).estimatedCost(BigDecimal.valueOf(10000)).build(); + Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") + .eventAdded("event").dateAdded(date).phoneNumber("1").emailAddress("expertemail").partyID("id2").build(); + + assertThat(mapUpdatePartyDetailsFormToDQExperts(wrapElements(expert1, expert2), wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedExpert1, expectedExpert2)); + } + + @Test + void shouldAddExperts() { + Expert expectedExpert1 = Expert.builder().firstName("Lewis").lastName("John") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) + .partyID(null) //change this for CIV-10382 + .build(); + Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") + .emailAddress("expertemail") + .partyID(null) //change this for CIV-10382 + .build(); + + assertThat(mapUpdatePartyDetailsFormToDQExperts(null, wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedExpert1, expectedExpert2)); + } + + @Test + void shouldAddExpertsWithExistingExperts() { + Expert expectedExpert1 = Expert.builder().firstName("Lewis").lastName("John").partyID("id") + .eventAdded("event").dateAdded(date).estimatedCost(BigDecimal.valueOf(10000)).build(); + Expert expectedExpert2 = Expert.builder().firstName("Second").lastName("expert").fieldOfExpertise("field") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") + .emailAddress("expertemail") + .partyID(null) //change this for CIV-10382 + .build(); + + assertThat(mapUpdatePartyDetailsFormToDQExperts(wrapElements(expert1), wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedExpert1, expectedExpert2)); + } + } + + @Nested + class MapToDQWitnesses { + UpdatePartyDetailsForm party = UpdatePartyDetailsForm.builder().firstName("Lewis").lastName("John") + .partyId("id").build(); + UpdatePartyDetailsForm party2 = UpdatePartyDetailsForm.builder().firstName("Second").lastName("witness") + .phoneNumber("1").emailAddress("witnessemail").partyId("id2").build(); + + LocalDate date = LocalDate.of(2020, 3, 20); + + Witness witness1 = Witness.builder().firstName("First").lastName("Name").partyID("id").eventAdded("event") + .dateAdded(date).reasonForWitness("reason").build(); + Witness witness2 = Witness.builder().firstName("Second").lastName("expert").eventAdded("event") + .dateAdded(date).phoneNumber("1").emailAddress("email").partyID("id2").build(); + + @Test + void shouldEditWitnesses() { + Witness expectedWitness1 = Witness.builder().firstName("Lewis").lastName("John") + .eventAdded("event").dateAdded(date).reasonForWitness("reason").partyID("id").build(); + + Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness") + .eventAdded("event").dateAdded(date).phoneNumber("1").emailAddress("witnessemail") + .partyID("id2").build(); + + assertThat(mapUpdatePartyDetailsFormToDQWitnesses(wrapElements(witness1, witness2), wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedWitness1, expectedWitness2)); + } + + @Test + void shouldAddWitnesses() { + Witness expectedWitness1 = Witness.builder().firstName("Lewis").lastName("John") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()) + .partyID(null).build(); // CIV-10382 + Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") + .emailAddress("witnessemail") + .partyID(null).build(); // CIV-10382 + + assertThat(mapUpdatePartyDetailsFormToDQWitnesses(null, wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedWitness1, expectedWitness2)); + } + + @Test + void shouldRemoveWitnesses() { + assertThat(mapUpdatePartyDetailsFormToDQWitnesses(wrapElements(witness1, witness2), null)) + .isEmpty(); + } + + @Test + void shouldAddWitnessesWithExistingWitnesses() { + Witness expectedWitness1 = Witness.builder().firstName("Lewis").lastName("John").partyID("id") + .reasonForWitness("reason").eventAdded("event").dateAdded(date).build(); + Witness expectedWitness2 = Witness.builder().firstName("Second").lastName("witness") + .eventAdded("Manage Contact Information Event").dateAdded(LocalDate.now()).phoneNumber("1") + .emailAddress("witnessemail") + .partyID(null) //change this for CIV-10382 + .build(); + + assertThat(mapUpdatePartyDetailsFormToDQWitnesses(wrapElements(witness1), wrapElements(party, party2))) + .isEqualTo(wrapElements(expectedWitness1, expectedWitness2)); + } + } + + @Nested + class AppendCorrectUserAndType { + @Test + void shouldHaveCorrectID_ClaimantOneAdminIndividual() { + CaseData caseData = CaseDataBuilder.builder() + .applicant1(Party.builder().type(INDIVIDUAL).build()).build(); + + String result = appendUserAndType(CLAIMANT_ONE_ID, caseData, true); + + assertThat(result).isEqualTo("CLAIMANT_1_ADMIN_INDIVIDUAL"); + } + + @Test + void shouldHaveCorrectID_ClaimantTwoAdminSoleTrader() { + CaseData caseData = CaseDataBuilder.builder() + .applicant2(Party.builder().type(SOLE_TRADER).build()).build(); + + String result = appendUserAndType(CLAIMANT_TWO_ID, caseData, true); + + assertThat(result).isEqualTo("CLAIMANT_2_ADMIN_SOLE_TRADER"); + } + + @Test + void shouldHaveCorrectID_DefendantOneAdminOrganisation() { + CaseData caseData = CaseDataBuilder.builder() + .respondent1(Party.builder().type(ORGANISATION).build()).build(); + + String result = appendUserAndType(DEFENDANT_ONE_ID, caseData, true); + + assertThat(result).isEqualTo("DEFENDANT_1_ADMIN_ORGANISATION"); + } + + @Test + void shouldHaveCorrectID_DefendantTwoAdminCompany() { + CaseData caseData = CaseDataBuilder.builder() + .respondent2(Party.builder().type(COMPANY).build()).build(); + + String result = appendUserAndType(DEFENDANT_TWO_ID, caseData, true); + + assertThat(result).isEqualTo("DEFENDANT_2_ADMIN_COMPANY"); + } + + @Test + void shouldHaveCorrectID_DefendantTwoLegalRepIndividual() { + CaseData caseData = CaseDataBuilder.builder() + .respondent2(Party.builder().type(INDIVIDUAL).build()).build(); + + String result = appendUserAndType(DEFENDANT_TWO_ID, caseData, false); + + assertThat(result).isEqualTo("DEFENDANT_2_LR_INDIVIDUAL"); + } + + @Test + void shouldHaveCorrectID_Applicant1LitigationFriendAdmin() { + CaseData caseData = CaseDataBuilder.builder().build(); + + String result = appendUserAndType(CLAIMANT_ONE_LITIGATION_FRIEND_ID, caseData, false); + + assertThat(result).isEqualTo("CLAIMANT_1_LITIGATION_FRIEND_LR"); + } + + @Test + void shouldHaveCorrectID_Defendant2LitigationFriendAdmin() { + CaseData caseData = CaseDataBuilder.builder().build(); + + String result = appendUserAndType(DEFENDANT_TWO_LITIGATION_FRIEND_ID, caseData, true); + + assertThat(result).isEqualTo("DEFENDANT_2_LITIGATION_FRIEND_ADMIN"); + } + } + private List expectedApplicant1Options(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("CLAIMANT_1", "CLAIMANT 1: Mr. John Rambo")); - list.add(dynamicElementFromCode("CLAIMANT_1_LITIGATIONFRIEND", "CLAIMANT 1: Litigation Friend: Applicant Litigation Friend")); - list.add(dynamicElementFromCode("CLAIMANT_1_INDIVIDUALSSOLICITORORG", "CLAIMANT 1: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("CLAIMANT_1_LITIGATION_FRIEND", "CLAIMANT 1: Litigation Friend: Applicant Litigation Friend")); + list.add(dynamicElementFromCode("CLAIMANT_1_LR_INDIVIDUALS", "CLAIMANT 1: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("CLAIMANT_1_WITNESSES", "CLAIMANT 1: Witnesses")); list.add(dynamicElementFromCode("CLAIMANT_1_EXPERTS", "CLAIMANT 1: Experts")); @@ -261,8 +487,8 @@ private List expectedApplicant1Options(boolean withExpertsAn private List expectedApplicant1OrgOptions(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("CLAIMANT_1", "CLAIMANT 1: Test Inc")); - list.add(dynamicElementFromCode("CLAIMANT_1_INDIVIDUALSORG", "CLAIMANT 1: Individuals attending for the organisation")); - list.add(dynamicElementFromCode("CLAIMANT_1_INDIVIDUALSSOLICITORORG", "CLAIMANT 1: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("CLAIMANT_1_ORGANISATION_INDIVIDUALS", "CLAIMANT 1: Individuals attending for the organisation")); + list.add(dynamicElementFromCode("CLAIMANT_1_LR_INDIVIDUALS", "CLAIMANT 1: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("CLAIMANT_1_WITNESSES", "CLAIMANT 1: Witnesses")); list.add(dynamicElementFromCode("CLAIMANT_1_EXPERTS", "CLAIMANT 1: Experts")); @@ -273,10 +499,10 @@ private List expectedApplicant1OrgOptions(boolean withExpert private List expectedApplicants2v1Options(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("CLAIMANT_1", "CLAIMANT 1: Mr. John Rambo")); - list.add(dynamicElementFromCode("CLAIMANT_1_LITIGATIONFRIEND", "CLAIMANT 1: Litigation Friend: Applicant Litigation Friend")); + list.add(dynamicElementFromCode("CLAIMANT_1_LITIGATION_FRIEND", "CLAIMANT 1: Litigation Friend: Applicant Litigation Friend")); list.add(dynamicElementFromCode("CLAIMANT_2", "CLAIMANT 2: Mr. Jason Rambo")); - list.add(dynamicElementFromCode("CLAIMANT_2_LITIGATIONFRIEND", "CLAIMANT 2: Litigation Friend: Applicant Two Litigation Friend")); - list.add(dynamicElementFromCode("CLAIMANT_1_INDIVIDUALSSOLICITORORG", "CLAIMANTS: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("CLAIMANT_2_LITIGATION_FRIEND", "CLAIMANT 2: Litigation Friend: Applicant Two Litigation Friend")); + list.add(dynamicElementFromCode("CLAIMANT_1_LR_INDIVIDUALS", "CLAIMANTS: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("CLAIMANT_1_WITNESSES", "CLAIMANTS: Witnesses")); list.add(dynamicElementFromCode("CLAIMANT_1_EXPERTS", "CLAIMANTS: Experts")); @@ -287,8 +513,8 @@ private List expectedApplicants2v1Options(boolean withExpert private List expectedDefendant1Options(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("DEFENDANT_1", "DEFENDANT 1: Mr. Sole Trader")); - list.add(dynamicElementFromCode("DEFENDANT_1_LITIGATIONFRIEND", "DEFENDANT 1: Litigation Friend: Litigation Friend")); - list.add(dynamicElementFromCode("DEFENDANT_1_INDIVIDUALSSOLICITORORG", "DEFENDANT 1: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("DEFENDANT_1_LITIGATION_FRIEND", "DEFENDANT 1: Litigation Friend: Litigation Friend")); + list.add(dynamicElementFromCode("DEFENDANT_1_LR_INDIVIDUALS", "DEFENDANT 1: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("DEFENDANT_1_WITNESSES", "DEFENDANT 1: Witnesses")); list.add(dynamicElementFromCode("DEFENDANT_1_EXPERTS", "DEFENDANT 1: Experts")); @@ -299,8 +525,8 @@ private List expectedDefendant1Options(boolean withExpertsAn private List expectedDefendant2Options(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("DEFENDANT_2", "DEFENDANT 2: Mr. John Rambo")); - list.add(dynamicElementFromCode("DEFENDANT_2_LITIGATIONFRIEND", "DEFENDANT 2: Litigation Friend: Litigation Friend")); - list.add(dynamicElementFromCode("DEFENDANT_2_INDIVIDUALSSOLICITORORG", "DEFENDANT 2: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("DEFENDANT_2_LITIGATION_FRIEND", "DEFENDANT 2: Litigation Friend: Litigation Friend")); + list.add(dynamicElementFromCode("DEFENDANT_2_LR_INDIVIDUALS", "DEFENDANT 2: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("DEFENDANT_2_WITNESSES", "DEFENDANT 2: Witnesses")); list.add(dynamicElementFromCode("DEFENDANT_2_EXPERTS", "DEFENDANT 2: Experts")); @@ -311,10 +537,10 @@ private List expectedDefendant2Options(boolean withExpertsAn private List expectedDefendants1v2SameSolicitorOptions(boolean withExpertsAndWitnesses, boolean isAdmin) { List list = new ArrayList<>(); list.add(dynamicElementFromCode("DEFENDANT_1", "DEFENDANT 1: Mr. Sole Trader")); - list.add(dynamicElementFromCode("DEFENDANT_1_LITIGATIONFRIEND", "DEFENDANT 1: Litigation Friend: Litigation Friend")); + list.add(dynamicElementFromCode("DEFENDANT_1_LITIGATION_FRIEND", "DEFENDANT 1: Litigation Friend: Litigation Friend")); list.add(dynamicElementFromCode("DEFENDANT_2", "DEFENDANT 2: Mr. John Rambo")); - list.add(dynamicElementFromCode("DEFENDANT_2_LITIGATIONFRIEND", "DEFENDANT 2: Litigation Friend: Litigation Friend")); - list.add(dynamicElementFromCode("DEFENDANT_1_INDIVIDUALSSOLICITORORG", "DEFENDANTS: Individuals attending for the legal representative")); + list.add(dynamicElementFromCode("DEFENDANT_2_LITIGATION_FRIEND", "DEFENDANT 2: Litigation Friend: Litigation Friend")); + list.add(dynamicElementFromCode("DEFENDANT_1_LR_INDIVIDUALS", "DEFENDANTS: Individuals attending for the legal representative")); if (withExpertsAndWitnesses || isAdmin) { list.add(dynamicElementFromCode("DEFENDANT_1_WITNESSES", "DEFENDANTS: Witnesses")); list.add(dynamicElementFromCode("DEFENDANT_1_EXPERTS", "DEFENDANTS: Experts"));