-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for MeansAssessmentApiService
- Loading branch information
1 parent
45d30e3
commit b1b6476
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...rc/test/java/uk/gov/justice/laa/crime/evidence/service/MeansAssessmentApiServiceTest.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,51 @@ | ||
package uk.gov.justice.laa.crime.evidence.service; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.atLeastOnce; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Spy; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import uk.gov.justice.laa.crime.common.model.meansassessment.ApiGetMeansAssessmentResponse; | ||
import uk.gov.justice.laa.crime.common.model.meansassessment.ApiMeansAssessmentResponse; | ||
import uk.gov.justice.laa.crime.common.model.meansassessment.ApiUpdateMeansAssessmentRequest; | ||
import uk.gov.justice.laa.crime.commons.client.RestAPIClient; | ||
import uk.gov.justice.laa.crime.enums.MagCourtOutcome; | ||
import uk.gov.justice.laa.crime.evidence.config.MockServicesConfiguration; | ||
import uk.gov.justice.laa.crime.evidence.config.ServicesConfiguration; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class MeansAssessmentApiServiceTest { | ||
@Mock | ||
private RestAPIClient cmaApiClient; | ||
|
||
@InjectMocks | ||
private MeansAssessmentApiService meansAssessmentApiService; | ||
|
||
@Spy | ||
private ServicesConfiguration configuration = MockServicesConfiguration.getConfiguration(1000); | ||
|
||
@Test | ||
void givenAValidFinancialAssessmentId_whenFindIsInvoked_thenResponseIsReturned() { | ||
when(cmaApiClient.get(any(), any(), eq(1))).thenReturn(new ApiGetMeansAssessmentResponse()); | ||
meansAssessmentApiService.find(1); | ||
verify(cmaApiClient, atLeastOnce()).get(any(), any(), eq(1)); | ||
} | ||
|
||
@Test | ||
void givenAValidRequest_whenUpdateIsInvoked_thenResponseIsReturned() { | ||
ApiUpdateMeansAssessmentRequest request = new ApiUpdateMeansAssessmentRequest() | ||
.withFinancialAssessmentId(2) | ||
.withMagCourtOutcome(MagCourtOutcome.APPEAL_TO_CC); | ||
|
||
when(cmaApiClient.put(eq(request), any(), any(), any())).thenReturn(new ApiMeansAssessmentResponse()); | ||
meansAssessmentApiService.update(request); | ||
verify(cmaApiClient, atLeastOnce()).put(eq(request), any(), any(), any()); | ||
} | ||
} |