use of org.folio.rest.jaxrs.model.Snapshot 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();
});
}
use of org.folio.rest.jaxrs.model.Snapshot 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.rest.jaxrs.model.Snapshot 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.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class RecordCleanupServiceTest method before.
@Before
public void before(TestContext testContext) throws InterruptedException {
Async async = testContext.async();
ReactiveClassicGenericQueryExecutor queryExecutor = postgresClientFactory.getQueryExecutor(TENANT_ID);
SnapshotDaoUtil.save(queryExecutor, snapshot).compose(ar -> recordService.saveRecord(deletedRecord, TENANT_ID)).compose(ar -> recordService.saveRecord(oldRecordForDeletedRecord, TENANT_ID)).compose(ar -> recordService.saveRecord(actualRecord, TENANT_ID)).compose(ar -> recordService.saveRecord(oldRecordForActualRecord, TENANT_ID)).onComplete(ar -> async.complete());
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SourceStorageBatchApiTest method shouldFailWithInvalidSnapshotStatusBadRequest.
@Test
public void shouldFailWithInvalidSnapshotStatusBadRequest(TestContext testContext) {
Async async = testContext.async();
Snapshot snapshot = new Snapshot().withJobExecutionId(UUID.randomUUID().toString()).withStatus(Snapshot.Status.NEW);
RestAssured.given().spec(spec).body(snapshot).when().post(SOURCE_STORAGE_SNAPSHOTS_PATH).then().statusCode(HttpStatus.SC_CREATED).body("jobExecutionId", is(snapshot.getJobExecutionId())).body("status", is(snapshot.getStatus().name()));
async.complete();
async = testContext.async();
List<Record> expected = TestMocks.getRecords().stream().filter(record -> record.getRecordType().equals(RecordType.MARC_BIB)).map(record -> record.withSnapshotId(snapshot.getJobExecutionId())).collect(Collectors.toList());
RecordCollection recordCollection = new RecordCollection().withRecords(expected).withTotalRecords(expected.size());
RestAssured.given().spec(spec).body(recordCollection).when().post(SOURCE_STORAGE_BATCH_RECORDS_PATH).then().statusCode(HttpStatus.SC_BAD_REQUEST).body(is(format(SNAPSHOT_NOT_STARTED_MESSAGE_TEMPLATE, snapshot.getStatus())));
async.complete();
}
Aggregations