use of org.folio.rest.jaxrs.model.Snapshot 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.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldGetSnapshotById.
@Test
public void shouldGetSnapshotById(TestContext context) {
Async async = context.async();
Snapshot expected = TestMocks.getSnapshot(0);
snapshotDao.saveSnapshot(expected, TENANT_ID).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
snapshotService.getSnapshotById(expected.getJobExecutionId(), TENANT_ID).onComplete(get -> {
if (get.failed()) {
context.fail(get.cause());
}
context.assertTrue(get.result().isPresent());
compareSnapshots(context, expected, get.result().get());
async.complete();
});
});
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldUpdateSnapshot.
@Test
public void shouldUpdateSnapshot(TestContext context) {
Async async = context.async();
Snapshot original = TestMocks.getSnapshot(0);
snapshotDao.saveSnapshot(original, TENANT_ID).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
Snapshot expected = new Snapshot().withJobExecutionId(original.getJobExecutionId()).withStatus(Status.COMMITTED).withProcessingStartedDate(original.getProcessingStartedDate()).withMetadata(original.getMetadata());
snapshotService.updateSnapshot(expected, TENANT_ID).onComplete(update -> {
if (update.failed()) {
context.fail(update.cause());
}
context.assertTrue(update.result().getMetadata().getUpdatedDate().after(update.result().getMetadata().getCreatedDate()));
compareSnapshots(context, expected, update.result());
async.complete();
});
});
}
use of org.folio.rest.jaxrs.model.Snapshot 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.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class AbstractRestVerticleTest method postSnapshots.
protected void postSnapshots(TestContext testContext, Snapshot... snapshots) {
Async async = testContext.async();
for (Snapshot snapshot : snapshots) {
RestAssured.given().spec(spec).body(snapshot).when().post(SOURCE_STORAGE_SNAPSHOTS_PATH).then().statusCode(HttpStatus.SC_CREATED);
}
async.complete();
}
Aggregations