Search in sources :

Example 21 with JournalRecord

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();
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) EDIFACT(org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT) MARC_BIBLIOGRAPHIC(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_BIBLIOGRAPHIC) MARC_AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_AUTHORITY) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) Matchers.not(org.hamcrest.Matchers.not) HttpStatus(org.apache.http.HttpStatus) CHILD(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD) MockitoAnnotations(org.mockito.MockitoAnnotations) Matchers.everyItem(org.hamcrest.Matchers.everyItem) JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) After(org.junit.After) Spy(org.mockito.Spy) Matchers.nullValue(org.hamcrest.Matchers.nullValue) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JsonObject(io.vertx.core.json.JsonObject) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) ZoneOffset(java.time.ZoneOffset) HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.HOLDINGS) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) StatusDto(org.folio.rest.jaxrs.model.StatusDto) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.AUTHORITY) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) UUID(java.util.UUID) Instant(java.time.Instant) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) List(java.util.List) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RestAssured(io.restassured.RestAssured) Progress(org.folio.rest.jaxrs.model.Progress) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) PARENT_MULTIPLE(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.PARENT_MULTIPLE) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) JournalRecordCollection(org.folio.rest.jaxrs.model.JournalRecordCollection) EntityType(org.folio.rest.jaxrs.model.EntityType) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Status(org.folio.services.Status) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) MARC(org.folio.rest.jaxrs.model.JobProfileInfo.DataType.MARC) ITEM(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ITEM) Matchers.empty(org.hamcrest.Matchers.empty) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) UPDATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) INSTANCE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INSTANCE) NON_MATCH(org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH) RunBy(org.folio.rest.jaxrs.model.RunBy) INVOICE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE) ChronoUnit(java.time.temporal.ChronoUnit) Matchers.hasItem(org.hamcrest.Matchers.hasItem) JobExecutionsCache(org.folio.services.JobExecutionsCache) DateTimeFormatter(java.time.format.DateTimeFormatter) Assert(org.junit.Assert) JournalRecordDaoImpl(org.folio.dao.JournalRecordDaoImpl) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 22 with JournalRecord

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();
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) EDIFACT(org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT) MARC_BIBLIOGRAPHIC(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_BIBLIOGRAPHIC) MARC_AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_AUTHORITY) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) Matchers.not(org.hamcrest.Matchers.not) HttpStatus(org.apache.http.HttpStatus) CHILD(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD) MockitoAnnotations(org.mockito.MockitoAnnotations) Matchers.everyItem(org.hamcrest.Matchers.everyItem) JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) After(org.junit.After) Spy(org.mockito.Spy) Matchers.nullValue(org.hamcrest.Matchers.nullValue) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JsonObject(io.vertx.core.json.JsonObject) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) ZoneOffset(java.time.ZoneOffset) HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.HOLDINGS) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) StatusDto(org.folio.rest.jaxrs.model.StatusDto) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.AUTHORITY) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) UUID(java.util.UUID) Instant(java.time.Instant) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) List(java.util.List) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RestAssured(io.restassured.RestAssured) Progress(org.folio.rest.jaxrs.model.Progress) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) PARENT_MULTIPLE(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.PARENT_MULTIPLE) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) JournalRecordCollection(org.folio.rest.jaxrs.model.JournalRecordCollection) EntityType(org.folio.rest.jaxrs.model.EntityType) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Status(org.folio.services.Status) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) MARC(org.folio.rest.jaxrs.model.JobProfileInfo.DataType.MARC) ITEM(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ITEM) Matchers.empty(org.hamcrest.Matchers.empty) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) UPDATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) INSTANCE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INSTANCE) NON_MATCH(org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH) RunBy(org.folio.rest.jaxrs.model.RunBy) INVOICE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE) ChronoUnit(java.time.temporal.ChronoUnit) Matchers.hasItem(org.hamcrest.Matchers.hasItem) JobExecutionsCache(org.folio.services.JobExecutionsCache) DateTimeFormatter(java.time.format.DateTimeFormatter) Assert(org.junit.Assert) JournalRecordDaoImpl(org.folio.dao.JournalRecordDaoImpl) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 23 with JournalRecord

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();
    }));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) TestContext(io.vertx.ext.unit.TestContext) EDIFACT(org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT) MARC_BIBLIOGRAPHIC(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_BIBLIOGRAPHIC) MARC_AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_AUTHORITY) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) Matchers.not(org.hamcrest.Matchers.not) HttpStatus(org.apache.http.HttpStatus) CHILD(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD) MockitoAnnotations(org.mockito.MockitoAnnotations) Matchers.everyItem(org.hamcrest.Matchers.everyItem) JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) After(org.junit.After) Spy(org.mockito.Spy) Matchers.nullValue(org.hamcrest.Matchers.nullValue) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JsonObject(io.vertx.core.json.JsonObject) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) ZoneOffset(java.time.ZoneOffset) HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.HOLDINGS) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) StatusDto(org.folio.rest.jaxrs.model.StatusDto) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.AUTHORITY) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) UUID(java.util.UUID) Instant(java.time.Instant) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) List(java.util.List) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RestAssured(io.restassured.RestAssured) Progress(org.folio.rest.jaxrs.model.Progress) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) PARENT_MULTIPLE(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.PARENT_MULTIPLE) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) JournalRecordCollection(org.folio.rest.jaxrs.model.JournalRecordCollection) EntityType(org.folio.rest.jaxrs.model.EntityType) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Status(org.folio.services.Status) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) MARC(org.folio.rest.jaxrs.model.JobProfileInfo.DataType.MARC) ITEM(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ITEM) Matchers.empty(org.hamcrest.Matchers.empty) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) UPDATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) INSTANCE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INSTANCE) NON_MATCH(org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH) RunBy(org.folio.rest.jaxrs.model.RunBy) INVOICE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE) ChronoUnit(java.time.temporal.ChronoUnit) Matchers.hasItem(org.hamcrest.Matchers.hasItem) JobExecutionsCache(org.folio.services.JobExecutionsCache) DateTimeFormatter(java.time.format.DateTimeFormatter) Assert(org.junit.Assert) JournalRecordDaoImpl(org.folio.dao.JournalRecordDaoImpl) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 24 with JournalRecord

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();
    }));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) TestContext(io.vertx.ext.unit.TestContext) EDIFACT(org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT) MARC_BIBLIOGRAPHIC(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_BIBLIOGRAPHIC) MARC_AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_AUTHORITY) Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) Matchers.not(org.hamcrest.Matchers.not) HttpStatus(org.apache.http.HttpStatus) CHILD(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.CHILD) MockitoAnnotations(org.mockito.MockitoAnnotations) Matchers.everyItem(org.hamcrest.Matchers.everyItem) JobExecution(org.folio.rest.jaxrs.model.JobExecution) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) After(org.junit.After) Spy(org.mockito.Spy) Matchers.nullValue(org.hamcrest.Matchers.nullValue) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JsonObject(io.vertx.core.json.JsonObject) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) ZoneOffset(java.time.ZoneOffset) HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.HOLDINGS) JobExecutionDto(org.folio.rest.jaxrs.model.JobExecutionDto) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) StatusDto(org.folio.rest.jaxrs.model.StatusDto) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.AUTHORITY) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.lessThanOrEqualTo(org.hamcrest.Matchers.lessThanOrEqualTo) UUID(java.util.UUID) Instant(java.time.Instant) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) List(java.util.List) JobExecutionDtoCollection(org.folio.rest.jaxrs.model.JobExecutionDtoCollection) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RestAssured(io.restassured.RestAssured) Progress(org.folio.rest.jaxrs.model.Progress) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) PARENT_MULTIPLE(org.folio.rest.jaxrs.model.JobExecution.SubordinationType.PARENT_MULTIPLE) DeleteJobExecutionsResp(org.folio.rest.jaxrs.model.DeleteJobExecutionsResp) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) JournalRecordCollection(org.folio.rest.jaxrs.model.JournalRecordCollection) EntityType(org.folio.rest.jaxrs.model.EntityType) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Status(org.folio.services.Status) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) MARC(org.folio.rest.jaxrs.model.JobProfileInfo.DataType.MARC) ITEM(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ITEM) Matchers.empty(org.hamcrest.Matchers.empty) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) UPDATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) INSTANCE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INSTANCE) NON_MATCH(org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH) RunBy(org.folio.rest.jaxrs.model.RunBy) INVOICE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE) ChronoUnit(java.time.temporal.ChronoUnit) Matchers.hasItem(org.hamcrest.Matchers.hasItem) JobExecutionsCache(org.folio.services.JobExecutionsCache) DateTimeFormatter(java.time.format.DateTimeFormatter) Assert(org.junit.Assert) JournalRecordDaoImpl(org.folio.dao.JournalRecordDaoImpl) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JournalRecordCollection(org.folio.rest.jaxrs.model.JournalRecordCollection) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) ChangeManagerAPITest(org.folio.rest.impl.changeManager.ChangeManagerAPITest) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 25 with JournalRecord

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);
}
Also used : ArrayList(java.util.ArrayList) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord)

Aggregations

JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)52 Test (org.junit.Test)42 Date (java.util.Date)40 Future (io.vertx.core.Future)34 List (java.util.List)34 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)34 JobExecution (org.folio.rest.jaxrs.model.JobExecution)34 COMPLETED (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED)34 CREATE (org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE)34 Async (io.vertx.ext.unit.Async)33 TestContext (io.vertx.ext.unit.TestContext)33 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)33 UUID (java.util.UUID)33 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)33 ERROR (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR)33 MODIFY (org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY)33 Matchers.is (org.hamcrest.Matchers.is)33 Assert (org.junit.Assert)33 Before (org.junit.Before)33 RunWith (org.junit.runner.RunWith)33