As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Hello,
I'm trying to take in hand Activiti using Eclipse through this tutorial . I'm at the part 5 and the instanciation test doesn't work, I always have 0 and not 1 as I expect. But I don't see other ways to do it instead of the following code
process :
<process id="my-process"> <startEvent id="startEvent" name="request" activiti:initiator="employeeName"> <extensionElements> <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true"/> <!--<activiti:formProperty id="startDate" name="Vacation start date (MM-dd-yyyy)" type="date" required="true"/>--> <activiti:formProperty id="reason" name="Reason for leave" type="string" /> </extensionElements> </startEvent> <userTask id="handle_vacation_request" name="Handle Request for Vacation"> <documentation> ${employeeName} would like to take ${numberOfDays} day(s) of vacation (Motivation: ${reason}). </documentation> <extensionElements> <activiti:formProperty id="vacationApproved" name="Do you approve this vacation request?" type="enum" required="true"/> <activiti:formProperty id="comments" name="Comments from Manager" type="string" /> </extensionElements> <potentialOwner> <resourceAssignmentExpression> <formalExpression> management </formalExpression> </resourceAssignmentExpression> </potentialOwner> </userTask> <serviceTask id="send-email-confirmation" name="Send email confirmation" activiti:class="com.example.activiti.servicetasks.SendEmailServiceTask"> </serviceTask> <sequenceFlow id="flow3" name="approved" sourceRef="handle_vacation_request" targetRef="send-email-confirmation"> <conditionExpression xsi:type="tFormalExpression"> <![CDATA[${vacationApproved == 'true'}]]> </conditionExpression> </sequenceFlow> </process>
The Junit test :
package process_6.process_6; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.test.ActivitiRule; import org.activiti.engine.test.Deployment; import org.junit.Rule; import org.junit.Test; import static org.junit.Assert.*; import java.util.HashMap; import java.util.Map; public class MyUnitTest { @Rule public ActivitiRule activitiRule = new ActivitiRule(); @Test @Deployment(resources = {"process_6/process_6/my-process.bpmn20.xml"}) public void givenBPMN_whenDeployProcess_thenDeployed() { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); RepositoryService repositoryService = processEngine.getRepositoryService(); repositoryService.createDeployment().addClasspathResource("process_6/process_6/my-process.bpmn20.xml").deploy(); //Long count=repositoryService.createProcessDefinitionQuery().count(); //assertEquals("1", count.toString()); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("employeeName", "Kermit"); variables.put("numberOfDays", 4); variables.put("reason", "I'm really tired!"); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process", variables); // Verify that we started a new process instance Long count= runtimeService.createProcessInstanceQuery().count(); assertEquals("1", count.toString()); //Log.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count()); } }
And the result is 0, wheres it was wiating for 1