use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method get_Relationship_by_ID.
@Test
@Graph("I know you")
public void get_Relationship_by_ID() throws JsonParseException {
Node node = data.get().get("I");
Relationship relationship;
try (Transaction transaction = node.getGraphDatabase().beginTx()) {
relationship = node.getSingleRelationship(RelationshipType.withName("know"), Direction.OUTGOING);
}
String response = gen().expectedStatus(com.sun.jersey.api.client.ClientResponse.Status.OK.getStatusCode()).get(getRelationshipUri(relationship)).entity();
assertTrue(JsonHelper.jsonToMap(response).containsKey("start"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method get_single_property_on_a_relationship.
@Test
@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 get_single_property_on_a_relationship() throws Exception {
Relationship loves = getFirstRelationshipFromRomeoNode();
String response = gen().expectedStatus(ClientResponse.Status.OK).get(getRelPropURI(loves, "cost")).entity();
assertTrue(response.contains("high"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TestGraphDescription method ensurePeopleCanEatBananasAndApples.
@Test
@Graph({ "a:Person EATS b:Banana", "a EATS b:Apple" })
public void ensurePeopleCanEatBananasAndApples() throws Exception {
Map<String, Node> graph = data.get();
Node a = graph.get("a");
Node b = graph.get("b");
try (Transaction ignored = graphdb.beginTx()) {
assertTrue("Person label missing", a.hasLabel(label("Person")));
assertTrue("Banana label missing", b.hasLabel(label("Banana")));
assertTrue("Apple label missing", b.hasLabel(label("Apple")));
}
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TestGraphDescription method ensurePeopleCanEatBananas.
@Test
@Graph({ "a:Person EATS b:Banana" })
public void ensurePeopleCanEatBananas() throws Exception {
Map<String, Node> graph = data.get();
Node a = graph.get("a");
Node b = graph.get("b");
try (Transaction ignored = graphdb.beginTx()) {
assertTrue(a.hasLabel(label("Person")));
assertTrue(b.hasLabel(label("Banana")));
}
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TraverserIT method shouldGetExpectedHitsWhenTraversingAtDepth.
@Documented("Traversal returning nodes below a certain depth.\n" + "\n" + "Here, all nodes at a traversal depth below 3 are returned.")
@Graph({ "Root knows Mattias", "Root knows Johan", "Johan knows Emil", "Emil knows Peter", "Emil knows Tobias", "Tobias loves Sara" })
@Test
public void shouldGetExpectedHitsWhenTraversingAtDepth() throws JsonParseException {
Node start = getNode("Root");
String description = createJsonFrom(map("prune_evaluator", map("language", "builtin", "name", "none"), "return_filter", map("language", "javascript", "body", "position.length()<3;")));
String entity = gen().expectedStatus(200).payload(description).post(getTraverseUriNodes(start)).entity();
expectNodes(entity, getNodes("Root", "Mattias", "Johan", "Emil"));
}
Aggregations