use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class DataImportConsumersVerticleTest method setUp.
@Before
public void setUp(TestContext context) throws IOException {
WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(MAPPING_METADATA_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(new MappingMetadataDto().withMappingParams(Json.encode(new MappingParameters()))))));
RawRecord rawRecord = new RawRecord().withId(recordId).withContent(new ObjectMapper().readValue(TestUtil.readFileFromPath(RAW_MARC_RECORD_CONTENT_SAMPLE_PATH), String.class));
ParsedRecord parsedRecord = new ParsedRecord().withId(recordId).withContent(PARSED_CONTENT);
Snapshot snapshot = new Snapshot().withJobExecutionId(snapshotId).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).withExternalIdsHolder(new ExternalIdsHolder().withAuthorityId(UUID.randomUUID().toString()));
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
RecordDaoImpl recordDao = new RecordDaoImpl(postgresClientFactory);
SnapshotDaoUtil.save(queryExecutor, snapshot).compose(v -> recordDao.saveRecord(record, TENANT_ID)).onComplete(context.asyncAssertSuccess());
}
use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class MarcBibliographicMatchEventHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
MockitoAnnotations.initMocks(this);
recordDao = new RecordDaoImpl(postgresClientFactory);
handler = new MarcBibliographicMatchEventHandler(recordDao);
Async async = context.async();
Snapshot existingRecordSnapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
Snapshot incomingRecordSnapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
List<Snapshot> snapshots = new ArrayList<>();
snapshots.add(existingRecordSnapshot);
snapshots.add(incomingRecordSnapshot);
String existingRecordId = "acf4f6e2-115c-4509-9d4c-536c758ef917";
this.existingRecord = new Record().withId(existingRecordId).withMatchedId(existingRecordId).withSnapshotId(existingRecordSnapshot.getJobExecutionId()).withGeneration(0).withRecordType(MARC_BIB).withRawRecord(new RawRecord().withId(existingRecordId).withContent(rawRecordContent)).withParsedRecord(new ParsedRecord().withId(existingRecordId).withContent(PARSED_CONTENT_WITH_ADDITIONAL_FIELDS)).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("681394b4-10d8-4cb1-a618-0f9bd6152119").withInstanceHrid("12345"));
String incomingRecordId = UUID.randomUUID().toString();
this.incomingRecord = new Record().withId(incomingRecordId).withMatchedId(existingRecordId).withSnapshotId(incomingRecordSnapshot.getJobExecutionId()).withGeneration(1).withRecordType(MARC_BIB).withRawRecord(new RawRecord().withId(incomingRecordId).withContent(rawRecordContent)).withParsedRecord(new ParsedRecord().withId(incomingRecordId).withContent(PARSED_CONTENT_WITH_ADDITIONAL_FIELDS)).withExternalIdsHolder(new ExternalIdsHolder());
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshots).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
async.complete();
});
}
use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class RecordServiceTest method setUp.
@Before
public void setUp(TestContext context) {
recordDao = new RecordDaoImpl(postgresClientFactory);
recordService = new RecordServiceImpl(recordDao);
Async async = context.async();
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), TestMocks.getSnapshots()).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
async.complete();
});
}
use of org.folio.dao.RecordDaoImpl in project mod-source-record-storage by folio-org.
the class MarcAuthorityUpdateModifyEventHandlerTest 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 MarcAuthorityUpdateModifyEventHandler(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 MarcAuthorityMatchEventHandlerTest method setUp.
@Before
public void setUp(TestContext context) {
MockitoAnnotations.initMocks(this);
recordDao = new RecordDaoImpl(postgresClientFactory);
handler = new MarcAuthorityMatchEventHandler(recordDao);
Async async = context.async();
Snapshot existingRecordSnapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
Snapshot incomingRecordSnapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
List<Snapshot> snapshots = new ArrayList<>();
snapshots.add(existingRecordSnapshot);
snapshots.add(incomingRecordSnapshot);
this.existingRecord = new Record().withId(existingRecordId).withMatchedId(existingRecordId).withSnapshotId(existingRecordSnapshot.getJobExecutionId()).withGeneration(0).withRecordType(MARC_AUTHORITY).withRawRecord(new RawRecord().withId(existingRecordId).withContent(rawRecordContent)).withParsedRecord(new ParsedRecord().withId(existingRecordId).withContent(PARSED_CONTENT)).withExternalIdsHolder(new ExternalIdsHolder().withAuthorityHrid("1000649")).withState(Record.State.ACTUAL);
String incomingRecordId = UUID.randomUUID().toString();
this.incomingRecord = new Record().withId(incomingRecordId).withMatchedId(existingRecord.getId()).withSnapshotId(incomingRecordSnapshot.getJobExecutionId()).withGeneration(1).withRecordType(MARC_AUTHORITY).withRawRecord(new RawRecord().withId(incomingRecordId).withContent(rawRecordContent)).withParsedRecord(new ParsedRecord().withId(incomingRecordId).withContent(PARSED_CONTENT)).withExternalIdsHolder(new ExternalIdsHolder());
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshots).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
async.complete();
});
}
Aggregations