Skip to content

Commit

Permalink
CIV-11205 CIV-10754 Initiate GA about to sumit and updated written Re…
Browse files Browse the repository at this point in the history
…p templates for local (#3566)

* CIV-11205 populated full address for after sdo scenarios

* CIV-11205 update TriggerGenApp to  update address

* CIV-11205 Updated address during TriggerLocationUpdate Event

* CIV-11205 Unit tests covered for location update

* CIV-11205 updated templates with court full address

* CIV-11205 Code smell corrected

* CIV-11205 Updated written representation templates with location

* CIV-11205 updated locationName to courtName

* CIV-10754 updated with the changes

* CIV-10754 removed duplicate assignment

* CIV-10754 check style issue corrected

* CIV-10754 checkstyle issues corrected

* CIV-10754  Setting up the id only when caseRole is not null

* CIV-10754 checkstyle issues corrected

* CIV-10754 Added condition to avoid users having multiple roles

* CIV-10754 updated tests

* CIV-10754 updated unit test data

* CIV-10754 Added condition to avoid null pointer

* CIV-10754 added condition for adding respondent solicitors

* CIV-10754 Log to verify ccd userroles
  • Loading branch information
deepthidoppalapudihmcts authored Nov 22, 2023
1 parent 67305d1 commit 1c05384
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01070.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01071.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

Expand All @@ -39,6 +40,7 @@ public class InitiateGeneralApplicationServiceHelper {
private final AuthTokenGenerator authTokenGenerator;
private final UserService userService;
private final CrossAccessUserConfiguration crossAccessUserConfiguration;
public CaseAssignedUserRolesResource userRoles;

public boolean isGAApplicantSameAsPCClaimant(CaseData caseData, String organisationIdentifier) {

Expand All @@ -56,14 +58,12 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder
|| (YES.equals(caseData.getAddRespondent2()) && caseData.getRespondent2OrganisationPolicy() == null)) {
throw new IllegalArgumentException("Solicitor Org details are not set correctly.");
}
GeneralApplication.GeneralApplicationBuilder applicationBuilder = generalApplication.toBuilder();

String parentCaseId = caseData.getCcdCaseReference().toString();

String applicant1OrgCaseRole = caseData.getApplicant1OrganisationPolicy().getOrgPolicyCaseAssignedRole();
String respondent1OrgCaseRole = caseData.getRespondent1OrganisationPolicy().getOrgPolicyCaseAssignedRole();

CaseAssignedUserRolesResource userRoles = getUserRoles(parentCaseId);
userRoles = getUserRoles(parentCaseId);

/*Filter the case users to collect solicitors whose ID doesn't match with GA Applicant Solicitor's ID*/
List<CaseAssignedUserRole> respondentSolicitors = userRoles.getCaseAssignedUserRoles().stream()
Expand Down Expand Up @@ -119,7 +119,7 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder
}
}
}

GeneralApplication.GeneralApplicationBuilder applicationBuilder = generalApplication.toBuilder();
applicationBuilder
.generalAppApplnSolicitor(applicantBuilder.build());
String applicantPartyName = null;
Expand All @@ -133,28 +133,33 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder
GASolicitorDetailsGAspec.GASolicitorDetailsGAspecBuilder specBuilder = GASolicitorDetailsGAspec
.builder();

specBuilder.id(respSol.getUserId());

if (respSol.getCaseRole() != null) {
log.info(respSol.getCaseRole(), "**", respSol.getUserId());
/*Populate the GA respondent solicitor details in accordance with civil case Applicant Solicitor 1
details if case role of collected user matches with case role of Applicant 1*/
if (respSol.getCaseRole().equals(applicant1OrgCaseRole)) {
if (caseData.getApplicantSolicitor1UserDetails() != null) {
specBuilder.id(respSol.getUserId());
specBuilder.email(caseData.getApplicantSolicitor1UserDetails().getEmail());
specBuilder.organisationIdentifier(caseData.getApplicant1OrganisationPolicy()
.getOrganisation().getOrganisationID());
}
/*Populate the GA respondent solicitor details in accordance with civil case Respondent
Solicitor 1 details if caserole of collected user matches with caserole Respondent Solicitor 1*/
} else if (respSol.getCaseRole().equals(respondent1OrgCaseRole)) {
specBuilder.id(respSol.getUserId());
specBuilder.email(caseData.getRespondentSolicitor1EmailAddress());
specBuilder.organisationIdentifier(getRespondent1SolicitorOrgId(caseData));

/*Populate the GA respondent solicitor details in accordance with civil case Respondent
Solicitor 2 details if it's 1 V 2 Different Solicitor scenario*/
} else {
specBuilder.email(caseData.getRespondentSolicitor2EmailAddress());
specBuilder.organisationIdentifier(getRespondent2SolicitorOrgId(caseData));
if (Objects.nonNull(caseData.getAddRespondent2())
&& caseData.getAddRespondent2().equals(YES)) {
specBuilder.id(respSol.getUserId());
specBuilder.email(caseData.getRespondentSolicitor2EmailAddress());
specBuilder.organisationIdentifier(getRespondent2SolicitorOrgId(caseData));
}
}
/*Set the GA Respondent solicitor details to Empty if above checks are failed*/
} else {
Expand All @@ -167,7 +172,10 @@ public GeneralApplication setRespondentDetailsIfPresent(CaseData.CaseDataBuilder
}

GASolicitorDetailsGAspec gaSolicitorDetailsGAspec = specBuilder.build();
respondentSols.add(element(gaSolicitorDetailsGAspec));
if (Objects.nonNull(gaSolicitorDetailsGAspec.getId())) {
respondentSols.add(element(gaSolicitorDetailsGAspec));
}

});
applicantPartyName = getApplicantPartyName(userRoles, userDetails, caseData);
applicationBuilder.applicantPartyName(applicantPartyName);
Expand Down Expand Up @@ -252,8 +260,12 @@ public boolean isGAApplicantSameAsParentCaseClaimant(CaseData caseData, String a
}

public CaseAssignedUserRolesResource getUserRoles(String parentCaseId) {
return caseAccessDataStoreApi.getUserRoles(
getCaaAccessToken(), authTokenGenerator.generate(), List.of(parentCaseId));
if (Objects.isNull(userRoles)) {
userRoles = caseAccessDataStoreApi.getUserRoles(
getCaaAccessToken(), authTokenGenerator.generate(), List.of(parentCaseId));
}
log.info("UserRoles from API :" + userRoles);
return userRoles;
}

public String getCaaAccessToken() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.reform.civil.handler.callback.user;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -95,6 +96,11 @@ void setup() {
.caseAssignedUserRoles(getCaseAssignedApplicantUserRoles()).build());
}

@AfterEach
void setUserRolesAsNull() {
helper.userRoles = null;
}

public List<CaseAssignedUserRole> getCaseAssignedApplicantUserRoles() {
return List.of(
CaseAssignedUserRole.builder().caseDataId("1").userId(STRING_NUM_CONSTANT)
Expand Down Expand Up @@ -268,6 +274,7 @@ void shouldSetApplicantSolicitorOrgIDTo200() {
.respondentSolicitor1EmailAddress(RESPONDENT_EMAIL_ID_CONSTANT)
.applicant1(Party.builder().type(COMPANY).companyName("Applicant1").build())
.respondent2(Party.builder().type(COMPANY).companyName("Respondent1").build())
.addRespondent2(YesOrNo.YES)
.applicant1OrganisationPolicy(OrganisationPolicy.builder()
.organisation(Organisation.builder().organisationID("200").build())
.orgPolicyCaseAssignedRole(APPLICANTSOLICITORONE.getFormattedName())
Expand Down Expand Up @@ -309,6 +316,7 @@ void shouldSetApplicantSolicitorOrgIDTo100() {
.applicant2(Party.builder().type(COMPANY).companyName("Applicant2").build())
.respondent1(Party.builder().type(COMPANY).companyName("Respondent1").build())
.respondent2(Party.builder().type(COMPANY).companyName("Respondent2").build())
.addRespondent2(YesOrNo.YES)
.applicant1OrganisationPolicy(OrganisationPolicy.builder()
.organisation(Organisation.builder().organisationID("200").build())
.orgPolicyCaseAssignedRole(APPLICANTSOLICITORONE.getFormattedName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,7 @@ public CaseData getVaryJudgmentWithN245TestData() {
.ccdCaseReference(1L)
.applicant1(Party.builder().type(Party.Type.COMPANY).companyName("Applicant1").build())
.respondent1(Party.builder().type(Party.Type.COMPANY).companyName("Respondent1").build())
.addRespondent2(NO)
.courtLocation(CourtLocation.builder()
.caseLocation(CaseLocationCivil.builder()
.region("2")
Expand Down

0 comments on commit 1c05384

Please sign in to comment.