generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase Mutation coverage for Staff Reference Data (#741)
* rd caseworker mutation upgrade
- Loading branch information
1 parent
b07cd94
commit aa4fe8d
Showing
13 changed files
with
391 additions
and
9 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
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
27 changes: 27 additions & 0 deletions
27
src/test/java/uk/gov/hmcts/reform/cwrdapi/domain/RoleDeletionResponseTest.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,27 @@ | ||
package uk.gov.hmcts.reform.cwrdapi.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import uk.gov.hmcts.reform.cwrdapi.client.domain.RoleDeletionResponse; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.junit.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class RoleDeletionResponseTest { | ||
|
||
@Test | ||
void testSkillResposne_for_valid_data() { | ||
|
||
RoleDeletionResponse roleDeletionResponse = new RoleDeletionResponse(); | ||
|
||
roleDeletionResponse.setRoleName("role"); | ||
roleDeletionResponse.setIdamStatusCode("active"); | ||
roleDeletionResponse.setIdamMessage("message"); | ||
|
||
assertNotNull(roleDeletionResponse); | ||
assertThat(roleDeletionResponse.getRoleName(),is("role")); | ||
assertThat(roleDeletionResponse.getIdamMessage(), is("message")); | ||
assertThat(roleDeletionResponse.getIdamStatusCode(), is("active")); | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/uk/gov/hmcts/reform/cwrdapi/domain/ServiceResponseTest.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,33 @@ | ||
package uk.gov.hmcts.reform.cwrdapi.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import uk.gov.hmcts.reform.cwrdapi.client.domain.ServiceResponse; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class ServiceResponseTest { | ||
|
||
@Test | ||
void testSkillResposne_for_tostring_builder() { | ||
|
||
ServiceResponse serviceResponse = ServiceResponse.builder() | ||
.service("testservice") | ||
.serviceCode("testServiceCode") | ||
.build(); | ||
|
||
assertNotNull(serviceResponse); | ||
assertEquals("testservice",serviceResponse.getService()); | ||
assertEquals("testServiceCode",serviceResponse.getServiceCode()); | ||
|
||
|
||
String description = ServiceResponse.builder() | ||
.serviceCode("testServiceCode").toString(); | ||
|
||
|
||
assertTrue(description | ||
.contains("ServiceResponse.ServiceResponseBuilder(service=null, serviceCode=testServiceCode)")); | ||
|
||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/test/java/uk/gov/hmcts/reform/cwrdapi/domain/SkillResponseTest.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,61 @@ | ||
package uk.gov.hmcts.reform.cwrdapi.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import uk.gov.hmcts.reform.cwrdapi.client.domain.SkillResponse; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.junit.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class SkillResponseTest { | ||
|
||
|
||
@Test | ||
void testSkillResposne_for_valid_data() { | ||
|
||
SkillResponse skillResponse = new SkillResponse(); | ||
skillResponse.setSkillId(123L); | ||
skillResponse.setDescription("testresponsedescription"); | ||
|
||
assertNotNull(skillResponse); | ||
assertThat(skillResponse.getSkillId(),is(123L)); | ||
assertThat(skillResponse.getDescription(), is("testresponsedescription")); | ||
|
||
} | ||
|
||
@Test | ||
void testSkillResposne_for_empty_data() { | ||
|
||
SkillResponse skillResponse = new SkillResponse(); | ||
skillResponse.setSkillId(123L); | ||
skillResponse.setDescription(" "); | ||
|
||
assertNotNull(skillResponse); | ||
assertThat(skillResponse.getSkillId(),is(123L)); | ||
assertThat(skillResponse.getDescription(), is(" ")); | ||
|
||
} | ||
|
||
|
||
@Test | ||
void testSkillResposne_for_tostring_builder() { | ||
|
||
SkillResponse skillResponse = SkillResponse.builder() | ||
.skillId(123L) | ||
.description("testresponsedescription") | ||
.build(); | ||
|
||
assertNotNull(skillResponse); | ||
assertEquals(123L, skillResponse.getSkillId()); | ||
assertEquals("testresponsedescription", skillResponse.getDescription()); | ||
|
||
|
||
String description = SkillResponse.builder().description("test").toString(); | ||
|
||
assertTrue(description.contains("SkillResponse.SkillResponseBuilder(skillId=null, description=test)")); | ||
|
||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
import static org.mockito.ArgumentMatchers.anyList; | ||
import static org.mockito.ArgumentMatchers.anyLong; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.util.ResourceUtils.getFile; | ||
|
@@ -98,6 +99,7 @@ void shouldProcessCaseWorkerFileWithPartialSuccess() throws IOException { | |
ImmutableList.of(ExceptionCaseWorker.builder().errorDescription("Up Failed").excelRowId("1").build()); | ||
when(exceptionCaseWorkerRepository.findByJobId(anyLong())).thenReturn(exceptionCaseWorkers); | ||
ResponseEntity<Object> responseEntity = caseWorkerServiceFacade.processFile(multipartFile); | ||
verify(validationServiceFacadeImpl,times(1)).saveJsrExceptionsForCaseworkerJob(anyLong()); | ||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
} | ||
|
||
|
@@ -233,12 +235,49 @@ void shouldProcessCaseWorkerFileWithSuspendedRowFailed() throws IOException { | |
when(validationServiceFacadeImpl.getInvalidRecords(anyList())).thenReturn(Collections.emptyList()); | ||
when(caseWorkerProfileConverter.getSuspendedRowIds()).thenReturn(List.of(1L)); | ||
ResponseEntity<Object> responseEntity = caseWorkerServiceFacade.processFile(multipartFile); | ||
verify(caseWorkerInternalApiClient,times(1)).postRequest(any(),anyString()); | ||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
String responseString = mapper.writeValueAsString(responseEntity.getBody()); | ||
assertTrue(responseString.contains("1 record(s) failed validation and 1 record(s) uploaded")); | ||
} | ||
|
||
@Test | ||
void shouldProcessCaseWorkerFileWithDuplicateEmail() throws IOException { | ||
CaseWorkerProfile caseWorkerProfile1 = CaseWorkerProfile.builder() | ||
.firstName("test").lastName("test") | ||
.officialEmail("[email protected]") | ||
.regionId(1) | ||
.regionName("test") | ||
.userType("testUser") | ||
.build(); | ||
|
||
CaseWorkerProfile caseWorkerProfile2 = CaseWorkerProfile.builder() | ||
.firstName("test1").lastName("test1") | ||
.officialEmail("[email protected]") | ||
.regionId(1) | ||
.regionName("test1") | ||
.userType("testUser") | ||
.build(); | ||
List<CaseWorkerProfile> caseWorkerProfiles = new ArrayList<>(); | ||
|
||
caseWorkerProfiles.add(caseWorkerProfile1); | ||
caseWorkerProfiles.add(caseWorkerProfile2); | ||
MultipartFile multipartFile = createCaseWorkerMultiPartFile("Staff Data Upload.xls"); | ||
|
||
List<ExceptionCaseWorker> exceptionCaseWorkers = | ||
ImmutableList.of(ExceptionCaseWorker.builder().errorDescription("Up Failed").excelRowId("1").build()); | ||
when(exceptionCaseWorkerRepository.findByJobId(anyLong())).thenReturn(exceptionCaseWorkers); | ||
when(excelAdaptorService | ||
.parseExcel(workbook, CaseWorkerProfile.class)) | ||
.thenReturn(caseWorkerProfiles); | ||
when(validationServiceFacadeImpl.getInvalidRecords(anyList())).thenReturn(Collections.emptyList()); | ||
when(caseWorkerProfileConverter.getSuspendedRowIds()).thenReturn(List.of(1L)); | ||
ResponseEntity<Object> responseEntity = caseWorkerServiceFacade.processFile(multipartFile); | ||
verify(validationServiceFacadeImpl,times(2)).logFailures(anyString(),anyLong()); | ||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK); | ||
} | ||
|
||
@Test | ||
void shouldProcessCaseWorkerFileWithUploadedAndSuspendedMessage() throws IOException { | ||
CaseWorkerProfile caseWorkerProfile1 = CaseWorkerProfile.builder() | ||
|
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
Oops, something went wrong.