use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.ORDER in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnMarcBibAndAllEntitiesWithoutErrors.
@Test
public void shouldReturnMarcBibAndAllEntitiesWithoutErrors(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String recordTitle = "test title";
String instanceId = UUID.randomUUID().toString();
String instanceHrid = "i001";
String holdingsId = UUID.randomUUID().toString();
String holdingsHrid = "h001";
String itemId = UUID.randomUUID().toString();
String itemHrid = "it001";
String orderId = UUID.randomUUID().toString();
String orderHrid = "o001";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, holdingsId, holdingsHrid, null, 0, CREATE, HOLDINGS, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, itemId, itemHrid, null, 0, CREATE, ITEM, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, orderId, orderHrid, null, 0, CREATE, ORDER, COMPLETED, null)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId() + "/records/" + sourceRecordId).then().statusCode(HttpStatus.SC_OK).body("jobExecutionId", is(createdJobExecution.getId())).body("sourceRecordId", is(sourceRecordId)).body("sourceRecordTitle", is(recordTitle)).body("sourceRecordOrder", is(0)).body("error", emptyOrNullString()).body("relatedInstanceInfo.idList[0]", is(instanceId)).body("relatedInstanceInfo.hridList[0]", is(instanceHrid)).body("relatedInstanceInfo.error", emptyOrNullString()).body("relatedHoldingsInfo.idList[0]", is(holdingsId)).body("relatedHoldingsInfo.hridList[0]", is(holdingsHrid)).body("relatedHoldingsInfo.error", emptyOrNullString()).body("relatedItemInfo.idList[0]", is(itemId)).body("relatedItemInfo.hridList[0]", is(itemHrid)).body("relatedItemInfo.error", emptyOrNullString()).body("relatedOrderInfo.idList[0]", is(orderId)).body("relatedOrderInfo.hridList[0]", is(orderHrid)).body("relatedOrderInfo.error", emptyOrNullString()).body("relatedInvoiceInfo.idList", empty()).body("relatedInvoiceInfo.hridList", empty()).body("relatedInvoiceInfo.error", emptyOrNullString());
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.ORDER in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnSortedEntriesWhenSortByParameterSpecified.
@Test
public void shouldReturnSortedEntriesWhenSortByParameterSpecified(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId1 = UUID.randomUUID().toString();
String sourceRecordId2 = UUID.randomUUID().toString();
String sourceRecordId3 = UUID.randomUUID().toString();
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId1, null, null, null, 1, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId1, null, "in00000000002", null, 1, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId2, null, null, null, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId2, null, "in00000000001", null, 0, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId3, null, null, null, 3, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId3, null, "in00000000003", null, 3, CREATE, INSTANCE, COMPLETED, null)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
List<JobLogEntryDto> jobLogEntries = RestAssured.given().spec(spec).queryParam("sortBy", "source_record_order").queryParam("order", "desc").when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("entries", hasSize(3)).body("totalRecords", is(3)).extract().body().as(JobLogEntryDtoCollection.class).getEntries();
context.assertTrue(Integer.parseInt(jobLogEntries.get(0).getSourceRecordOrder()) > Integer.parseInt(jobLogEntries.get(1).getSourceRecordOrder()));
context.assertTrue(Integer.parseInt(jobLogEntries.get(1).getSourceRecordOrder()) > Integer.parseInt(jobLogEntries.get(2).getSourceRecordOrder()));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.ORDER in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnLimitedCollectionOnGetWithLimitAndOffset.
@Test
public void shouldReturnLimitedCollectionOnGetWithLimitAndOffset(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId1 = UUID.randomUUID().toString();
String sourceRecordId2 = UUID.randomUUID().toString();
String sourceRecordId3 = UUID.randomUUID().toString();
String recordTitle1 = "title1";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId1, null, null, recordTitle1, 1, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId1, null, "in00000000001", null, 1, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId2, null, null, "title0", 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId2, null, null, null, 0, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId3, null, null, "title3", 3, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId3, null, null, null, 3, CREATE, INSTANCE, COMPLETED, null)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).queryParam("sortBy", "source_record_order").queryParam("order", "desc").queryParam("limit", "1").queryParam("offset", "1").when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("entries.size()", is(1)).body("totalRecords", is(3)).body("entries[0].jobExecutionId", is(createdJobExecution.getId())).body("entries[0].sourceRecordId", is(sourceRecordId1)).body("entries[0].sourceRecordTitle", is(recordTitle1)).body("entries[0].sourceRecordOrder", is("1")).body("entries[0].holdingsRecordHridList", is(empty())).body("entries[0].sourceRecordType", is(MARC_BIBLIOGRAPHIC.value()));
async.complete();
}));
}
Aggregations