BundledDocumentDiffer { public boolean diff(AbstractDocumentNodeState from, AbstractDocumentNodeState to, JsopWriter w){ boolean fromBundled = BundlorUtils.isBundledNode(from); boolean toBundled = BundlorUtils.isBundledNode(to); if (!fromBundled && !toBundled){ return true; } DocumentNodeState fromDocState = getDocumentNodeState(from); DocumentNodeState toDocState = getDocumentNodeState(to); diffChildren(fromDocState.getBundledChildNodeNames(), toDocState.getBundledChildNodeNames(), w); if (fromDocState.hasOnlyBundledChildren() && toDocState.hasOnlyBundledChildren()){ return false; } return true; } BundledDocumentDiffer(DocumentNodeStore nodeStore); boolean diff(AbstractDocumentNodeState from, AbstractDocumentNodeState to, JsopWriter w);  }
@Test public void testDiff() throws Exception { NodeBuilder builder = createContentStructure(); NodeState r1 = merge(store, builder); builder = store.getRoot().builder(); childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("foo", "bar"); NodeState r2 = merge(store, builder); JsopWriter w = new JsopBuilder(); String path = "/test"; assertTrue(differ.diff(dns(r1, path), dns(r2, path), w)); assertTrue(w.toString().isEmpty()); w = new JsopBuilder(); path = "/test/book.jpg"; assertFalse(differ.diff(dns(r1, path), dns(r2, path), w)); assertEquals("^\"jcr:content\":{}", w.toString()); builder = store.getRoot().builder(); childBuilder(builder, "/test/book.jpg/foo"); NodeState r3 = merge(store, builder); w = new JsopBuilder(); path = "/test/book.jpg"; assertTrue(differ.diff(dns(r1, path), dns(r3, path), w)); assertEquals("^\"jcr:content\":{}", w.toString()); }
@Test public void diffWithSecondary() throws Exception{ configureSecondary(); NodeBuilder builder = createContentStructure(); NodeState r1 = merge(store, builder); NodeState rs1 = DelegatingDocumentNodeState.wrap(secondary.getRoot(), store); builder = store.getRoot().builder(); childBuilder(builder, "/test/book.jpg/jcr:content").setProperty("foo", "bar"); NodeState r2 = merge(store, builder); JsopWriter w = new JsopBuilder(); String path = "/test/book.jpg"; assertFalse(differ.diff(adns(rs1, path), adns(r2, path), w)); assertEquals("^\"jcr:content\":{}", w.toString()); }