use of org.folio.rest.jaxrs.model.JournalRecord 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 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 in project mod-source-record-manager by folio-org.
the class MetadataProviderJobExecutionAPITest method shouldReturnUpdatedSourceRecordSummaryWhenRecordWasUpdated.
@Test
public void shouldReturnUpdatedSourceRecordSummaryWhenRecordWasUpdated(TestContext context) {
Async async = context.async();
JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
String sourceRecordId = UUID.randomUUID().toString();
String recordTitle = "test title";
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, null, null, null, 0, UPDATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).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(1)).body("sourceRecordSummary.totalDiscardedEntities", is(0)).body("sourceRecordSummary.totalErrors", is(0)).body("totalErrors", is(0));
async.complete();
}));
}
use of org.folio.rest.jaxrs.model.JournalRecord 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.JournalRecord in project mod-source-record-manager by folio-org.
the class JournalServiceImpl method saveBatch.
@Override
public void saveBatch(JsonArray journalRecords, String tenantId) {
List<JournalRecord> journalRecordList = new ArrayList<>();
for (int i = 0; i < journalRecords.size(); i++) {
JournalRecord journalRecord = journalRecords.getJsonObject(i).mapTo(JournalRecord.class);
journalRecord.setId(UUID.randomUUID().toString());
journalRecordList.add(journalRecord);
}
journalRecordDao.saveBatch(journalRecordList, tenantId);
}
Aggregations