use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityDeleteEventHandlerTest method actionProfileIsEligible.
@Test
public void actionProfileIsEligible() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Delete marc authority").withAction(DELETE).withFolioRecord(ActionProfile.FolioRecord.MARC_AUTHORITY);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withTenant(TENANT_ID).withContext(new HashMap<>()).withProfileSnapshot(profileSnapshotWrapper).withCurrentNode(profileSnapshotWrapper);
// when
boolean isEligible = eventHandler.isEligible(dataImportEventPayload);
// then
Assert.assertTrue(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityUpdateModifyEventHandlerTest 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-manager by folio-org.
the class DataImportJournalConsumerVerticleTest method testJournalErrorAction.
@Test
public void testJournalErrorAction(TestContext context) throws IOException, ExecutionException, InterruptedException {
Async async = context.async();
// given
DataImportEventPayload eventPayload = new DataImportEventPayload().withEventType(DI_ERROR.value()).withTenant(TENANT_ID).withOkapiUrl(OKAPI_URL).withToken(TOKEN).withContext(new HashMap<>() {
{
put(HOLDINGS.value(), recordJson.encode());
put(MARC_BIBLIOGRAPHIC.value(), recordJson.encode());
put("ERROR", "java.lang.IllegalArgumentException: Can not handle event payload");
}
}).withProfileSnapshot(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(new ActionProfile().withFolioRecord(ActionProfile.FolioRecord.HOLDINGS)))).withCurrentNode(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(new ActionProfile().withFolioRecord(ActionProfile.FolioRecord.HOLDINGS)))).withEventsChain(List.of(DI_SRS_MARC_BIB_RECORD_CREATED.value(), DI_INVENTORY_HOLDING_CREATED.value()));
// when
KafkaConsumerRecord<String, String> kafkaConsumerRecord = buildKafkaConsumerRecord(eventPayload);
dataImportJournalKafkaHandler.handle(kafkaConsumerRecord);
// then
Future<List<JournalRecord>> future = journalRecordDao.getByJobExecutionId(jobExecution.getId(), "action_type", "asc", TENANT_ID);
future.onComplete(ar -> {
context.assertTrue(ar.succeeded());
Assert.assertNotNull(ar.result());
async.complete();
});
}
use of org.folio.ActionProfile in project mod-source-record-manager by folio-org.
the class DataImportJournalConsumerVerticleTest method testJournalCompletedAction.
@Test
public void testJournalCompletedAction(TestContext context) throws IOException, ExecutionException, InterruptedException {
Async async = context.async();
// given
DataImportEventPayload completedEventPayload = new DataImportEventPayload().withEventType(DI_COMPLETED.value()).withTenant(TENANT_ID).withOkapiUrl(OKAPI_URL).withToken(TOKEN).withContext(new HashMap<>() {
{
put(ITEM.value(), recordJson.encode());
put(MARC_BIBLIOGRAPHIC.value(), recordJson.encode());
}
}).withProfileSnapshot(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(new ActionProfile().withFolioRecord(ActionProfile.FolioRecord.ITEM)))).withCurrentNode(new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(new ActionProfile().withFolioRecord(ActionProfile.FolioRecord.ITEM)))).withEventsChain(List.of(DI_INVENTORY_HOLDING_CREATED.value(), DI_INVENTORY_ITEM_CREATED.value()));
// when
KafkaConsumerRecord<String, String> kafkaConsumerRecord = buildKafkaConsumerRecord(completedEventPayload);
dataImportJournalKafkaHandler.handle(kafkaConsumerRecord);
// then
Future<List<JournalRecord>> future = journalRecordDao.getByJobExecutionId(jobExecution.getId(), "action_type", "asc", TENANT_ID);
future.onComplete(ar -> {
if (ar.succeeded()) {
context.assertTrue(ar.succeeded());
Assert.assertNotNull(ar.result());
}
});
async.complete();
}
use of org.folio.ActionProfile in project mod-inventory by folio-org.
the class CreateItemEventHandlerTest method shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile.
@Test
public void shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create preliminary Instance").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_SRS_MARC_BIB_RECORD_CREATED.value()).withCurrentNode(profileSnapshotWrapper);
// when
boolean isEligible = createItemHandler.isEligible(dataImportEventPayload);
// then
Assert.assertFalse(isEligible);
}
Aggregations