use of org.folio.rest.jaxrs.model.SourceRecord in project mod-source-record-storage by folio-org.
the class MarcUtilTest method readSourceRecord.
@Before
public void readSourceRecord() throws JsonParseException, JsonMappingException, IOException {
File file = new File(SOURCE_RECORD_PATH);
sourceRecord = new ObjectMapper().readValue(file, SourceRecord.class);
}
use of org.folio.rest.jaxrs.model.SourceRecord in project mod-source-record-storage by folio-org.
the class SourceStorageStreamApiTest method shouldReturnEmptyCollectionOnGetByRecordIdIfParsedRecordIsNull.
@Test
public void shouldReturnEmptyCollectionOnGetByRecordIdIfParsedRecordIsNull(TestContext testContext) {
postSnapshots(testContext, snapshot_1, snapshot_2);
postRecords(testContext, marc_bib_record_1, marc_bib_record_3);
Record createdRecord = RestAssured.given().spec(spec).body(marc_bib_record_3).when().post(SOURCE_STORAGE_RECORDS_PATH).body().as(Record.class);
final Async async = testContext.async();
InputStream response = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_STREAM_SOURCE_RECORDS_PATH + "?recordId=" + createdRecord.getId() + "&limit=1&offset=0").then().statusCode(HttpStatus.SC_OK).extract().response().asInputStream();
List<SourceRecord> actual = new ArrayList<>();
flowableInputStreamScanner(response).map(r -> Json.decodeValue(r, SourceRecord.class)).doFinally(() -> {
testContext.assertEquals(0, actual.size());
async.complete();
}).collect(() -> actual, (a, r) -> a.add(r)).subscribe();
}
use of org.folio.rest.jaxrs.model.SourceRecord in project mod-source-record-storage by folio-org.
the class SourceStorageStreamApiTest method shouldReturnSpecificSourceRecordOnGetByRecordLeaderRecordStatus.
@Test
public void shouldReturnSpecificSourceRecordOnGetByRecordLeaderRecordStatus(TestContext testContext) {
postSnapshots(testContext, snapshot_1, snapshot_2);
postRecords(testContext, marc_bib_record_1, marc_bib_record_3);
Record createdRecord = RestAssured.given().spec(spec).body(marc_bib_record_2).when().post(SOURCE_STORAGE_RECORDS_PATH).body().as(Record.class);
String leaderStatus = ParsedRecordDaoUtil.getLeaderStatus(createdRecord.getParsedRecord());
final Async async = testContext.async();
InputStream response = RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_STREAM_SOURCE_RECORDS_PATH + "?leaderRecordStatus=" + leaderStatus + "&limit=1&offset=0").then().statusCode(HttpStatus.SC_OK).extract().response().asInputStream();
List<SourceRecord> actual = new ArrayList<>();
flowableInputStreamScanner(response).map(r -> Json.decodeValue(r, SourceRecord.class)).doFinally(() -> {
testContext.assertEquals(1, actual.size());
testContext.assertTrue(Objects.nonNull(actual.get(0).getParsedRecord()));
async.complete();
}).collect(() -> actual, (a, r) -> a.add(r)).subscribe();
}
use of org.folio.rest.jaxrs.model.SourceRecord in project mod-source-record-storage by folio-org.
the class TestMocks method readSourceRecords.
private static List<SourceRecord> readSourceRecords() {
File sourceRecordsDirectory = new File(SOURCE_RECORDS_FOLDER_PATH);
String[] extensions = new String[] { "json" };
return FileUtils.listFiles(sourceRecordsDirectory, extensions, false).stream().map(TestMocks::readSourceRecord).filter(sr -> sr.isPresent()).map(sr -> sr.get()).collect(Collectors.toList());
}
use of org.folio.rest.jaxrs.model.SourceRecord in project mod-source-record-storage by folio-org.
the class EdifactUtilTest method readSourceRecord.
@Before
public void readSourceRecord() throws JsonParseException, JsonMappingException, IOException {
File file = new File(SOURCE_RECORD_PATH);
sourceRecord = new ObjectMapper().readValue(file, SourceRecord.class);
}
Aggregations