use of org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR in project mod-source-record-manager by folio-org.
the class JournalRecordDaoTest method shouldReturnSortedJournalRecordListByErrorMessage.
@Test
public void shouldReturnSortedJournalRecordListByErrorMessage(TestContext testContext) {
InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
List<JobExecution> createdJobExecutions = response.getJobExecutions();
Assert.assertThat(createdJobExecutions.size(), is(1));
JobExecution jobExec = createdJobExecutions.get(0);
JournalRecord journalRecord1 = new JournalRecord().withJobExecutionId(jobExec.getId()).withSourceRecordOrder(0).withSourceId(UUID.randomUUID().toString()).withEntityType(JournalRecord.EntityType.MARC_BIBLIOGRAPHIC).withEntityId(UUID.randomUUID().toString()).withActionType(CREATE).withActionDate(new Date()).withActionStatus(ERROR).withError("Record creation error");
JournalRecord journalRecord2 = new JournalRecord().withJobExecutionId(jobExec.getId()).withSourceRecordOrder(0).withSourceId(UUID.randomUUID().toString()).withEntityType(JournalRecord.EntityType.INSTANCE).withEntityId(UUID.randomUUID().toString()).withActionType(MODIFY).withActionDate(new Date()).withActionStatus(ERROR).withError("Instance was not updated");
JournalRecord journalRecord3 = new JournalRecord().withJobExecutionId(jobExec.getId()).withSourceRecordOrder(0).withSourceId(UUID.randomUUID().toString()).withEntityType(JournalRecord.EntityType.INSTANCE).withEntityId(UUID.randomUUID().toString()).withActionType(DELETE).withActionDate(new Date()).withActionStatus(ERROR).withError("No action taken");
Async async = testContext.async();
Future<List<JournalRecord>> getFuture = journalRecordDao.save(journalRecord1, TENANT_ID).compose(ar -> journalRecordDao.save(journalRecord2, TENANT_ID)).compose(ar -> journalRecordDao.save(journalRecord3, TENANT_ID)).compose(ar -> journalRecordDao.getByJobExecutionId(jobExec.getId(), "error", "desc", TENANT_ID));
getFuture.onComplete(ar -> {
testContext.verify(v -> {
Assert.assertTrue(ar.succeeded());
List<JournalRecord> journalRecords = ar.result();
Assert.assertEquals(3, journalRecords.size());
Assert.assertThat(journalRecords.get(0).getError(), greaterThan(journalRecords.get(1).getError()));
Assert.assertThat(journalRecords.get(1).getError(), greaterThan(journalRecords.get(2).getError()));
});
async.complete();
});
}
use of org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnEmptyMarcBibErrorAndInstanceDiscardedWhenInstanceCreationFailed.
@Test
public void shouldReturnEmptyMarcBibErrorAndInstanceDiscardedWhenInstanceCreationFailed(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String entityId = UUID.randomUUID().toString();
String entityHrid = "001";
String recordTitle = "test title";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, entityHrid, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, entityId, entityHrid, null, 0, CREATE, INSTANCE, ERROR, "error msg")).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(entityId)).body("relatedInstanceInfo.hridList[0]", is(entityHrid)).body("relatedInstanceInfo.error", is("error msg"));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR 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.ActionStatus.ERROR in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnNotEmptyListWithInvoicesLinesThatContainsError.
@Test
public void shouldReturnNotEmptyListWithInvoicesLinesThatContainsError(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String invoiceLineDescription = "Some description";
String invoiceLineId = "0704159";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, "228D126", "INVOICE", 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-1", invoiceLineDescription + "1", 1, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-2", invoiceLineDescription + "2", 2, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-3", invoiceLineDescription + "3", 3, CREATE, INVOICE, ERROR, "Exception")).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
List<JobLogEntryDto> jobLogEntries = RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("entries.size()", is(3)).body("totalRecords", is(3)).body("entries[0].jobExecutionId", is(createdJobExecution.getId())).body("entries[0].sourceRecordId", is(sourceRecordId)).body("entries[0].sourceRecordTitle", is(invoiceLineDescription + "1")).body("entries[0].sourceRecordOrder", is(invoiceLineId + "-1")).body("entries[2].sourceRecordTitle", is(invoiceLineDescription + "3")).body("entries[2].sourceRecordOrder", is(invoiceLineId + "-3")).extract().body().as(JobLogEntryDtoCollection.class).getEntries();
Assert.assertEquals("Exception", jobLogEntries.get(2).getError());
Assert.assertEquals(ActionStatus.DISCARDED, jobLogEntries.get(2).getInvoiceActionStatus());
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnInstanceDiscardedWithErrorsWhenInstanceCreationFailed.
@Test
public void shouldReturnInstanceDiscardedWithErrorsWhenInstanceCreationFailed(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, CREATE, INSTANCE, ERROR, "error msg")).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_SUMMARY_PATH + "/" + createdJobExecution.getId()).then().statusCode(HttpStatus.SC_OK).body("sourceRecordSummary.totalCreatedEntities", is(1)).body("sourceRecordSummary.totalUpdatedEntities", is(0)).body("sourceRecordSummary.totalDiscardedEntities", is(0)).body("sourceRecordSummary.totalErrors", is(0)).body("instanceSummary.totalCreatedEntities", is(0)).body("instanceSummary.totalUpdatedEntities", is(0)).body("instanceSummary.totalDiscardedEntities", is(1)).body("instanceSummary.totalErrors", is(1)).body("totalErrors", is(1));
async.complete();
}));
}
Aggregations