private Node addNode(EmbeddedGraphDatabase graphDb) {
   Node referenceNode = graphDb.getReferenceNode();
   Node node = graphDb.createNode();
   node.setProperty("theId", node.getId());
   referenceNode.createRelationshipTo(node, MyRels.TEST);
   return node;
 }
  public void generate(String dbPath) {
    EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(dbPath);
    Index<Node> nodeIndex = graphDb.index().forNodes("nodes");
    Index<Relationship> relationshipIndex = graphDb.index().forRelationships("relationships");
    graphDb.beginTx();
    Node n = graphDb.createNode();
    Relationship rel = graphDb.getReferenceNode().createRelationshipTo(n, REL_TYPE);

    nodeIndex.add(n, "name", "a");
    relationshipIndex.add(rel, "name", "a");
  }
 public static void main(String[] args) {
   String storeDir = args[0];
   boolean setGraphProperty = args.length > 1 ? Boolean.parseBoolean(args[1]) : false;
   EmbeddedGraphDatabase db = new EmbeddedGraphDatabase(storeDir);
   Transaction tx = db.beginTx();
   Node node = db.createNode();
   node.setProperty("name", "Something");
   if (setGraphProperty)
     db.getNodeManager().getGraphProperties().setProperty("prop", "Some value");
   tx.success();
   tx.finish();
   System.exit(0);
 }
 public Node createNode() {
   return inner.createNode();
 }
  @Test
  public void testLowGrabSize() {
    Map<String, String> config = new HashMap<String, String>();
    config.put("relationship_grab_size", "1");
    EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(getStorePath("neo2"), config);
    Transaction tx = graphDb.beginTx();
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.createRelationshipTo(node2, MyRelTypes.TEST);
    node2.createRelationshipTo(node1, MyRelTypes.TEST2);
    node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
    tx.success();
    tx.finish();
    tx = graphDb.beginTx();
    Set<Relationship> rels = new HashSet<Relationship>();
    RelationshipType types[] =
        new RelationshipType[] {MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL};
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();

    for (Relationship rel : node1.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(types)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships()) {
      assertTrue(rels.add(rel));
    }
    assertEquals(3, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node1.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());

    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.OUTGOING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(1, rels.size());
    rels.clear();
    graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
    for (Relationship rel : node2.getRelationships(Direction.INCOMING)) {
      assertTrue(rels.add(rel));
    }
    assertEquals(2, rels.size());

    tx.success();
    tx.finish();
    graphDb.shutdown();
  }