use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class TestNeo4jCacheAndPersistence method testNodeRemoveProperty.
@Test
public void testNodeRemoveProperty() {
Node node1 = getGraphDb().getNodeById(node1Id);
Node node2 = getGraphDb().getNodeById(node2Id);
Relationship rel = node1.getSingleRelationship(MyRelTypes.TEST, Direction.BOTH);
// test remove property
assertEquals(1, node1.removeProperty(key1));
assertEquals(2, node2.removeProperty(key1));
assertEquals(1, rel.removeProperty(key1));
assertEquals(string1, node1.removeProperty(key2));
assertEquals(string2, node2.removeProperty(key2));
assertEquals(string1, rel.removeProperty(key2));
assertTrue(node1.removeProperty(arrayKey) != null);
assertTrue(node2.removeProperty(arrayKey) != null);
assertTrue(rel.removeProperty(arrayKey) != null);
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class TestNeo4jCacheAndPersistence method testNodeChangeProperty.
@Test
public void testNodeChangeProperty() {
Node node1 = getGraphDb().getNodeById(node1Id);
Node node2 = getGraphDb().getNodeById(node2Id);
Relationship rel = node1.getSingleRelationship(MyRelTypes.TEST, Direction.BOTH);
// test change property
node1.setProperty(key1, int2);
node2.setProperty(key1, int1);
rel.setProperty(key1, int2);
int[] newIntArray = new int[] { 3, 2, 1 };
node1.setProperty(arrayKey, newIntArray);
node2.setProperty(arrayKey, newIntArray);
rel.setProperty(arrayKey, newIntArray);
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class TestNeo4jCacheAndPersistence method testAddCacheCleared.
@Test
public void testAddCacheCleared() {
Node nodeA = getGraphDb().createNode();
nodeA.setProperty("1", 1);
Node nodeB = getGraphDb().createNode();
Relationship rel = nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
rel.setProperty("1", 1);
commit();
newTransaction();
nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
int count = 0;
for (Relationship relToB : nodeA.getRelationships(MyRelTypes.TEST)) {
count++;
}
assertEquals(2, count);
nodeA.setProperty("2", 2);
assertEquals(1, nodeA.getProperty("1"));
rel.setProperty("2", 2);
assertEquals(1, rel.getProperty("1"));
// trigger empty load
getGraphDb().getNodeById(nodeA.getId());
getGraphDb().getRelationshipById(rel.getId());
// apply COW maps
commit();
newTransaction();
count = 0;
for (Relationship relToB : nodeA.getRelationships(MyRelTypes.TEST)) {
count++;
}
assertEquals(2, count);
assertEquals(1, nodeA.getProperty("1"));
assertEquals(1, rel.getProperty("1"));
assertEquals(2, nodeA.getProperty("2"));
assertEquals(2, rel.getProperty("2"));
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class TestNeo4jCacheAndPersistence method testSameTxWithArray.
@Test
public void testSameTxWithArray() {
commit();
newTransaction();
Node nodeA = getGraphDb().createNode();
Node nodeB = getGraphDb().createNode();
Relationship relA = nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
nodeA.setProperty(arrayKey, array);
relA.setProperty(arrayKey, array);
assertTrue(nodeA.getProperty(arrayKey) != null);
assertTrue(relA.getProperty(arrayKey) != null);
relA.delete();
nodeA.delete();
nodeB.delete();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class TestRelationship method testSimple2.
@Test
public void testSimple2() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
for (int i = 0; i < 3; i++) {
node1.createRelationshipTo(node2, MyRelTypes.TEST);
node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
node1.createRelationshipTo(node2, MyRelTypes.TEST2);
}
allGetRelationshipMethods(node1, Direction.OUTGOING);
allGetRelationshipMethods(node2, Direction.INCOMING);
newTransaction();
allGetRelationshipMethods(node1, Direction.OUTGOING);
allGetRelationshipMethods(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);
allGetRelationshipMethods(node1, Direction.OUTGOING);
allGetRelationshipMethods(node2, Direction.INCOMING);
newTransaction();
allGetRelationshipMethods(node1, Direction.OUTGOING);
allGetRelationshipMethods(node2, Direction.INCOMING);
for (Relationship rel : node1.getRelationships()) {
rel.delete();
}
node1.delete();
node2.delete();
}
Aggregations