Query process instances by key with no results
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2014 06:15 AM
I tried to query process instances with this simple test:
A process instance has been created but the list of instances is empty. I get the following debug output:
For some reason the process instances list is empty. What's wrong with my code?
* Activiti 5.14.1
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()); } }}
A process instance has been created but the list of instances is empty. I get the following debug output:
Process ID: 5 myProcess:1:4true
For some reason the process instances list is empty. What's wrong with my code?
* Activiti 5.14.1
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2014 02:17 AM
Hi,
Could you zip your jUnit test project and add it to the reply?
Regards
Martin
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.Could you zip your jUnit test project and add it to the reply?
Regards
Martin
