use of org.folio.rest.jaxrs.model.JobExecutionDtoCollection in project mod-source-record-manager by folio-org.
the class JobExecutionDaoImpl method mapToJobExecutionDtoCollection.
private JobExecutionDtoCollection mapToJobExecutionDtoCollection(RowSet<Row> rowSet) {
JobExecutionDtoCollection jobCollection = new JobExecutionDtoCollection().withTotalRecords(0);
rowSet.iterator().forEachRemaining(row -> {
jobCollection.getJobExecutions().add(mapRowToJobExecutionDto(row));
jobCollection.setTotalRecords(row.getInteger(TOTAL_COUNT_FIELD));
});
return jobCollection;
}
use of org.folio.rest.jaxrs.model.JobExecutionDtoCollection in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnSortedCollectionByMultipleFieldsOnGet.
@Test
public void shouldReturnSortedCollectionByMultipleFieldsOnGet() {
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(4).getJobExecutions();
List<JobExecution> childJobsToUpdate = createdJobExecution.stream().filter(jobExecution -> jobExecution.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
for (int i = 0; i < childJobsToUpdate.size(); i++) {
putJobExecution(createdJobExecution.get(i).withRunBy(new RunBy().withFirstName("John").withLastName("Doe-" + i)));
}
// We do not expect to get JobExecution with subordinationType=PARENT_MULTIPLE
int expectedJobExecutionsNumber = childJobsToUpdate.size();
JobExecutionDtoCollection jobExecutionCollection = RestAssured.given().spec(spec).when().queryParam("sortBy", "job_user_first_name,asc").queryParam("sortBy", "job_user_last_name,desc").get(GET_JOB_EXECUTIONS_PATH).then().statusCode(HttpStatus.SC_OK).extract().response().body().as(JobExecutionDtoCollection.class);
List<JobExecutionDto> jobExecutions = jobExecutionCollection.getJobExecutions();
Assert.assertEquals(expectedJobExecutionsNumber, jobExecutions.size());
assertThat(jobExecutions.get(0).getRunBy().getLastName(), greaterThan(jobExecutions.get(1).getRunBy().getLastName()));
assertThat(jobExecutions.get(1).getRunBy().getLastName(), greaterThan(jobExecutions.get(2).getRunBy().getLastName()));
assertThat(jobExecutions.get(2).getRunBy().getLastName(), greaterThan(jobExecutions.get(3).getRunBy().getLastName()));
}
use of org.folio.rest.jaxrs.model.JobExecutionDtoCollection in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnSortedJobExecutionsByTotalProgressOnGet.
@Test
public void shouldReturnSortedJobExecutionsByTotalProgressOnGet() {
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(4).getJobExecutions();
List<JobExecution> childJobsToUpdate = createdJobExecution.stream().filter(jobExecution -> jobExecution.getSubordinationType().equals(CHILD)).collect(Collectors.toList());
for (int i = 0; i < childJobsToUpdate.size(); i++) {
putJobExecution(createdJobExecution.get(i).withProgress(new Progress().withTotal(i * 5)));
}
// We do not expect to get JobExecution with subordinationType=PARENT_MULTIPLE
int expectedJobExecutionsNumber = childJobsToUpdate.size();
JobExecutionDtoCollection jobExecutionCollection = RestAssured.given().spec(spec).when().queryParam("sortBy", "progress_total,desc").get(GET_JOB_EXECUTIONS_PATH).then().statusCode(HttpStatus.SC_OK).extract().response().body().as(JobExecutionDtoCollection.class);
List<JobExecutionDto> jobExecutions = jobExecutionCollection.getJobExecutions();
Assert.assertEquals(expectedJobExecutionsNumber, jobExecutions.size());
assertThat(jobExecutions.get(0).getProgress().getTotal(), greaterThan(jobExecutions.get(1).getProgress().getTotal()));
assertThat(jobExecutions.get(1).getProgress().getTotal(), greaterThan(jobExecutions.get(2).getProgress().getTotal()));
assertThat(jobExecutions.get(2).getProgress().getTotal(), greaterThan(jobExecutions.get(3).getProgress().getTotal()));
}
use of org.folio.rest.jaxrs.model.JobExecutionDtoCollection 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()));
}
use of org.folio.rest.jaxrs.model.JobExecutionDtoCollection in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnSortedJobExecutionsOnGetWhenSortByIsSpecified.
@Test
public void shouldReturnSortedJobExecutionsOnGetWhenSortByIsSpecified() {
List<JobExecution> createdJobExecution = constructAndPostInitJobExecutionRqDto(5).getJobExecutions();
for (int i = 0; i < createdJobExecution.size(); i++) {
putJobExecution(createdJobExecution.get(i).withCompletedDate(new Date(1234567892000L + i)));
}
// We do not expect to get JobExecution with subordinationType=PARENT_MULTIPLE
int expectedJobExecutionsNumber = createdJobExecution.size() - 1;
JobExecutionDtoCollection jobExecutionCollection = RestAssured.given().spec(spec).when().queryParam("uiStatusAny", "INITIALIZATION").queryParam("sortBy", "completed_date,desc").get(GET_JOB_EXECUTIONS_PATH).then().log().all().statusCode(HttpStatus.SC_OK).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