Hello,

In my junit code, I constructed a decision node and added transitions to it. 
But I do not know how to add the decision handlers. The purpose of this unit 
test is to prove all node classes can be created programmatically. Here is my 
junit test code. The AmountDecisionHandler is a  DecisionHandler and always 
returns "forwardTo" value on decision method.
Please help me.



    ProcessDefinition processDefinition =  
ProcessDefinition.createNewProcessDefinition();
    StartState startState = new StartState();
    startState.setName("start");
    processDefinition.addNode(startState);

    
    Decision amountcheck = new Decision();
    amountcheck.setName("amountcheck");
    processDefinition.addNode(amountcheck);
    
    State reenter = new State();
    reenter.setName("reenter");
    processDefinition.addNode(reenter);
    
    State increase = new State();
    increase.setName("increase");
    processDefinition.addNode(increase);
    
    EndState endState = new EndState();
    endState.setName("end");
    processDefinition.addNode(endState);
    
    
    Transition amountCheckTxns = new Transition();
    amountCheckTxns.setTo(amountcheck);
    
    
    Transition successTxns = new Transition();
    successTxns.setName("success");
    successTxns.setTo(increase);
    
     
    Transition failTxns = new Transition();
    failTxns.setName("fail");
    failTxns.setTo(reenter);
    
    Transition endTrans = new Transition();
    endTrans.setTo(endState);
    
    //bind transitions to node
    startState.addLeavingTransition(amountCheckTxns);
    amountcheck.addLeavingTransition(successTxns);
    amountcheck.addLeavingTransition(failTxns);
    reenter.addLeavingTransition(amountCheckTxns);
    increase.addLeavingTransition(endTrans);
    
    
    ProcessInstance processInstance = new ProcessInstance(processDefinition);
    AmountDecisionHandler.forwardTo ="success";
    // after the first signal the AmountDecisionHandler of amountcheck 
    // would be called. The handler forwards to increase node imediately.
    processInstance.signal();

    assertSame(processDefinition.getNode("increase"), 
processInstance.getRootToken().getNode());
    
    processInstance.signal();

    assertSame(processDefinition.getNode("end"), 
processInstance.getRootToken().getNode());
      
    processInstance = new ProcessInstance(processDefinition);
    
    //now forward to "fail" state
    AmountDecisionHandler.forwardTo ="fail";
    // after the first signal the AmountDecisionHandler of amountcheck 
    // would be called. The handler forwards to reenter node imediately.
    processInstance.signal();

    assertSame(processDefinition.getNode("reenter"), 
processInstance.getRootToken().getNode());
    
    AmountDecisionHandler.forwardTo ="success";
    processInstance.signal();

    assertSame(processDefinition.getNode("increase"), 
processInstance.getRootToken().getNode());
    


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3956626#3956626

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3956626


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to