AnsweredAssumed Answered

exclusive gateway test case

Question asked by tomi87 on Jan 4, 2013
Latest reply on Jan 4, 2013 by ronald.van.kuijk
Hello I don't know how I should write the test for the following exclusive gateway:


   <exclusiveGateway id="XORAProjectOrNot" name="" />
      <sequenceFlow id="flow63" name="Project" sourceRef="XORAProjectOrNot"
         targetRef="sendInformationsFromTheProfessors">
         <conditionExpression xsi:type="tFormalExpression">${StudentAppInfo.project == true}</conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flow69" name="No Project" sourceRef="XORAProjectOrNot"
         targetRef="XORBProjectOrNot">
         <conditionExpression xsi:type="tFormalExpression">${StudentAppInfo.project  == false}</conditionExpression>
      </sequenceFlow>
I want to get the project value from:


<startEvent id="start">
         <extensionElements>
            <activiti:formProperty id="studentName" name="Studenten Name"
               required="true" type="string" />
            <activiti:formProperty id="emailAddress" name="Email address"
               required="true" type="string" />
            <activiti:formProperty id="dateFrom" name="Date from"
               required="true" type="long" />
            <activiti:formProperty id="dateToo" name="Date too"
               required="true" type="long" />
            <activiti:formProperty id="homeCountry" name="Home Country"
               required="true" type="string" />
            <activiti:formProperty id="homeUniversity"
               name="Home University" required="true" type="string" />
            <activiti:formProperty id="homeDepartment"
               name="Home Department" required="true" type="string" />
            <activiti:formProperty id="targetUniversity"
               name="Target University" required="true" type="string" />
            <activiti:formProperty id="targetDepartment"
               name="Target Department" required="true" type="string" />
            <activiti:formProperty id="research" name="Research"
               required="true" type="string" />
            <activiti:formProperty id="courseEnrollment"
               name="Course Enrollment" required="true" type="string" />
            <activiti:formProperty id="project" name="With project"
               required="true" type="boolean" />
         </extensionElements>
      </startEvent>
      <sequenceFlow id="flow114" sourceRef="start" targetRef="createRequest"></sequenceFlow>
      <serviceTask id="createRequest" name="Create Request"
         activiti:class="org.process1.CreateStudentApp"></serviceTask>


public class StudentAppInfo implements Serializable {

   private static final long serialVersionUID = 1L;

   private String studentName;
   private String emailAddress;
   
   private long dateFrom;
   private long dateToo;
   private long month;
   
   private String homeCountry;
   private String homeUniversity;
   private String homeDepartment;
   private String targetUniversity;
   private String targetDepartment;
   
   private String research;
   private String courseEnrollment;
   private Boolean project;

   public Boolean getProject() {
      return project;
   }
}

My idea is at first to enter everything
@Deployment(resources = { "Part1Application.bpmn20.xml" })
   public void startFormSubmit() {
      ProcessDefinition definition = activitiRule.getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionKey("part1Application").singleResult();
      assertNotNull(definition);

      // call the FormService interface
      FormService formService = activitiRule.getFormService();
      List<FormProperty> formList = formService.getStartFormData(
            definition.getId()).getFormProperties();
      assertEquals(12, formList.size());

      Map<String, String> formProperties = new HashMap<String, String>();
      formProperties.put("studentName", "Toni Muller");
      formProperties.put("emailAddress", "toni@localhost");
      formProperties.put("dateFrom", "1234");
      formProperties.put("dateToo", "2345");
      formProperties.put("homeCountry", "usa");
      formProperties.put("homeUniversity", "univbersityy");
      formProperties.put("homeDepartment", "Computer Science");
      formProperties.put("targetUniversity", "Universityaaa");
      formProperties.put("targetDepartment", "Communication Engineering");
      formProperties.put("research", "Enrollment Process");
      formProperties.put("courseEnrollment", "UML");
      formProperties.put("project", "true");

      // submit form properties
      formService.submitStartFormData(definition.getId(), formProperties);
      // view history query for form properties
      List<HistoricDetail> historyVariables = activitiRule
            .getHistoryService().createHistoricDetailQuery()
            .formProperties().list();

and then try to input the project value:
(it can't find "runtimeService." and "taskService." "Cannot be resolved" What can I do to fix it?)


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

import static org.junit.Assert.*;
import org.activiti.engine.runtime.ProcessInstance;
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;

Map<String, Object> variables = new HashMap<String, Object>();

    // Test with input == true
    variables.put("input", true);
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("XORAProjectOrNot", variables);
    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("send informations from the professors", task.getName());

    // Test with input == false
    variables.put("input", false);
    pi = runtimeService.startProcessInstanceByKey("XORAProjectOrNot", variables);
    task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("XOR B Project Or Not", task.getName());

My problem is that I don't know how to write it in the right way. Hope you can help me!

Outcomes