cancel
Showing results for 
Search instead for 
Did you mean: 

NullPointerException for Testcase

tomi87
Champ in-the-making
Champ in-the-making
I need some help to solve my problem with the correct way of writing for the following test. Because he give me the error code:
java.lang.NullPointerException
   at org.activiti.designer.test.TestProcess1.testXorFunctionality(TestProcess1.java:37)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

How can I write it in the right way ?

public class TestProcess1{

   @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg.xml");

   @Test
   @Deployment(resources = { "XOR.bpmn20.xml" })
   
      public void testXorFunctionality(){
      
         Map<String, Object> variables = new HashMap<String, Object>();
         variables.put("choose", 2);
   
         TaskService taskService = activitiRule.getTaskService();
         RuntimeService runtimeService = activitiRule.getRuntimeService();
         
         ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("xorTest", variables);
      // ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceById("xorTest", variables);
     
      Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
      assertEquals("Choose 2", task.getName());
      taskService.complete(task.getId());

      task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
         assertEquals("pepare 2", task.getName());
      }
   }
10 REPLIES 10

trademak
Star Contributor
Star Contributor
Please sent me your full unit test class and BPMN XML file so I can take a look at it.
You can sent it to tijs.rademakers At gmail.com

Best regards,