Search code examples
mulemunit

Specifying Mule Message Collection as payload in MUnit Mock Processor


In MUnit Mock Message Processor how do we specify a non specific payload such as Mule Message Collection (comma separated XML data) in the return with message payload field.

In general if we just hard code the value, it would be taken as a string which makes it difficult to read it further.

How can we specify the data type as Mule Message Collection ?

Please help me out with this .

Thanks in Advance.


Solution

  • Use MEL expressions to create a collection. Based on your example a comma separated list of strings, you can use MEL with any Java/MVEL operations to create a list from that:

    <mock:then-return payload="#[Arrays.asList(('${mycommaseparatedlistofstrings}'.split(',')))]" />