use of org.folio.rest.jaxrs.model.Snapshot 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.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class ParsedRecordChunkConsumersVerticleTest method setUp.
@Before
public void setUp(TestContext context) {
MockitoAnnotations.initMocks(this);
Async async = context.async();
Snapshot snapshot = new Snapshot().withJobExecutionId(snapshotId).withProcessingStartedDate(new Date()).withStatus(Snapshot.Status.COMMITTED);
SnapshotDaoUtil.save(postgresClientFactory.getQueryExecutor(TENANT_ID), snapshot).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 shouldNotDeleteSnapshot.
@Test
public void shouldNotDeleteSnapshot(TestContext context) {
Async async = context.async();
Snapshot snapshot = TestMocks.getSnapshot(0);
snapshotService.deleteSnapshot(snapshot.getJobExecutionId(), TENANT_ID).onComplete(delete -> {
if (delete.failed()) {
context.fail(delete.cause());
}
context.assertFalse(delete.result());
async.complete();
});
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldFailToUpdateSnapshot.
@Test
public void shouldFailToUpdateSnapshot(TestContext context) {
Async async = context.async();
Snapshot snapshot = TestMocks.getSnapshot(0);
snapshotDao.getSnapshotById(snapshot.getJobExecutionId(), TENANT_ID).onComplete(get -> {
if (get.failed()) {
context.fail(get.cause());
}
context.assertFalse(get.result().isPresent());
snapshotService.updateSnapshot(snapshot, TENANT_ID).onComplete(update -> {
context.assertTrue(update.failed());
String expected = String.format("Snapshot with id '%s' was not found", snapshot.getJobExecutionId());
context.assertEquals(expected, update.cause().getMessage());
async.complete();
});
});
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldSaveSnapshot.
@Test
public void shouldSaveSnapshot(TestContext context) {
Async async = context.async();
Snapshot expected = TestMocks.getSnapshot(0);
snapshotService.saveSnapshot(expected, TENANT_ID).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
snapshotDao.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();
});
});
}
Aggregations