Search in sources :

Example 1 with ITEM

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

the class MetaDataProviderJobLogEntriesAPITest method shouldReturnMarcBibAndAllEntitiesWithoutErrors.

@Test
public void shouldReturnMarcBibAndAllEntitiesWithoutErrors(TestContext context) {
    Async async = context.async();
    JobExecution createdJobExecution = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0);
    String sourceRecordId = UUID.randomUUID().toString();
    String recordTitle = "test title";
    String instanceId = UUID.randomUUID().toString();
    String instanceHrid = "i001";
    String holdingsId = UUID.randomUUID().toString();
    String holdingsHrid = "h001";
    String itemId = UUID.randomUUID().toString();
    String itemHrid = "it001";
    String orderId = UUID.randomUUID().toString();
    String orderHrid = "o001";
    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, instanceId, instanceHrid, null, 0, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, holdingsId, holdingsHrid, null, 0, CREATE, HOLDINGS, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, itemId, itemHrid, null, 0, CREATE, ITEM, COMPLETED, null)).compose(v -> createJournalRecord(createdJobExecution.getId(), sourceRecordId, orderId, orderHrid, null, 0, CREATE, ORDER, 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() + "/records/" + sourceRecordId).then().statusCode(HttpStatus.SC_OK).body("jobExecutionId", is(createdJobExecution.getId())).body("sourceRecordId", is(sourceRecordId)).body("sourceRecordTitle", is(recordTitle)).body("sourceRecordOrder", is(0)).body("error", emptyOrNullString()).body("relatedInstanceInfo.idList[0]", is(instanceId)).body("relatedInstanceInfo.hridList[0]", is(instanceHrid)).body("relatedInstanceInfo.error", emptyOrNullString()).body("relatedHoldingsInfo.idList[0]", is(holdingsId)).body("relatedHoldingsInfo.hridList[0]", is(holdingsHrid)).body("relatedHoldingsInfo.error", emptyOrNullString()).body("relatedItemInfo.idList[0]", is(itemId)).body("relatedItemInfo.hridList[0]", is(itemHrid)).body("relatedItemInfo.error", emptyOrNullString()).body("relatedOrderInfo.idList[0]", is(orderId)).body("relatedOrderInfo.hridList[0]", is(orderHrid)).body("relatedOrderInfo.error", emptyOrNullString()).body("relatedInvoiceInfo.idList", empty()).body("relatedInvoiceInfo.hridList", empty()).body("relatedInvoiceInfo.error", emptyOrNullString());
        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 2 with ITEM

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

the class MetadataProviderJobExecutionAPITest method shouldReturnCreatedRecordInstanceHoldingItemSummary.

@Test
public void shouldReturnCreatedRecordInstanceHoldingItemSummary(TestContext context) {
    Async async = context.async();
    String jobExecutionId = constructAndPostInitJobExecutionRqDto(1).getJobExecutions().get(0).getId();
    String sourceRecordId = UUID.randomUUID().toString();
    String recordTitle = "test title";
    Future<JournalRecord> future = Future.succeededFuture().compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, recordTitle, 0, CREATE, MARC_BIBLIOGRAPHIC, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, recordTitle, 0, CREATE, INSTANCE, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, recordTitle, 0, CREATE, HOLDINGS, COMPLETED, null)).compose(v -> createJournalRecord(jobExecutionId, sourceRecordId, null, null, recordTitle, 0, CREATE, ITEM, 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("jobExecutionId", is(jobExecutionId)).body("sourceRecordSummary.totalCreatedEntities", is(1)).body("sourceRecordSummary.totalUpdatedEntities", is(0)).body("sourceRecordSummary.totalDiscardedEntities", is(0)).body("sourceRecordSummary.totalErrors", is(0)).body("instanceSummary.totalCreatedEntities", is(1)).body("instanceSummary.totalUpdatedEntities", is(0)).body("instanceSummary.totalDiscardedEntities", is(0)).body("instanceSummary.totalErrors", is(0)).body("holdingSummary.totalCreatedEntities", is(1)).body("holdingSummary.totalUpdatedEntities", is(0)).body("holdingSummary.totalDiscardedEntities", is(0)).body("holdingSummary.totalErrors", is(0)).body("itemSummary.totalCreatedEntities", is(1)).body("itemSummary.totalUpdatedEntities", is(0)).body("itemSummary.totalDiscardedEntities", is(0)).body("itemSummary.totalErrors", is(0)).body("authoritySummary", nullValue()).body("orderSummary", nullValue()).body("invoiceSummary", nullValue()).body("totalErrors", is(0)).extract().response().prettyPrint();
        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)

Aggregations

RestAssured (io.restassured.RestAssured)2 Future (io.vertx.core.Future)2 Async (io.vertx.ext.unit.Async)2 TestContext (io.vertx.ext.unit.TestContext)2 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)2 Date (java.util.Date)2 List (java.util.List)2 UUID (java.util.UUID)2 HttpStatus (org.apache.http.HttpStatus)2 JournalRecordDaoImpl (org.folio.dao.JournalRecordDaoImpl)2 PostgresClientFactory (org.folio.dao.util.PostgresClientFactory)2 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)2 JobExecution (org.folio.rest.jaxrs.model.JobExecution)2 JournalRecord (org.folio.rest.jaxrs.model.JournalRecord)2 COMPLETED (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.COMPLETED)2 ERROR (org.folio.rest.jaxrs.model.JournalRecord.ActionStatus.ERROR)2 CREATE (org.folio.rest.jaxrs.model.JournalRecord.ActionType.CREATE)2 MODIFY (org.folio.rest.jaxrs.model.JournalRecord.ActionType.MODIFY)2 NON_MATCH (org.folio.rest.jaxrs.model.JournalRecord.ActionType.NON_MATCH)2 UPDATE (org.folio.rest.jaxrs.model.JournalRecord.ActionType.UPDATE)2