use of org.neo4j.test.GraphDescription.Graph in project neo4j-documentation by neo4j.
the class DepthTwoDocIT method shouldReturnAllNodesAtDepthTwoOnPost.
@Documented("Get nodes at depth two.")
@Test
@Graph({ "I know you", "you know him" })
public void shouldReturnAllNodesAtDepthTwoOnPost() throws JsonParseException {
Node node = data.get().get("I");
String uri = (String) getNodeLevelPluginMetadata(DepthTwo.class, node.getId()).get(NODES_ON_DEPTH_TWO);
String result = performPost(uri);
List<Map<String, Object>> list = JsonHelper.jsonToList(result);
assertThat(list, notNullValue());
assertThat(list.size(), equalTo(1));
Map<String, Object> map = list.get(0);
assertThat(map.get("data").toString(), containsString("him"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j-documentation by neo4j.
the class DepthTwoDocIT method shouldReturnAllRelationshipsAtDepthTwoOnPost.
@Documented("Get relationships at depth two.")
@Test
@Graph({ "I know you", "you know him" })
public void shouldReturnAllRelationshipsAtDepthTwoOnPost() throws JsonParseException {
Node node = data.get().get("I");
String uri = (String) getNodeLevelPluginMetadata(DepthTwo.class, node.getId()).get(RELATIONSHIPS_ON_DEPTH_TWO);
String result = performPost(uri);
List<Map<String, Object>> list = JsonHelper.jsonToList(result);
assertThat(list, notNullValue());
assertThat(list.size(), equalTo(1));
Map<String, Object> map = list.get(0);
assertThat(map.get("type").toString(), containsString("know"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j-documentation by neo4j.
the class RelationshipDocIT 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-documentation by neo4j.
the class RelationshipDocIT method shouldReturn204WhenPropertiesAreRemovedFromRelationship.
@Test
@Title("Remove properties from a relationship")
@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 shouldReturn204WhenPropertiesAreRemovedFromRelationship() {
Relationship loves = getFirstRelationshipFromRomeoNode();
gen().description(startGraph("remove properties from a relationship")).expectedStatus(Status.NO_CONTENT.getStatusCode()).delete(functionalTestHelper.relationshipPropertiesUri(loves.getId())).entity();
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TestGraphDescription method canCreateGraphFromMultipleStrings.
@Test
@Graph({ "a TO b", "b TO c", "c TO a" })
public void canCreateGraphFromMultipleStrings() {
Map<String, Node> graph = data.get();
Set<Node> unique = new HashSet<>();
Node n = graph.get("a");
while (unique.add(n)) {
try (Transaction tx = graphdb.beginTx()) {
n = tx.getNodeById(n.getId()).getSingleRelationship(RelationshipType.withName("TO"), Direction.OUTGOING).getEndNode();
}
}
assertEquals(graph.size(), unique.size());
}
Aggregations