use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method testProfiling.
@Test
@Title("Profile a query")
@Documented("By passing in an extra parameter, you can ask the cypher executor to return a profile of the " + "query as it is executed. This can help in locating bottlenecks.")
@Graph(nodes = { @NODE(name = "I", setNameProperty = true), @NODE(name = "you", setNameProperty = true), @NODE(name = "him", setNameProperty = true, properties = { @PROP(key = "age", value = "25", type = GraphDescription.PropType.INTEGER) }) }, relationships = { @REL(start = "I", end = "him", type = "know", properties = {}), @REL(start = "I", end = "you", type = "know", properties = {}) })
public void testProfiling() throws Exception {
String script = createScript("MATCH (x)-[r]->(n) WHERE id(x) = %I% RETURN type(r), n.name, n.age");
// WHEN
String response = doCypherRestCall(cypherUri() + "?profile=true", script, Status.OK);
// THEN
Map<String, Object> des = jsonToMap(response);
assertThat(des.get("plan"), instanceOf(Map.class));
@SuppressWarnings("unchecked") Map<String, Object> plan = (Map<String, Object>) des.get("plan");
assertThat(plan.get("name"), instanceOf(String.class));
assertThat(plan.get("children"), instanceOf(Collection.class));
assertThat(plan.get("rows"), instanceOf(Number.class));
assertThat(plan.get("dbHits"), instanceOf(Number.class));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method error_gets_returned_as_json.
@Test
@Title("Errors")
@Documented("Errors on the server will be reported as a JSON-formatted message, exception name and stacktrace.")
@Graph("I know you")
public void error_gets_returned_as_json() throws Exception {
String response = cypherRestCall("MATCH (x {name: 'I'}) RETURN x.dummy/0", Status.BAD_REQUEST);
Map<String, Object> output = jsonToMap(response);
assertTrue(output.toString(), output.containsKey("message"));
assertTrue(output.containsKey("exception"));
assertTrue(output.containsKey("stackTrace"));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method testPropertyColumn.
@Test
@Title("Send a query")
@Documented("A simple query returning all nodes connected to some node, returning the node and the name " + "property, if it exists, otherwise `NULL`:")
@Graph(nodes = { @NODE(name = "I", setNameProperty = true), @NODE(name = "you", setNameProperty = true), @NODE(name = "him", setNameProperty = true, properties = { @PROP(key = "age", value = "25", type = GraphDescription.PropType.INTEGER) }) }, relationships = { @REL(start = "I", end = "him", type = "know", properties = {}), @REL(start = "I", end = "you", type = "know", properties = {}) })
public void testPropertyColumn() throws UnsupportedEncodingException {
String script = createScript("MATCH (x {name: 'I'})-[r]->(n) RETURN type(r), n.name, n.age");
String response = cypherRestCall(script, Status.OK);
assertThat(response, containsString("you"));
assertThat(response, containsString("him"));
assertThat(response, containsString("25"));
assertThat(response, not(containsString("\"x\"")));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method send_queries_with_syntax_errors.
@Test
@Title("Syntax errors")
@Documented("Sending a query with syntax errors will give a bad request (HTTP 400) response together with " + "an error message.")
@Graph(value = { "I know you" }, autoIndexNodes = true)
public void send_queries_with_syntax_errors() throws Exception {
data.get();
String script = "START x = node:node_auto_index(name={startName}) MATC path = (x-[r]-friend) WHERE friend" + ".name = {name} RETURN TYPE(r)";
String response = cypherRestCall(script, Status.BAD_REQUEST, Pair.of("startName", "I"), Pair.of("name", "you"));
Map<String, Object> output = jsonToMap(response);
assertTrue(output.containsKey("message"));
assertTrue(output.containsKey("stackTrace"));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method return_paths.
@Test
@Title("Return paths")
@Documented("Paths can be returned just like other return types.")
@Graph("I know you")
public void return_paths() throws Exception {
String script = "MATCH path = (x {name: 'I'})--(friend) RETURN path, friend.name";
String response = cypherRestCall(script, Status.OK);
assertEquals(2, (jsonToMap(response)).size());
assertThat(response, containsString("data"));
assertThat(response, containsString("you"));
}
Aggregations