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 AncestorTestCase method test.
@Test
@Graph({ "root contains child1", "child1 contains child11", "child1 contains child12", "root contains child2", "child12 contains child121", "child1 contains child13" })
public void test() {
PathExpander expander = PathExpanders.forTypeAndDirection(Rels.contains, Direction.INCOMING);
List<Node> nodeSet = new ArrayList<Node>();
Map<String, Node> graph = data.get();
nodeSet.add(graph.get("child1"));
nodeSet.add(graph.get("root"));
try (Transaction transaction = gdb.beginTx()) {
Node ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("root"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("child11"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("child1"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child121"));
nodeSet.add(graph.get("child12"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("child12"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child11"));
nodeSet.add(graph.get("child13"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("child1"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child2"));
nodeSet.add(graph.get("child121"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("root"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child11"));
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("child13"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("child1"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child11"));
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("child13"));
nodeSet.add(graph.get("child121"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("child1"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child11"));
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("child13"));
nodeSet.add(graph.get("child121"));
nodeSet.add(graph.get("child2"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("root"), ancestor);
nodeSet.clear();
nodeSet.add(graph.get("child11"));
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("child13"));
nodeSet.add(graph.get("child121"));
nodeSet.add(graph.get("child12"));
nodeSet.add(graph.get("root"));
ancestor = AncestorsUtil.lowestCommonAncestor(nodeSet, expander);
assertEquals(graph.get("root"), ancestor);
}
}
Aggregations