Search in sources :

Example 1 with ACTION_PROFILE

use of org.folio.rest.jaxrs.model.ProfileSnapshotWrapper.ContentType.ACTION_PROFILE 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();
        });
    }));
}
Also used : TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Json(io.vertx.core.json.Json) EventHandler(org.folio.processing.events.services.handler.EventHandler) RecordDaoImpl(org.folio.dao.RecordDaoImpl) Date(java.util.Date) RawRecord(org.folio.rest.jaxrs.model.RawRecord) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ACTION_PROFILE(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper.ContentType.ACTION_PROFILE) MarcAuthorityDeleteEventHandler(org.folio.services.handlers.actions.MarcAuthorityDeleteEventHandler) MARC_AUTHORITY(org.folio.rest.jaxrs.model.Record.RecordType.MARC_AUTHORITY) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) ExternalIdsHolder(org.folio.rest.jaxrs.model.ExternalIdsHolder) JsonObject(io.vertx.core.json.JsonObject) ActionProfile(org.folio.ActionProfile) Before(org.junit.Before) Record(org.folio.rest.jaxrs.model.Record) DataImportEventPayload(org.folio.DataImportEventPayload) Test(org.junit.Test) IOException(java.io.IOException) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) SnapshotDaoUtil(org.folio.dao.util.SnapshotDaoUtil) UUID(java.util.UUID) NotFoundException(javax.ws.rs.NotFoundException) UPDATE(org.folio.ActionProfile.Action.UPDATE) DI_SRS_MARC_AUTHORITY_RECORD_DELETED(org.folio.rest.jaxrs.model.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_DELETED) MARC_BIB(org.folio.rest.jaxrs.model.Record.RecordType.MARC_BIB) DELETE(org.folio.ActionProfile.Action.DELETE) Assert(org.junit.Assert) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Snapshot(org.folio.rest.jaxrs.model.Snapshot) HashMap(java.util.HashMap) Async(io.vertx.ext.unit.Async) RawRecord(org.folio.rest.jaxrs.model.RawRecord) Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) DataImportEventPayload(org.folio.DataImportEventPayload) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) ActionProfile(org.folio.ActionProfile) Test(org.junit.Test)

Aggregations

Json (io.vertx.core.json.Json)1 JsonObject (io.vertx.core.json.JsonObject)1 Async (io.vertx.ext.unit.Async)1 TestContext (io.vertx.ext.unit.TestContext)1 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 NotFoundException (javax.ws.rs.NotFoundException)1 ActionProfile (org.folio.ActionProfile)1 DELETE (org.folio.ActionProfile.Action.DELETE)1 UPDATE (org.folio.ActionProfile.Action.UPDATE)1 DataImportEventPayload (org.folio.DataImportEventPayload)1 RecordDaoImpl (org.folio.dao.RecordDaoImpl)1 SnapshotDaoUtil (org.folio.dao.util.SnapshotDaoUtil)1 EventHandler (org.folio.processing.events.services.handler.EventHandler)1 DI_SRS_MARC_AUTHORITY_RECORD_DELETED (org.folio.rest.jaxrs.model.DataImportEventTypes.DI_SRS_MARC_AUTHORITY_RECORD_DELETED)1 ExternalIdsHolder (org.folio.rest.jaxrs.model.ExternalIdsHolder)1