use of org.folio.rest.jaxrs.model.AdditionalInfo in project mod-source-record-storage by folio-org.
the class SourceStorageBatchApiTest method shouldUpdateParsedRecordsWithJsonContent.
@Test
public void shouldUpdateParsedRecordsWithJsonContent(TestContext testContext) {
postSnapshots(testContext, snapshot_2);
Record newRecord = new Record().withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(UUID.randomUUID().toString()).withAdditionalInfo(new AdditionalInfo().withSuppressDiscovery(false));
Async async = testContext.async();
Response createResponse = RestAssured.given().spec(spec).body(newRecord).when().post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Record createdRecord = createResponse.body().as(Record.class);
async.complete();
ParsedRecord parsedRecordJson = new ParsedRecord().withId(createdRecord.getParsedRecord().getId()).withContent(new JsonObject().put("leader", "01542ccm a2200361 4500").put("fields", new JsonArray()));
RecordCollection recordCollection = new RecordCollection().withRecords(Collections.singletonList(createdRecord.withParsedRecord(parsedRecordJson))).withTotalRecords(1);
async = testContext.async();
ParsedRecordsBatchResponse updatedParsedRecordCollection = RestAssured.given().spec(spec).body(recordCollection).when().put(SOURCE_STORAGE_BATCH_PARSED_RECORDS_PATH).then().statusCode(HttpStatus.SC_OK).extract().response().body().as(ParsedRecordsBatchResponse.class);
ParsedRecord updatedParsedRecord = updatedParsedRecordCollection.getParsedRecords().get(0);
assertThat(updatedParsedRecord.getId(), notNullValue());
assertThat(JsonObject.mapFrom(updatedParsedRecord).encode(), containsString("\"leader\":\"01542ccm a2200361 4500\""));
async.complete();
}
use of org.folio.rest.jaxrs.model.AdditionalInfo in project mod-source-record-storage by folio-org.
the class SourceStorageBatchApiTest method shouldUpdateParsedRecords.
@Test
public void shouldUpdateParsedRecords(TestContext testContext) {
postSnapshots(testContext, snapshot_2);
String matchedId = UUID.randomUUID().toString();
Record newRecord = new Record().withId(matchedId).withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(matchedId).withState(Record.State.ACTUAL).withAdditionalInfo(new AdditionalInfo().withSuppressDiscovery(false));
Async async = testContext.async();
Response createResponse = RestAssured.given().spec(spec).body(newRecord).when().post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Record createdRecord = createResponse.body().as(Record.class);
async.complete();
RecordCollection recordCollection = new RecordCollection().withRecords(Collections.singletonList(createdRecord)).withTotalRecords(1);
async = testContext.async();
ParsedRecordsBatchResponse updatedParsedRecordCollection = RestAssured.given().spec(spec).body(recordCollection).when().put(SOURCE_STORAGE_BATCH_PARSED_RECORDS_PATH).then().statusCode(HttpStatus.SC_OK).extract().response().body().as(ParsedRecordsBatchResponse.class);
ParsedRecord updatedParsedRecord = updatedParsedRecordCollection.getParsedRecords().get(0);
assertThat(updatedParsedRecord.getId(), notNullValue());
assertThat(JsonObject.mapFrom(updatedParsedRecord).encode(), containsString("\"leader\":\"01542ccm a2200361 4500\""));
async.complete();
RestAssured.given().spec(spec).body(recordCollection).when().get(SOURCE_STORAGE_RECORDS_PATH + "/" + createdRecord.getId()).then().statusCode(HttpStatus.SC_OK).body("metadata", notNullValue()).body("metadata.createdDate", notNullValue(String.class)).body("metadata.createdByUserId", notNullValue(String.class)).body("metadata.updatedDate", notNullValue(String.class)).body("metadata.updatedByUserId", notNullValue(String.class));
}
Aggregations