private Node node(long id) throws NodeNotFoundException {
   try {
     return graphDb.getNodeById(id);
   } catch (NotFoundException e) {
     throw new NodeNotFoundException(e);
   }
 }
Example #2
0
 protected void assertNodeExists(long id) {
   try (Transaction ignore = db.beginTx()) {
     db.getNodeById(id);
   } catch (NotFoundException e) {
     fail("Node " + id + " should exist");
   }
 }
Example #3
0
 protected void assertNodeDoesntExist(long id) {
   try (Transaction ignore = db.beginTx()) {
     db.getNodeById(id);
     fail("Relationship " + id + " shouldn't exist");
   } catch (NotFoundException e) {
     // Good
   }
 }
 @Override
 public void run(GraphDatabaseAPI graphdb) {
   try (Transaction ignored = graphdb.beginTx()) {
     // TODO: Pass a node reference around of assuming the id will be deterministically assigned,
     // artifact of removing the reference node, upon which this test used to depend.
     assertTrue((Boolean) graphdb.getNodeById(3).getProperty("success"));
   }
 }
Example #5
0
 protected Node getCurrentNode() throws RemoteException, ShellException {
   Serializable current =
       shellServer.interpretVariable(shellClient.getId(), Variables.CURRENT_KEY);
   int nodeId = parseInt(current.toString().substring(1));
   try (Transaction tx = db.beginTx()) {
     Node nodeById = db.getNodeById(nodeId);
     tx.success();
     return nodeById;
   }
 }
Example #6
0
 private void updateNode(long nodeId, int value) {
   Transaction tx = db.beginTx();
   try {
     Node node = db.getNodeById(nodeId);
     node.setProperty(NUM_BANANAS_KEY, value);
     tx.success();
   } finally {
     tx.finish();
   }
 }