REPO-1682 / MNT-15447: getCurrentVersion(node) throws ConcurrencyFailureException after creating multiple versions of a node

- Throw IllegalArgumentException when not a 'live' noderef is used for retrieving the current version.
   - Added Junit test.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133884 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2016-12-19 12:05:24 +00:00
parent 9c99f44e0e
commit 9794eb72dc
3 changed files with 50 additions and 14 deletions

View File

@@ -308,7 +308,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
assertEquals(3, vh.getAllVersions().size());
// TODO check list of versions ... !
}
}
/**
* Tests the creation of multiple versions of a versionable node with null version properties
@@ -336,10 +336,41 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
createVersion(node);
}
// TODO test versioning numberious times with branchs implies by different workspaces
/**
* Test retrieving the current version for a node with multiple versions
*/
public void testGetCurrentVersion()
{
NodeRef versionableNode = createNewVersionableNode();
createVersion(versionableNode);
createVersion(versionableNode);
createVersion(versionableNode);
VersionHistory vh = this.versionService.getVersionHistory(versionableNode);
Version version = vh.getRootVersion();
// Get current version from live node
NodeRef node = version.getVersionedNodeRef();
Version currentVersion = versionService.getCurrentVersion(node);
assertNotNull("Failed to retrieve the current version from the head", currentVersion);
try
{
// Get current version from the version node (frozen state version node) - not allowed (MNT-15447)
node = version.getFrozenStateNodeRef();
currentVersion = versionService.getCurrentVersion(node);
fail("Getting the current version is only allowed on live nodes, not on version nodes.");
}
catch (IllegalArgumentException ex)
{
// expected
}
}
// TODO test versioning numberious times with branches implies by different workspaces
/**
* Test versioning the children of a verionable node
* Test versioning the children of a versionable node
*/
public void testVersioningChildren()
{