use of org.folio.ActionProfile.Action.DELETE 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();
});
}));
}
Aggregations