Added logic for creation, mangemnet and display of case links#1527
Added logic for creation, mangemnet and display of case links#1527aschalew-at wants to merge 30 commits intomasterfrom
Conversation
CCD diff summary👉 Full report: https://github.com/hmcts/pcs-api/actions/runs/23911120884?check_suite_focus=true AuthorisationCaseState.json
CaseField.json
AuthorisationCaseEvent/AuthorisationCaseEvent.json
AuthorisationCaseField/caseworker-pcs.json
AuthorisationCaseField/caseworker-pcs-solicitor.json
CaseEvent/maintainCaseLink.json
CaseEvent/createCaseLink.json
CaseEventToFields/maintainCaseLink.json
CaseEventToFields/createCaseLink.json
CaseTypeTab/6_caseLinkscaseworker-pcs-solicitor.json
|
| } | ||
|
|
||
| this.caseLinks.clear(); | ||
| this.caseLinks.addAll(result); |
There was a problem hiding this comment.
Is there a reason for not just assigning result, (which could have a better name btw), to this.caseLinks ?
There was a problem hiding this comment.
Same as above. The caseLinks field in PcsCaseEntity is annotated with @onetomany with orphanRemoval set to true, Hibernate tracks the original collection instance and expects the same collection to be mutated and not swapped out. result renamed to mergedCaseLinkEntities.
| @Override | ||
| public SetMultimap<HasRole, Permission> getGrants() { | ||
| SetMultimap<HasRole, Permission> grants = HashMultimap.create(); | ||
| grants.putAll(PCS_SOLICITOR, Permission.CRU); |
There was a problem hiding this comment.
Is the Delete missing for permissions ? In the event - CreateCaseLink class, solicitor has full CRUD access.
There was a problem hiding this comment.
The access profile in CaseLinkinAccess is applied to the fields in PCSCase (for updating cases) do not need the Delete permission in association with the events CreateCaseLink and MaintainLinkCase. In the event class CreateCaseLink, we only need the permissions CRU, whereas in the event class MaintainLinkCase, we need the Delete permission as well. Hence I will remove the Delete permission in CreateCaseLink and keep it in MaintainLinkCase. I will keep CRU in CaseLinkinAccess class
…n for solicitor in CreateCaseLink
tvr-hmcts
left a comment
There was a problem hiding this comment.
Some comments for consideration
| .build(); | ||
| caseLinkReasonEntities.add(caseLinkReasonEntity); | ||
| } | ||
| caseLinkEntity.getReasons().clear(); |
There was a problem hiding this comment.
Is this call needed again here?
| } | ||
|
|
||
| @Test | ||
| void shouldAddCaseLinkReason() { |
There was a problem hiding this comment.
This is just testing a setter no? Guess I am not understanding the value.
|
|
||
| if (dto.getReasonForLink() != null) { | ||
| List<CaseLinkReasonEntity> caseLinkReasonEntities = new ArrayList<>(); | ||
| for (ListValue<LinkReason> incomingLinkReason : dto.getReasonForLink()) { |
There was a problem hiding this comment.
This can just be streamed into the reasons collection within the entity rather than create this new arraylist.
| @Component | ||
| public class CaseLinkView { | ||
|
|
||
| public void setCaseFields(PCSCase pcsCase, PcsCaseEntity pcsCaseEntity) { |
There was a problem hiding this comment.
Not understanding the point in this wrapper. The same check is made within the other method also. So the other can just be public
|
|
||
| private final PcsCaseService pcsCaseService; | ||
|
|
||
|
|
| } | ||
|
|
||
| @Test | ||
| void shouldPatchCaseData() { |
There was a problem hiding this comment.
Need another test for when the pcsCase.getCaseLinks() != null
| // Given | ||
| PcsCaseEntity pcsCaseEntity = mock(PcsCaseEntity.class); | ||
| PCSCase caseData = PCSCase.builder().build(); | ||
| when(pcsCaseRepository.findByCaseReference(CASE_REFERENCE)).thenReturn(java.util.Optional.of(pcsCaseEntity)); |
There was a problem hiding this comment.
import java.util.Optional
| underTest.patchCaseLinks(CASE_REFERENCE, caseData); | ||
|
|
||
| // Then | ||
| verify(caseLinkService, atLeastOnce()).mergeCaseLinks(caseData.getCaseLinks(), pcsCaseEntity); |
There was a problem hiding this comment.
The number of times can be asserted more strictly here.
| } | ||
|
|
||
| @Test | ||
| void shouldModifyCaseLinksInSubmitCallback() { |
There was a problem hiding this comment.
The logic in here is a duplication of the other test CreateCaseLinkTest
| // Then | ||
| List<ListValue<CaseLink>> mappedCaseLinks = pcsCase.getCaseLinks(); | ||
| assertThat(mappedCaseLinks).hasSize(1); | ||
| assertThat(mappedCaseLinks.getFirst().getValue().getCaseReference()).isEqualTo("1234"); |
There was a problem hiding this comment.
mappedCaseLinks.getFirst().getValue() can be extracted and the variable used in the other asserts rather than call the same chain each time.
Jira link
See [HDPI-4510](https://tools.hmcts.net/jira/browse/HDPI-4510)
[HDPI-4509](https://tools.hmcts.net/jira/browse/HDPI-4509)
[HDPI-4512](https://tools.hmcts.net/jira/browse/HDPI-4512)
Change description
This is about case linking which is linking of cases based on certain reasons.The PR includes changes for creation, managing and displaying of cases links.
Testing done
Security Vulnerability Assessment
CVE Suppression: Are there any CVEs present in the codebase (either newly introduced or pre-existing) that are being intentionally suppressed or ignored by this commit?
Checklist