Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ public class PrlAppsConstants {
public static final String CITIZEN_RESPONDENT_APPLCATION = "Respondent application";
public static final String CITIZEN_RESPONDENT_C1A_APPLCATION = "Respondent C1A application";
public static final String SOLICITOR_RESPONDENT_APPLCATION = "Respondent Application";
public static final String SOLICITOR_RESPONDENT_APPLICATION_CATEGORY_ID = "respondentApplication";
public static final String SOLICITOR_RESPONDENT_C1A_APPLCATION = "Respondent C1A Application";
public static final String RESPONDENT_C1A_RESPONSE = "Respondent C1A response";
public static final String CASE_SUMMARY = "Case summary";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_ADMIN;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_ADMIN_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_STAFF;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.INTERNAL_CORRESPONDENCE_CATEGORY_ID;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.INTERNAL_CORRESPONDENCE_LABEL;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.JUDGE_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.JURISDICTION;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.LEGAL_ADVISER_ROLE;
Expand Down Expand Up @@ -378,14 +376,12 @@ private QuarantineLegalDoc convertQuarantineDocumentToRightCategoryDocument(Quar
}

private QuarantineLegalDoc covertManageDocToQuarantineDoc(ManageDocuments manageDocument, UserDetails userDetails) {
boolean isCourtPartySelected = DocumentPartyEnum.COURT.equals(manageDocument.getDocumentParty());

String loggedInUserType = DocumentUtils.getLoggedInUserType(userDetails);
QuarantineLegalDoc quarantineLegalDoc = QuarantineLegalDoc.builder()
.documentParty(manageDocument.getDocumentParty().getDisplayedValue())
.documentUploadedDate(LocalDateTime.now(ZoneId.of(LONDON_TIME_ZONE)))
.categoryId(isCourtPartySelected ? INTERNAL_CORRESPONDENCE_CATEGORY_ID : manageDocument.getDocumentCategories().getValueCode())
.categoryName(isCourtPartySelected ? INTERNAL_CORRESPONDENCE_LABEL : manageDocument.getDocumentCategories().getValueLabel())
.categoryId(manageDocument.getDocumentCategories().getValueCode())
.categoryName(manageDocument.getDocumentCategories().getValueLabel())
//PRL-4320 - Manage documents redesign
.isConfidential(manageDocument.getIsConfidential())
.isRestricted(manageDocument.getIsRestricted())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_ADMIN;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_ADMIN_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.COURT_STAFF;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.INTERNAL_CORRESPONDENCE_CATEGORY_ID;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.INTERNAL_CORRESPONDENCE_LABEL;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.JUDGE_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.LEGAL_ADVISER_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.RESTRICTED_DOCUMENTS;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.SOLICITOR_RESPONDENT_APPLCATION;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.SOLICITOR_RESPONDENT_APPLICATION_CATEGORY_ID;
import static uk.gov.hmcts.reform.prl.constants.PrlAppsConstants.SOLICITOR_ROLE;
import static uk.gov.hmcts.reform.prl.constants.PrlLaunchDarklyFlagConstants.ROLE_ASSIGNMENT_API_IN_ORDERS_JOURNEY;
import static uk.gov.hmcts.reform.prl.services.managedocuments.ManageDocumentsService.MANAGE_DOCUMENTS_RESTRICTED_FLAG;
Expand Down Expand Up @@ -1344,6 +1348,15 @@ private RoleAssignmentServiceResponse setAndGetRoleAssignmentServiceResponse(Str

@Test
public void testCopyDocumentIfNotRestrictedAndUploadedOnBehalfOfCourt() {
DynamicListElement element = DynamicListElement.builder()
.code(INTERNAL_CORRESPONDENCE_CATEGORY_ID)
.label(INTERNAL_CORRESPONDENCE_LABEL)
.build();

dynamicList = DynamicList.builder()
.value(element)
.build();

ManageDocuments manageDocuments = ManageDocuments.builder()
.documentParty(DocumentPartyEnum.COURT)
.documentCategories(dynamicList)
Expand Down Expand Up @@ -1396,6 +1409,70 @@ public void testCopyDocumentIfNotRestrictedAndUploadedOnBehalfOfCourt() {
assertNull(caseDataMapUpdated.get("manageDocuments"));
}

@Test
public void testUseSelectedCategoryWhenPartyIsCourt() {
DynamicListElement element = DynamicListElement.builder()
.code(SOLICITOR_RESPONDENT_APPLICATION_CATEGORY_ID)
.label(SOLICITOR_RESPONDENT_APPLCATION)
.build();

dynamicList = DynamicList.builder()
.value(element)
.build();

ManageDocuments manageDocuments = ManageDocuments.builder()
.documentParty(DocumentPartyEnum.COURT)
.documentCategories(dynamicList)
.documentRestrictCheckbox(new ArrayList<>())
.document(uk.gov.hmcts.reform.prl.models.documents.Document.builder().build())
.build();
HashMap hashMap = new HashMap();
hashMap.put("respondentApplicationDocument", manageDocuments.getDocument());

Map<String, Object> caseDataMapInitial = new HashMap<>();
caseDataMapInitial.put("manageDocuments",manageDocuments);

List<Element<QuarantineLegalDoc>> legalProfQuarantineDocsListInitial = new ArrayList<>();
caseDataMapInitial.put("legalProfQuarantineDocsList",legalProfQuarantineDocsListInitial);

List<Element<QuarantineLegalDoc>> legalProfUploadDocListDocTabInitial = new ArrayList<>();
caseDataMapInitial.put("legalProfUploadDocListDocTab",legalProfUploadDocListDocTabInitial);

manageDocumentsElement = element(manageDocuments);

QuarantineLegalDoc quarantineLegalDoc = QuarantineLegalDoc.builder().build();
quarantineLegalDocElement = element(quarantineLegalDoc);
ReviewDocuments reviewDocuments = ReviewDocuments.builder().build();

CaseData caseData = CaseData.builder()
.reviewDocuments(reviewDocuments)
.documentManagementDetails(DocumentManagementDetails.builder()
.manageDocuments(List.of(manageDocumentsElement))
.build())
.build();
CaseDetails caseDetails = CaseDetails.builder().id(12345L).data(caseDataMapInitial).build();
CallbackRequest callbackRequest = CallbackRequest.builder().caseDetails(caseDetails).build();

when(objectMapper.convertValue(hashMap, QuarantineLegalDoc.class)).thenReturn(quarantineLegalDoc);
when(objectMapper.convertValue(caseDetails.getData(), CaseData.class)).thenReturn(caseData);
when(caseUtils.getCaseData(callbackRequest.getCaseDetails(), objectMapper)).thenReturn(caseData);
when(userService.getUserDetails(auth)).thenReturn(userDetailsCourtAdminRole);
when(authTokenGenerator.generate()).thenReturn("serviceAuthToken");
RoleAssignmentServiceResponse roleAssignmentServiceResponse = setAndGetRoleAssignmentServiceResponse(
"hearing-centre-admin");
when(roleAssignmentApi.getRoleAssignments(auth, authTokenGenerator.generate(), null, "345")).thenReturn(
roleAssignmentServiceResponse);
when(launchDarklyClient.isFeatureEnabled("role-assignment-api-in-orders-journey")).thenReturn(true);

Map<String, Object> caseDataMapUpdated = manageDocumentsService.copyDocument(callbackRequest, auth);

courtStaffUploadDocListDocTab = (List<Element<QuarantineLegalDoc>>) caseDataMapUpdated.get("courtStaffUploadDocListDocTab");
QuarantineLegalDoc result = courtStaffUploadDocListDocTab.getFirst().getValue();

assertEquals(SOLICITOR_RESPONDENT_APPLICATION_CATEGORY_ID, result.getCategoryId());
assertEquals(SOLICITOR_RESPONDENT_APPLCATION, result.getCategoryName());
}

@Test
public void returnTrueIfUserIsCourtStaff() {
when(userService.getUserDetails(auth)).thenReturn(userDetailsCourtAdminRole);
Expand Down