use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class Neo4jConstraintsTest method testDeleteNodeWithRel3.
@Test
public void testDeleteNodeWithRel3() {
// make sure we can delete in wrong order
Node node0 = getGraphDb().createNode();
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel0 = node0.createRelationshipTo(node1, MyRelTypes.TEST);
Relationship rel1 = node0.createRelationshipTo(node2, MyRelTypes.TEST);
node1.delete();
rel0.delete();
Transaction tx = getTransaction();
tx.success();
tx.close();
setTransaction(getGraphDb().beginTx());
node2.delete();
rel1.delete();
node0.delete();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class Neo4jConstraintsTest method testAddPropertyDeletedRelationship.
@Test
public void testAddPropertyDeletedRelationship() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel = node1.createRelationshipTo(node2, MyRelTypes.TEST);
rel.delete();
try {
rel.setProperty(key, 1);
Transaction tx = getTransaction();
tx.success();
tx.close();
fail("Add property on deleted rel should not validate");
} catch (Exception e) {
// good
}
node1.delete();
node2.delete();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class Neo4jConstraintsTest method testChangePropertyDeletedRelationship.
@Test
public void testChangePropertyDeletedRelationship() {
Node node1 = getGraphDb().createNode();
Node node2 = getGraphDb().createNode();
Relationship rel = node1.createRelationshipTo(node2, MyRelTypes.TEST);
rel.setProperty(key, 1);
rel.delete();
try {
rel.setProperty(key, 2);
Transaction tx = getTransaction();
tx.success();
tx.close();
fail("Change property on deleted rel should not validate");
} catch (Exception e) {
// ok
}
node1.delete();
node2.delete();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class Neo4jConstraintsTest method testDeleteReferenceNodeOrLastNodeIsOk.
@Test
public void testDeleteReferenceNodeOrLastNodeIsOk() {
Transaction tx = getTransaction();
for (int i = 0; i < 10; i++) {
getGraphDb().createNode();
}
// empty the DB instance
for (Node node : getGraphDb().getAllNodes()) {
for (Relationship rel : node.getRelationships()) {
rel.delete();
}
node.delete();
}
tx.success();
tx.close();
tx = getGraphDb().beginTx();
assertFalse(getGraphDb().getAllNodes().iterator().hasNext());
// TODO: this should be valid, fails right now!
// assertEquals( 0, numNodesPost );
tx.success();
tx.close();
}
use of org.neo4j.graphdb.Relationship in project neo4j by neo4j.
the class RelationshipProxyTest method createDropRelationshipLongStringProperty.
@Test
public void createDropRelationshipLongStringProperty() {
Label markerLabel = DynamicLabel.label("marker");
String testPropertyKey = "testProperty";
String propertyValue = RandomStringUtils.randomAscii(255);
try (Transaction tx = db.beginTx()) {
Node start = db.createNode(markerLabel);
Node end = db.createNode(markerLabel);
Relationship relationship = start.createRelationshipTo(end, withName("type"));
relationship.setProperty(testPropertyKey, propertyValue);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
assertEquals(propertyValue, relationship.getProperty(testPropertyKey));
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
relationship.removeProperty(testPropertyKey);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
assertFalse(relationship.hasProperty(testPropertyKey));
tx.success();
}
}
Aggregations