VersionablePathHook implements CommitHook { @NotNull @Override public NodeState processCommit( NodeState before, NodeState after, CommitInfo info) throws CommitFailedException { NodeBuilder rootBuilder = after.builder(); NodeBuilder vsRoot = rootBuilder.child(NodeTypeConstants.JCR_SYSTEM).child(NodeTypeConstants.JCR_VERSIONSTORAGE); ReadWriteVersionManager vMgr = new ReadWriteVersionManager(vsRoot, rootBuilder); ReadOnlyNodeTypeManager ntMgr = ReadOnlyNodeTypeManager.getInstance(providerCtx.getRootProvider().createReadOnlyRoot(rootBuilder.getNodeState()), NamePathMapper.DEFAULT); after.compareAgainstBaseState(before, new Diff(vMgr, ntMgr, new Node(rootBuilder))); return rootBuilder.getNodeState(); } VersionablePathHook(@NotNull String workspaceName, @NotNull ProviderCtx providerCtx); @NotNull @Override NodeState processCommit(
            NodeState before, NodeState after, CommitInfo info); @Override String toString();  }
@Test public void testInvalidVersionHistoryIsIgnored() throws Exception { NodeState after = new AbstractNodeState() { @Override public boolean exists() { return true; } @Override public @NotNull Iterable<? extends PropertyState> getProperties() { return ImmutableList.of(PropertyStates.createProperty(JCR_VERSIONHISTORY, "someValue")); } @Override public boolean hasChildNode(@NotNull String name) { return true; } @Override public @NotNull NodeState getChildNode(@NotNull String name) throws IllegalArgumentException { return this; } @Override public @NotNull Iterable<? extends ChildNodeEntry> getChildNodeEntries() { return Collections.emptyList(); } @Override public @NotNull NodeBuilder builder() { return new MemoryNodeBuilder(this); } }; NodeState spyAfter = spy(after); NodeState before = getTreeProvider().asNodeState(t); vpHook.processCommit(before, spyAfter, new CommitInfo("sid", null)); verify(spyAfter, never()).getProperty(JCR_UUID); }