-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSCSSI-247: Added new method updateCaseV2WithUnaryFunction (#1665)
* SSCSSI-247: Overloaded updateCaseV2 and updated recover methods * SSCSSI-247: Added new method updateCaseV2WithUnaryFunction * SSCSSI-247: Updated supressions file * SSCSSI-247: Reverted updates * SSCSSI-247: restored updateCaseV2WithUnaryFunction * SSCSSI-247: Added recover method * SSCSSI-247: Restored UpdateCcdCaseServiceTest * SSCSSI-247: Updates to updateCaseV2 * SSCSSI-247: Reverted indenation to master * SSCSSI-247: Added null check for UpdateResult SscsCaseDetails * SSCSSI-247: Replaced optional with null * Revert "SSCSCI-1214 (#1667)" This reverts commit 2c587eb. * SSCSCI-1214 (#1667) * updating country of residence and port of entry Enum's to reflect new values * updated port of entries * updating airlookup for new ports of entry and ibc RPCs * updating airlookup to remove duplicates * updating AirLookupServiceTest to check for whitespace and different casing * updating suppressions (cherry picked from commit 2c587eb) --------- Co-authored-by: sanjayparekh-hmcts <[email protected]> Co-authored-by: Nilay <[email protected]>
- Loading branch information
1 parent
2c587eb
commit eaccce6
Showing
2 changed files
with
243 additions
and
3 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
213 changes: 213 additions & 0 deletions
213
src/test/java/uk/gov/hmcts/reform/sscs/ccd/service/UpdateCcdCaseServiceTest.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,213 @@ | ||
package uk.gov.hmcts.reform.sscs.ccd.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyLong; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.ArgumentMatchers.isA; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
import static uk.gov.hmcts.reform.sscs.ccd.domain.EventType.POST_HEARING_REQUEST; | ||
import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.NO; | ||
import static uk.gov.hmcts.reform.sscs.ccd.domain.YesNo.YES; | ||
|
||
import java.util.function.UnaryOperator; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import uk.gov.hmcts.reform.ccd.client.model.StartEventResponse; | ||
import uk.gov.hmcts.reform.sscs.ccd.client.CcdClient; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseData; | ||
import uk.gov.hmcts.reform.sscs.ccd.domain.SscsCaseDetails; | ||
import uk.gov.hmcts.reform.sscs.idam.IdamService; | ||
import uk.gov.hmcts.reform.sscs.idam.IdamTokens; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class UpdateCcdCaseServiceTest { | ||
|
||
@Mock | ||
private IdamService idamService; | ||
@Mock | ||
private SscsCcdConvertService sscsCcdConvertService; | ||
@Mock | ||
private CcdClient ccdClient; | ||
|
||
@Captor | ||
private ArgumentCaptor<SscsCaseData> sscsCaseDataArgumentCaptor; | ||
|
||
@InjectMocks | ||
private UpdateCcdCaseService updateCcdCaseService; | ||
|
||
@Test | ||
void handleUpdateCaseV2WithUnaryFunction() { | ||
long caseId = 1234L; | ||
String benefitCode = "200DD"; | ||
UnaryOperator<SscsCaseDetails> unaryOperator = sscsCaseDetails -> sscsCaseDetails.toBuilder() | ||
.data(SscsCaseData.builder() | ||
.addDocuments(YES) | ||
.benefitCode(benefitCode) | ||
.build()) | ||
.build(); | ||
|
||
when(ccdClient.startEvent(isA(IdamTokens.class), anyLong(), eq(POST_HEARING_REQUEST.getType()))) | ||
.thenReturn(StartEventResponse.builder().build()); | ||
|
||
when(sscsCcdConvertService.getCaseDetails(isA(StartEventResponse.class))) | ||
.thenReturn(SscsCaseDetails.builder() | ||
.data(SscsCaseData.builder() | ||
.addDocuments(NO) | ||
.build()) | ||
.build()); | ||
|
||
String postHearingSummary = "Post hearing Summary"; | ||
String postHearingDescription = "Post hearing Description"; | ||
|
||
updateCcdCaseService.updateCaseV2WithUnaryFunction( | ||
caseId, | ||
POST_HEARING_REQUEST.getType(), | ||
postHearingSummary, | ||
postHearingDescription, | ||
IdamTokens.builder().build(), | ||
unaryOperator); | ||
|
||
verify(sscsCcdConvertService).getCaseDataContent( | ||
sscsCaseDataArgumentCaptor.capture(), | ||
any(), | ||
eq(postHearingSummary), | ||
eq(postHearingDescription)); | ||
|
||
SscsCaseData sscsCaseData = sscsCaseDataArgumentCaptor.getValue(); | ||
assertThat(sscsCaseData.getAddDocuments()) | ||
.isEqualTo(YES); | ||
assertThat(sscsCaseData.getBenefitCode()) | ||
.isEqualTo(benefitCode); | ||
} | ||
|
||
@Test | ||
void handleUpdateCaseV2() { | ||
long caseId = 1234L; | ||
String benefitCode = "200DD"; | ||
|
||
when(ccdClient.startEvent(isA(IdamTokens.class), anyLong(), eq(POST_HEARING_REQUEST.getType()))) | ||
.thenReturn(StartEventResponse.builder().build()); | ||
|
||
when(sscsCcdConvertService.getCaseDetails(isA(StartEventResponse.class))) | ||
.thenReturn(SscsCaseDetails.builder() | ||
.data(SscsCaseData.builder() | ||
.addDocuments(NO) | ||
.build()) | ||
.build()); | ||
|
||
String postHearingSummary = "Post hearing Summary"; | ||
String postHearingDescription = "Post hearing Description"; | ||
|
||
updateCcdCaseService.updateCaseV2( | ||
caseId, | ||
POST_HEARING_REQUEST.getType(), | ||
postHearingSummary, | ||
postHearingDescription, | ||
IdamTokens.builder().build(), | ||
sscsCaseDetails -> { | ||
sscsCaseDetails.getData().setAddDocuments(YES); | ||
sscsCaseDetails.getData().setBenefitCode(benefitCode); | ||
}); | ||
|
||
verify(sscsCcdConvertService).getCaseDataContent( | ||
sscsCaseDataArgumentCaptor.capture(), | ||
any(), | ||
eq(postHearingSummary), | ||
eq(postHearingDescription)); | ||
|
||
SscsCaseData sscsCaseData = sscsCaseDataArgumentCaptor.getValue(); | ||
assertThat(sscsCaseData.getAddDocuments()) | ||
.isEqualTo(YES); | ||
assertThat(sscsCaseData.getBenefitCode()) | ||
.isEqualTo(benefitCode); | ||
} | ||
|
||
@Test | ||
void handleUpdateCaseV2WithUpdateResult() { | ||
long caseId = 1234L; | ||
String benefitCode = "200DD"; | ||
|
||
when(ccdClient.startEvent(isA(IdamTokens.class), anyLong(), eq(POST_HEARING_REQUEST.getType()))) | ||
.thenReturn(StartEventResponse.builder().build()); | ||
|
||
when(sscsCcdConvertService.getCaseDetails(isA(StartEventResponse.class))) | ||
.thenReturn(SscsCaseDetails.builder() | ||
.data(SscsCaseData.builder() | ||
.addDocuments(NO) | ||
.build()) | ||
.build()); | ||
|
||
String postHearingSummary = "Post hearing Summary"; | ||
String postHearingDescription = "Post hearing Description"; | ||
|
||
updateCcdCaseService.updateCaseV2( | ||
caseId, | ||
POST_HEARING_REQUEST.getType(), | ||
IdamTokens.builder().build(), | ||
sscsCaseDetails -> { | ||
sscsCaseDetails.getData().setAddDocuments(YES); | ||
sscsCaseDetails.getData().setBenefitCode(benefitCode); | ||
return new UpdateCcdCaseService.UpdateResult(postHearingSummary, postHearingDescription); | ||
}); | ||
|
||
verify(sscsCcdConvertService).getCaseDataContent( | ||
sscsCaseDataArgumentCaptor.capture(), | ||
any(), | ||
eq(postHearingSummary), | ||
eq(postHearingDescription)); | ||
|
||
SscsCaseData sscsCaseData = sscsCaseDataArgumentCaptor.getValue(); | ||
assertThat(sscsCaseData.getAddDocuments()) | ||
.isEqualTo(YES); | ||
assertThat(sscsCaseData.getBenefitCode()) | ||
.isEqualTo(benefitCode); | ||
} | ||
|
||
@Test | ||
void handleUpdateCaseV2WithUpdateResultSetWithNullSccsCaseDetails() { | ||
long caseId = 1234L; | ||
String benefitCode = "200DD"; | ||
|
||
when(ccdClient.startEvent(isA(IdamTokens.class), anyLong(), eq(POST_HEARING_REQUEST.getType()))) | ||
.thenReturn(StartEventResponse.builder().build()); | ||
|
||
when(sscsCcdConvertService.getCaseDetails(isA(StartEventResponse.class))) | ||
.thenReturn(SscsCaseDetails.builder() | ||
.data(SscsCaseData.builder() | ||
.addDocuments(NO) | ||
.build()) | ||
.build()); | ||
|
||
String postHearingSummary = "Post hearing Summary"; | ||
String postHearingDescription = "Post hearing Description"; | ||
|
||
updateCcdCaseService.updateCaseV2( | ||
caseId, | ||
POST_HEARING_REQUEST.getType(), | ||
IdamTokens.builder().build(), | ||
sscsCaseDetails -> { | ||
sscsCaseDetails.getData().setAddDocuments(YES); | ||
sscsCaseDetails.getData().setBenefitCode(benefitCode); | ||
return new UpdateCcdCaseService.UpdateResult(null, postHearingSummary, postHearingDescription); | ||
}); | ||
|
||
verify(sscsCcdConvertService).getCaseDataContent( | ||
sscsCaseDataArgumentCaptor.capture(), | ||
any(), | ||
eq(postHearingSummary), | ||
eq(postHearingDescription)); | ||
|
||
SscsCaseData sscsCaseData = sscsCaseDataArgumentCaptor.getValue(); | ||
assertThat(sscsCaseData.getAddDocuments()) | ||
.isEqualTo(YES); | ||
assertThat(sscsCaseData.getBenefitCode()) | ||
.isEqualTo(benefitCode); | ||
} | ||
} |