Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)

127262 arebegea: Merged 5.0.N (5.0.4) to 5.1.N (5.1.2)
      127234 cpopa: MNT-16063 : Activiti workflows without userTask does not work
         - Prevent tasks retrieval from finished executions


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127287 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Cristian Turlica
2016-05-20 13:17:01 +00:00
parent 0cd4e43ec5
commit 7992f174cf
4 changed files with 69 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.HistoryService;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
@@ -97,6 +98,7 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
protected ServiceRegistry serviceRegistry;
protected WorkflowTestHelper wfTestHelper;
protected TransactionServiceImpl transactionService;
protected HistoryService historyService;
public void testDeployWorkflowDefinition()
{
@@ -1341,6 +1343,7 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
this.workflowService = serviceRegistry.getWorkflowService();
this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
this.nodeService = serviceRegistry.getNodeService();
this.historyService = (HistoryService) applicationContext.getBean("activitiHistoryService");
Repository repositoryHelper = (Repository) applicationContext.getBean("repositoryHelper");
this.companyHome = repositoryHelper.getCompanyHome();
try

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.workflow.activiti;
@@ -35,11 +35,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.history.HistoricProcessInstance;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.workflow.AbstractWorkflowServiceIntegrationTest;
import org.alfresco.repo.workflow.WorkflowBuilder;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
@@ -638,6 +640,26 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ
assertNotNull(completed);
}
public void testBuildWorkflowWithNoUserTasks() throws Exception
{
// Deploy a definition containing only a service task
WorkflowDefinition testDefinition = deployDefinition("activiti/testWorkflowNoUserTasks.bpmn20.xml");
WorkflowBuilder builder = new WorkflowBuilder(testDefinition, workflowService, nodeService, null);
// Build a workflow
WorkflowInstance builtInstance = builder.build();
assertNotNull(builtInstance);
// Check that there is no active workflow for the deployed definition(it should have finished already due to absence of user tasks)
List<WorkflowInstance> activeInstances = workflowService.getActiveWorkflows(testDefinition.getId());
assertNotNull(activeInstances);
assertEquals(0, activeInstances.size());
// Check that there's a historic record of our 'only service task' workflow being run.
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
.finishedAfter(builtInstance.getStartDate())
.singleResult();
assertNotNull(historicProcessInstance);
}
@Override
protected String getEngine()