use of org.neo4j.doc.server.rest.PrettyJSON in project neo4j-documentation by neo4j.
the class StreamingBatchOperationDocIT method shouldHandleUnicodeGetCorrectly.
@Test
@SuppressWarnings("unchecked")
public void shouldHandleUnicodeGetCorrectly() throws Exception {
String asianText = "\u4f8b\u5b50";
String germanText = "öäüÖÄÜß";
String complicatedString = asianText + germanText;
String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key(complicatedString).value(complicatedString).endObject().endObject().endArray().toString();
String entity = gen.get().expectedType(APPLICATION_JSON_TYPE).withHeader(StreamingFormat.STREAM_HEADER, "true").expectedStatus(200).payload(jsonString).post(batchUri()).entity();
// Pull out the property value from the depths of the response
Map<String, Object> response = (Map<String, Object>) JsonHelper.jsonToList(entity).get(0).get("body");
String returnedValue = (String) ((Map<String, Object>) response.get("data")).get(complicatedString);
// Ensure nothing was borked.
assertThat(returnedValue, is(complicatedString));
}
use of org.neo4j.doc.server.rest.PrettyJSON in project neo4j-documentation by neo4j.
the class StreamingBatchOperationDocIT method shouldHandleEscapedStrings.
@Test
@Graph("Peter likes Jazz")
public void shouldHandleEscapedStrings() throws ClientHandlerException, UniformInterfaceException, JSONException, JsonParseException {
String string = "Jazz";
Node gnode = getNode(string);
assertThat(gnode, inTx(graphdb(), Neo4jMatchers.hasProperty("name").withValue(string)));
String name = "string\\ and \"test\"";
String jsonString = new PrettyJSON().array().object().key("method").value("PUT").key("to").value("/node/" + gnode.getId() + "/properties").key("body").object().key("name").value(name).endObject().endObject().endArray().toString();
gen.get().expectedType(APPLICATION_JSON_TYPE).withHeader(StreamingFormat.STREAM_HEADER, "true").expectedStatus(200).payload(jsonString).post(batchUri()).entity();
jsonString = new PrettyJSON().array().object().key("method").value("GET").key("to").value("/node/" + gnode.getId() + "/properties/name").endObject().endArray().toString();
String entity = gen.get().expectedStatus(200).payload(jsonString).post(batchUri()).entity();
List<Map<String, Object>> results = JsonHelper.jsonToList(entity);
assertEquals(results.get(0).get("body"), name);
}
Aggregations