Search in sources :

Example 66 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class CypherIT method testDataColumnOrder.

/**
     * Ensure that order of data and column is ok.
     */
@Test
@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 testDataColumnOrder() throws UnsupportedEncodingException {
    String script = createScript("MATCH (x)-[r]->(n) WHERE id(x) = %I% RETURN type(r), n.name, n.age");
    String response = cypherRestCall(script, Status.OK);
    assertThat(response.indexOf("columns") < response.indexOf("data"), is(true));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Test(org.junit.Test)

Example 67 with Graph

use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.

the class CypherIT method send_query_to_create_a_node.

@Test
@Documented("Create a node with a label and a property using Cypher. See the request for the parameter " + "sent with the query.")
@Title("Create a node")
@Graph
public void send_query_to_create_a_node() throws Exception {
    data.get();
    String script = "CREATE (n:Person { name : {name} }) RETURN n";
    String response = cypherRestCall(script, Status.OK, Pair.of("name", "Andres"));
    assertTrue(response.contains("name"));
    assertTrue(response.contains("Andres"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 68 with Graph

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\"]")));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Test(org.junit.Test)

Example 69 with Graph

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"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Example 70 with Graph

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();
}
Also used : Relationship(org.neo4j.graphdb.Relationship) Graph(org.neo4j.test.GraphDescription.Graph) Documented(org.neo4j.kernel.impl.annotations.Documented) Test(org.junit.Test) Title(org.neo4j.test.TestData.Title)

Aggregations

Graph (org.neo4j.test.GraphDescription.Graph)96 Test (org.junit.Test)92 Documented (org.neo4j.kernel.impl.annotations.Documented)48 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)37 Title (org.neo4j.test.TestData.Title)36 Node (org.neo4j.graphdb.Node)35 Relationship (org.neo4j.graphdb.Relationship)21 Transaction (org.neo4j.graphdb.Transaction)21 Map (java.util.Map)19 ArrayList (java.util.ArrayList)5 Matchers.containsString (org.hamcrest.Matchers.containsString)4 JsonHelper.jsonToMap (org.neo4j.server.rest.domain.JsonHelper.jsonToMap)4 HashSet (java.util.HashSet)3 Test (org.junit.jupiter.api.Test)3 RelationshipRepresentationTest (org.neo4j.server.rest.repr.RelationshipRepresentationTest)3 Collection (java.util.Collection)2 List (java.util.List)2 JsonNode (org.codehaus.jackson.JsonNode)2 PrettyJSON (org.neo4j.doc.server.rest.PrettyJSON)2 PrettyJSON (org.neo4j.server.rest.PrettyJSON)2