use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class CypherIT method array_property.
@Test
@Graph(value = { "I know you" }, autoIndexNodes = false)
public void array_property() throws Exception {
setProperty("I", "array1", new int[] { 1, 2, 3 });
setProperty("I", "array2", new String[] { "a", "b", "c" });
String script = "MATCH (n) WHERE id(n) = %I% RETURN n.array1, n.array2";
String response = cypherRestCall(script, Status.OK);
assertThat(response, anyOf(containsString("[ 1, 2, 3 ]"), containsString("[1,2,3]")));
assertThat(response, anyOf(containsString("[ \"a\", \"b\", \"c\" ]"), containsString("[\"a\",\"b\",\"c\"]")));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class CypherIT method send_query_to_create_a_node_from_a_map.
@Test
@Title("Create a node with multiple properties")
@Documented("Create a node with a label and multiple properties using Cypher. See the request for the parameter " + "sent with the query.")
@Graph
public void send_query_to_create_a_node_from_a_map() throws Exception {
data.get();
String script = "CREATE (n:Person { props } ) RETURN n";
String params = "\"props\" : { \"position\" : \"Developer\", \"name\" : \"Michael\", \"awesome\" : true, \"children\" : 3 }";
String response = cypherRestCall(script, Status.OK, params);
assertTrue(response.contains("name"));
assertTrue(response.contains("Michael"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationship.
@Test
@Title("Remove non-existent property from a relationship")
@Documented("Attempting to remove a property that doesn't exist results in an error.")
@Graph(nodes = { @NODE(name = "Romeo", setNameProperty = true), @NODE(name = "Juliet", setNameProperty = true) }, relationships = { @REL(start = "Romeo", end = "Juliet", type = "LOVES", properties = { @PROP(key = "cost", value = "high", type = GraphDescription.PropType.STRING) }) })
public void shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationship() {
data.get();
Relationship loves = getFirstRelationshipFromRomeoNode();
gen().expectedStatus(Status.NOT_FOUND.getStatusCode()).delete(getPropertiesUri(loves) + "/non-existent").entity();
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TraverserIT method shouldAllowTypeOrderedTraversals.
@Test
@Graph({ "Root knows Mattias", "Root knows Johan", "Johan knows Emil", "Emil knows Peter", "Root eats Cork", "Cork hates Root", "Root likes Banana", "Banana is_a Fruit" })
public void shouldAllowTypeOrderedTraversals() throws JsonParseException {
Node start = getNode("Root");
String description = createJsonFrom(map("expander", "order_by_type", "relationships", new Map[] { map("type", "eats"), map("type", "knows"), map("type", "likes") }, "prune_evaluator", map("language", "builtin", "name", "none"), "return_filter", map("language", "javascript", "body", "position.length()<2;")));
@SuppressWarnings("unchecked") List<Map<String, Object>> nodes = (List<Map<String, Object>>) readJson(gen().expectedStatus(200).payload(description).post(getTraverseUriNodes(start)).entity());
assertThat(nodes.size(), is(5));
assertThat(getName(nodes.get(0)), is("Root"));
assertThat(getName(nodes.get(1)), is("Cork"));
// We don't really care about the ordering between Johan and Mattias, we just assert that they
// both are there, in between Root/Cork and Banana
Set<String> knowsNodes = new HashSet<>(Arrays.asList("Johan", "Mattias"));
assertTrue(knowsNodes.remove(getName(nodes.get(2))));
assertTrue(knowsNodes.remove(getName(nodes.get(3))));
assertThat(getName(nodes.get(4)), is("Banana"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class SetNodePropertiesIT method set_node_properties_in_Unicode.
@Graph("jim knows joe")
@Test
public void set_node_properties_in_Unicode() throws JsonParseException {
Node jim = data.get().get("jim");
gen.get().payload(JsonHelper.createJsonFrom(MapUtil.map("name", "例子"))).expectedStatus(204).put(getPropertiesUri(jim));
assertThat(jim, inTx(graphdb(), hasProperty("name").withValue("例子")));
}
Aggregations