use of org.folio.rest.jaxrs.model.JournalRecordCollection in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnJournalRecordsSortedBySourceRecordOrder.
@Test
public void shouldReturnJournalRecordsSortedBySourceRecordOrder(TestContext testContext) {
Async async = testContext.async();
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExec = createdJobExecutions.get(0);
String sourceRecordId = UUID.randomUUID().toString();
String title = "test title";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecutions.get(0).getId(), sourceRecordId, null, null, title, 1, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecutions.get(0).getId(), sourceRecordId, null, null, title, 1, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecutions.get(0).getId(), sourceRecordId, null, null, title, 2, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecutions.get(0).getId(), sourceRecordId, null, null, title, 2, CREATE, INSTANCE, COMPLETED, null)).onFailure(testContext::fail);
future.onComplete(ar -> testContext.verify(v -> {
JournalRecordCollection journalRecords = RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + jobExec.getId() + "?sortBy=source_record_order&order=desc").then().statusCode(HttpStatus.SC_OK).extract().response().body().as(JournalRecordCollection.class);
assertThat(journalRecords.getTotalRecords(), is(4));
assertThat(journalRecords.getJournalRecords().size(), is(4));
Assert.assertEquals(journalRecords.getJournalRecords().get(0).getSourceRecordOrder(), journalRecords.getJournalRecords().get(1).getSourceRecordOrder());
assertThat(journalRecords.getJournalRecords().get(1).getSourceRecordOrder(), greaterThan(journalRecords.getJournalRecords().get(2).getSourceRecordOrder()));
Assert.assertEquals(journalRecords.getJournalRecords().get(2).getSourceRecordOrder(), journalRecords.getJournalRecords().get(3).getSourceRecordOrder());
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecordCollection in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnEmptyListWhenProcessingWasNotStarted.
@Test
public void shouldReturnEmptyListWhenProcessingWasNotStarted() {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExec = createdJobExecutions.get(0);
JournalRecordCollection journalRecords = RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).extract().response().body().as(JournalRecordCollection.class);
assertThat(journalRecords.getTotalRecords(), is(0));
assertThat(journalRecords.getJournalRecords().size(), is(0));
}
Aggregations