AnsweredAssumed Answered

Hi folks, Any solution for this.... 

Question asked by kaushikkrishna on Jun 18, 2018

 

I don't understand why is it returning null.... Coz there should be atleast one ProcessInstance....

New To Activiti.... Trying to work on Java API... Please help me out...

Thanks in advance....

 

Regards,

Kaushik  

 

Code Snippet: 

 

package org.Activiti.test;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;


public class Sample3Test {

private static RuntimeService runtimeService;

@BeforeClass
public static void init()
{
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().addClasspathResource("diagrams/Sample3Diagram.bpmn").deploy();
RuntimeService runtimeService = processEngine.getRuntimeService();
}

@Test
public void startProcessInstance()
{
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("isbn", "12345");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("bookOrder",variableMap);
assertNotNull(processInstance);
System.out.println("id : " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
}

@Test
public void queryProcessInstance()
{
List<ProcessInstance> instanceList = runtimeService
.createProcessInstanceQuery()
.processDefinitionKey("bookOrder")
.list();
for(ProcessInstance queryProcessInstance : instanceList)
{
assertEquals(false, queryProcessInstance.isEnded());
System.out.println("id : " + queryProcessInstance.getId() + " ended : " + queryProcessInstance.isEnded());
}

}
}

 

 

 

Stack Trace :

 

java.lang.NullPointerException
at org.Activiti.test.Sample3Test.queryProcessInstance(Sample3Test.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Attachments

Outcomes