method.setRequestEntity(new StringRequestEntity(content, "application/json", "UTF-8"));
client.executeMethod(method);
Gson gson = new Gson();
QueryResult result = gson.fromJson(method.getResponseBodyAsString(),
new TypeToken<QueryResult>() {
}.getType());
System.out.println("results: " + result);
Assert.assertEquals(2, result.getData().size());
for (List<ResponseNode> data : result.getData()) {
Map<String, String> props = data.get(0).getData();
for (String key : props.keySet()) {
System.out.println("Property ("+key+"): "+props.get(key));
}
}
client = new HttpClient();
method = new PostMethod("http://localhost:7575/db/data/ext/CypherPlugin/graphdb/execute_query");
method.setRequestHeader("Content-type", "application/json");
method.setRequestHeader("Accept", "application/json");
content = "{\"query\": \"start v=(vehicles, 'vehicleId:" + vehicle.getId() + "') match (v) <-[USE]- (w) return w\"}";
method.setRequestEntity(new StringRequestEntity(content, "application/json", "UTF-8"));
client.executeMethod(method);
gson = new Gson();
result = gson.fromJson(method.getResponseBodyAsString(),
new TypeToken<QueryResult>() {
}.getType());
System.out.println("results: " + result);
Assert.assertEquals(1, result.getData().size());
for (List<ResponseNode> data : result.getData()) {
Map<String, String> props = data.get(0).getData();
for (String key : props.keySet()) {
System.out.println("Property ("+key+"): "+props.get(key));
}
}