ModifiedPathDiff implements NodeStateDiff { public static Set<String> getModifiedPaths(NodeState before, NodeState after) { ModifiedPathDiff diff = new ModifiedPathDiff(); after.compareAgainstBaseState(before, diff); return diff.getPaths(); } private  ModifiedPathDiff(); private  ModifiedPathDiff(ModifiedPathDiff parent, String name); static Set<String> getModifiedPaths(NodeState before, NodeState after); @Override boolean propertyAdded(PropertyState after); @Override boolean propertyChanged(PropertyState before, PropertyState after); @Override boolean propertyDeleted(PropertyState before); @Override boolean childNodeAdded(String name, NodeState after); @Override boolean childNodeChanged(String name, NodeState before, NodeState after); @Override boolean childNodeDeleted(String name, NodeState before);  }
@Test public void testAddedNodesAreModified() { NodeBuilder builder = base.builder(); builder.getChildNode("a").child("xyz"); builder.getChildNode("c").getChildNode("d").child("abc"); Set<String> paths = ModifiedPathDiff.getModifiedPaths(base, builder.getNodeState()); assertEquals(newHashSet("/a/xyz", "/c/d/abc"), paths); }
@Test public void testRemovedNodesAreModified() { NodeBuilder builder = base.builder(); builder.getChildNode("a").remove(); builder.getChildNode("c").getChildNode("d").remove(); Set<String> paths = ModifiedPathDiff.getModifiedPaths(base, builder.getNodeState()); assertEquals(newHashSet("/a", "/c/d"), paths); }
@Test public void testModifiedNodesAreModified() { NodeBuilder builder = base.builder(); builder.getChildNode("a").setProperty("x", 1l, Type.LONG); builder.getChildNode("c").getChildNode("d").setProperty("x", 1l, Type.LONG); Set<String> paths = ModifiedPathDiff.getModifiedPaths(base, builder.getNodeState()); assertEquals(newHashSet("/a", "/c/d"), paths); }