AnsweredAssumed Answered

exclusiveTest with local variable

Question asked by tomi87 on Jan 7, 2013
Latest reply on Jan 10, 2013 by frederikheremans1
Hello I need some help for my test.
At first I'm really not sure if this test to test a XOR gate with this code is working:


package org.bpmwithactiviti.Part1ApplicationTest;
import static org.junit.Assert.*;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.junit.Rule;
import org.junit.Test;

public class XORAdvisorOrNot {
   @Rule
   public ActivitiRule activitiRule = new ActivitiRule();
   @Test
   // deploys process with form properties
   @Deployment(resources = { "Part1Application.bpmn20.xml" })
   public void testProjectDecision() {

      // Test with input == true
       RuntimeService runtimeService = activitiRule.getRuntimeService();
       runtimeService.startProcessInstanceByKey("decideToBeTheAdvisorForTheStudent");
       runtimeService.setVariableLocal("requestAccepted", "Do you accepted this request?", "Yes");
     
       TaskService taskService = activitiRule.getTaskService();
      
       Task task = taskService.createTaskQuery().singleResult();
       assertEquals("XORAdvisorOrNot", task.getId());
       task = taskService.createTaskQuery().singleResult();
       assertEquals("PG1a", task.getId());
      taskService.complete(task.getId());
         
       // Test with input == false
       runtimeService.startProcessInstanceByKey("decideToBeTheAdvisorForTheStudent");
       runtimeService.setVariableLocal("requestAccepted", "Do you accepted this request?", "Yes");
      
       task = taskService.createTaskQuery().singleResult();
       assertEquals("XORAdvisorOrNot", task.getId());
       task = taskService.createTaskQuery().singleResult();
       assertEquals("searchAProfessorAsAdvisor", task.getId());
      taskService.complete(task.getId());
   }
}
Part1Application.bpm20.xml
<process id="part1Application">

<userTask id="decideToBeTheAdvisorForTheStudent" name="decide to be the advisor for the student"
         activiti:candidateGroups="AdvisorGroup">
         <documentation>advisor</documentation>
      
         <extensionElements>
            <activiti:formProperty id="requestAccepted"
               name="Do you accepted this request?" required="true" type="enum">
               <activiti:value id="true" name="Yes" />
               <activiti:value id="false" name="No" />
            </activiti:formProperty>
            <activiti:formProperty id="comments" name="Comments">
            </activiti:formProperty>
         </extensionElements>
   </userTask>
   <sequenceFlow id="flow103" name="" sourceRef="decideToBeTheAdvisorForTheStudent" targetRef="XORAdvisorOrNot">      </sequenceFlow>
      <exclusiveGateway id="XORAdvisorOrNot" name="" />
      <sequenceFlow id="flow104" name="request is accepted" sourceRef="XORAdvisorOrNot" targetRef="PG1a">
         <conditionExpression xsi:type="tFormalExpression">${requestAccepted == true}</conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flow105" name="request is refused"
         sourceRef="XORAdvisorOrNot" targetRef="searchAProfessorAsAdvisor">
         <conditionExpression xsi:type="tFormalExpression">${requestAccepted == false}</conditionExpression>
      </sequenceFlow>

Second, if I start this test I get a error message:

org.activiti.engine.ActivitiException: no processes deployed with key 'decideToBeTheAdvisorForTheStudent'
at org.activiti.engine.impl.persistence.deploy.DeploymentCache.findDeployedLatestProcessDefinitionByKey(DeploymentCache.java:63)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:58)
   at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:31)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:47)
   at org.bpmwithactiviti.Part1ApplicationTest.XORAdvisorOrNot.testProjectDecision(XORAdvisorOrNot.java:35)
   …
How can I deploy this user case? What should I change?

Outcomes