2 Replies Latest reply on Mar 16, 2006 9:52 AM by d b

    basic process workflow question

    d b Newbie

      I have created a basic process
      Start State-> Node -> Task Node -> End State

      when I start the process, it will go from directly to End State after I have called instance.signal() once.
      I was expecting it to stop once by Node and once more by Task Node, have I misunderstood how it works?







      below is the sources, the same as the default process, changed very little

      (replace {} with lt/gt)

      {process-definition}
      xmlns="urn:jbpm.org:jpdl-3.1"
      name="simple"}

      {start-state name="start"}
      {task}
      {controller}
      {variable name="color" /}
      {variable name="size" /}
      {/controller}
      {/task}
      {transition name="tr1" to="startpoa"}
      {action name="action" class="com.sample.action.MessageActionHandler"}
      {message}Going to the startpoa state!{/message}
      {/action}
      {/transition}
      {/start-state}

      {node name="startpoa"}
      {transition name="tr2" to="applicant approve"}
      {action name="action1"}{/action}
      {/transition}
      {/node}

      {task-node name="applicant approve"}
      {transition name="tr3" to="end"}{/transition}
      {/task-node}

      {end-state name="end"}{/end-state}

      {/process-definition}

      public void testSimpleProcess() throws Exception {

      // Extract a process definition from the processdefinition.xml file.
      ProcessDefinition definition =
      ProcessDefinition.parseXmlResource("simple.par/processdefinition.xml");
      assertNotNull("Definition should not be null", definition);

      // Create an instance of the process definition.
      ProcessInstance instance = new ProcessInstance(definition);

      assertEquals(
      "Instance is in start state",
      instance.getRootToken().getNode().getName(),
      "start");
      assertNull(
      "Message variable should not exist yet",
      instance.getContextInstance().getVariable("message"));

      // Move the process instance from its start state to the first state.
      // The configured action should execute and the appropriate message
      // should appear in the message process variable.

      instance.signal();

      //THIS TEST FAILS, the node name is "end" and not "startpoa" as I expected
      assertEquals(
      "Instance is in the first node",
      "startpoa",
      instance.getRootToken().getNode().getName()
      );
      assertEquals(
      "Message variable contains message",
      instance.getContextInstance().getVariable("message"),
      "Going to the first state!");

      // Move the process instance to the end state. The configured action
      // should execute again. The message variable contains a new value.
      instance.signal();

      assertEquals(
      "Instance is in end state",
      instance.getRootToken().getNode().getName(),
      "end");
      assertTrue("Instance has ended", instance.hasEnded());
      assertEquals(
      "Message variable is changed",
      instance.getContextInstance().getVariable("message"),
      "About to finish!");

      }