[jboss-user] [JBoss jBPM] - Re: JBPM Nested Fork/Joins Doesn't seem to work

philsegal do-not-reply at jboss.com
Mon Jun 8 08:59:09 EDT 2009


Thanks, Junit and jbpm xml file are below.


package com.jpmorgan.orion.workflow.ny;

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

import com.jpmorgan.orion.workflow.service.BaseManagerTestCase;

/**
 * Phil Segal
 * @date @14 May 2009
 */
public class JoinsTest extends BaseManagerTestCase {

	@Test
	public void testNoAdjustments() throws Exception {
		ProcessDefinition def = ProcessDefinition.parseXmlResource("workflow/ny-workflow-2/processdefinition.xml");
		
		assertNotNull("Definition should not be null", def);
		
		ProcessInstance instance = new ProcessInstance(def);
		assertEquals("Def should be at start",
				"start-daily-pnl",
				instance.getRootToken().getNode().getName());

		instance.signal("default");
		
		instance.getRootToken().getChild("signoff").signal("signoff pnl");
		instance.getRootToken().getChild("propose").signal("cancel fork1");
		
		assertEquals("Def should be at auto approve",
				"auto-signoff-adj",
				instance.getRootToken().getNode().getName()
			);
		instance.signal("leave-asa");

		assertEquals("Def should be at ds feeds",
				"downstream-feeds",
				instance.getRootToken().getNode().getName());
		instance.signal("leave-dsf");
		
		assertEquals("Def should be at fork 3",
				"fork3",
			instance.getRootToken().getNode().getName());
		
		instance.getRootToken().getChild("reviewed").signal("review");
		instance.getRootToken().getChild("unsignoff").signal("cancel");
		
//		instance.signal();
		
		assertTrue("Instance has ended", instance.hasEnded());
	}
	
	@Test
	public void testWithAdjustmentsProcessNoApprove() throws Exception
	{
		ProcessDefinition def = ProcessDefinition.parseXmlResource("workflow/ny-workflow-2/processdefinition.xml");
		
		assertNotNull("Definition should not be null", def);
		
		ProcessInstance instance = new ProcessInstance(def);
		assertEquals("Def should be at start",
				"start-daily-pnl",
				instance.getRootToken().getNode().getName());

		instance.signal("default");
		
		instance.getRootToken().getChild("propose").signal("propose an adjustment");
		
		assertEquals("Def should be at fork2",
				"fork2",
				instance.getRootToken().getChild("propose").getNode().getName());
		
		instance.getRootToken().getChild("propose").getChild("propose").signal("cancel");
		instance.getRootToken().getChild("propose").getChild("approve").signal("cancel");

		assertEquals("child should be at join1",
				"join1",
				instance.getRootToken().getChild("propose").getNode().getName());
		assertEquals("parent should be at fork1",
				"fork1",
				instance.getRootToken().getNode().getName());
		
		instance.getRootToken().getChild("signoff").signal("signoff pnl");
		
		assertEquals("Def should be at auto approve",
				"auto-signoff-adj",
				instance.getRootToken().getNode().getName()
			);
		
	}
	@Test
	public void testWithMultipleAdjustmentsProcessNoApprove() throws Exception
	{
		ProcessDefinition def = ProcessDefinition.parseXmlResource("workflow/ny-workflow-2/processdefinition.xml");
		
		assertNotNull("Definition should not be null", def);
		
		ProcessInstance instance = new ProcessInstance(def);
		assertEquals("Def should be at start",
				"start-daily-pnl",
				instance.getRootToken().getNode().getName());
		
		instance.signal("default");
		
		instance.getRootToken().getChild("propose").signal("propose an adjustment");
		
		assertEquals("Def should be at fork2",
				"fork2",
				instance.getRootToken().getChild("propose").getNode().getName());
		
		instance.getRootToken().getChild("propose").getChild("propose").signal("propose an adjustment");

//		Use either just cancel, or both approve and default signals for approve signalling...
//		instance.getRootToken().getChild("propose").getChild("approve").signal("cancel");
		instance.getRootToken().getChild("propose").getChild("approve").signal("approve");
		instance.getRootToken().getChild("propose").getChild("approve").signal("default");

		
		instance.getRootToken().getChild("propose").getChild("propose").getChild("propose").signal("cancel");
		instance.getRootToken().getChild("propose").getChild("propose").getChild("approve").signal("cancel");
		
		assertEquals("propose/propose should be at join1",
				"join1",
				instance.getRootToken().getChild("propose").getChild("propose").getNode().getName());
		assertEquals("propose/approve should be at join2",
				"join2",
				instance.getRootToken().getChild("propose").getChild("approve").getNode().getName());

		assertEquals("parent should be at fork1",
				"fork1",
				instance.getRootToken().getNode().getName());

		assertEquals("propose should be at join1",
				"join1",
				instance.getRootToken().getChild("propose").getNode().getName());
		

		instance.getRootToken().getChild("signoff").signal("signoff pnl");
		assertEquals("signoff should be at join1",
				"join1",
				instance.getRootToken().getChild("signoff").getNode().getName());
		
//		instance.getRootToken().getChild("propose").getChild("propose").getChild("propose").signal("cancel");
//		instance.getRootToken().getChild("propose").getChild("propose").getChild("propose").signal("propose an adjustment");
//		instance.getRootToken().getChild("propose").getChild("propose").getChild("propose").getChild("propose").signal("cancel fork1");
//		instance.getRootToken().getChild("propose").getChild("propose").getChild("approve").signal("cancel fork1");
//		instance.getRootToken().getChild("propose").getChild("propose").getChild("propose").getChild("approve").signal("cancel fork1");
		
		assertEquals("Def should be at auto approve",
				"auto-signoff-adj",
				instance.getRootToken().getNode().getName()
		);
		
	}

}


____________________________________________________
processdefinition

<?xml version="1.0" encoding="UTF-8"?>

<process-definition  xmlns=""  name="ny-workflow-2">

	<start-state name="start-daily-pnl">
		
	</start-state>

	<task-node name="signoff-pnl">
		
			<!-- timer name="signoff-timer" duedate="1 minute" repeat="true">
				<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
					signOffTimerAction
					jbpmConfiguration
				
			</timer-->
			<assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
				pnlSignOffMOAssignmentHandler
				jbpmConfiguration
			
			
				<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
					signOffMultiAction
					jbpmConfiguration
				
			
		
		
			<!-- cancel-timer name="signoff-timer"/-->
		
	</task-node>

	<task-node name="propose-adjustments">
		
			<assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
				proposeAdjustmentAssignmentHandler
				jbpmConfiguration
			
			
				<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
					proposeAdjustmentsAction
					jbpmConfiguration
				
			
		
		
		
		
	</task-node>

	<task-node name="approve-reject-adj">
		
			<assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
				approveRejectAdjustmentAssignmentHandler
				jbpmConfiguration
			
		
		
		
		
		
	</task-node>

	<!--  Reject select adjustment(s) -->
	
		<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
			rejectAdjustmentsAction
			jbpmConfiguration
		
		
	

	<task-node name="review">
		
			<assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
				reviewPnlAssignmentHandler
				jbpmConfiguration
			
			
				<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
					reviewPnlAction
					jbpmConfiguration
				
			
		
		
	</task-node>

	
		<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
			autoApproveAdjustmentsAction
			jbpmConfiguration
		
		
	

	
		
		
	

	
		
		
	

	
		<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
			approveAdjustmentsAction
			jbpmConfiguration
		
		
	

	
		
	

	
		<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
			downstreamFeedsAction
			jbpmConfiguration
		
		
	

	<task-node name="unsignoff-pnl">
		
			<assignment config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
				pnlSignOffMOAssignmentHandler
				jbpmConfiguration
			
			
				<action config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandler">
					unsignoffAction
					jbpmConfiguration
				
			
			<!-- timer name="unsignoff-timer" duedate="1 business second" repeat="true">
				<action class="org.springmodules.workflow.jbpm31.JbpmHandler" config-type="bean">
					unsignOffTimerAction
					jbpmConfiguration
				
			</timer-->
		
		
			<!--cancel-timer name="unsignoff-timer"/-->
		
		
			<!--cancel-timer name="unsignoff-timer"/-->
		
	</task-node>

	
		
		
	

	
		
	

	
		
	

	<end-state name="end-daily-pnl"></end-state>

</process-definition>


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

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



More information about the jboss-user mailing list