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);
}
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));
}
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));
}
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));
}
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);
}
Aggregations