AnsweredAssumed Answered

NullPointerException for Testcase

Question asked by tomi87 on Jan 20, 2013
Latest reply on Jan 27, 2013 by trademak
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());
      }
   }

Outcomes