Search in sources :

Example 31 with Snapshot

use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.

the class AbstractPostProcessingEventHandlerTest method setUp.

@Before
public void setUp(TestContext context) {
    MockitoAnnotations.initMocks(this);
    WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA__URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters()))))));
    mappingParametersCache = new MappingParametersSnapshotCache(vertx);
    recordDao = new RecordDaoImpl(postgresClientFactory);
    handler = createHandler(recordDao, kafkaConfig);
    Async async = context.async();
    Snapshot snapshot1 = new Snapshot().withJobExecutionId(snapshotId1).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
    Snapshot snapshot2 = new Snapshot().withJobExecutionId(snapshotId2).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
    List<Snapshot> snapshots = new ArrayList<>();
    snapshots.add(snapshot1);
    snapshots.add(snapshot2);
    this.record = new Record().withId(recordId).withMatchedId(recordId).withSnapshotId(snapshotId1).withGeneration(0).withRecordType(getMarcType()).withRawRecord(rawRecord).withParsedRecord(parsedRecord).withExternalIdsHolder(null);
    SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshots).onComplete(save -> {
        if (save.failed()) {
            context.fail(save.cause());
        }
        async.complete();
    });
}
Also used : Snapshot(org.folio.rest.jaxrs.model.Snapshot) RecordDaoImpl(org.folio.dao.RecordDaoImpl) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Async(io.vertx.ext.unit.Async) ArrayList(java.util.ArrayList) MappingMetadataDto(org.folio.rest.jaxrs.model.MappingMetadataDto) RawRecord(org.folio.rest.jaxrs.model.RawRecord) Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) MappingParameters(org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters) MappingParametersSnapshotCache(org.folio.services.caches.MappingParametersSnapshotCache) Date(java.util.Date) Before(org.junit.Before)

Aggregations

Snapshot (org.folio.rest.jaxrs.model.Snapshot)31 Async (io.vertx.ext.unit.Async)25 Test (org.junit.Test)21 Record (org.folio.rest.jaxrs.model.Record)15 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)14 RawRecord (org.folio.rest.jaxrs.model.RawRecord)14 Before (org.junit.Before)13 ArrayList (java.util.ArrayList)10 Date (java.util.Date)10 JsonObject (io.vertx.core.json.JsonObject)9 UUID (java.util.UUID)9 TestContext (io.vertx.ext.unit.TestContext)8 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)8 RecordDaoImpl (org.folio.dao.RecordDaoImpl)8 SnapshotDaoUtil (org.folio.dao.util.SnapshotDaoUtil)8 ExternalIdsHolder (org.folio.rest.jaxrs.model.ExternalIdsHolder)8 RunWith (org.junit.runner.RunWith)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 IOException (java.io.IOException)7 Collections (java.util.Collections)7