mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Publishing: Tidied PublishingService and ChannelService interface to remove obsolete operations.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30437 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,25 +19,16 @@
|
||||
|
||||
package org.alfresco.repo.publishing;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.alfresco.repo.publishing.PublishingModel.PROP_CHANNEL_TYPE;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.publishing.channels.ChannelType;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.transfer.NodeFilter;
|
||||
import org.alfresco.service.cmr.transfer.NodeFinder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -91,67 +82,4 @@ public class ChannelServiceImplTest
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChannelDependancyNodeFinder() throws Exception
|
||||
{
|
||||
when(serviceRegistry.getNodeService()).thenReturn(nodeService);
|
||||
NodeRef node = new NodeRef("test://foo/bar");
|
||||
NodeRef parent = new NodeRef("test://foo/barParent");
|
||||
ChildAssociationRef assoc = new ChildAssociationRef(null, parent, null, node);
|
||||
|
||||
NodeFinder nodeFinder = channelService.getChannelDependancyNodeFinder();
|
||||
assertNotNull(nodeFinder);
|
||||
|
||||
// Initialize Node Finders
|
||||
ChannelDependancyNodeFinder cdnf = (ChannelDependancyNodeFinder) nodeFinder;
|
||||
cdnf.setServiceRegistry(serviceRegistry);
|
||||
cdnf.init();
|
||||
|
||||
// Need to call afterPropertiesSet() again to pick up nodeService.
|
||||
mockChannelType.afterPropertiesSet();
|
||||
|
||||
// Check no nodes found if NodeRef does not have a channel type.
|
||||
Set<NodeRef> results = nodeFinder.findFrom(node);
|
||||
assertTrue(results.isEmpty());
|
||||
|
||||
// Check no nodes found if NodeRef has an unregistered channel type.
|
||||
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
|
||||
.thenReturn("Foo");
|
||||
results = nodeFinder.findFrom(node);
|
||||
assertTrue(results.isEmpty());
|
||||
|
||||
// Check returns parent if MockChannelType found.
|
||||
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
|
||||
.thenReturn(MockChannelType.ID);
|
||||
when(nodeService.getPrimaryParent(node))
|
||||
.thenReturn(assoc);
|
||||
results = nodeFinder.findFrom(node);
|
||||
assertEquals(1, results.size());
|
||||
assertTrue(results.contains(parent));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChannelDependancyNodeFilter() throws Exception
|
||||
{
|
||||
when(serviceRegistry.getNodeService()).thenReturn(nodeService);
|
||||
NodeRef node = new NodeRef("test://foo/bar");
|
||||
|
||||
NodeFilter nodeFinder = channelService.getChannelDependancyNodeFilter();
|
||||
assertNotNull(nodeFinder);
|
||||
|
||||
// Initialize Node Finders
|
||||
ChannelDependancyNodeFilter cdnf = (ChannelDependancyNodeFilter) nodeFinder;
|
||||
cdnf.setServiceRegistry(serviceRegistry);
|
||||
cdnf.init();
|
||||
|
||||
// Check no nodes filtered if NodeRef does not have a channel type.
|
||||
assertTrue(nodeFinder.accept(node));
|
||||
|
||||
// Check no nodes filtered if NodeRef has an unregistered channel type.
|
||||
when(nodeService.getProperty(node, PROP_CHANNEL_TYPE))
|
||||
.thenReturn("Foo");
|
||||
assertTrue(nodeFinder.accept(node));
|
||||
|
||||
// TODO Test other NodeFilter behaviour when added.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user