use of org.folio.services.Status in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldNotReturnDiscardedInCollection.
@Test
public void shouldNotReturnDiscardedInCollection() {
int numberOfFiles = 5;
int expectedNotDiscardedNumber = 2;
List<JobExecution> createdJobExecutions = constructAndPostInitJobExecutionRqDto(numberOfFiles).getJobExecutions();
List<JobExecution> children = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
StatusDto discardedStatus = new StatusDto().withStatus(StatusDto.Status.DISCARDED);
for (int i = 0; i < children.size() - expectedNotDiscardedNumber; i++) {
updateJobExecutionStatus(children.get(i), discardedStatus).then().statusCode(HttpStatus.SC_OK);
}
RestAssured.given().spec(spec).when().queryParam("statusNot", Status.DISCARDED).get(GET_JOB_EXECUTIONS_PATH).then().statusCode(HttpStatus.SC_OK).body("jobExecutions.size()", is(expectedNotDiscardedNumber)).body("jobExecutions*.status", not(StatusDto.Status.DISCARDED.name())).body("totalRecords", is(expectedNotDiscardedNumber));
}
use of org.folio.services.Status in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnFilteredAndSortedJobExecutionsOnGetWhenConditionAndSortByIsSpecified.
@Test
public void shouldReturnFilteredAndSortedJobExecutionsOnGetWhenConditionAndSortByIsSpecified() {
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(8).getJobExecutions();
List<JobExecution> childJobsToUpdate = createdJobExecution.stream().filter(jobExecution -> jobExecution.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
for (int i = 0; i < childJobsToUpdate.size(); i++) {
if (i % 2 == 0) {
childJobsToUpdate.get(i).withStatus(JobExecution.Status.COMMITTED).withUiStatus(JobExecution.UiStatus.RUNNING_COMPLETE);
}
createdJobExecution.get(i).setCompletedDate(new Date(1234567892000L + i));
putJobExecution(createdJobExecution.get(i));
}
// We do not expect to get JobExecution with subordinationType=PARENT_MULTIPLE
int expectedJobExecutionsNumber = childJobsToUpdate.size() / 2;
JobExecutionDtoCollection jobExecutionCollection = RestAssured.given().spec(spec).when().queryParam("uiStatusAny", JobExecution.UiStatus.RUNNING_COMPLETE).queryParam("statusAny", Status.COMMITTED, Status.ERROR).queryParam("sortBy", "completed_date,desc").get(GET_JOB_EXECUTIONS_PATH).then().log().all().statusCode(HttpStatus.SC_OK).body("jobExecutions*.status", everyItem(is(JobExecution.Status.COMMITTED.value()))).body("jobExecutions*.uiStatus", everyItem(is(JobExecution.UiStatus.RUNNING_COMPLETE.value()))).extract().response().body().as(JobExecutionDtoCollection.class);
List<JobExecutionDto> jobExecutionDtoList = jobExecutionCollection.getJobExecutions();
Assert.assertEquals(expectedJobExecutionsNumber, jobExecutionDtoList.size());
Assert.assertTrue(jobExecutionDtoList.get(0).getCompletedDate().after(jobExecutionDtoList.get(1).getCompletedDate()));
Assert.assertTrue(jobExecutionDtoList.get(1).getCompletedDate().after(jobExecutionDtoList.get(2).getCompletedDate()));
Assert.assertTrue(jobExecutionDtoList.get(2).getCompletedDate().after(jobExecutionDtoList.get(3).getCompletedDate()));
}
Aggregations