use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class RelationshipIT method shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipStreaming.
@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 shouldReturn404WhenPropertyWhichDoesNotExistRemovedFromRelationshipStreaming() {
data.get();
Relationship loves = getFirstRelationshipFromRomeoNode();
gen().withHeader(StreamingFormat.STREAM_HEADER, "true").expectedStatus(Status.NOT_FOUND.getStatusCode()).delete(getPropertiesUri(loves) + "/non-existent").entity();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class RelationshipIT method set_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 set_all_properties_on_a_relationship() throws Exception {
Relationship loves = getFirstRelationshipFromRomeoNode();
assertThat(loves, inTx(graphdb(), hasProperty("cost").withValue("high")));
gen().expectedStatus(ClientResponse.Status.NO_CONTENT).payload(JsonHelper.createJsonFrom(MapUtil.map("happy", false))).put(getRelPropsURI(loves)).entity();
assertThat(loves, inTx(graphdb(), hasProperty("happy").withValue(false)));
assertThat(loves, inTx(graphdb(), not(hasProperty("cost"))));
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class GraphDbHelper method setRelationshipProperties.
public void setRelationshipProperties(long relationshipId, Map<String, Object> properties) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AnonymousContext.writeToken())) {
Relationship relationship = database.getGraph().getRelationshipById(relationshipId);
for (Map.Entry<String, Object> propertyEntry : properties.entrySet()) {
relationship.setProperty(propertyEntry.getKey(), propertyEntry.getValue());
}
tx.success();
}
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class RelationshipExpanderBuilderTest method shouldInterpretNoSpecifiedRelationshipsAsAll.
@Test
public void shouldInterpretNoSpecifiedRelationshipsAsAll() throws Exception {
// GIVEN
Node node = createSomeData();
PathExpander expander = RelationshipExpanderBuilder.describeRelationships(map());
// WHEN
Set<Relationship> expanded;
try (Transaction tx = db.beginTx()) {
expanded = asSet(expander.expand(singleNodePath(node), NO_STATE));
tx.success();
}
try (Transaction tx = db.beginTx()) {
// THEN
assertEquals(asSet(node.getRelationships()), expanded);
tx.success();
}
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class GraphDbHelper method getRelationship.
public Relationship getRelationship(long relationshipId) {
try (Transaction tx = database.getGraph().beginTransaction(implicit, AnonymousContext.read())) {
Relationship relationship = database.getGraph().getRelationshipById(relationshipId);
tx.success();
return relationship;
}
}
Aggregations