<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Junit Test : Starting a ProcessInstance, using Activiti with Eclipse in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/junit-test-starting-a-processinstance-using-activiti-with/m-p/133899#M36048</link>
    <description>&lt;DIV class=""&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;process :&lt;/P&gt;&lt;PRE&gt;&amp;lt;process id=&lt;SPAN class=""&gt;"my-process"&lt;/SPAN&gt;&amp;gt;
    &amp;lt;startEvent id=&lt;SPAN class=""&gt;"startEvent"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"request"&lt;/SPAN&gt; activiti:initiator=&lt;SPAN class=""&gt;"employeeName"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;extensionElements&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"numberOfDays"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Number of days"&lt;/SPAN&gt;                   type=&lt;SPAN class=""&gt;"long"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;
            &amp;lt;!--&amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"startDate"&lt;/SPAN&gt;    name=&lt;SPAN class=""&gt;"Vacation start date (MM-dd-yyyy)"&lt;/SPAN&gt; type=&lt;SPAN class=""&gt;"date"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;--&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"reason"&lt;/SPAN&gt;       name=&lt;SPAN class=""&gt;"Reason for leave"&lt;/SPAN&gt;                 type=&lt;SPAN class=""&gt;"string"&lt;/SPAN&gt;              /&amp;gt;
       &amp;lt;/extensionElements&amp;gt;
    &amp;lt;/startEvent&amp;gt;
    &amp;lt;userTask id=&lt;SPAN class=""&gt;"handle_vacation_request"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Handle Request for Vacation"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;documentation&amp;gt;
            ${employeeName} would like to take ${numberOfDays} day(s) of &lt;SPAN class=""&gt;vacation&lt;/SPAN&gt; &lt;SPAN class=""&gt;(Motivation: ${reason})&lt;/SPAN&gt;.
        &amp;lt;/documentation&amp;gt;
        &amp;lt;extensionElements&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"vacationApproved"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Do you approve this vacation request?"&lt;/SPAN&gt; type=&lt;SPAN class=""&gt;"enum"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"comments"&lt;/SPAN&gt;         name=&lt;SPAN class=""&gt;"Comments from Manager"&lt;/SPAN&gt;                 type=&lt;SPAN class=""&gt;"string"&lt;/SPAN&gt;              /&amp;gt;
        &amp;lt;/extensionElements&amp;gt;
        &amp;lt;potentialOwner&amp;gt;
            &amp;lt;resourceAssignmentExpression&amp;gt;
                &amp;lt;formalExpression&amp;gt;
                    management
                &amp;lt;/formalExpression&amp;gt;
            &amp;lt;/resourceAssignmentExpression&amp;gt;
        &amp;lt;/potentialOwner&amp;gt;
    &amp;lt;/userTask&amp;gt;
    &amp;lt;serviceTask 
        id=&lt;SPAN class=""&gt;"send-email-confirmation"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Send email confirmation"&lt;/SPAN&gt; activiti:class=&lt;SPAN class=""&gt;"com.example.activiti.servicetasks.SendEmailServiceTask"&lt;/SPAN&gt;&amp;gt;
    &amp;lt;/serviceTask&amp;gt;
    &amp;lt;sequenceFlow id=&lt;SPAN class=""&gt;"flow3"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"approved"&lt;/SPAN&gt; sourceRef=&lt;SPAN class=""&gt;"handle_vacation_request"&lt;/SPAN&gt; targetRef=&lt;SPAN class=""&gt;"send-email-confirmation"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;conditionExpression xsi:type=&lt;SPAN class=""&gt;"tFormalExpression"&lt;/SPAN&gt;&amp;gt;
            &amp;lt;![CDATA[${vacationApproved == &lt;SPAN class=""&gt;'true'&lt;/SPAN&gt;}]]&amp;gt;
        &amp;lt;/conditionExpression&amp;gt;
    &amp;lt;/sequenceFlow&amp;gt;
&amp;lt;/process&amp;gt;&lt;/PRE&gt;&lt;P&gt;The Junit test :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;package&lt;/SPAN&gt; process_6.process_6;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.ProcessEngine;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.ProcessEngines;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.RepositoryService;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.RuntimeService;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.runtime.ProcessInstance;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.test.ActivitiRule;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.test.Deployment;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.junit.Rule;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.junit.Test;

&lt;SPAN class=""&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;static&lt;/SPAN&gt; org.junit.Assert.*;

&lt;SPAN class=""&gt;import&lt;/SPAN&gt; java.util.HashMap;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; java.util.Map;

&lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;class&lt;/SPAN&gt; &lt;SPAN class=""&gt;MyUnitTest&lt;/SPAN&gt; {

    &lt;SPAN class=""&gt;@Rule&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;ActivitiRule&lt;/SPAN&gt; &lt;SPAN class=""&gt;activitiRule&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;ActivitiRule&lt;/SPAN&gt;();

    &lt;SPAN class=""&gt;@Test&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;@Deployment(resources = {"process_6/process_6/my-process.bpmn20.xml"})&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;void&lt;/SPAN&gt; &lt;SPAN class=""&gt;givenBPMN_whenDeployProcess_thenDeployed&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt; {
        &lt;SPAN class=""&gt;ProcessEngine&lt;/SPAN&gt; &lt;SPAN class=""&gt;processEngine&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; ProcessEngines.getDefaultProcessEngine();
        &lt;SPAN class=""&gt;RepositoryService&lt;/SPAN&gt; &lt;SPAN class=""&gt;repositoryService&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; processEngine.getRepositoryService();
        repositoryService.createDeployment().addClasspathResource(&lt;SPAN class=""&gt;"process_6/process_6/my-process.bpmn20.xml"&lt;/SPAN&gt;).deploy();
        &lt;SPAN class=""&gt;//Long count=repositoryService.createProcessDefinitionQuery().count();&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;//assertEquals("1", count.toString());&lt;/SPAN&gt;
        
        Map&amp;lt;String, Object&amp;gt; variables = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;HashMap&lt;/SPAN&gt;&amp;lt;String, Object&amp;gt;();
        variables.put(&lt;SPAN class=""&gt;"employeeName"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"Kermit"&lt;/SPAN&gt;);
        variables.put(&lt;SPAN class=""&gt;"numberOfDays"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;4&lt;/SPAN&gt;);
        variables.put(&lt;SPAN class=""&gt;"reason"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"I'm really tired!"&lt;/SPAN&gt;);

        &lt;SPAN class=""&gt;RuntimeService&lt;/SPAN&gt; &lt;SPAN class=""&gt;runtimeService&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; processEngine.getRuntimeService();
        &lt;SPAN class=""&gt;ProcessInstance&lt;/SPAN&gt; &lt;SPAN class=""&gt;processInstance&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; runtimeService.startProcessInstanceByKey(&lt;SPAN class=""&gt;"my-process"&lt;/SPAN&gt;, variables);

        &lt;SPAN class=""&gt;// Verify that we started a new process instance&lt;/SPAN&gt;
        Long count= runtimeService.createProcessInstanceQuery().count();
        assertEquals(&lt;SPAN class=""&gt;"1"&lt;/SPAN&gt;, count.toString());
        &lt;SPAN class=""&gt;//Log.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count());&lt;/SPAN&gt;

    }
}&lt;/PRE&gt;&lt;P&gt;And the result is 0, wheres it was wiating for 1&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 15 Jul 2022 09:24:51 GMT</pubDate>
    <dc:creator>letailla</dc:creator>
    <dc:date>2022-07-15T09:24:51Z</dc:date>
    <item>
      <title>Junit Test : Starting a ProcessInstance, using Activiti with Eclipse</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/junit-test-starting-a-processinstance-using-activiti-with/m-p/133899#M36048</link>
      <description>&lt;DIV class=""&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;process :&lt;/P&gt;&lt;PRE&gt;&amp;lt;process id=&lt;SPAN class=""&gt;"my-process"&lt;/SPAN&gt;&amp;gt;
    &amp;lt;startEvent id=&lt;SPAN class=""&gt;"startEvent"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"request"&lt;/SPAN&gt; activiti:initiator=&lt;SPAN class=""&gt;"employeeName"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;extensionElements&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"numberOfDays"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Number of days"&lt;/SPAN&gt;                   type=&lt;SPAN class=""&gt;"long"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;
            &amp;lt;!--&amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"startDate"&lt;/SPAN&gt;    name=&lt;SPAN class=""&gt;"Vacation start date (MM-dd-yyyy)"&lt;/SPAN&gt; type=&lt;SPAN class=""&gt;"date"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;--&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"reason"&lt;/SPAN&gt;       name=&lt;SPAN class=""&gt;"Reason for leave"&lt;/SPAN&gt;                 type=&lt;SPAN class=""&gt;"string"&lt;/SPAN&gt;              /&amp;gt;
       &amp;lt;/extensionElements&amp;gt;
    &amp;lt;/startEvent&amp;gt;
    &amp;lt;userTask id=&lt;SPAN class=""&gt;"handle_vacation_request"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Handle Request for Vacation"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;documentation&amp;gt;
            ${employeeName} would like to take ${numberOfDays} day(s) of &lt;SPAN class=""&gt;vacation&lt;/SPAN&gt; &lt;SPAN class=""&gt;(Motivation: ${reason})&lt;/SPAN&gt;.
        &amp;lt;/documentation&amp;gt;
        &amp;lt;extensionElements&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"vacationApproved"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Do you approve this vacation request?"&lt;/SPAN&gt; type=&lt;SPAN class=""&gt;"enum"&lt;/SPAN&gt; required=&lt;SPAN class=""&gt;"true"&lt;/SPAN&gt;/&amp;gt;
            &amp;lt;activiti:formProperty id=&lt;SPAN class=""&gt;"comments"&lt;/SPAN&gt;         name=&lt;SPAN class=""&gt;"Comments from Manager"&lt;/SPAN&gt;                 type=&lt;SPAN class=""&gt;"string"&lt;/SPAN&gt;              /&amp;gt;
        &amp;lt;/extensionElements&amp;gt;
        &amp;lt;potentialOwner&amp;gt;
            &amp;lt;resourceAssignmentExpression&amp;gt;
                &amp;lt;formalExpression&amp;gt;
                    management
                &amp;lt;/formalExpression&amp;gt;
            &amp;lt;/resourceAssignmentExpression&amp;gt;
        &amp;lt;/potentialOwner&amp;gt;
    &amp;lt;/userTask&amp;gt;
    &amp;lt;serviceTask 
        id=&lt;SPAN class=""&gt;"send-email-confirmation"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"Send email confirmation"&lt;/SPAN&gt; activiti:class=&lt;SPAN class=""&gt;"com.example.activiti.servicetasks.SendEmailServiceTask"&lt;/SPAN&gt;&amp;gt;
    &amp;lt;/serviceTask&amp;gt;
    &amp;lt;sequenceFlow id=&lt;SPAN class=""&gt;"flow3"&lt;/SPAN&gt; name=&lt;SPAN class=""&gt;"approved"&lt;/SPAN&gt; sourceRef=&lt;SPAN class=""&gt;"handle_vacation_request"&lt;/SPAN&gt; targetRef=&lt;SPAN class=""&gt;"send-email-confirmation"&lt;/SPAN&gt;&amp;gt;
        &amp;lt;conditionExpression xsi:type=&lt;SPAN class=""&gt;"tFormalExpression"&lt;/SPAN&gt;&amp;gt;
            &amp;lt;![CDATA[${vacationApproved == &lt;SPAN class=""&gt;'true'&lt;/SPAN&gt;}]]&amp;gt;
        &amp;lt;/conditionExpression&amp;gt;
    &amp;lt;/sequenceFlow&amp;gt;
&amp;lt;/process&amp;gt;&lt;/PRE&gt;&lt;P&gt;The Junit test :&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;package&lt;/SPAN&gt; process_6.process_6;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.ProcessEngine;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.ProcessEngines;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.RepositoryService;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.RuntimeService;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.runtime.ProcessInstance;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.test.ActivitiRule;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.activiti.engine.test.Deployment;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.junit.Rule;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; org.junit.Test;

&lt;SPAN class=""&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;static&lt;/SPAN&gt; org.junit.Assert.*;

&lt;SPAN class=""&gt;import&lt;/SPAN&gt; java.util.HashMap;
&lt;SPAN class=""&gt;import&lt;/SPAN&gt; java.util.Map;

&lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;class&lt;/SPAN&gt; &lt;SPAN class=""&gt;MyUnitTest&lt;/SPAN&gt; {

    &lt;SPAN class=""&gt;@Rule&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;ActivitiRule&lt;/SPAN&gt; &lt;SPAN class=""&gt;activitiRule&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;ActivitiRule&lt;/SPAN&gt;();

    &lt;SPAN class=""&gt;@Test&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;@Deployment(resources = {"process_6/process_6/my-process.bpmn20.xml"})&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;public&lt;/SPAN&gt; &lt;SPAN class=""&gt;void&lt;/SPAN&gt; &lt;SPAN class=""&gt;givenBPMN_whenDeployProcess_thenDeployed&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt; {
        &lt;SPAN class=""&gt;ProcessEngine&lt;/SPAN&gt; &lt;SPAN class=""&gt;processEngine&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; ProcessEngines.getDefaultProcessEngine();
        &lt;SPAN class=""&gt;RepositoryService&lt;/SPAN&gt; &lt;SPAN class=""&gt;repositoryService&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; processEngine.getRepositoryService();
        repositoryService.createDeployment().addClasspathResource(&lt;SPAN class=""&gt;"process_6/process_6/my-process.bpmn20.xml"&lt;/SPAN&gt;).deploy();
        &lt;SPAN class=""&gt;//Long count=repositoryService.createProcessDefinitionQuery().count();&lt;/SPAN&gt;
        &lt;SPAN class=""&gt;//assertEquals("1", count.toString());&lt;/SPAN&gt;
        
        Map&amp;lt;String, Object&amp;gt; variables = &lt;SPAN class=""&gt;new&lt;/SPAN&gt; &lt;SPAN class=""&gt;HashMap&lt;/SPAN&gt;&amp;lt;String, Object&amp;gt;();
        variables.put(&lt;SPAN class=""&gt;"employeeName"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"Kermit"&lt;/SPAN&gt;);
        variables.put(&lt;SPAN class=""&gt;"numberOfDays"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;4&lt;/SPAN&gt;);
        variables.put(&lt;SPAN class=""&gt;"reason"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;"I'm really tired!"&lt;/SPAN&gt;);

        &lt;SPAN class=""&gt;RuntimeService&lt;/SPAN&gt; &lt;SPAN class=""&gt;runtimeService&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; processEngine.getRuntimeService();
        &lt;SPAN class=""&gt;ProcessInstance&lt;/SPAN&gt; &lt;SPAN class=""&gt;processInstance&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; runtimeService.startProcessInstanceByKey(&lt;SPAN class=""&gt;"my-process"&lt;/SPAN&gt;, variables);

        &lt;SPAN class=""&gt;// Verify that we started a new process instance&lt;/SPAN&gt;
        Long count= runtimeService.createProcessInstanceQuery().count();
        assertEquals(&lt;SPAN class=""&gt;"1"&lt;/SPAN&gt;, count.toString());
        &lt;SPAN class=""&gt;//Log.info("Number of process instances: " + runtimeService.createProcessInstanceQuery().count());&lt;/SPAN&gt;

    }
}&lt;/PRE&gt;&lt;P&gt;And the result is 0, wheres it was wiating for 1&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Jul 2022 09:24:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/junit-test-starting-a-processinstance-using-activiti-with/m-p/133899#M36048</guid>
      <dc:creator>letailla</dc:creator>
      <dc:date>2022-07-15T09:24:51Z</dc:date>
    </item>
  </channel>
</rss>

