06-30-2014 06:15 AM
package org.activiti.designer.test;
import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.BeforeClass;
import org.junit.Test;
public class MyProcess_StartProcessWithParam_Test {
private static RuntimeService runtimeService;
@BeforeClass
public static void init() throws Exception {
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment()
/ .addClasspathResource("MyProcess.bpmn")
.deploy();
runtimeService = processEngine.getRuntimeService();
}
@Test
public void startProcessInstance() {
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("param1", "123456");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
assertNotNull(processInstance.getId());
System.out.println("Process ID: " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
// Query for running process instances
List<ProcessInstance> instanceList = runtimeService.createProcessInstanceQuery().processDefinitionKey("myProcess").list();
// Debug
System.out.println(instanceList.isEmpty());
for (ProcessInstance queryProcessInstance : instanceList) {
assertEquals(false, queryProcessInstance.isEnded());
System.out.println("id " + queryProcessInstance.getId() + ", ended=" + queryProcessInstance.isEnded());
}
}
}
Process ID: 5 myProcess:1:4
true
07-01-2014 02:17 AM
What's wrong with my code?I do not know. I have found almost the same jUnit test in the activiti sources.
org.activiti.engine.test.api.runtime.RuntimeServiceTest#testStartProcessInstanceByIdNullVariables
It should work.Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.