Search in sources :

Example 1 with MODIFY

use of org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY in project mod-source-record-manager by folio-org.

the class JournalRecordDaoTest method shouldReturnSortedJournalRecordListByActionType.

@Test
public void shouldReturnSortedJournalRecordListByActionType(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(COMPLETED);
    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(COMPLETED);
    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(COMPLETED);
    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(), "action_type", "asc", 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).getActionType(), lessThan(journalRecords.get(1).getActionType()));
            Assert.assertThat(journalRecords.get(1).getActionType(), lessThan(journalRecords.get(2).getActionType()));
        });
        async.complete();
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Date(java.util.Date) RunWith(org.junit.runner.RunWith) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) MockitoAnnotations(org.mockito.MockitoAnnotations) JobExecution(org.folio.rest.jaxrs.model.JobExecution) Spy(org.mockito.Spy) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Matchers.lessThan(org.hamcrest.Matchers.lessThan) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) DELETE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.DELETE) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) UUID(java.util.UUID) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) Future(io.vertx.core.Future) List(java.util.List) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Assert(org.junit.Assert) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) List(java.util.List) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Date(java.util.Date) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Example 2 with MODIFY

use of org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY 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();
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Date(java.util.Date) RunWith(org.junit.runner.RunWith) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) MockitoAnnotations(org.mockito.MockitoAnnotations) JobExecution(org.folio.rest.jaxrs.model.JobExecution) Spy(org.mockito.Spy) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Matchers.lessThan(org.hamcrest.Matchers.lessThan) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) DELETE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.DELETE) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) UUID(java.util.UUID) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) Future(io.vertx.core.Future) List(java.util.List) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Assert(org.junit.Assert) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) Async(io.vertx.ext.unit.Async) List(java.util.List) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) Date(java.util.Date) Test(org.junit.Test) AbstractRestTest(org.folio.rest.impl.AbstractRestTest)

Example 3 with MODIFY

use of org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY in project mod-source-record-manager by folio-org.

the class MetaDataProviderJobLogEntriesAPITest method shouldReturnMarcBibUpdatedWhenMarcBibWasModified.

@Test
public void shouldReturnMarcBibUpdatedWhenMarcBibWasModified(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, MODIFY, MARC_BIBLIOGRAPHIC, 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()).then().statusCode(HttpStatus.SC_OK).body("entries", hasSize(1)).body("totalRecords", is(1)).body("entries[0].jobExecutionId", is(createdJobExecution.getId())).body("entries[0].sourceRecordId", is(sourceRecordId)).body("entries[0].sourceRecordTitle", is(recordTitle)).body("entries[0].sourceRecordActionStatus", is(ActionStatus.UPDATED.value()));
        async.complete();
    }));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) EDIFACT(org.folio.rest.jaxrs.model.JournalRecord.EntityType.EDIFACT) MARC_BIBLIOGRAPHIC(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_BIBLIOGRAPHIC) TestContext(io.vertx.ext.unit.TestContext) MARC_AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_AUTHORITY) Date(java.util.Date) Matchers.not(org.hamcrest.Matchers.not) HttpStatus(org.apache.http.HttpStatus) MockitoAnnotations(org.mockito.MockitoAnnotations) Matchers.everyItem(org.hamcrest.Matchers.everyItem) Matchers.nullValue(org.hamcrest.Matchers.nullValue) JobExecution(org.folio.rest.jaxrs.model.JobExecution) Spy(org.mockito.Spy) ActionStatus(org.folio.rest.jaxrs.model.ActionStatus) ERROR(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR) HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.HOLDINGS) MODIFY(org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY) GenericCompositeFuture(org.folio.okapi.common.GenericCompositeFuture) AUTHORITY(org.folio.rest.jaxrs.model.JournalRecord.EntityType.AUTHORITY) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) UUID(java.util.UUID) Future(io.vertx.core.Future) List(java.util.List) Matchers.is(org.hamcrest.Matchers.is) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) RestAssured(io.restassured.RestAssured) Async(io.vertx.ext.unit.Async) JobLogEntryDtoCollection(org.folio.rest.jaxrs.model.JobLogEntryDtoCollection) RunWith(org.junit.runner.RunWith) JobLogEntryDto(org.folio.rest.jaxrs.model.JobLogEntryDto) PostgresClientFactory(org.folio.dao.util.PostgresClientFactory) CompositeFuture(io.vertx.core.CompositeFuture) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) MARC_HOLDINGS(org.folio.rest.jaxrs.model.JournalRecord.EntityType.MARC_HOLDINGS) Matchers.hasSize(org.hamcrest.Matchers.hasSize) Before(org.junit.Before) InjectMocks(org.mockito.InjectMocks) ITEM(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ITEM) Matchers.empty(org.hamcrest.Matchers.empty) UPDATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) COMPLETED(org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED) INSTANCE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INSTANCE) ORDER(org.folio.rest.jaxrs.model.JournalRecord.EntityType.ORDER) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) NON_MATCH(org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH) INVOICE(org.folio.rest.jaxrs.model.JournalRecord.EntityType.INVOICE) Assert(org.junit.Assert) CREATE(org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE) JournalRecordDaoImpl(org.folio.dao.JournalRecordDaoImpl) Async(io.vertx.ext.unit.Async) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) JournalRecord(org.folio.rest.jaxrs.model.JournalRecord) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 4 with MODIFY

use of org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY in project mod-source-record-manager by folio-org.

the class MetadataProviderJobExecutionAPITest method shouldReturnUpdatedSourceRecordSummaryWhenRecordWasModified.

@Test
public void shouldReturnUpdatedSourceRecordSummaryWhenRecordWasModified(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, MODIFY, 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)

Aggregations

Future (io.vertx.core.Future)4 Async (io.vertx.ext.unit.Async)4 TestContext (io.vertx.ext.unit.TestContext)4 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)4 Date (java.util.Date)4 List (java.util.List)4 UUID (java.util.UUID)4 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)4 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)4 JobExecution (org.folio.rest.jaxrs.model.JobExecution)4 JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)4 COMPLETED (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED)4 ERROR (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR)4 CREATE (org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE)4 MODIFY (org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY)4 Vertx (io.vertx.core.Vertx)3 InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)3 Matchers.is (org.hamcrest.Matchers.is)3 Assert (org.junit.Assert)3 Before (org.junit.Before)3