use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class TraverserIT method shouldGetExpectedHitsWhenTraversingWithDescription.
@Documented("Traversal using a return filter.\n" + "\n" + "In this example, the +none+ prune evaluator is used and a return filter\n" + "is supplied in order to return all names containing \"t\".\n" + "The result is to be returned as nodes and the max depth is\n" + "set to 3.")
@Graph({ "Root knows Mattias", "Root knows Johan", "Johan knows Emil", "Emil knows Peter", "Emil knows Tobias", "Tobias loves Sara" })
@Test
public void shouldGetExpectedHitsWhenTraversingWithDescription() throws JsonParseException {
Node start = getNode("Root");
List<Map<String, Object>> rels = new ArrayList<>();
rels.add(map("type", "knows", "direction", "all"));
rels.add(map("type", "loves", "direction", "all"));
String description = createJsonFrom(map("order", "breadth_first", "uniqueness", "node_global", "prune_evaluator", map("language", "javascript", "body", "position.length() > 10"), "return_filter", map("language", "javascript", "body", "position.endNode().getProperty('name').toLowerCase().contains('t')"), "relationships", rels, "max_depth", 3));
String entity = gen().expectedStatus(200).payload(description).post(getTraverseUriNodes(start)).entity();
expectNodes(entity, getNodes("Root", "Mattias", "Peter", "Tobias"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method get_all_properties_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), @PROP(key = "since", value = "1day", type = GraphDescription.PropType.STRING) }) })
public void get_all_properties_on_a_relationship() throws Exception {
Relationship loves = getFirstRelationshipFromRomeoNode();
String response = gen().expectedStatus(ClientResponse.Status.OK).get(getRelPropsURI(loves)).entity();
assertTrue(response.contains("high"));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method set_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 set_single_property_on_a_relationship() throws Exception {
Relationship loves = getFirstRelationshipFromRomeoNode();
assertThat(loves, inTx(graphdb(), hasProperty("cost").withValue("high")));
gen().expectedStatus(ClientResponse.Status.NO_CONTENT).payload("\"deadly\"").put(getRelPropURI(loves, "cost")).entity();
assertThat(loves, inTx(graphdb(), hasProperty("cost").withValue("deadly")));
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT method shouldReturn204WhenPropertyIsRemovedFromRelationship.
@Test
@Title("Remove property from a relationship")
@Documented("See the example request below.")
@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 shouldReturn204WhenPropertyIsRemovedFromRelationship() {
data.get();
Relationship loves = getFirstRelationshipFromRomeoNode();
gen().expectedStatus(Status.NO_CONTENT.getStatusCode()).delete(getPropertiesUri(loves) + "/cost").entity();
}
use of org.neo4j.test.GraphDescription.Graph in project neo4j by neo4j.
the class RelationshipIT 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().expectedStatus(Status.NO_CONTENT.getStatusCode()).delete(functionalTestHelper.relationshipPropertiesUri(loves.getId())).entity();
}
Aggregations