Skip to content

Commit

Permalink
CIV-11838 Internal Case Name Refactor (#3853)
Browse files Browse the repository at this point in the history
* Adjusted internal case name to be populated the same as public case name

* Implemented updating public and internal case names in add litigation friend callback handler

---------

Co-authored-by: GarethLancaster <[email protected]>
Co-authored-by: mounikahmcts <[email protected]>
  • Loading branch information
3 people authored Jan 19, 2024
1 parent bafadc6 commit e10f2c9
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uk.gov.hmcts.reform.civil.service.UserService;
import uk.gov.hmcts.reform.civil.service.flowstate.StateFlowEngine;
import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser;
import uk.gov.hmcts.reform.civil.utils.CaseNameUtils;
import uk.gov.hmcts.reform.idam.client.models.UserInfo;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -137,6 +138,9 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
populateWithPartyIds(caseDataUpdated);
}

caseDataUpdated.caseNameHmctsInternal(CaseNameUtils.buildCaseName(caseDataUpdated.build()));
caseDataUpdated.caseNamePublic(CaseNameUtils.buildCaseName(caseDataUpdated.build()));

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataUpdated.build().toMap(objectMapper))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
import static uk.gov.hmcts.reform.civil.utils.CaseListSolicitorReferenceUtils.getAllDefendantSolicitorReferences;
import static uk.gov.hmcts.reform.civil.utils.CaseListSolicitorReferenceUtils.getAllOrganisationPolicyReferences;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseName;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getAllPartyNames;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateWithPartyIds;
Expand Down Expand Up @@ -496,7 +496,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {

//assign casemanagementcategory to the case and assign casenamehmctsinternal
//casename
dataBuilder.caseNameHmctsInternal(buildCaseNameInternal(caseData));
dataBuilder.caseNameHmctsInternal(buildCaseName(caseData));

//case management category
CaseManagementCategoryElement civil =
Expand Down Expand Up @@ -524,7 +524,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {
//assign category ids to documents uploaded as part of particulars of claim
assignParticularOfClaimCategoryIds(caseData);

dataBuilder.caseNamePublic(CaseNameUtils.buildCaseNamePublic(caseData));
dataBuilder.caseNamePublic(CaseNameUtils.buildCaseName(caseData));

caseFlagInitialiser.initialiseCaseFlags(CREATE_CLAIM, dataBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE_TIME_AT;
import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.formatLocalDateTime;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNameInternal;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseName;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.populateWithPartyIds;

Expand Down Expand Up @@ -477,7 +477,7 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {
dataBuilder.featureToggleWA(toggleConfiguration.getFeatureToggle());

//assign case management category to the case and caseNameHMCTSinternal
dataBuilder.caseNameHmctsInternal(buildCaseNameInternal(caseData));
dataBuilder.caseNameHmctsInternal(buildCaseName(caseData));

CaseManagementCategoryElement civil =
CaseManagementCategoryElement.builder().code("Civil").label("Civil").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import uk.gov.hmcts.reform.civil.service.CoreCaseUserService;
import uk.gov.hmcts.reform.civil.service.UserService;
import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser;
import uk.gov.hmcts.reform.civil.utils.CaseNameUtils;
import uk.gov.hmcts.reform.civil.validation.PostcodeValidator;
import uk.gov.hmcts.reform.idam.client.models.UserInfo;

Expand All @@ -54,8 +55,7 @@
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.CaseNameUtils.buildCaseNameInternal;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseNamePublic;
import static uk.gov.hmcts.reform.civil.utils.CaseNameUtils.buildCaseName;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements;
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;
Expand Down Expand Up @@ -421,8 +421,8 @@ private CallbackResponse submitChanges(CallbackParams callbackParams) {

if (isParty(partyChosenId) || isLitigationFriend(partyChosenId)) {
// update case name for hmc if applicant/respondent/litigation friend was updated
builder.caseNameHmctsInternal(buildCaseNameInternal(caseData));
builder.caseNamePublic(buildCaseNamePublic(caseData));
builder.caseNameHmctsInternal(CaseNameUtils.buildCaseName(caseData));
builder.caseNamePublic(buildCaseName(caseData));
}

// last step before clearing update details form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static String getHmctsInternalCaseName(CaseData caseData) {

public static String getPublicCaseName(CaseData caseData) {
return caseData.getCaseNamePublic() != null ? caseData.getCaseNamePublic()
: CaseNameUtils.buildCaseNamePublic(caseData);
: CaseNameUtils.buildCaseName(caseData);
}

public static String getCaseDeepLink(Long caseId,
Expand Down
30 changes: 3 additions & 27 deletions src/main/java/uk/gov/hmcts/reform/civil/utils/CaseNameUtils.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package uk.gov.hmcts.reform.civil.utils;

import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario;
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 static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario;

public class CaseNameUtils {

private CaseNameUtils() {
//no op
}

public static String buildCaseNamePublic(CaseData caseData) {
public static String buildCaseName(CaseData caseData) {
return new StringBuilder()
.append(getFormattedPartyName(caseData.getApplicant1()))
.append(getFormattedLitigationFriendName(caseData.getApplicant1LitigationFriend()))
.append(getFormattedPartyName(caseData.getApplicant2(), true))
.append(getFormattedLitigationFriendName(caseData.getApplicant2LitigationFriend()))
.append(" v ")
.append(getFormattedPartyName(caseData.getRespondent1()))
.append(getFormattedLitigationFriendName(caseData.getRespondent1LitigationFriend()))
.append(getFormattedPartyName(caseData.getRespondent2(), true))
.append(getFormattedLitigationFriendName(caseData.getRespondent2LitigationFriend()))
.toString();
}

Expand All @@ -41,27 +40,4 @@ public static String getFormattedLitigationFriendName(LitigationFriend litigatio
litigationFriend.getLastName()
) : "";
}

public static String buildCaseNameInternal(CaseData caseData) {
StringBuilder participantString = new StringBuilder();
MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData);
if (multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP)
|| multiPartyScenario.equals(MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP)) {
participantString.append(caseData.getApplicant1().getPartyName())
.append(" v ").append(caseData.getRespondent1().getPartyName())
.append(" and ").append(caseData.getRespondent2().getPartyName());

} else if (multiPartyScenario.equals(MultiPartyScenario.TWO_V_ONE)) {
participantString.append(caseData.getApplicant1().getPartyName())
.append(" and ").append(caseData.getApplicant2().getPartyName()).append(" v ")
.append(caseData.getRespondent1()
.getPartyName());

} else {
participantString.append(caseData.getApplicant1().getPartyName()).append(" v ")
.append(caseData.getRespondent1()
.getPartyName());
}
return participantString.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ void shouldSetRespondent1LF_WhenRespondentOneSelected_WithMultiParty_1v2_SameSol
assertThat(response.getData()).extracting("respondent1LitigationFriendDate").isNotNull();
assertThat(response.getData()).extracting("respondent1LitigationFriendCreatedDate").isNotNull();
assertThat(response.getData()).doesNotHaveToString("respondent2LitigationFriend");
assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader' represented by 'Litigation Friend' (litigation friend), 'John Rambo'");
assertThat(response.getData()).extracting("caseNamePublic")
.isEqualTo("'John Rambo' v 'Sole Trader' represented by 'Litigation Friend' (litigation friend), 'John Rambo'");

}

Expand All @@ -233,7 +237,10 @@ void shouldSetRespondent2LF_WhenRespondentTwoSelected_WithMultiParty_1v2_SameSol
assertThat(response.getData()).extracting("respondent2LitigationFriend").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriendDate").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriendCreatedDate").isNotNull();

assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo' represented by 'Litigation Friend' (litigation friend)");
assertThat(response.getData()).extracting("caseNamePublic")
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo' represented by 'Litigation Friend' (litigation friend)");
}

@Test
Expand All @@ -257,7 +264,6 @@ void shouldSetBothRespondentLF_WhenBothRespondentSelected_WithMultiParty_1v2_Sam
assertThat(response.getData()).extracting("respondent2LitigationFriend").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriendDate").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriendCreatedDate").isNotNull();

}

@Test
Expand All @@ -277,7 +283,12 @@ void shouldSetRespondent2_whenRespondent1OptionIsSelected_WithMultiParty_1v2_Sam

assertThat(response.getData()).doesNotHaveToString("respondent1LitigationFriend");
assertThat(response.getData()).extracting("respondent2LitigationFriend").isNotNull();

assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo' represented by "
+ "'Litigation Friend' (litigation friend)");
assertThat(response.getData()).extracting("caseNamePublic")
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo' represented by "
+ "'Litigation Friend' (litigation friend)");
}

@Test
Expand All @@ -297,6 +308,10 @@ void shouldSetRespondent2_whenRespondent2OptionIsSelected_WithMultiParty_1v2_Sam

assertThat(response.getData()).extracting("respondent1LitigationFriend").isNotNull();
assertThat(response.getData()).doesNotHaveToString("respondent2LitigationFriend");
assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader' represented by 'Litigation Friend' (litigation friend), 'John Rambo'");
assertThat(response.getData()).extracting("caseNamePublic")
.isEqualTo("'John Rambo' v 'Sole Trader' represented by 'Litigation Friend' (litigation friend), 'John Rambo'");

}

Expand All @@ -317,7 +332,6 @@ void shouldSetBothRespondent_whenRespondent2OptionIsSelected_WithMultiParty_1v2_

assertThat(response.getData()).extracting("respondent1LitigationFriend").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriend").isNotNull();

}

@Test
Expand All @@ -336,7 +350,6 @@ void should_Set_Respondent1_Ensuring_That_Production_Is_Unaffected_1v1() {

assertThat(response.getData()).extracting("respondent1LitigationFriend").isNotNull();
assertThat(response.getData()).doesNotHaveToString("respondent2LitigationFriend");

}

@Test
Expand Down Expand Up @@ -375,6 +388,8 @@ void shouldSetRespondent1LF_WithMultiParty_1v2_DiffSolicitor() {
assertThat(response.getData()).extracting("respondent1LitigationFriendDate").isNotNull();
assertThat(response.getData()).extracting("respondent1LitigationFriendCreatedDate").isNotNull();
assertThat(response.getData()).doesNotHaveToString("respondent2LitigationFriend");
assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader' represented by 'Litigation Friend' (litigation friend), 'John Rambo'");
}

@Test
Expand All @@ -398,6 +413,8 @@ void shouldSetRespondent2LF_WithMultiParty_1v2_DiffSolicitor() {
assertThat(response.getData()).extracting("respondent2LitigationFriendDate").isNotNull();
assertThat(response.getData()).extracting("respondent2LitigationFriendCreatedDate").isNotNull();
assertThat(response.getData()).doesNotHaveToString("respondent1LitigationFriend");
assertThat(response.getData()).extracting("caseNameHmctsInternal")
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo' represented by 'Litigation Friend' (litigation friend)");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void shouldAssignCaseName1v2_whenCaseIs1v2() {
callbackParamsOf(caseData, ABOUT_TO_SUBMIT));

assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo v Mr. Sole Trader and Mr. John Rambo");
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand All @@ -1261,7 +1261,7 @@ void shouldAssignCaseName2v1_whenCaseIs2v1() {
callbackParamsOf(caseData, ABOUT_TO_SUBMIT));

assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo and Mr. Jason Rambo v Mr. Sole Trader");
.isEqualTo("'John Rambo', 'Jason Rambo' v 'Sole Trader'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand All @@ -1274,7 +1274,7 @@ void shouldAssignCaseName1v1_whenCaseIs1v1() {
callbackParamsOf(caseData, ABOUT_TO_SUBMIT));

assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo v Mr. Sole Trader");
.isEqualTo("'John Rambo' v 'Sole Trader'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ void shouldAssignCaseName1v2_whenCaseIs1v2() {

// Then
assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo v Mr. Sole Trader and Mr. John Rambo");
.isEqualTo("'John Rambo' v 'Sole Trader', 'John Rambo'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand All @@ -1915,7 +1915,7 @@ void shouldAssignCaseName2v1_whenCaseIs2v1() {

// Then
assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo and Mr. Jason Rambo v Mr. Sole Trader");
.isEqualTo("'John Rambo', 'Jason Rambo' v 'Sole Trader'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand All @@ -1931,7 +1931,7 @@ void shouldAssignCaseName1v1_whenCaseIs1v1() {

// Then
assertThat(response.getData().get("caseNameHmctsInternal"))
.isEqualTo("Mr. John Rambo v Mr. Sole Trader");
.isEqualTo("'John Rambo' v 'Sole Trader'");
assertThat(response.getData().get("caseManagementCategory")).extracting("value")
.extracting("code").isEqualTo("Civil");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,32 @@ void shouldCopyFlagsForRespondents(String partyChosenId) {
}
}

@Test
void shouldUpdateInternalCaseName() {
CaseData caseData = CaseDataBuilder.builder()
.atStateApplicantRespondToDefenceAndProceed()
.addApplicant1LitigationFriend()
.updateDetailsForm(UpdateDetailsForm.builder()
.partyChosen(DynamicList.builder()
.value(DynamicListElement.builder()
.code(CLAIMANT_ONE_ID)
.build())
.build())
.partyChosenId(CLAIMANT_ONE_ID)
.updateExpertsDetailsForm(wrapElements(party))
.build())
.build();
CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);

AboutToStartOrSubmitCallbackResponse response = (AboutToStartOrSubmitCallbackResponse) handler
.handle(params);

CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class);
assertThat(updatedData.getCaseNameHmctsInternal())
.isEqualTo("'John Rambo' represented by 'Applicant Litigation Friend' (litigation friend) " +
"v 'Sole Trader'");
}

@Test
void shouldUpdateApplicantOneExperts() {
CaseData caseData = CaseDataBuilder.builder()
Expand Down
Loading

0 comments on commit e10f2c9

Please sign in to comment.