예제 #1
0
 private int loadRelationships(Node node, RelationshipType type, Direction direction) {
   int count;
   try (Transaction tx = db.beginTx()) {
     count = count(node.getRelationships(type, direction));
     int pCount = node.getDegree(type, direction);
     assertEquals(count, pCount);
     tx.success();
   }
   return count;
 }
예제 #2
0
  protected void verifyData(int nodeCount, GraphDatabaseService db) {
    // Verify that all the labels are in place
    Set<Label> expectedLabels = new HashSet<>();
    for (String label : LABELS) {
      expectedLabels.add(DynamicLabel.label(label));
    }
    GlobalGraphOperations globalOps = GlobalGraphOperations.at(db);
    Set<Label> allLabels = Iterables.toSet(globalOps.getAllLabels());
    assertThat(allLabels, is(expectedLabels));

    // Sample some nodes for deeper inspection of their contents
    Random random = new Random();
    for (int i = 0; i < nodeCount / 10; i++) {
      Node node = db.getNodeById(random.nextInt(nodeCount));
      int count = count(node.getRelationships());
      assertEquals("For node " + node, count, node.getDegree());
      for (String key : node.getPropertyKeys()) {
        node.getProperty(key);
        Set<Label> actualLabels = Iterables.toSet(node.getLabels());
        assertThat(actualLabels, is(expectedLabels));
      }
    }
  }