use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class RecordsGenerationTest method shouldCalculateRecordsGeneration.
@Test
public void shouldCalculateRecordsGeneration(TestContext testContext) {
List<Snapshot> snapshots = Arrays.asList(snapshot_1, snapshot_2, snapshot_3, snapshot_4);
for (int i = 0; i < snapshots.size(); i++) {
Async async = testContext.async();
RestAssured.given().spec(spec).body(snapshots.get(i).withStatus(Snapshot.Status.PARSING_IN_PROGRESS)).when().post(SOURCE_STORAGE_SNAPSHOTS_PATH).then().statusCode(HttpStatus.SC_CREATED);
async.complete();
async = testContext.async();
Record record = new Record().withId(matchedId).withSnapshotId(snapshots.get(i).getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(matchedId);
Record created = RestAssured.given().spec(spec).body(record).when().post(SOURCE_STORAGE_RECORDS_PATH).body().as(Record.class);
RestAssured.given().spec(spec).body(snapshots.get(i).withStatus(Snapshot.Status.COMMITTED)).when().put(SOURCE_STORAGE_SNAPSHOTS_PATH + "/" + snapshots.get(i).getJobExecutionId()).then().statusCode(HttpStatus.SC_OK);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_RECORDS_PATH + "/" + created.getId()).then().statusCode(HttpStatus.SC_OK).body("id", is(created.getId())).body("rawRecord.content", is(rawRecord.getContent())).body("matchedId", is(matchedId)).body("generation", is(i));
async.complete();
}
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotApiTest method shouldReturnLimitedCollectionOnGet.
@Test
public void shouldReturnLimitedCollectionOnGet(TestContext testContext) {
Snapshot[] snapshots = new Snapshot[] { snapshot_1, snapshot_2, snapshot_3, snapshot_4 };
postSnapshots(testContext, snapshots);
Async async = testContext.async();
RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_SNAPSHOTS_PATH + "?limit=3").then().statusCode(HttpStatus.SC_OK).body("snapshots.size()", is(3)).body("totalRecords", is(snapshots.length));
async.complete();
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldNotGetSnapshotById.
@Test
public void shouldNotGetSnapshotById(TestContext context) {
Async async = context.async();
Snapshot expected = TestMocks.getSnapshot(0);
snapshotService.getSnapshotById(expected.getJobExecutionId(), TENANT_ID).onComplete(get -> {
if (get.failed()) {
context.fail(get.cause());
}
context.assertFalse(get.result().isPresent());
async.complete();
});
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldDeleteSnapshot.
@Test
public void shouldDeleteSnapshot(TestContext context) {
Async async = context.async();
Snapshot snapshot = TestMocks.getSnapshot(0);
snapshotDao.saveSnapshot(snapshot, TENANT_ID).onComplete(save -> {
if (save.failed()) {
context.fail(save.cause());
}
snapshotService.deleteSnapshot(snapshot.getJobExecutionId(), TENANT_ID).onComplete(delete -> {
if (delete.failed()) {
context.fail(delete.cause());
}
context.assertTrue(delete.result());
snapshotDao.getSnapshotById(snapshot.getJobExecutionId(), TENANT_ID).onComplete(get -> {
if (get.failed()) {
context.fail(get.cause());
}
context.assertFalse(get.result().isPresent());
async.complete();
});
});
});
}
use of org.folio.rest.jaxrs.model.Snapshot in project mod-source-record-storage by folio-org.
the class SnapshotServiceTest method shouldFailToSaveSnapshot.
@Test
public void shouldFailToSaveSnapshot(TestContext context) {
Async async = context.async();
Snapshot valid = TestMocks.getSnapshot(0);
Snapshot invalid = new Snapshot().withJobExecutionId(valid.getJobExecutionId()).withProcessingStartedDate(valid.getProcessingStartedDate()).withMetadata(valid.getMetadata());
snapshotService.saveSnapshot(invalid, TENANT_ID).onComplete(save -> {
context.assertTrue(save.failed());
String expected = "null value in column \"status\" violates not-null constraint";
context.assertTrue(save.cause().getMessage().contains(expected));
async.complete();
});
}
Aggregations