mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Further ML implementation: createEdition
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4744 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package org.alfresco.repo.model.ml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -27,10 +29,14 @@ import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.ml.MultilingualContentService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
@@ -51,6 +57,7 @@ public class MultilingualContentServiceImplTest extends TestCase
|
||||
private TransactionService transactionService;
|
||||
private NodeService nodeService;
|
||||
private FileFolderService fileFolderService;
|
||||
private VersionService versionService;
|
||||
private MultilingualContentService multilingualContentService;
|
||||
private NodeRef folderNodeRef;
|
||||
|
||||
@@ -62,6 +69,7 @@ public class MultilingualContentServiceImplTest extends TestCase
|
||||
transactionService = serviceRegistry.getTransactionService();
|
||||
nodeService = serviceRegistry.getNodeService();
|
||||
fileFolderService = serviceRegistry.getFileFolderService();
|
||||
versionService = serviceRegistry.getVersionService();
|
||||
multilingualContentService = (MultilingualContentService) ctx.getBean("MultilingualContentService");
|
||||
|
||||
// Run as admin
|
||||
@@ -128,8 +136,7 @@ public class MultilingualContentServiceImplTest extends TestCase
|
||||
// Check it
|
||||
assertNotNull("Container not created", mlContainerNodeRef);
|
||||
// Check the container child count
|
||||
int childCount = nodeService.getChildAssocs(mlContainerNodeRef).size();
|
||||
assertEquals("Incorrect number of child nodes", 1, childCount);
|
||||
assertEquals("Incorrect number of child nodes", 1, nodeService.getChildAssocs(mlContainerNodeRef).size());
|
||||
}
|
||||
|
||||
public void testAddTranslationUsingContainer() throws Exception
|
||||
@@ -147,8 +154,7 @@ public class MultilingualContentServiceImplTest extends TestCase
|
||||
// Make sure that the original container was used
|
||||
assertEquals("Existing container should have been used", mlContainerNodeRef, newMLContainerNodeRef);
|
||||
// Check the container child count
|
||||
int childCount = nodeService.getChildAssocs(mlContainerNodeRef).size();
|
||||
assertEquals("Incorrect number of child nodes", 2, childCount);
|
||||
assertEquals("Incorrect number of child nodes", 2, nodeService.getChildAssocs(mlContainerNodeRef).size());
|
||||
}
|
||||
|
||||
public void testAddTranslationUsingContent() throws Exception
|
||||
@@ -166,7 +172,51 @@ public class MultilingualContentServiceImplTest extends TestCase
|
||||
// Make sure that the original container was used
|
||||
assertEquals("Existing container should have been used", mlContainerNodeRef, newMLContainerNodeRef);
|
||||
// Check the container child count
|
||||
int childCount = nodeService.getChildAssocs(mlContainerNodeRef).size();
|
||||
assertEquals("Incorrect number of child nodes", 2, childCount);
|
||||
assertEquals("Incorrect number of child nodes", 2, nodeService.getChildAssocs(mlContainerNodeRef).size());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void testCreateEdition() throws Exception
|
||||
{
|
||||
// Make some content
|
||||
NodeRef chineseContentNodeRef = createContent();
|
||||
NodeRef frenchContentNodeRef = createContent();
|
||||
NodeRef japaneseContentNodeRef = createContent();
|
||||
// Add to container
|
||||
NodeRef mlContainerNodeRef = multilingualContentService.makeTranslation(chineseContentNodeRef, Locale.CHINESE);
|
||||
multilingualContentService.addTranslation(frenchContentNodeRef, mlContainerNodeRef, Locale.FRENCH);
|
||||
multilingualContentService.addTranslation(japaneseContentNodeRef, mlContainerNodeRef, Locale.JAPANESE);
|
||||
// Check the container child count
|
||||
assertEquals("Incorrect number of child nodes", 3, nodeService.getChildAssocs(mlContainerNodeRef).size());
|
||||
|
||||
// Version each of the documents
|
||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>(3);
|
||||
nodeRefs.add(chineseContentNodeRef);
|
||||
nodeRefs.add(frenchContentNodeRef);
|
||||
nodeRefs.add(japaneseContentNodeRef);
|
||||
versionService.createVersion(nodeRefs, null);
|
||||
// Get the current versions of each of the documents
|
||||
Version chineseVersionPreEdition = versionService.getCurrentVersion(chineseContentNodeRef);
|
||||
Version frenchVersionPreEdition = versionService.getCurrentVersion(frenchContentNodeRef);
|
||||
Version japaneseVersionPreEdition = versionService.getCurrentVersion(japaneseContentNodeRef);
|
||||
|
||||
// Create the edition, keeping the Chinese translation as the basis
|
||||
multilingualContentService.createEdition(mlContainerNodeRef, chineseContentNodeRef);
|
||||
// Check the container child count
|
||||
assertEquals("Incorrect number of child nodes", 1, nodeService.getChildAssocs(mlContainerNodeRef).size());
|
||||
|
||||
// Get the document versions now
|
||||
Version chineseVersionPostEdition = versionService.getCurrentVersion(chineseContentNodeRef);
|
||||
assertFalse("Expected document to be gone", nodeService.exists(frenchContentNodeRef));
|
||||
assertFalse("Expected document to be gone", nodeService.exists(japaneseContentNodeRef));
|
||||
|
||||
// Now be sure that we can get the required information using the version service
|
||||
VersionHistory mlContainerVersionHistory = versionService.getVersionHistory(mlContainerNodeRef);
|
||||
Version mlContainerRootVersion = mlContainerVersionHistory.getRootVersion();
|
||||
NodeRef mlContainerRootVersionNodeRef = mlContainerRootVersion.getVersionedNodeRef();
|
||||
// Get the root version's children
|
||||
List<ChildAssociationRef> mlContainerRootVersionChildren = nodeService.getChildAssocs(mlContainerRootVersionNodeRef);
|
||||
// Check them
|
||||
// assertEquals("Incorrect number of child nodes for root version", 3, mlContainerRootVersionChildren.size());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user