1 17 package org.alfresco.repo.configuration; 18 19 import java.util.List ; 20 21 import org.alfresco.model.ContentModel; 22 import org.alfresco.service.ServiceRegistry; 23 import org.alfresco.service.cmr.repository.ChildAssociationRef; 24 import org.alfresco.service.cmr.repository.NodeRef; 25 import org.alfresco.service.cmr.repository.NodeService; 26 import org.alfresco.service.cmr.repository.StoreRef; 27 import org.alfresco.service.namespace.RegexQNamePattern; 28 import org.alfresco.util.BaseSpringTest; 29 30 35 public class ConfigurableServiceImplTest extends BaseSpringTest 36 { 37 public NodeService nodeService; 38 private ServiceRegistry serviceRegistry; 39 private ConfigurableService configurableService; 40 private StoreRef testStoreRef; 41 private NodeRef rootNodeRef; 42 private NodeRef nodeRef; 43 44 47 @Override 48 protected void onSetUpInTransaction() throws Exception 49 { 50 this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); 51 this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); 52 this.configurableService = (ConfigurableService)this.applicationContext.getBean("configurableService"); 53 54 this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); 55 this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); 56 57 this.nodeRef = this.nodeService.createNode( 59 this.rootNodeRef, 60 ContentModel.ASSOC_CHILDREN, 61 ContentModel.ASSOC_CHILDREN, 62 ContentModel.TYPE_CONTAINER).getChildRef(); 63 } 64 65 68 public void testIsConfigurable() 69 { 70 assertFalse(this.configurableService.isConfigurable(this.nodeRef)); 71 this.configurableService.makeConfigurable(this.nodeRef); 72 assertTrue(this.configurableService.isConfigurable(this.nodeRef)); 73 } 74 75 78 public void testMakeConfigurable() 79 { 80 this.configurableService.makeConfigurable(this.nodeRef); 81 assertTrue(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_CONFIGURABLE)); 82 List <ChildAssociationRef> assocs = this.nodeService.getChildAssocs( 83 this.nodeRef, 84 RegexQNamePattern.MATCH_ALL, 85 ContentModel.ASSOC_CONFIGURATIONS); 86 assertNotNull(assocs); 87 assertEquals(1, assocs.size()); 88 } 89 90 93 public void testGetConfigurationFolder() 94 { 95 assertNull(this.configurableService.getConfigurationFolder(this.nodeRef)); 96 this.configurableService.makeConfigurable(nodeRef); 97 NodeRef configFolder = this.configurableService.getConfigurationFolder(this.nodeRef); 98 assertNotNull(configFolder); 99 NodeRef parentNodeRef = this.nodeService.getPrimaryParent(configFolder).getParentRef(); 100 assertNotNull(parentNodeRef); 101 assertEquals(nodeRef, parentNodeRef); 102 } 103 104 } 105 | Popular Tags |