Package net.fp.rp.jbpm

Source Code of net.fp.rp.jbpm.SimpleProcessTest

/**
*
*/
package net.fp.rp.jbpm;

import junit.framework.TestCase;

import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;

/**
* Test of a simple process
* @author paul.browne
* Copyright @link www.firstpartners.net/red
*/
public class SimpleProcessTest extends TestCase {

  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();
    assertEquals(
        "Instance is in first state",
        instance.getRootToken().getNode().getName(),
        "first");
    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!");

  }

}
TOP

Related Classes of net.fp.rp.jbpm.SimpleProcessTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.