[jboss-user] [jBPM] - Unit Testing/Checking Variables

Timothy Charman do-not-reply at jboss.com
Fri Apr 20 02:55:11 EDT 2012

Timothy Charman [https://community.jboss.org/people/tcharman] created the discussion

"Unit Testing/Checking Variables"

To view the discussion, visit: https://community.jboss.org/message/731239#731239

Hello All

Sorry to ask this, but I've looked around and haven't seen how to do this.

I have a simple unit test using JbpmJUnitTestCase.  I want to validate my custom work handlers, so I have created a BPMN2 workflow with a work handler in it.  The work handler takes in some parameters and has results that are mapped to a variable.  I know that it is generally working correctly as I can put a script task after the custom task to output the variables to the console.  My unit test creates a parameter map and launches the flow:

 | ProcessInstance processInstance = knowledgeSession.createProcessInstance("testprocess", parameterMap); |
 | knowledgeSession.startProcessInstance(processInstance.getId()); |

I know I can do this in one step using the startProcess method.  This method above works, as does the startProcess method.

I am also able to successfully assert, e.g.:

However by this time the processInstance is completed (per the assertation).  So the variable context has been destroyed and I cannot use standard JUnit asserts to validate the output, retreived using getVariableValue.

So does anyone have an idea how I am meant to get variables from the context after the flow is complete?  Or am I meant to watch the variables while the flow is happening, maybe through an event listener?

Thanks for any help.

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120420/6dc0d7a7/attachment.html 

More information about the jboss-user mailing list