use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class MarcBibUpdateModifyEventHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA__URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters()))))));
recordDao = new RecordDaoImpl(postgresClientFactory);
recordService = new RecordServiceImpl(recordDao);
modifyRecordEventHandler = new MarcBibUpdateModifyEventHandler(recordService, new MappingParametersSnapshotCache(vertx), vertx);
Snapshot snapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
snapshotForRecordUpdate = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withStatus(Snapshot.Status.PARSING_IN_PROGRESS);
record = new Record().withId(recordId).withSnapshotId(snapshot.getJobExecutionId()).withGeneration(0).withMatchedId(recordId).withRecordType(MARC_BIB).withRawRecord(rawRecord).withParsedRecord(parsedRecord);
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
SnapshotDaoUtil.save(queryExecutor, snapshot).compose(v -> recordService.saveRecord(record, TENANT_ID)).compose(v -> SnapshotDaoUtil.save(queryExecutor, snapshotForRecordUpdate)).onComplete(context.asyncAssertSuccess());
}
use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class QuickMarcKafkaHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
MockitoAnnotations.initMocks(this);
recordDao = new RecordDaoImpl(postgresClientFactory);
recordService = new RecordServiceImpl(recordDao);
Async async = context.async();
Snapshot snapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
record = new Record().withId(recordId).withSnapshotId(snapshot.getJobExecutionId()).withGeneration(0).withMatchedId(recordId).withRecordType(MARC_BIB).withRawRecord(rawRecord).withParsedRecord(parsedRecord);
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshot).compose(savedSnapshot -> recordService.saveRecord(record, TENANT_ID)).onSuccess(ar -> async.complete()).onFailure(context::fail);
}
use of org.folio.dao.RecordDaoImpl 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();
});
}
Aggregations