-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DTSCCI-313 check defendant is linked for civil claims (#5098)
* check if civil claim is linked. * clean up functionality to use 1 endpoint for both ocmc and civil cases. * remove unnecessary try catch * fix build * add test for sonar * add test for sonar (2) * clean + test * improve test --------- Co-authored-by: Nigel Dunne <[email protected]> Co-authored-by: mfallonhmcts <[email protected]>
- Loading branch information
1 parent
0b6d0a1
commit b5ef5bb
Showing
5 changed files
with
135 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/uk/gov/hmcts/reform/civil/model/DefendantLinkStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package uk.gov.hmcts.reform.civil.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class DefendantLinkStatus { | ||
|
||
private boolean isOcmcCase; | ||
private boolean linked; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import uk.gov.hmcts.reform.civil.model.BusinessProcess; | ||
import uk.gov.hmcts.reform.civil.model.CaseData; | ||
import uk.gov.hmcts.reform.civil.model.DefendantPinToPostLRspec; | ||
import uk.gov.hmcts.reform.civil.model.IdamUserDetails; | ||
import uk.gov.hmcts.reform.civil.sampledata.CaseDataBuilder; | ||
import uk.gov.hmcts.reform.civil.sampledata.CaseDetailsBuilder; | ||
import uk.gov.hmcts.reform.civil.service.claimstore.ClaimStoreService; | ||
|
@@ -149,7 +150,7 @@ void shouldResetPinExpiryDateSuccessfully() { | |
} | ||
|
||
@Test | ||
void shouldReturnTrueIfDefendantIsLinked() { | ||
void shouldReturnTrueIfOcmcDefendantIsLinked() { | ||
when(claimStoreService.isOcmcDefendantLinked("620MC123")).thenReturn(createDefendantLinkStatus(true)); | ||
|
||
boolean status = defendantPinToPostLRspecService.isOcmcDefendantLinked("620MC123"); | ||
|
@@ -158,14 +159,62 @@ void shouldReturnTrueIfDefendantIsLinked() { | |
} | ||
|
||
@Test | ||
void shouldReturnFalseIfDefendantIsNotLinked() { | ||
void shouldReturnFalseIfOcmcDefendantIsNotLinked() { | ||
when(claimStoreService.isOcmcDefendantLinked("620MC123")).thenReturn(createDefendantLinkStatus(false)); | ||
|
||
boolean status = defendantPinToPostLRspecService.isOcmcDefendantLinked("620MC123"); | ||
|
||
assertFalse(status); | ||
} | ||
|
||
@Test | ||
void shouldReturnTrueIfDefendantIsLinked() { | ||
CaseData caseData = new CaseDataBuilder() | ||
.defendantUserDetails( | ||
IdamUserDetails.builder() | ||
.id("1234") | ||
.email("[email protected]") | ||
.build()) | ||
.build(); | ||
CaseDetails caseDetails = createCaseDetails(caseData); | ||
when(caseDetailsConverter.toCaseData(caseDetails)).thenReturn(caseData); | ||
boolean status = defendantPinToPostLRspecService.isDefendantLinked(caseDetails); | ||
|
||
assertTrue(status); | ||
} | ||
|
||
@Test | ||
void shouldReturnFalseIfDefendantIsNotLinked() { | ||
CaseData caseData = new CaseDataBuilder().defendantUserDetails(null).build(); | ||
CaseDetails caseDetails = createCaseDetails(caseData); | ||
when(caseDetailsConverter.toCaseData(caseDetails)).thenReturn(caseData); | ||
boolean status = defendantPinToPostLRspecService.isDefendantLinked(caseDetails); | ||
|
||
assertFalse(status); | ||
} | ||
|
||
@Test | ||
void shouldReturnFalseIfUserDetailsEmailIsEmpty() { | ||
CaseData caseData = new CaseDataBuilder().defendantUserDetails(IdamUserDetails.builder().id("1234").build()).build(); | ||
CaseDetails caseDetails = createCaseDetails(caseData); | ||
when(caseDetailsConverter.toCaseData(caseDetails)).thenReturn(caseData); | ||
boolean status = defendantPinToPostLRspecService.isDefendantLinked(caseDetails); | ||
|
||
assertFalse(status); | ||
} | ||
|
||
@Test | ||
void shouldReturnFalseIfUserDetailsIdIsEmpty() { | ||
CaseData caseData = new CaseDataBuilder().defendantUserDetails( | ||
IdamUserDetails.builder().email("[email protected]").build() | ||
).build(); | ||
CaseDetails caseDetails = createCaseDetails(caseData); | ||
when(caseDetailsConverter.toCaseData(caseDetails)).thenReturn(caseData); | ||
boolean status = defendantPinToPostLRspecService.isDefendantLinked(caseDetails); | ||
|
||
assertFalse(status); | ||
} | ||
|
||
private CaseData createCaseDataWithPin(String accessCode, int daysToExpiry) { | ||
return new CaseDataBuilder().atStateClaimSubmitted() | ||
.addRespondent1PinToPostLRspec(createPinToPost(accessCode, LocalDate.now().plusDays(daysToExpiry))) | ||
|