use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method send_queries_with_parameters.
@Test
@Title("Use parameters")
@Documented("Cypher supports queries with parameters which are submitted as JSON.")
@Graph(value = { "I know you" }, autoIndexNodes = true)
public void send_queries_with_parameters() throws Exception {
data.get();
String script = "MATCH (x {name: {startName}})-[r]-(friend) WHERE friend" + ".name = {name} RETURN TYPE(r)";
String response = cypherRestCall(script, Status.OK, Pair.of("startName", "I"), Pair.of("name", "you"));
assertEquals(2, (jsonToMap(response)).size());
assertTrue(response.contains("know"));
assertTrue(response.contains("data"));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method setAllPropertiesUsingMap.
@Test
@Title("Set all properties on a node using Cypher")
@Documented("Set all properties on a node.")
@Graph
public void setAllPropertiesUsingMap() throws Exception {
data.get();
String script = "CREATE (n:Person { name: 'this property is to be deleted' } ) SET n = { props } RETURN n";
String params = "\"props\" : { \"position\" : \"Developer\", \"firstName\" : \"Michael\", \"awesome\" : true, \"children\" : 3 }";
String response = cypherRestCall(script, Status.OK, params);
assertTrue(response.contains("firstName"));
assertTrue(response.contains("Michael"));
assertTrue(!response.contains("name"));
assertTrue(!response.contains("deleted"));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CreateRelationshipTest method create_relationship.
@Test
@Documented("Upon successful creation of a relationship, the new relationship is returned.")
@Title("Create relationship")
@Graph("Joe knows Sara")
public void create_relationship() throws Exception {
String jsonString = "{\"to\" : \"" + getDataUri() + "node/" + getNode("Sara").getId() + "\", \"type\" : \"LOVES\"}";
Node i = getNode("Joe");
String entity = gen.get().expectedStatus(Status.CREATED.getStatusCode()).payload(jsonString).post(getNodeUri(i) + "/relationships").entity();
try (Transaction tx = graphdb().beginTx()) {
assertTrue(i.hasRelationship(RelationshipType.withName("LOVES")));
}
assertProperRelationshipRepresentation(JsonHelper.jsonToMap(entity));
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CreateRelationshipTest method create_a_relationship_with_properties.
@Test
@Graph("Joe knows Sara")
@Documented("Upon successful creation of a relationship, the new relationship is returned.")
@Title("Create a relationship with properties")
public void create_a_relationship_with_properties() throws Exception {
String jsonString = "{\"to\" : \"" + getDataUri() + "node/" + getNode("Sara").getId() + "\", \"type\" : \"LOVES\", \"data\" : {\"foo\" : \"bar\"}}";
Node i = getNode("Joe");
gen.get().expectedStatus(Status.CREATED.getStatusCode()).payload(jsonString).post(getNodeUri(i) + "/relationships");
try (Transaction tx = graphdb().beginTx()) {
assertTrue(i.hasRelationship(RelationshipType.withName("LOVES")));
}
}
use of org.neo4j.test.TestData.Title in project neo4j by neo4j.
the class CypherIT method send_queries_with_errors.
@Test
@Title("Send queries with errors")
@Documented("This example shows what happens if you misspell an identifier.")
@Graph(value = { "I know you" }, autoIndexNodes = true)
public void send_queries_with_errors() throws Exception {
data.get();
String script = "START x = node:node_auto_index(name={startName}) MATCH path = (x)-[r]-(friend) WHERE frien" + ".name = {name} RETURN type(r)";
String response = cypherRestCall(script, Status.BAD_REQUEST, Pair.of("startName", "I"), Pair.of("name", "you"));
Map<String, Object> responseMap = jsonToMap(response);
assertThat(responseMap.keySet(), containsInAnyOrder("message", "exception", "fullname", "stackTrace", "cause", "errors"));
assertThat(response, containsString("message"));
assertThat((String) responseMap.get("message"), containsString("Variable `frien` not defined"));
}
Aggregations