Mergeing form EC-MC: Completed. Removed intwined aspect deletion behaviour

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5745 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-05-22 05:05:00 +00:00
parent d818c54e99
commit f6fbed84a0
18 changed files with 373 additions and 539 deletions

View File

@@ -169,50 +169,4 @@ public class EmptyTranslationAspectTest extends AbstractMultilingualTestCases {
fileFolderService.getReader(empty).getContentString(),
fileFolderService.getReader(pivot).getContentString());
}
public void testRemoveAspect() throws Exception
{
NodeRef pivot = createContent();
NodeRef empty = null;
multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
// 1. remove mlEmptyTranslation aspect with empty content
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
// Ensure that the empty translation is deleted
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with no content the node must be deleted",
nodeService.exists(empty));
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with no content the node must be deleted and can't be archived",
nodeService.exists(nodeArchiveService.getArchivedNode(empty)));
// 2. remove mlDocument aspect with empty content
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT);
// Ensure that the empty translation is deleted
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " of an empty translation with no content the node must be deleted",
nodeService.exists(empty));
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " of an empty translation with no content the node must be deleted and can't be archived",
nodeService.exists(nodeArchiveService.getArchivedNode(empty)));
// 3. remove mlEmptyTranslation aspect with not empty content
empty = multilingualContentService.addEmptyTranslation(pivot, "empty_" + System.currentTimeMillis(), Locale.CHINESE);
ContentWriter writer = contentService.getWriter(empty, ContentModel.PROP_CONTENT, true);
writer.setMimetype("text/plain");
writer.putContent("ANY_CONTENT");
nodeService.removeAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION);
// Ensure that the empty translation is NOT deleted
assertTrue("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content the node must NOT be deleted",
nodeService.exists(empty));
// Ensure that the mlEmptyTranslation aspect is removed
assertFalse("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content this aspect must be removed",
nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION));
// Ensure that the mlEmptyDocument in NOT removed
assertTrue("After removed the " + ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION + " of an empty translation with content the " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " aspect must be keeped",
nodeService.hasAspect(empty, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
}
}

View File

@@ -39,30 +39,8 @@ import org.alfresco.service.namespace.QName;
*
* @author yanipig
*/
public class MLContainerTypeTest extends AbstractMultilingualTestCases {
public void testDeleteNode() throws Exception
{
NodeRef pivot = createContent();
NodeRef empty;
NodeRef mlContainer = multilingualContentService.makeTranslation(pivot, Locale.FRENCH);
empty = multilingualContentService.addEmptyTranslation(pivot, "Empty_" + System.currentTimeMillis(), Locale.ENGLISH);
nodeService.deleteNode(mlContainer);
// Ensure that the mlContainer is deleted
assertFalse("The mlContainer must be deleted", nodeService.exists(mlContainer));
// Ensure that the empty translation is deleted
assertFalse("The mlEmptyTranslation must be deleted", nodeService.exists(empty));
// Ensure that the non-empty document is not deleted
assertTrue("The mlDocument must not be deleted", nodeService.exists(pivot));
// Ensure that the mlDocument property of the non-empty document is removed
assertFalse("The " + ContentModel.ASPECT_MULTILINGUAL_DOCUMENT + " aspect of the mlDocument must be removed",
nodeService.hasAspect(pivot, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
}
public class MLContainerTypeTest extends AbstractMultilingualTestCases
{
@SuppressWarnings("unused")
public void testEditLocale() throws Exception
{

View File

@@ -87,8 +87,11 @@ public class MultilingualDocumentAspectTest extends AbstractMultilingualTestCase
assertEquals("The restored node would not be restaured to the mlContainer", 2, multilingualContentService.getTranslations(mlContainer).size());
// Ensure that the restored node doesn't keep the mlDocument aspect
assertFalse("The restored node can't keep the multilingual aspect", nodeService.hasAspect(restoredNode, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
// Ensure that the restored node doesn't keep the locale property
assertNull("The restaured node can't keep the locale property", nodeService.getProperty(restoredNode, ContentModel.PROP_LOCALE));
// DH: The locale is stored on an aspect that is independent of the ML model.
// It is therefore not possible to remove the locale just because the node
// is being unhooked from the ML structures
// // Ensure that the restored node doesn't keep the locale property
// assertNull("The restaured node can't keep the locale property", nodeService.getProperty(restoredNode, ContentModel.PROP_LOCALE));
}
public void testDeletePivot() throws Exception
@@ -109,8 +112,10 @@ public class MultilingualDocumentAspectTest extends AbstractMultilingualTestCase
assertTrue("The last translation would not be removed", nodeService.exists(trans1));
// Ensure that trans1 has no mlDocument aspect
assertFalse("The last translation can't keep the multilingual aspect", nodeService.hasAspect(trans1, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT));
// Ensure that trans1 has no locale propety
assertNull("The last translation can't keep the locale property", nodeService.getProperty(trans1, ContentModel.PROP_LOCALE));
// DH: Here too, the sys:locale property must be left alone as it is independent of the
// ML model
// // Ensure that trans1 has no locale propety
// assertNull("The last translation can't keep the locale property", nodeService.getProperty(trans1, ContentModel.PROP_LOCALE));
}
public void testDeleteLastNode() throws Exception