use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class AutoIndexOperationsTest method shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode.
@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() {
RelationshipType type = MyRelTypes.TEST;
long startId;
long endId;
Relationship rel;
try (Transaction tx = db.beginTx()) {
Node start = db.createNode();
Node end = db.createNode();
startId = start.getId();
endId = end.getId();
rel = start.createRelationshipTo(end, type);
rel.setProperty("Type", type.name());
tx.success();
}
try (Transaction tx = db.beginTx()) {
ReadableRelationshipIndex autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
Node start = db.getNodeById(startId);
Node end = db.getNodeById(endId);
IndexHits<Relationship> hits = autoRelationshipIndex.get("Type", type.name(), start, end);
assertEquals(1, count(hits));
assertEquals(1, hits.size());
rel.delete();
autoRelationshipIndex = db.index().getRelationshipAutoIndexer().getAutoIndex();
hits = autoRelationshipIndex.get("Type", type.name(), start, end);
assertEquals(0, count(hits));
assertEquals(0, hits.size());
tx.success();
}
}
use of org.neo4j.graphdb.Relationship 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.graphdb.Relationship 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.graphdb.Relationship 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.graphdb.Relationship 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