use of org.folio.rest.jaxrs.model.Record in project mod-source-record-storage by folio-org.
the class SourceRecordApiTest method shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified.
@Test
public void shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified(TestContext testContext) {
postSnapshots(testContext, snapshot_1, snapshot_2, snapshot_3);
String firstMatchedId = UUID.randomUUID().toString();
Record record_4_tmp = new Record().withId(firstMatchedId).withSnapshotId(snapshot_1.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(firstMatchedId).withOrder(1).withState(Record.State.ACTUAL);
String secondMathcedId = UUID.randomUUID().toString();
Record record_2_tmp = new Record().withId(secondMathcedId).withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(secondMathcedId).withOrder(11).withState(Record.State.ACTUAL);
postRecords(testContext, record_2, record_2_tmp, record_4, record_4_tmp, record_7);
Async async = testContext.async();
List<SourceRecord> sourceRecordList = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_SOURCE_RECORDS_PATH + "?recordType=MARC_BIB&orderBy=createdDate,DESC").then().statusCode(HttpStatus.SC_OK).body("sourceRecords.size()", is(4)).body("totalRecords", is(4)).body("sourceRecords*.recordType", everyItem(is(RecordType.MARC_BIB.name()))).body("sourceRecords*.deleted", everyItem(is(false))).extract().response().body().as(SourceRecordCollection.class).getSourceRecords();
testContext.assertTrue(sourceRecordList.get(0).getMetadata().getCreatedDate().after(sourceRecordList.get(1).getMetadata().getCreatedDate()));
testContext.assertTrue(sourceRecordList.get(1).getMetadata().getCreatedDate().after(sourceRecordList.get(2).getMetadata().getCreatedDate()));
testContext.assertTrue(sourceRecordList.get(2).getMetadata().getCreatedDate().after(sourceRecordList.get(3).getMetadata().getCreatedDate()));
async.complete();
}
use of org.folio.rest.jaxrs.model.Record in project mod-source-record-storage by folio-org.
the class AbstractRestVerticleTest method postRecords.
protected void postRecords(TestContext testContext, Record... records) {
Async async = testContext.async();
for (Record record : records) {
RestAssured.given().spec(spec).body(record).when().post(SOURCE_STORAGE_RECORDS_PATH).then().statusCode(HttpStatus.SC_CREATED);
}
async.complete();
}
use of org.folio.rest.jaxrs.model.Record in project mod-source-record-storage by folio-org.
the class RecordApiTest method shouldReturnMarcBibRecordsOnGetBySpecifiedSnapshotId.
@Test
public void shouldReturnMarcBibRecordsOnGetBySpecifiedSnapshotId(TestContext testContext) {
postSnapshots(testContext, snapshot_1, snapshot_2, snapshot_3);
Record recordWithOldStatus = new Record().withId(FOURTH_UUID).withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawMarcRecord).withParsedRecord(parsedMarcRecord).withMatchedId(FOURTH_UUID).withOrder(1).withState(Record.State.OLD);
postRecords(testContext, record_1, record_2, record_3, record_6, recordWithOldStatus);
Async async = testContext.async();
RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_RECORDS_PATH + "?recordType=MARC_BIB&state=ACTUAL&snapshotId=" + record_2.getSnapshotId()).then().statusCode(HttpStatus.SC_OK).body("totalRecords", is(2)).body("records*.recordType", everyItem(is(RecordType.MARC_BIB.name()))).body("records*.snapshotId", everyItem(is(record_2.getSnapshotId()))).body("records*.additionalInfo.suppressDiscovery", everyItem(is(false)));
async.complete();
}
use of org.folio.rest.jaxrs.model.Record in project mod-source-record-storage by folio-org.
the class RecordApiTest method shouldReturnSortedRecordsOnGetWhenSortByOrderIsSpecified.
@Test
public void shouldReturnSortedRecordsOnGetWhenSortByOrderIsSpecified(TestContext testContext) {
postSnapshots(testContext, snapshot_2);
postRecords(testContext, record_2, record_3, record_5);
Async async = testContext.async();
List<Record> records = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_RECORDS_PATH + "?snapshotId=" + snapshot_2.getJobExecutionId() + "&orderBy=order").then().statusCode(HttpStatus.SC_OK).body("records.size()", is(3)).body("totalRecords", is(3)).body("records*.deleted", everyItem(is(false))).extract().response().body().as(RecordCollection.class).getRecords();
Assert.assertEquals(11, records.get(0).getOrder().intValue());
Assert.assertEquals(101, records.get(1).getOrder().intValue());
Assert.assertNull(records.get(2).getOrder());
async.complete();
}
use of org.folio.rest.jaxrs.model.Record in project mod-source-record-storage by folio-org.
the class RecordApiTest method shouldUpdateExistingMarcRecordOnPut.
@Test
public void shouldUpdateExistingMarcRecordOnPut(TestContext testContext) {
postSnapshots(testContext, snapshot_1);
Async async = testContext.async();
Response createResponse = RestAssured.given().spec(spec).body(record_1).when().post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Record createdRecord = createResponse.body().as(Record.class);
async.complete();
async = testContext.async();
Response putResponse = RestAssured.given().spec(spec).body(createdRecord.withParsedRecord(parsedMarcRecord)).when().put(SOURCE_STORAGE_RECORDS_PATH + "/" + createdRecord.getId());
assertThat(putResponse.statusCode(), is(HttpStatus.SC_OK));
Record updatedRecord = putResponse.body().as(Record.class);
assertThat(updatedRecord.getId(), is(createdRecord.getId()));
assertThat(updatedRecord.getRawRecord().getContent(), is(rawMarcRecord.getContent()));
assertThat(updatedRecord.getAdditionalInfo().getSuppressDiscovery(), is(false));
async.complete();
}
Aggregations