use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnInvoiceSummaryWithErrorsWhenAnyInvoiceLineCreationFailed.
@Test
public void shouldReturnInvoiceSummaryWithErrorsWhenAnyInvoiceLineCreationFailed(TestContext context) {
Async async = context.async();
String jobExecutionId = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0).getId();
String sourceRecordId = UUID.randomUUID().toString();
String invoiceTitle = "INVOICE";
String invoiceLineDescription = "Some description";
String invoiceVendorNo = "0704159";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, null, 0, CREATE, EDIFACT, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo, invoiceTitle, 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-1", invoiceLineDescription, 1, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-2", invoiceLineDescription, 2, CREATE, INVOICE, ERROR, "error msg")).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_SUMMARY_PATH + "/" + jobExecutionId).then().statusCode(HttpStatus.SC_OK).body("sourceRecordSummary.totalCreatedEntities", is(1)).body("sourceRecordSummary.totalErrors", is(0)).body("invoiceSummary.totalCreatedEntities", is(1)).body("invoiceSummary.totalUpdatedEntities", is(0)).body("invoiceSummary.totalDiscardedEntities", is(1)).body("invoiceSummary.totalErrors", is(1)).body("totalErrors", is(1));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnInvoiceSummaryWhenInvoiceWasCreated.
@Test
public void shouldReturnInvoiceSummaryWhenInvoiceWasCreated(TestContext context) {
Async async = context.async();
String jobExecutionId = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0).getId();
String sourceRecordId = UUID.randomUUID().toString();
String invoiceTitle = "INVOICE";
String invoiceLineDescription = "Some description";
String invoiceVendorNo = "0704159";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, null, 0, CREATE, EDIFACT, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo, invoiceTitle, 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-1", invoiceLineDescription, 1, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-2", invoiceLineDescription, 2, CREATE, INVOICE, COMPLETED, null)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_SUMMARY_PATH + "/" + jobExecutionId).then().statusCode(HttpStatus.SC_OK).body("invoiceSummary.totalCreatedEntities", is(1)).body("invoiceSummary.totalUpdatedEntities", is(0)).body("invoiceSummary.totalDiscardedEntities", is(0)).body("invoiceSummary.totalErrors", is(0)).body("totalErrors", is(0)).body("instanceSummary", nullValue()).body("holdingSummary", nullValue()).body("itemSummary", nullValue()).body("authoritySummary", nullValue()).body("orderSummary", nullValue());
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnDataForParticularInvoiceLine.
@Test
public void shouldReturnDataForParticularInvoiceLine(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String invoiceId = UUID.randomUUID().toString();
String invoiceHrid = "228D126";
String invoiceVendorNumber = "0704159";
String invoiceLineId1 = UUID.randomUUID().toString();
String invoiceLineId2 = UUID.randomUUID().toString();
String invoiceLineDescription = "Some description";
Promise<String> journalRecordIdPromise = Promise.promise();
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, CREATE, EDIFACT, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, invoiceId, invoiceHrid, "INVOICE", 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, invoiceLineId1, invoiceVendorNumber + "-1", invoiceLineDescription + "1", 1, CREATE, INVOICE, COMPLETED, null)).onSuccess(journalRecord -> journalRecordIdPromise.complete(journalRecord.getId())).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, invoiceLineId2, invoiceVendorNumber + "-2", invoiceLineDescription + "2", 2, CREATE, INVOICE, COMPLETED, null)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
String invoiceLineJournalRecordId = journalRecordIdPromise.future().result();
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId() + "/records/" + invoiceLineJournalRecordId).then().statusCode(HttpStatus.SC_OK).body("jobExecutionId", is(createdJobExecution.getId())).body("sourceRecordId", is(sourceRecordId)).body("sourceRecordOrder", is(0)).body("sourceRecordTitle", is(invoiceLineDescription + "1")).body("error", emptyOrNullString()).body("relatedInstanceInfo.idList.size", is(0)).body("relatedInstanceInfo.hridList.size", is(0)).body("relatedInstanceInfo.error", nullValue()).body("relatedHoldingsInfo.idList.size", is(0)).body("relatedHoldingsInfo.hridList.size", is(0)).body("relatedHoldingsInfo.error", emptyOrNullString()).body("relatedItemInfo.idList.size", is(0)).body("relatedItemInfo.hridList.size", is(0)).body("relatedItemInfo.error", emptyOrNullString()).body("relatedOrderInfo.idList.size", is(0)).body("relatedOrderInfo.hridList.size", is(0)).body("relatedOrderInfo.error", emptyOrNullString()).body("relatedInvoiceInfo.idList[0]", is(invoiceId)).body("relatedInvoiceInfo.hridList[0]", is(invoiceHrid)).body("relatedInvoiceInfo.error", emptyOrNullString()).body("relatedInvoiceLineInfo.id", is(invoiceLineId1)).body("relatedInvoiceLineInfo.fullInvoiceLineNumber", is(invoiceVendorNumber + "-1")).body("relatedInvoiceLineInfo.error", emptyOrNullString());
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnInvoiceLineInfoWithError.
@Test
public void shouldReturnInvoiceLineInfoWithError(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String invoiceId = UUID.randomUUID().toString();
String invoiceHrid = "228D126";
String invoiceVendorNumber = "0704159";
String invoiceLineId1 = UUID.randomUUID().toString();
String invoiceLineDescription = "Some description";
String errorMsg = "error-msg";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, null, null, 0, CREATE, EDIFACT, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, invoiceId, invoiceHrid, "INVOICE", 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, invoiceLineId1, invoiceVendorNumber + "-1", invoiceLineDescription + "1", 1, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceVendorNumber + "-2", invoiceLineDescription + "2", 2, CREATE, INVOICE, ERROR, errorMsg)).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
String invoiceLineJournalRecordId = future.result().getId();
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_JOURNAL_RECORDS_PATH + "/" + createdJobExecution.getId() + "/records/" + invoiceLineJournalRecordId).then().statusCode(HttpStatus.SC_OK).body("jobExecutionId", is(createdJobExecution.getId())).body("sourceRecordId", is(sourceRecordId)).body("sourceRecordOrder", is(0)).body("sourceRecordTitle", is(invoiceLineDescription + "2")).body("error", emptyOrNullString()).body("relatedInvoiceInfo.idList[0]", is(invoiceId)).body("relatedInvoiceInfo.hridList[0]", is(invoiceHrid)).body("relatedInvoiceInfo.error", emptyOrNullString()).body("relatedInvoiceLineInfo.id", nullValue()).body("relatedInvoiceLineInfo.fullInvoiceLineNumber", is(invoiceVendorNumber + "-2")).body("relatedInvoiceLineInfo.error", is(errorMsg));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnOneInvoiceErrorWhenAllInvoiceLinesCreationFailed.
@Test
public void shouldReturnOneInvoiceErrorWhenAllInvoiceLinesCreationFailed(TestContext context) {
Async async = context.async();
String jobExecutionId = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0).getId();
String sourceRecordId = UUID.randomUUID().toString();
String invoiceTitle = "INVOICE";
String invoiceLineDescription = "Some description";
String invoiceVendorNo = "0704159";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, null, 0, CREATE, EDIFACT, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo, invoiceTitle, 0, CREATE, INVOICE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-1", invoiceLineDescription, 1, CREATE, INVOICE, ERROR, "error msg")).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, invoiceVendorNo + "-2", invoiceLineDescription, 2, CREATE, INVOICE, ERROR, "error msg")).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
RestAssured.given().spec(spec).when().get(GET_JOB_EXECUTION_SUMMARY_PATH + "/" + jobExecutionId).then().statusCode(HttpStatus.SC_OK).body("sourceRecordSummary.totalCreatedEntities", is(1)).body("sourceRecordSummary.totalErrors", is(0)).body("invoiceSummary.totalCreatedEntities", is(1)).body("invoiceSummary.totalUpdatedEntities", is(0)).body("invoiceSummary.totalDiscardedEntities", is(1)).body("invoiceSummary.totalErrors", is(1)).body("totalErrors", is(1));
async.complete();
}));
}
Aggregations