use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnNotEmptyListWithInvoicesLines.
@Test
public void shouldReturnNotEmptyListWithInvoicesLines(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";
CompositeFuture future = GenericCompositeFuture.all(List.of(createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, "228D126", "INVOICE", 0, CREATE, INVOICE, COMPLETED, null).map(JournalRecord::getId), createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-1", invoiceLineDescription + "1", 1, CREATE, INVOICE, COMPLETED, null).map(JournalRecord::getId), createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-2", invoiceLineDescription + "2", 2, CREATE, INVOICE, COMPLETED, null).map(JournalRecord::getId), createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, invoiceLineId + "-3", invoiceLineDescription + "3", 3, CREATE, INVOICE, COMPLETED, null).map(JournalRecord::getId))).onFailure(context::fail);
future.onComplete(ar -> context.verify(v -> {
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*.jobExecutionId", everyItem(is(createdJobExecution.getId()))).body("entries*.sourceRecordId", everyItem(is(sourceRecordId))).body("entries[0].sourceRecordTitle", is(invoiceLineDescription + "1")).body("entries[1].sourceRecordTitle", is(invoiceLineDescription + "2")).body("entries[2].sourceRecordTitle", is(invoiceLineDescription + "3")).body("entries[0].sourceRecordOrder", is(invoiceLineId + "-1")).body("entries[1].sourceRecordOrder", is(invoiceLineId + "-2")).body("entries[2].sourceRecordOrder", is(invoiceLineId + "-3")).body("entries[0].invoiceLineJournalRecordId", is(future.resultAt(1).toString())).body("entries[1].invoiceLineJournalRecordId", is(future.resultAt(2).toString())).body("entries[2].invoiceLineJournalRecordId", is(future.resultAt(3).toString()));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE 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.EntityType.INVOICE 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.INVOICE 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.INVOICE in project mod-source-record-manager by folio-org.
the class MetaDataProviderJobLogEntriesAPITest method shouldReturnOnlyInvoiceLinesWithErrorWhenRetrieveWithErrorsOnlyParam.
@Test
public void shouldReturnOnlyInvoiceLinesWithErrorWhenRetrieveWithErrorsOnlyParam(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String invoiceLineDescription = "Some description";
String invoiceLineId = "246816";
Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, null, "10001", "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().param("errorsOnly", true).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(sourceRecordId)).extract().body().as(JobLogEntryDtoCollection.class).getEntries();
Assert.assertEquals("Exception", jobLogEntries.get(0).getError());
Assert.assertEquals(ActionStatus.DISCARDED, jobLogEntries.get(0).getInvoiceActionStatus());
async.complete();
}));
}
Aggregations