ReadOnlyVersionManager { @Nullable public Tree getVersionHistory(@NotNull Tree versionable) throws UnsupportedRepositoryOperationException, RepositoryException { checkVersionable(versionable); String uuid = versionable.getProperty(VersionConstants.JCR_UUID).getValue(Type.STRING); return TreeUtil.getTree(getVersionStorage(), getVersionHistoryPath(uuid)); }  @NotNull static ReadOnlyVersionManager getInstance(final Root root,
                                                     final NamePathMapper namePathMapper); boolean isCheckedOut(@NotNull Tree tree); @Nullable Tree getVersionHistory(@NotNull Tree versionable); @Nullable Tree getVersion(@NotNull String uuid); @NotNull String getVersionHistoryPath(@NotNull String uuid); @Nullable Tree getBaseVersion(@NotNull Tree versionable); static boolean isVersionStoreTree(@NotNull Tree tree); @Nullable Tree getVersionable(@NotNull Tree versionTree, @NotNull String workspaceName);  }
@Test public void testRemoveEmptyHistoryAfterRemovingVersionable() throws RepositoryException, CommitFailedException { NodeUtil node = new NodeUtil(root.getTree("/")); NodeUtil testVersionable = node.addChild("testVersionable", NodeTypeConstants.NT_OAK_UNSTRUCTURED); TreeUtil.addMixin(testVersionable.getTree(), JcrConstants.MIX_VERSIONABLE, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), null); root.commit(); String historyPath = versionManager.getVersionHistory(testVersionable.getTree()).getPath(); assertTrue(root.getTree(historyPath).exists()); testVersionable.getTree().remove(); root.commit(); assertFalse(root.getTree(historyPath).exists()); }
@Test public void testPreserveNonEmptyHistoryAfterRemovingVersionable() throws RepositoryException, CommitFailedException { String historyPath = versionManager.getVersionHistory(versionable).getPath(); assertTrue(root.getTree(historyPath).exists()); versionable.remove(); root.commit(); assertTrue(root.getTree(historyPath).exists()); }
@Test public void testPreserveHistoryAfterMovingVersionable() throws RepositoryException, CommitFailedException { NodeUtil node = new NodeUtil(root.getTree("/")); NodeUtil testVersionable = node.addChild("testVersionable", NodeTypeConstants.NT_OAK_UNSTRUCTURED); TreeUtil.addMixin(testVersionable.getTree(), JcrConstants.MIX_VERSIONABLE, root.getTree(NodeTypeConstants.NODE_TYPES_PATH), null); root.commit(); Tree history = versionManager.getVersionHistory(testVersionable.getTree()); assertTrue(history.exists()); String historyUuid = history.getProperty(JCR_UUID).getValue(Type.STRING); assertTrue(root.move("/testVersionable", "/testVersionable2")); root.commit(); history = versionManager.getVersionHistory(root.getTree("/testVersionable2")); assertTrue(history.exists()); assertEquals(historyUuid, history.getProperty(JCR_UUID).getValue(Type.STRING)); }