use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class InstancePostProcessingEventHandlerTest method shouldReturnFalseWhenCurrentNodeIsNull.
@Test
public void shouldReturnFalseWhenCurrentNodeIsNull() {
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create instance").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withTenant(TENANT_ID).withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withContext(new HashMap<>()).withProfileSnapshot(profileSnapshotWrapper);
boolean isEligible = handler.isEligible(dataImportEventPayload);
Assert.assertFalse(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class InstancePostProcessingEventHandlerTest method shouldReturnFalseWhenHandlerIsNotEligibleForProfile.
@Test
public void shouldReturnFalseWhenHandlerIsNotEligibleForProfile() {
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create instance").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withTenant(TENANT_ID).withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withContext(new HashMap<>()).withProfileSnapshot(profileSnapshotWrapper).withCurrentNode(profileSnapshotWrapper);
boolean isEligible = handler.isEligible(dataImportEventPayload);
Assert.assertFalse(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcBibUpdateModifyEventHandlerTest method shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile.
@Test
public void shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create instance").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withTenant(TENANT_ID).withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withContext(new HashMap<>()).withProfileSnapshot(profileSnapshotWrapper).withCurrentNode(profileSnapshotWrapper);
// when
boolean isEligible = modifyRecordEventHandler.isEligible(dataImportEventPayload);
// then
Assert.assertFalse(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcBibUpdateModifyEventHandlerTest method shouldReturnTrueWhenHandlerIsEligibleForUpdateMarcBibActionProfile.
@Test
public void shouldReturnTrueWhenHandlerIsEligibleForUpdateMarcBibActionProfile() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Update marc bib").withAction(ActionProfile.Action.UPDATE).withFolioRecord(ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withTenant(TENANT_ID).withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withContext(new HashMap<>()).withProfileSnapshot(profileSnapshotWrapper).withCurrentNode(profileSnapshotWrapper);
// when
boolean isEligible = modifyRecordEventHandler.isEligible(dataImportEventPayload);
// then
Assert.assertTrue(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityDeleteEventHandlerTest method shouldCompleteExceptionallyIfNoRecordInPayload.
@Test
public void shouldCompleteExceptionallyIfNoRecordInPayload(TestContext context) {
Async async = context.async();
// given
HashMap<String, String> payloadContext = new HashMap<>();
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withContext(payloadContext).withTenant(TENANT_ID).withCurrentNode(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(ACTION_PROFILE).withContent(new ActionProfile().withId(UUID.randomUUID().toString()).withName("Delete Marc Authorities").withAction(DELETE).withFolioRecord(ActionProfile.FolioRecord.MARC_AUTHORITY)));
// when
CompletableFuture<DataImportEventPayload> future = eventHandler.handle(dataImportEventPayload);
// then
future.whenComplete((eventPayload, throwable) -> {
context.assertNotNull(throwable);
context.assertEquals("Failed to handle event payload, cause event payload context does not contain required data to modify MARC record", throwable.getMessage());
async.complete();
});
}
Aggregations