MNT-13097 content reverted as well to head version if you delete last version of node

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@133732 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-12-15 13:29:14 +00:00
parent 6cd7c42905
commit 3c8f669b98

View File

@@ -88,7 +88,11 @@ import org.springframework.context.ApplicationContext;
public class VersionServiceImplTest extends BaseVersionStoreTest
{
private static Log logger = LogFactory.getLog(VersionServiceImplTest.class);
private static final String UPDATED_NAME_1 = "a.txt";
private static final String UPDATED_NAME_2 = "b.txt";
private static final String UPDATED_TITLE_1 = "a";
private static final String UPDATED_TITLE_2 = "b";
private static final String UPDATED_VALUE_1 = "updatedValue1";
private static final String UPDATED_VALUE_2 = "updatedValue2";
private static final String UPDATED_VALUE_3 = "updatedValue3";
@@ -1242,8 +1246,10 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// Use 1.0, 2.0 etc for the main part
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
// Create a versionable node with content
// Create a versionable node with a name, title and content
NodeRef versionableNode = createNewVersionableNode();
this.nodeService.setProperty(versionableNode, ContentModel.PROP_NAME, UPDATED_NAME_1);
this.nodeService.setProperty(versionableNode, ContentModel.PROP_TITLE, UPDATED_TITLE_1);
ContentWriter contentWriter = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
assertNotNull(contentWriter);
contentWriter.putContent(UPDATED_CONTENT_1);
@@ -1251,13 +1257,21 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// Create first version
Version version1 = createVersion(versionableNode);
// Update Content
// Update name, title and content
this.nodeService.setProperty(versionableNode, ContentModel.PROP_NAME, UPDATED_NAME_2);
this.nodeService.setProperty(versionableNode, ContentModel.PROP_TITLE, UPDATED_TITLE_2);
contentWriter = this.contentService.getWriter(versionableNode, ContentModel.PROP_CONTENT, true);
contentWriter.putContent(UPDATED_CONTENT_2);
// Create second version
Version version2 = createVersion(versionableNode);
// Check that the name and title is right
String name2 = (String) this.nodeService.getProperty(versionableNode, ContentModel.PROP_NAME);
assertEquals(UPDATED_NAME_2, name2);
String title2 = (String) this.nodeService.getProperty(versionableNode, ContentModel.PROP_TITLE);
assertEquals(UPDATED_TITLE_2, title2);
// Check that the version label is right
Version currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(version2.getVersionLabel(), currentVersion.getVersionLabel());
@@ -1269,13 +1283,26 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
// Delete version 2.0
this.versionService.deleteVersion(versionableNode, version2);
// Check that the version label is resetted
// Check that the name and title is reverted
String name1 = (String) this.nodeService.getProperty(versionableNode, ContentModel.PROP_NAME);
assertEquals(UPDATED_NAME_1, name1);
String title1 = (String) this.nodeService.getProperty(versionableNode, ContentModel.PROP_TITLE);
assertEquals(UPDATED_TITLE_1, title1);
// Check that the version label is reverted
currentVersion = this.versionService.getCurrentVersion(versionableNode);
assertEquals(version1.getVersionLabel(), currentVersion.getVersionLabel());
// Check that the content has been reverted
contentReader1 = this.contentService.getReader(versionableNode, ContentModel.PROP_CONTENT);
assertEquals(UPDATED_CONTENT_1, contentReader1.getContentString());
// We should only have 1.0 Version left
VersionHistory vhistory = this.versionService.getVersionHistory(versionableNode);
for(Version v : vhistory.getAllVersions()){
//System.err.println(v.toString());
assertEquals("1.0", v.getVersionLabel());
}
}
/**