@Override public boolean tree(NodeRef left, NodeRef right) { final NodeRef node = left == null ? right : left; if (NodeRef.ROOT.equals(node.name())) { // ignore the call on the root tree and follow the traversal return true; } if (left == null || right == null) { addTreeFeatures(node.getObjectId(), left != null, right != null); if (left == null) { count.addedTrees(1); } else { count.removedTrees(1); } return false; } count.changedTrees(1);// the tree changed, or this method wouldn't have been called return true; }
@Override public boolean tree(NodeRef left, NodeRef right) { final NodeRef node = left == null ? right : left; if (NodeRef.ROOT.equals(node.name())) { // ignore the call on the root tree and follow the traversal return true; } if (left == null || right == null) { RevTree tree = (left == null ? rightSource : leftSource).getTree(node.getObjectId()); addTreeFeatures(tree, left != null, right != null); if (left == null) { count.addedTrees(1); } else { count.removedTrees(1); } return false; } count.changedTrees(1);// the tree changed, or this method wouldn't have been called return true; }
@Test public void testToString() { DiffObjectCount count = new DiffObjectCount(); count.addedFeatures(1); count.changedFeatures(2); count.removedFeatures(3); count.addedTrees(4); count.changedTrees(5); count.removedTrees(6); String expected = "trees [ added: 4, changed: 5, removed: 6]\n" + "features[ added: 1, changed: 2, removed: 3]"; assertEquals(expected, count.toString()); } }
assertEquals(5, count.removedTrees(5)); assertEquals(5, count.getTreesRemoved()); assertEquals(70, count.featureCount()); assertEquals(10, count.removedTrees(5)); assertEquals(10, count.getTreesRemoved()); assertEquals(70, count.featureCount());