use of org.folio.ActionProfile in project mod-inventory by folio-org.
the class CreateHoldingEventHandlerTest method isEligibleShouldReturnFalseIfActionIsNotCreate.
@Test
public void isEligibleShouldReturnFalseIfActionIsNotCreate() {
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create preliminary Item").withAction(ActionProfile.Action.DELETE).withFolioRecord(HOLDINGS);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(actionProfile.getId()).withContentType(JOB_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_INVENTORY_HOLDING_CREATED.value()).withContext(new HashMap<>()).withCurrentNode(profileSnapshotWrapper);
assertFalse(createHoldingEventHandler.isEligible(dataImportEventPayload));
}
use of org.folio.ActionProfile in project mod-inventory by folio-org.
the class UpdateItemEventHandlerTest method shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile.
@Test
public void shouldReturnFalseWhenHandlerIsNotEligibleForActionProfile() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create preliminary Item").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.ITEM);
ProfileSnapshotWrapper profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile);
DataImportEventPayload dataImportEventPayload = new DataImportEventPayload().withEventType(DI_INVENTORY_ITEM_MATCHED.value()).withCurrentNode(profileSnapshotWrapper);
// when
boolean isEligible = updateItemHandler.isEligible(dataImportEventPayload);
// then
Assert.assertFalse(isEligible);
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityDeleteEventHandlerTest method shouldDeleteRecord.
@Test
public void shouldDeleteRecord(TestContext context) {
Async async = context.async();
// given
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put("MATCHED_MARC_AUTHORITY", Json.encode(record));
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)));
recordService.saveRecord(record, TENANT_ID).onSuccess(ar -> eventHandler.handle(dataImportEventPayload).whenComplete((eventPayload, throwable) -> {
context.assertNull(throwable);
context.assertEquals(DI_SRS_MARC_AUTHORITY_RECORD_DELETED.value(), eventPayload.getEventType());
context.assertNull(eventPayload.getContext().get("MATCHED_MARC_AUTHORITY"));
context.assertEquals(record.getExternalIdsHolder().getAuthorityId(), eventPayload.getContext().get("AUTHORITY_RECORD_ID"));
recordService.getRecordById(record.getId(), TENANT_ID).onSuccess(optionalDeletedRecord -> {
context.assertTrue(optionalDeletedRecord.isPresent());
Record deletedRecord = optionalDeletedRecord.get();
context.assertTrue(deletedRecord.getDeleted());
async.complete();
});
}));
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityDeleteEventHandlerTest method shouldCompleteExceptionallyIfNoRecordStored.
@Test
public void shouldCompleteExceptionallyIfNoRecordStored(TestContext context) {
Async async = context.async();
// given
HashMap<String, String> payloadContext = new HashMap<>();
payloadContext.put("MATCHED_MARC_AUTHORITY", Json.encode(record));
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(NotFoundException.class, throwable.getClass());
async.complete();
});
}
use of org.folio.ActionProfile in project mod-source-record-storage by folio-org.
the class MarcAuthorityDeleteEventHandlerTest method actionProfileIsNotEligible.
@Test
public void actionProfileIsNotEligible() {
// given
ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Delete marc authority").withAction(UPDATE).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.assertFalse(isEligible);
}
Aggregations