Search in sources :

Example 16 with ProfileSnapshotWrapper

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper in project mod-inventory by folio-org.

the class CreateMarcHoldingsEventHandlerTest method shouldThrowExceptionIfChildSnapshotWrappersIsEmpty.

@Test(expected = ExecutionException.class)
public void shouldThrowExceptionIfChildSnapshotWrappersIsEmpty() throws ExecutionException, InterruptedException, TimeoutException, IOException {
    var parsedHoldingsRecord = new JsonObject(TestUtil.readFileFromPath(PARSED_HOLDINGS_RECORD));
    Record record = new Record().withParsedRecord(new ParsedRecord().withContent(parsedHoldingsRecord.encode()));
    HashMap<String, String> context = new HashMap<>();
    context.put(MARC_HOLDINGS.value(), Json.encode(record));
    profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile).withChildSnapshotWrappers(Collections.emptyList());
    DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_SRS_MARC_HOLDING_RECORD_CREATED.value()).withContext(context).withCurrentNode(profileSnapshotWrapper);
    CompletableFuture<DataImportEventPayload> future = createMarcHoldingsEventHandler.handle(dataImportEventPayload);
    future.get(10000, TimeUnit.MILLISECONDS);
}
Also used : HashMap(java.util.HashMap) JsonObject(io.vertx.core.json.JsonObject) HoldingsRecord(org.folio.HoldingsRecord) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Record(org.folio.rest.jaxrs.model.Record) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test)

Example 17 with ProfileSnapshotWrapper

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper in project mod-inventory by folio-org.

the class CreateMarcHoldingsEventHandlerTest method isEligibleShouldReturnFalseIfCurrentNodeIsNotActionProfile.

@Test
public void isEligibleShouldReturnFalseIfCurrentNodeIsNotActionProfile() {
    ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile);
    DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_INVENTORY_HOLDING_CREATED.value()).withContext(new HashMap<>()).withCurrentNode(profileSnapshotWrapper);
    assertFalse(createMarcHoldingsEventHandler.isEligible(dataImportEventPayload));
}
Also used : HashMap(java.util.HashMap) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test)

Example 18 with ProfileSnapshotWrapper

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper in project mod-inventory by folio-org.

the class DeleteAuthorityEventHandlerTest method isEligibleShouldReturnFalseIfActionIsNotDelete.

@Test
public void isEligibleShouldReturnFalseIfActionIsNotDelete() {
    ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Update Marc Authorities").withAction(UPDATE).withFolioRecord(MARC_AUTHORITY);
    ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
    DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_SRS_MARC_AUTHORITY_RECORD_DELETED.value()).withContext(context).withCurrentNode(profileSnapshotWrapper);
    assertFalse(eventHandler.isEligible(dataImportEventPayload));
}
Also used : ActionProfile(org.folio.ActionProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test)

Example 19 with ProfileSnapshotWrapper

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper in project mod-inventory by folio-org.

the class DeleteAuthorityEventHandlerTest method isEligibleShouldReturnFalseIfCurrentNodeIsNotActionProfile.

@Test
public void isEligibleShouldReturnFalseIfCurrentNodeIsNotActionProfile() {
    JobProfile jobProfile = new JobProfile().withId(UUID.randomUUID().toString()).withName("Create MARC Authority").withDataType(JobProfile.DataType.MARC);
    ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile);
    DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_SRS_MARC_AUTHORITY_RECORD_DELETED.value()).withContext(context).withCurrentNode(profileSnapshotWrapper);
    assertFalse(eventHandler.isEligible(dataImportEventPayload));
}
Also used : JobProfile(org.folio.JobProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test)

Example 20 with ProfileSnapshotWrapper

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper in project mod-inventory by folio-org.

the class MarcBibModifiedPostProcessingEventHandlerTest method shouldReturnFalseWhenHandlerIsNotEligibleForProfile.

@Test
public void shouldReturnFalseWhenHandlerIsNotEligibleForProfile() {
    // given
    ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create instance").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
    ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withContentType(ACTION_PROFILE).withContent(actionProfile);
    DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withCurrentNode(profileSnapshotWrapper);
    // when
    boolean isEligible = marcBibModifiedEventHandler.isEligible(dataImportEventPayload);
    // then
    Assert.assertFalse(isEligible);
}
Also used : ActionProfile(org.folio.ActionProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test)

Aggregations

ProfileSnapshotWrapper (org.folio.rest.jaxrs.model.ProfileSnapshotWrapper)120 DataImportEventPayload (org.folio.DataImportEventPayload)106 Test (org.junit.Test)100 HashMap (java.util.HashMap)77 ActionProfile (org.folio.ActionProfile)34 Record (org.folio.rest.jaxrs.model.Record)32 Async (io.vertx.ext.unit.Async)29 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)29 MatchProfile (org.folio.MatchProfile)28 JsonObject (io.vertx.core.json.JsonObject)27 EventHandler (org.folio.processing.events.services.handler.EventHandler)23 MappingProfile (org.folio.MappingProfile)22 List (java.util.List)18 RawRecord (org.folio.rest.jaxrs.model.RawRecord)18 ArrayList (java.util.ArrayList)16 Before (org.junit.Before)16 Json (io.vertx.core.json.Json)15 TestContext (io.vertx.ext.unit.TestContext)15 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)15 UUID (java.util.UUID)15