use of org.neo4j.server.rest.PrettyJSON in project neo4j by neo4j.
the class StreamingBatchOperationIT 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);
}
use of org.neo4j.server.rest.PrettyJSON in project neo4j by neo4j.
the class StreamingBatchOperationIT method shouldGetLocationHeadersWhenCreatingThings.
@Test
public void shouldGetLocationHeadersWhenCreatingThings() throws Exception {
long originalNodeCount = countNodes();
final String jsonString = new PrettyJSON().array().object().key("method").value("POST").key("to").value("/node").key("body").object().key("age").value(1).endObject().endObject().endArray().toString();
JaxRsResponse response = RestRequest.req().accept(APPLICATION_JSON_TYPE).header(StreamingFormat.STREAM_HEADER, "true").post(batchUri(), jsonString);
assertEquals(200, response.getStatus());
final String entity = response.getEntity();
List<Map<String, Object>> results = JsonHelper.jsonToList(entity);
assertEquals(originalNodeCount + 1, countNodes());
assertEquals(1, results.size());
Map<String, Object> result = results.get(0);
assertTrue(((String) result.get("location")).length() > 0);
}
Aggregations