mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
119558 gcornwell: Merged code coverage improvements to 5.1-MC1 (5.1.0) r117774 gjames: RA-567: Increase /workflow/processes API code coverage r117773 gjames: RA-567: /workflow/processes coverage, removed unused ActivitiTypeConverter r116883 gjames: RA-531: reapplied change after merge, for MultiTServiceImpl test coverage r116629 gjames: RA-568 Increase /workflow/process-definitions API code coverage r116574 gjames: RA-569 Increase /workflow/tasks API code coverage r116286 gjames: RA-567: Increase /workflow/processes API code coverage r115853 gjames: RA-566: Increasing /people api coverage (description field) r115811 gjames: RA-566: Increasing /people api coverage r113007 gjames: Adding additional test coverage for DictionaryNamespaceComponent and DynamicNamespacePrefixResolver RA-521 r113006 gjames: Adding additional test coverage for DictionaryNamespaceComponent and DictionaryComponent RA-514 r112969 gjames: Adding additional test coverage for TemplateServiceImpl RA-530 r112960 gjames: Alternative test approach for ModuleServiceImpl RA-520 r112703 gjames: Adding additional test coverage for NodeLocatorService RA-522 r112702 gjames: Adding additional test coverage for JobLockServiceImpl RA-516 r112699 gjames: Adding additional test coverage for ModuleServiceImpl RA-520 r112508 gjames: Adding additional test coverage for RenditionServiceImpl RA-526 r112476 gjames: Adding additional test coverage for ContentServiceImpl RA-513 r112475 gjames: Adding additional test coverage for MimetypeMap RA-519 r112238 gjames: Adding additional test coverage for MimetypeMap RA-519 r112237 gjames: Adding additional test coverage for TaggingService RA-529 r112236 gjames: Adding additional test coverage for MultiTServiceImpl RA-531 r112206 gjames: Adding additional test coverage for ContentServiceImpl RA-513 r112167 gcornwell: RA-523: Increase NodeService code coverage (removed redundant code that was testing a version store we no longer use) r112102 gjames: Reverted changes to PermissionServiceImpl for RA-524 r112048 gjames: Temporarily removed some PermissionServiceImpl code. I need to put it back. r111620 gjames: Adding additional test coverage for PermissionService RA-524 r111619 gjames: Added some @Override to make Sonar happier r111456 gjames: Adding additional test coverage for AuthenticationService RA-509 r111427 gjames: Adding additional test coverage for AttributeService RA-509 r111317 gjames: Adding additional test coverage for WorkflowService RA-533 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@119945 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
121 lines
5.4 KiB
Java
121 lines
5.4 KiB
Java
/*
|
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package org.alfresco.repo.rendition;
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.when;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
import org.alfresco.repo.action.ActionDefinitionImpl;
|
|
import org.alfresco.service.ServiceRegistry;
|
|
import org.alfresco.service.cmr.action.ActionDefinition;
|
|
import org.alfresco.service.cmr.action.ActionService;
|
|
import org.alfresco.service.cmr.rendition.RenderingEngineDefinition;
|
|
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.service.namespace.QName;
|
|
|
|
/**
|
|
* @author Nick Smith
|
|
*/
|
|
public class RenditionServiceImplTest extends TestCase
|
|
{
|
|
private final static String ENGINE_NAME = "Engine Name";
|
|
|
|
private ServiceRegistry serviceRegistry = new MockedTestServiceRegistry();
|
|
private ActionService actionService = mock(ActionService.class);
|
|
|
|
private final RenditionDefinitionPersisterImpl renditionDefinitionPersister = mock(RenditionDefinitionPersisterImpl.class);
|
|
private RenditionServiceImpl renditionService;
|
|
|
|
private final QName ACTION_NAME = QName.createQName(NamespaceService.ALFRESCO_URI, "testName");
|
|
|
|
@Override
|
|
protected void setUp() throws Exception
|
|
{
|
|
renditionService = new RenditionServiceImpl();
|
|
renditionService.setServiceRegistry(serviceRegistry);
|
|
renditionService.setActionService(actionService);
|
|
renditionService.setRenditionDefinitionPersister(renditionDefinitionPersister);
|
|
}
|
|
|
|
public void testGetRenderingEngineDefinition() throws Exception
|
|
{
|
|
// Check returns null when unknown name specified.
|
|
assertNull(renditionService.getRenderingEngineDefinition(""));
|
|
|
|
// Check returns null if action service returns an ActionDefinition
|
|
// which does not implement RenderingActionDefinition.
|
|
ActionDefinition actionDefinition = new ActionDefinitionImpl(ENGINE_NAME);
|
|
when(actionService.getActionDefinition(ENGINE_NAME)).thenReturn(actionDefinition);
|
|
assertNull(renditionService.getRenderingEngineDefinition(ENGINE_NAME));
|
|
|
|
// Check returns the definition if the action service returns an
|
|
// ActionDefinition
|
|
// which does implement RenderingActionDefinition.
|
|
ActionDefinition renderingDefinition = new RenderingEngineDefinitionImpl(ENGINE_NAME);
|
|
when(actionService.getActionDefinition(ENGINE_NAME)).thenReturn(renderingDefinition);
|
|
assertSame(renderingDefinition, renditionService.getRenderingEngineDefinition(ENGINE_NAME));
|
|
}
|
|
|
|
public void testGetRenderingEngineDefinitions() throws Exception
|
|
{
|
|
LinkedList<ActionDefinition> actionDefs = new LinkedList<ActionDefinition>();
|
|
when(actionService.getActionDefinitions()).thenReturn(actionDefs);
|
|
|
|
// Check case where no action definitions returned.
|
|
List<RenderingEngineDefinition> engineDefs = renditionService.getRenderingEngineDefinitions();
|
|
assertTrue("The list of rendering action definitions should be empty!", engineDefs.isEmpty());
|
|
|
|
// Check that when the action service returns a rendering engine
|
|
// definition then the rendering service includes this in the list of
|
|
// returned values.
|
|
ActionDefinition renderingDefinition = new RenderingEngineDefinitionImpl(ENGINE_NAME);
|
|
actionDefs.add(renderingDefinition);
|
|
engineDefs = renditionService.getRenderingEngineDefinitions();
|
|
assertEquals(1, engineDefs.size());
|
|
assertSame(renderingDefinition, engineDefs.get(0));
|
|
assertNotNull(renditionService.loadRenditionDefinitions(ENGINE_NAME));
|
|
|
|
// Check that when the action service returns a non-rendering action
|
|
// definition then the rendering service does not include it.
|
|
ActionDefinition actionDefinition = new ActionDefinitionImpl(ENGINE_NAME);
|
|
actionDefs.add(actionDefinition);
|
|
engineDefs = renditionService.getRenderingEngineDefinitions();
|
|
assertEquals(1, engineDefs.size());
|
|
assertSame(renderingDefinition, engineDefs.get(0));
|
|
}
|
|
|
|
public void testCreateRenditionDefinition() throws Exception
|
|
{
|
|
RenditionDefinition renderingAction = renditionService.createRenditionDefinition(ACTION_NAME, ENGINE_NAME);
|
|
assertNotNull(renderingAction);
|
|
assertEquals(ENGINE_NAME, renderingAction.getActionDefinitionName());
|
|
assertEquals(ACTION_NAME, renderingAction.getRenditionName());
|
|
String id = renderingAction.getId();
|
|
assertNotNull(id);
|
|
assertTrue(id.length() > 0);
|
|
}
|
|
|
|
} |