use of org.folio.rest.jaxrs.model.ErrorRecord in project mod-source-record-storage by folio-org.
the class RecordApiTest method shouldDeleteExistingMarcRecordOnDelete.
@Test
public void shouldDeleteExistingMarcRecordOnDelete(TestContext testContext) {
postSnapshots(testContext, snapshot_2);
Async async = testContext.async();
Response createParsed = RestAssured.given().spec(spec).body(record_2).when().post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createParsed.statusCode(), is(HttpStatus.SC_CREATED));
Record parsed = createParsed.body().as(Record.class);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().delete(SOURCE_STORAGE_RECORDS_PATH + "/" + parsed.getId()).then().statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_RECORDS_PATH + "/" + parsed.getId()).then().statusCode(HttpStatus.SC_OK).body("deleted", is(true));
async.complete();
async = testContext.async();
Response createErrorRecord = RestAssured.given().spec(spec).body(record_3).when().post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createErrorRecord.statusCode(), is(HttpStatus.SC_CREATED));
Record errorRecord = createErrorRecord.body().as(Record.class);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().delete(SOURCE_STORAGE_RECORDS_PATH + "/" + errorRecord.getId()).then().statusCode(HttpStatus.SC_NO_CONTENT);
async.complete();
async = testContext.async();
RestAssured.given().spec(spec).when().get(SOURCE_STORAGE_RECORDS_PATH + "/" + errorRecord.getId()).then().statusCode(HttpStatus.SC_OK).body("deleted", is(true));
async.complete();
}
use of org.folio.rest.jaxrs.model.ErrorRecord in project mod-source-record-storage by folio-org.
the class TestMocks method readRecord.
private static Optional<Record> readRecord(SourceRecord sourceRecord) {
File file = new File(format(RECORD_PATH_TEMPLATE, sourceRecord.getRecordId()));
if (file.exists()) {
try {
Record record = new ObjectMapper().readValue(file, Record.class).withRawRecord(sourceRecord.getRawRecord()).withParsedRecord(sourceRecord.getParsedRecord()).withExternalIdsHolder(sourceRecord.getExternalIdsHolder()).withAdditionalInfo(sourceRecord.getAdditionalInfo());
if (Objects.nonNull(sourceRecord.getMetadata())) {
record.withMetadata(sourceRecord.getMetadata());
}
Optional<ErrorRecord> errorRecord = errorRecords.stream().filter(er -> er.getId().equals(record.getId())).findAny();
if (errorRecord.isPresent()) {
record.withErrorRecord(errorRecord.get());
}
return Optional.of(record);
} catch (IOException e) {
e.printStackTrace();
}
}
return Optional.empty();
}
use of org.folio.rest.jaxrs.model.ErrorRecord in project mod-source-record-storage by folio-org.
the class RecordApiTest method shouldUpdateErrorRecordOnPut.
@Test
public void shouldUpdateErrorRecordOnPut(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();
createdRecord.setErrorRecord(errorRecord);
RestAssured.given().spec(spec).body(createdRecord).when().put(SOURCE_STORAGE_RECORDS_PATH + "/" + createdRecord.getId()).then().statusCode(HttpStatus.SC_OK).body("id", is(createdRecord.getId())).body("rawRecord.content", is(createdRecord.getRawRecord().getContent())).body("errorRecord.content", is(createdRecord.getErrorRecord().getContent())).body("additionalInfo.suppressDiscovery", is(false));
async.complete();
}
Aggregations