use of org.neo4j.graphdb.NotFoundException in project graphdb by neo4j-attic.
the class TestNode method testNodeCreateAndDelete.
@Test
public void testNodeCreateAndDelete() {
long nodeId = -1;
Node node = getGraphDb().createNode();
nodeId = node.getId();
getGraphDb().getNodeById(nodeId);
node.delete();
Transaction tx = getTransaction();
tx.success();
tx.finish();
setTransaction(getGraphDb().beginTx());
try {
getGraphDb().getNodeById(nodeId);
fail("Node[" + nodeId + "] should be deleted.");
} catch (NotFoundException e) {
}
}
use of org.neo4j.graphdb.NotFoundException in project graphdb by neo4j-attic.
the class TestNeo4jConstrains 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.finish();
tx = getGraphDb().beginTx();
// the DB should be empty
// long numNodesPost = getNodeManager().getNumberOfIdsInUse( Node.class
// );
// System.out.println(String.format( "pre: %d, post: %d", numNodesPre,
// numNodesPost ));
assertFalse(getGraphDb().getAllNodes().iterator().hasNext());
// assertEquals( 0, numNodesPost );
try {
getGraphDb().getReferenceNode();
fail();
} catch (NotFoundException nfe) {
// should be thrown
}
tx.success();
tx.finish();
}
use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class BatchGraphDatabaseImpl method getNodeById.
public Node getNodeById(long id) {
NodeBatchImpl node = nodes.get(id);
if (node == null) {
try {
node = new NodeBatchImpl(id, this, batchInserter.getNodeProperties(id));
nodes.put(id, node);
} catch (InvalidRecordException e) {
throw new NotFoundException(e);
}
}
return node;
}
use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class NodeImpl method getSingleRelationship.
public Relationship getSingleRelationship(NodeManager nodeManager, RelationshipType type, Direction dir) {
DirectionWrapper direction = RelIdArray.wrap(dir);
RelationshipType[] types = new RelationshipType[] { type };
Iterator<Relationship> rels = new IntArrayIterator(getAllRelationshipsOfType(nodeManager, direction, types), this, direction, nodeManager, types, !hasMoreRelationshipsToLoad());
if (!rels.hasNext()) {
return null;
}
Relationship rel = rels.next();
if (rels.hasNext()) {
throw new NotFoundException("More than one relationship[" + type + ", " + dir + "] found for " + this);
}
return rel;
}
use of org.neo4j.graphdb.NotFoundException in project neo4j-mobile-android by neo4j-contrib.
the class BatchGraphDatabaseImpl method getRelationshipById.
public Relationship getRelationshipById(long id) {
RelationshipBatchImpl rel = rels.get(id);
if (rel == null) {
try {
SimpleRelationship simpleRel = batchInserter.getRelationshipById(id);
Map<String, Object> props = batchInserter.getRelationshipProperties(id);
rel = new RelationshipBatchImpl(simpleRel, this, props);
rels.put(id, rel);
} catch (InvalidRecordException e) {
throw new NotFoundException(e);
}
}
return rel;
}
Aggregations