Package net.fp.rp.jbpm

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

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

import java.util.List;

import net.fp.rp.spring.SpringStarter;

import org.apache.log4j.Logger;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import junit.framework.TestCase;

/**
* @author paul.browne
* Copyright @link www.firstpartners.net/red
*/
public class DroolsDecisionHandlerTest extends TestCase {

  /**
   * Where to find the Spring Context that we use for testing
   */
  public static final String TEST_APP_CONTEXT="core/test/net/fp/rp/jbpm/DroolsDecisionHandlerTest-AppContext.xml";
 
  /**
   * The Name of the Spring Bean under test
   */
  public static final String TEST_BEAN="StartWorkFlowBean";
 
   /** Logger for this class and subclasses */
    protected final Logger log = Logger.getLogger(getClass());
 
    //The application context used by this test
    ApplicationContext context = null;
   
  public void setUp() throws Exception{
   
    context = new FileSystemXmlApplicationContext(TEST_APP_CONTEXT);
  }
 
  public void testTransition1() throws Throwable{
   
     //Start the Workflow
        SpringStarter myBean  = (SpringStarter) context.getBean(TEST_BEAN);
       
        //Depends on it being configure in the App-Context to be an instance of this class
        ParameterWorkflowStrategy pStrat = (ParameterWorkflowStrategy) myBean.getStarterStrategy();
        pStrat.param1="test";
        pStrat.param2="TestInput1";
               
        myBean.startWorkflow();
       
        //Now Carry out some assertions
        List<ExecutionContext> execList = TestActionHandler.getPreviousExecutions();
        assertEquals(1,execList.size());
       log.debug("NodeName:"+execList.get(0).getNode().getName());
       log.debug("Output:"+execList.get(0).getContextInstance().getVariable(DroolsDecisionHandler.OUTPUT_TRANSITION_NAME));
       assertEquals("two",execList.get(0).getContextInstance().getVariable(DroolsDecisionHandler.OUTPUT_TRANSITION_NAME));
       
  }
 
  public void testTransition2() throws Throwable{
   
     //Start the Workflow
        SpringStarter myBean  = (SpringStarter) context.getBean(TEST_BEAN);
       
        //Depends on it being configure in the App-Context to be an instance of this class
        ParameterWorkflowStrategy pStrat = (ParameterWorkflowStrategy) myBean.getStarterStrategy();
        pStrat.param1="test";
        pStrat.param2="TestInput2";
               
        myBean.startWorkflow();
       
        //Now Carry out some assertions
        List<ExecutionContext> execList = TestActionHandler.getPreviousExecutions();
        assertEquals(2,execList.size());
       log.debug("NodeName:"+execList.get(1).getNode().getName());
       log.debug("Output:"+execList.get(1).getContextInstance().getVariable(DroolsDecisionHandler.OUTPUT_TRANSITION_NAME));
       assertEquals("three",execList.get(1).getContextInstance().getVariable(DroolsDecisionHandler.OUTPUT_TRANSITION_NAME));
   
   
  }
 
}
TOP

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

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.