How to set headers before calling a sub-flow in MUnit 2.1.3 in Mule 4?

Setting Headers and UriParams in MUnit test case in Mule 4

Set Event Processor can be used to pass headers before calling any sub-flow in MUnit test flow.  Uri Parameters also can be set in the same way.


Headers

<munit:set-event doc:name="Set Event" doc:id="70453df1-e368-488b-abcc-f8522185dd4f">

       <munit:payload value="#['']" encoding="UTF-16" />

       <munit:attributes value="#[{headers : {'token' :'b536b9a9-5e11-4773-93d3-8c973519ad54','role' :'Administrator,User'}}]" encoding="UTF-16" />

</munit:set-event>

 

UriParams

<munit:set-event doc:name="Set Event" doc:id="70453df1-e368-488b-abcc-f8522185dd4f">

       <munit:payload value="#['']" encoding="UTF-16" />

       <munit:attributes value="#[{uriParams : {'id' :'123450','account-id' :'8474845'}}]" />

</munit:set-event>

 

And similarly, all other parameters can be set in the similar way.



 

Thanks
Jayaraman Pancharathinam
28 Nov 2018

Keywords: Mulesoft, Mule 4, MUnit 2.1.3, Anypoint Studio, Mocking, SOAP web service call, Transform processor  

Comments

  1. Hi .. this is very help full and understandable information.
    I got a situation to set the set event with headers and query params in a single setEvent component. Please help me in this.

    ReplyDelete
  2. Hi Thanks for informative article message.attributes.queryParams how set these values

    ReplyDelete

  3. Thanks for sharing useful information.. we have learned so much information from your blog..
    Mulesoft Training in Hyderabad
    Mulesoft Online Training

    ReplyDelete
  4. Thanks and I have a neat proposal: What Home Renovation Shows Are On Netflix home improvement near me

    ReplyDelete

Post a Comment

Popular posts from this blog

How to read xml file and set as mock response for an http web service call in MUnit 2.1.3 in Mule 4?

How to mock SOAP web service call with a SOAP message in MUnit 2.1.3?