@Test
 @Ignore
 public void testRels2() throws Exception {
   initializeStores();
   startTx();
   int relType1 = (int) ds.nextId(RelationshipType.class);
   String typeName = "relationshiptype1";
   xaCon.getTransaction().createRelationshipTypeToken(relType1, typeName);
   long nodeIds[] = new long[3];
   for (int i = 0; i < 3; i++) {
     nodeIds[i] = ds.nextId(Node.class);
     xaCon.getTransaction().nodeCreate(nodeIds[i]);
     xaCon.getTransaction().nodeAddProperty(nodeIds[i], index("nisse"), new Integer(10 - i));
   }
   for (int i = 0; i < 2; i++) {
     xaCon
         .getTransaction()
         .relationshipCreate(ds.nextId(Relationship.class), relType1, nodeIds[i], nodeIds[i + 1]);
   }
   xaCon
       .getTransaction()
       .relationshipCreate(ds.nextId(Relationship.class), relType1, nodeIds[0], nodeIds[2]);
   commitTx();
   startTx();
   for (int i = 0; i < 3; i++) {
     MutableRelationshipLoadingPosition pos = getPosition(xaCon, nodeIds[i]);
     for (RelationshipRecord rel : getMore(xaCon, nodeIds[i], pos)) {
       xaCon.getTransaction().relDelete(rel.getId());
     }
     xaCon.getTransaction().nodeDelete(nodeIds[i]);
   }
   commitTx();
   ds.stop();
 }
 private void deleteRel1(
     long rel,
     DefinedProperty prop1,
     DefinedProperty prop2,
     DefinedProperty prop3,
     long firstNode,
     long secondNode,
     int relType)
     throws IOException {
   ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
   xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props));
   int count = 0;
   for (int keyId : props.keySet()) {
     long id = props.get(keyId).other();
     PropertyRecord record = pStore.getRecord(id);
     PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
     DefinedProperty data = block.newPropertyData(pStore);
     if (data.propertyKeyId() == prop1.propertyKeyId()) {
       assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals("-string1", data.value());
     } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
       assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(-1, data.value());
     } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
       assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(false, data.value());
       xaCon.getTransaction().relRemoveProperty(rel, prop3.propertyKeyId());
     } else {
       throw new IOException();
     }
     count++;
   }
   assertEquals(3, count);
   CountingPropertyReceiver propertyCounter = new CountingPropertyReceiver();
   xaCon.getTransaction().relLoadProperties(rel, false, propertyCounter);
   assertEquals(3, propertyCounter.count);
   RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel);
   assertEquals(firstNode, relData.getFirstNode());
   assertEquals(secondNode, relData.getSecondNode());
   assertEquals(relType, relData.getType());
   xaCon.getTransaction().relDelete(rel);
   MutableRelationshipLoadingPosition firstPos = getPosition(xaCon, firstNode);
   Iterator<RelationshipRecord> first = getMore(xaCon, firstNode, firstPos).iterator();
   first.next();
   MutableRelationshipLoadingPosition secondPos = getPosition(xaCon, secondNode);
   Iterator<RelationshipRecord> second = getMore(xaCon, secondNode, secondPos).iterator();
   second.next();
   assertTrue(first.hasNext());
   assertTrue(second.hasNext());
 }
 private void validateRel2(
     long rel,
     DefinedProperty prop1,
     DefinedProperty prop2,
     DefinedProperty prop3,
     long firstNode,
     long secondNode,
     int relType)
     throws IOException {
   ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
   xaCon.getTransaction().relLoadProperties(rel, false, newPropertyReceiver(props));
   int count = 0;
   for (int keyId : props.keySet()) {
     long id = props.get(keyId).other();
     PropertyRecord record = pStore.getRecord(id);
     PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
     DefinedProperty data = block.newPropertyData(pStore);
     if (data.propertyKeyId() == prop1.propertyKeyId()) {
       assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals("string2", data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop1.propertyKeyId(), "-string2");
     } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
       assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(2, data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop2.propertyKeyId(), new Integer(-2));
     } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
       assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
       assertEquals(false, data.value());
       xaCon.getTransaction().relChangeProperty(rel, prop3.propertyKeyId(), true);
     } else {
       throw new IOException();
     }
     count++;
   }
   assertEquals(3, count);
   RelationshipRecord relData = xaCon.getTransaction().relLoadLight(rel);
   assertEquals(firstNode, relData.getFirstNode());
   assertEquals(secondNode, relData.getSecondNode());
   assertEquals(relType, relData.getType());
 }
  private void validateNodeRel2(
      long node,
      DefinedProperty prop1,
      DefinedProperty prop2,
      DefinedProperty prop3,
      long rel1,
      long rel2,
      int relType1,
      int relType2)
      throws IOException {
    NodeRecord nodeRecord = xaCon.getTransaction().nodeLoadLight(node);
    assertTrue(nodeRecord != null);
    ArrayMap<Integer, Pair<DefinedProperty, Long>> props = new ArrayMap<>();
    xaCon.getTransaction().nodeLoadProperties(node, false, newPropertyReceiver(props));
    int count = 0;
    for (int keyId : props.keySet()) {
      long id = props.get(keyId).other();
      PropertyRecord record = pStore.getRecord(id);
      PropertyBlock block = record.getPropertyBlock(props.get(keyId).first().propertyKeyId());
      DefinedProperty data = block.newPropertyData(pStore);
      if (data.propertyKeyId() == prop1.propertyKeyId()) {
        assertEquals("prop1", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals("string2", data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop1.propertyKeyId(), "-string2");
      } else if (data.propertyKeyId() == prop2.propertyKeyId()) {
        assertEquals("prop2", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals(2, data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop2.propertyKeyId(), new Integer(-2));
      } else if (data.propertyKeyId() == prop3.propertyKeyId()) {
        assertEquals("prop3", MyPropertyKeyToken.getIndexFor(keyId).name());
        assertEquals(false, data.value());
        xaCon.getTransaction().nodeChangeProperty(node, prop3.propertyKeyId(), true);
      } else {
        throw new IOException();
      }
      count++;
    }
    assertEquals(3, count);
    count = 0;

    MutableRelationshipLoadingPosition pos = getPosition(xaCon, node);
    while (true) {
      Iterable<RelationshipRecord> relData = getMore(xaCon, node, pos);
      if (!relData.iterator().hasNext()) {
        break;
      }
      for (RelationshipRecord rel : relData) {
        if (rel.getId() == rel1) {
          assertEquals(node, rel.getSecondNode());
          assertEquals(relType1, rel.getType());
        } else if (rel.getId() == rel2) {
          assertEquals(node, rel.getFirstNode());
          assertEquals(relType2, rel.getType());
        } else {
          throw new IOException();
        }
        count++;
      }
    }
    assertEquals(2, count);
  }
  @Test
  public void testCreateNeoStore() throws Exception {
    initializeStores();
    startTx();
    // setup test population
    long node1 = ds.nextId(Node.class);
    xaCon.getTransaction().nodeCreate(node1);
    long node2 = ds.nextId(Node.class);
    xaCon.getTransaction().nodeCreate(node2);
    DefinedProperty n1prop1 =
        xaCon.getTransaction().nodeAddProperty(node1, index("prop1"), "string1");
    DefinedProperty n1prop2 = xaCon.getTransaction().nodeAddProperty(node1, index("prop2"), 1);
    DefinedProperty n1prop3 = xaCon.getTransaction().nodeAddProperty(node1, index("prop3"), true);

    DefinedProperty n2prop1 =
        xaCon.getTransaction().nodeAddProperty(node2, index("prop1"), "string2");
    DefinedProperty n2prop2 = xaCon.getTransaction().nodeAddProperty(node2, index("prop2"), 2);
    DefinedProperty n2prop3 = xaCon.getTransaction().nodeAddProperty(node2, index("prop3"), false);

    int relType1 = (int) ds.nextId(RelationshipType.class);
    String typeName1 = "relationshiptype1";
    xaCon.getTransaction().createRelationshipTypeToken(relType1, typeName1);
    int relType2 = (int) ds.nextId(RelationshipType.class);
    String typeName2 = "relationshiptype2";
    xaCon.getTransaction().createRelationshipTypeToken(relType2, typeName2);
    long rel1 = ds.nextId(Relationship.class);
    xaCon.getTransaction().relationshipCreate(rel1, relType1, node1, node2);
    long rel2 = ds.nextId(Relationship.class);
    xaCon.getTransaction().relationshipCreate(rel2, relType2, node2, node1);

    DefinedProperty r1prop1 =
        xaCon.getTransaction().relAddProperty(rel1, index("prop1"), "string1");
    DefinedProperty r1prop2 = xaCon.getTransaction().relAddProperty(rel1, index("prop2"), 1);
    DefinedProperty r1prop3 = xaCon.getTransaction().relAddProperty(rel1, index("prop3"), true);

    DefinedProperty r2prop1 =
        xaCon.getTransaction().relAddProperty(rel2, index("prop1"), "string2");
    DefinedProperty r2prop2 = xaCon.getTransaction().relAddProperty(rel2, index("prop2"), 2);
    DefinedProperty r2prop3 = xaCon.getTransaction().relAddProperty(rel2, index("prop3"), false);
    commitTx();
    ds.stop();

    initializeStores();
    startTx();
    // validate node
    validateNodeRel1(node1, n1prop1, n1prop2, n1prop3, rel1, rel2, relType1, relType2);
    validateNodeRel2(node2, n2prop1, n2prop2, n2prop3, rel1, rel2, relType1, relType2);
    // validate rels
    validateRel1(rel1, r1prop1, r1prop2, r1prop3, node1, node2, relType1);
    validateRel2(rel2, r2prop1, r2prop2, r2prop3, node2, node1, relType2);
    validateRelTypes(relType1, relType2);
    // validate reltypes
    validateRelTypes(relType1, relType2);
    commitTx();
    ds.stop();

    initializeStores();
    startTx();
    // validate and delete rels
    deleteRel1(rel1, r1prop1, r1prop2, r1prop3, node1, node2, relType1);
    deleteRel2(rel2, r2prop1, r2prop2, r2prop3, node2, node1, relType2);
    // validate and delete nodes
    deleteNode1(node1, n1prop1, n1prop2, n1prop3);
    deleteNode2(node2, n2prop1, n2prop2, n2prop3);
    commitTx();
    ds.stop();

    initializeStores();
    startTx();
    assertNull(xaCon.getTransaction().nodeLoadLight(node1));
    assertNull(xaCon.getTransaction().nodeLoadLight(node2));
    testGetRels(new long[] {rel1, rel2});
    // testGetProps( neoStore, new int[] {
    // n1prop1, n1prop2, n1prop3, n2prop1, n2prop2, n2prop3,
    // r1prop1, r1prop2, r1prop3, r2prop1, r2prop2, r2prop3
    // } );
    long nodeIds[] = new long[10];
    for (int i = 0; i < 3; i++) {
      nodeIds[i] = ds.nextId(Node.class);
      xaCon.getTransaction().nodeCreate(nodeIds[i]);
      xaCon.getTransaction().nodeAddProperty(nodeIds[i], index("nisse"), new Integer(10 - i));
    }
    for (int i = 0; i < 2; i++) {
      long id = ds.nextId(Relationship.class);
      xaCon.getTransaction().relationshipCreate(id, relType1, nodeIds[i], nodeIds[i + 1]);
      xaCon.getTransaction().relDelete(id);
    }
    for (int i = 0; i < 3; i++) {
      MutableRelationshipLoadingPosition pos = getPosition(xaCon, nodeIds[i]);
      for (RelationshipRecord rel : getMore(xaCon, nodeIds[i], pos)) {
        xaCon.getTransaction().relDelete(rel.getId());
      }
      xaCon.getTransaction().nodeDelete(nodeIds[i]);
    }
    commitTx();
    ds.stop();
  }