パターンNo.1 Sequence

まずは基本パターンから。フローはこちら。f:id:wkzk:20060915023350j:image
で、そのXMLソースはこちら。



  
   
    
     
     
    
   
   
    
     Going to the first state!
    
   
  
  
   
    
     About to finish!
    
   
  
  

で、実装はこちら。

public class SimpleProcessTest extends TestCase {

  /**
   * パターン1:Sequence
   */
   public void testSimpleProcess() throws Exception {

    FileInputStream fis = new FileInputStream("processes/simple/processdefinition.xml");
    ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(fis);

    // プロセスインスタンス作成
    processInstance instance = new ProcessInstance(processDefinition);
    assertEquals("start stateなのだ",instance.getRootToken().getNode().getName(), "start");

    // 遷移しなさい!
    instance.signal();
    assertEquals("first stateなのだ",instance.getRootToken().getNode().getName(), "first");

    // さらに遷移しなさい!
    instance.signal();
    assertEquals("Instance is in end state",instance.getRootToken().getNode().getName(), "end");
    assertTrue("Instance has ended", instance.hasEnded());

  }
}