Setting flow variables in MUnit with java

I am implementing MUnit with java for a mule flow. The flow is having a flow variable who's value is being derived from a variable in another flow. So, I need to have this value set in java which would be run as Junit.

Please let me know how do we set flow/session variables in Java that will be testing the mule flow.

Thanks in advance.

Upvotes: 0

Views: 3941

Answers (3)

David Whitehurst
David Whitehurst

Reputation: 352

Like this:

    <set-session-variable doc:name="Session Variable" value="#[flowVars.acme_id]" variableName="myVar"/>
    <set-variable variableName="munit-json-payload" value="#[getResource('testData/good-response.json').asString()]" doc:name="Variable"/>

Upvotes: 0

Manish
Manish

Reputation: 11

We can set it by using eventcontext as below:

eventContext.getMessage().setInvocationProperty(key, value);

So , you can access that flow variable by key anywhere.

Upvotes: 0

Manik Magar
Manik Magar

Reputation: 1401

You can set variables on test message. Check this post - https://unittesters.com/blog/mule-munit-testing-variables-properties/

Upvotes: 1

Related Questions