1

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.

1 Answers1

2

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(',')))]" />
Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
  • Thanks Ryan for your suggestion. It does seem to be working now. I have one more concern. I am implementing MUnit for a flow which will have Mule Message Collection as return payload for one of the processors. So this collection has a very large XML Data. If I hard code this data for testing , I get a stack over flow error. Is there any way I can resolve this ? – Shivchetan Sambaragimath Jun 23 '16 at 10:54
  • If the XML is large you can read it from a file on the classpath for example. Munit has helper functions for this: #[getResource(xml/myxmlfile.xml').asString()]. For more detailed answers I would create another question. – Ryan Carter Jun 23 '16 at 10:58