use of org.neo4j.graphdb.Relationship in project graphdb by neo4j-attic.
the class TestRelationship method countRelationships.
private void countRelationships(int expectedCount, Iterable<Relationship> rels) {
int count = 0;
for (Relationship r : rels) {
count++;
}
assertEquals(expectedCount, count);
}
use of org.neo4j.graphdb.Relationship in project graphdb by neo4j-attic.
the class TestRelationship method testRollbackDeleteRelationship.
@Test
public void testRollbackDeleteRelationship() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel1 = node1.createRelationshipTo(node2, MyRelTypes.TEST);
newTransaction();
node1.delete();
rel1.delete();
getTransaction().failure();
getTransaction().finish();
setTransaction(getGraphDb().beginTx());
node1.delete();
node2.delete();
rel1.delete();
}
use of org.neo4j.graphdb.Relationship in project graphdb by neo4j-attic.
the class TestRelationship method testSimple3.
@Test
public void testSimple3() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
for (int i = 0; i < 1; i++) {
node1.createRelationshipTo(node2, MyRelTypes.TEST);
node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
node1.createRelationshipTo(node2, MyRelTypes.TEST2);
}
allGetRelationshipMethods2(node1, Direction.OUTGOING);
allGetRelationshipMethods2(node2, Direction.INCOMING);
newTransaction();
allGetRelationshipMethods2(node1, Direction.OUTGOING);
allGetRelationshipMethods2(node2, Direction.INCOMING);
node1.getRelationships(MyRelTypes.TEST, Direction.OUTGOING).iterator().next().delete();
node1.getRelationships(MyRelTypes.TEST_TRAVERSAL, Direction.OUTGOING).iterator().next().delete();
node1.getRelationships(MyRelTypes.TEST2, Direction.OUTGOING).iterator().next().delete();
node1.createRelationshipTo(node2, MyRelTypes.TEST);
node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
node1.createRelationshipTo(node2, MyRelTypes.TEST2);
allGetRelationshipMethods2(node1, Direction.OUTGOING);
allGetRelationshipMethods2(node2, Direction.INCOMING);
newTransaction();
allGetRelationshipMethods2(node1, Direction.OUTGOING);
allGetRelationshipMethods2(node2, Direction.INCOMING);
for (Relationship rel : node1.getRelationships()) {
rel.delete();
}
node1.delete();
node2.delete();
}
use of org.neo4j.graphdb.Relationship in project graphdb by neo4j-attic.
the class TestRelationship method testRelationshipIsType.
@Test
public void testRelationshipIsType() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel = node1.createRelationshipTo(node2, MyRelTypes.TEST);
assertTrue(rel.isType(MyRelTypes.TEST));
assertTrue(rel.isType(new RelationshipType() {
public String name() {
return MyRelTypes.TEST.name();
}
}));
assertFalse(rel.isType(MyRelTypes.TEST_TRAVERSAL));
rel.delete();
node1.delete();
node2.delete();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class LegacyIndexTest method createRelationshipLegacyIndexWithSingleRelationship.
private static void createRelationshipLegacyIndexWithSingleRelationship(GraphDatabaseService db, String indexName) {
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.createNode().createRelationshipTo(db.createNode(), TYPE);
Index<Relationship> relationshipIndexIndex = db.index().forRelationships(indexName);
relationshipIndexIndex.add(relationship, "key", System.currentTimeMillis());
tx.success();
}
}
Aggregations