ALFCOM-3024 - added optional property exclusion list to versionable aspect (-> onUpdateProperties)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14952 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-06-26 11:12:56 +00:00
parent 9c630f07f3
commit 8139b17300
2 changed files with 160 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ import org.springframework.context.ApplicationContext;
/**
* versionService test class.
*
* @author Roy Wetherall
* @author Roy Wetherall, janv
*/
public class VersionServiceImplTest extends BaseVersionStoreTest
{
@@ -937,7 +937,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author");
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 1");
return null;
}
@@ -975,7 +975,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode2, ContentModel.PROP_AUTHOR, "ano author");
nodeService.setProperty(versionableNode2, ContentModel.PROP_AUTHOR, "ano author 2");
return null;
}
@@ -996,6 +996,112 @@ public class VersionServiceImplTest extends BaseVersionStoreTest
});
}
public void testAutoVersionOnUpdatePropsOnlyWithExcludes()
{
// test auto-version props on - without any excludes
final NodeRef versionableNode = createNewVersionableNode();
this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true);
setComplete();
endTransaction();
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(1, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 1");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 1");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
return null;
}
});
VersionableAspect versionableAspect = (VersionableAspect)applicationContext.getBean("versionableAspect");
List<String> excludedOnUpdateProps = new ArrayList<String>(1);
excludedOnUpdateProps.add(ContentModel.PROP_AUTHOR.toPrefixString());
versionableAspect.setExcludedOnUpdateProps(excludedOnUpdateProps);
// test auto-version props on - with an excluded prop change
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_AUTHOR, "ano author 2");
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 2");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
return null;
}
});
// test auto-version props on - with a non-excluded prop change
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(2, versionHistory.getAllVersions().size());
nodeService.setProperty(versionableNode, ContentModel.PROP_DESCRIPTION, "description 3");
return null;
}
});
// Now lets have a look and make sure we have the correct number of entries in the version history
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
VersionHistory versionHistory = versionService.getVersionHistory(versionableNode);
assertNotNull(versionHistory);
assertEquals(3, versionHistory.getAllVersions().size());
return null;
}
});
}
public void testAR807()
{
QName prop = QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "intProp");