I have a Mule app which checks the payload's size using the contentLength metadata selector:
payload.^contentLength <= 512
When I regularly send a request to the Mule app (using Postman / SoapUI), the app works correctly.
However, when I use MUnit Set Event with the same payload, I get the following error:
org.mule.munit.runner.model.TestExecutionException: Error [MULE:EXPRESSION] while running test 'poc7-test-suite-api-mainTest':"Types `Null` and `Number` can not be compared.
Trace:
at main (Unknown)" evaluating expression: "payload.^contentLength <= 512".
So contentLength was not populated. How can I set it for the test?
If it helps, my MUnit Set Event is defined as follows (using the example from MuleSoft's documentation):
<munit:set-event doc:name="Set Event" doc:id="f48cd1dc-c1bb-40f7-91fc-cc4438a93ad2" >
<munit:payload value='#[ %dw 2.0 output multipart/form-data ns soap http://schemas.xmlsoap.org/soap/envelope/ --- { parts: { part0: { headers: { "Content-Type": "text/xml", "Content-Length": "1602", "Content-ID": "<mm7-submit>" }, content: { soap#Envelope: "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <msg:outboundMessageRequest xmlns:msg=\"urn:oma:xml:rest:netapi:messaging:1\"> <address>tel:+19585550103</address> <address>tel:+19585550104</address> <senderAddress>tel:+19585550100</senderAddress> <senderName>MyName</senderName> <receiptRequest> <notifyURL>http://application.example.com/notifications/DeliveryInfoNotification/77777</notifyURL> <callbackData>12345</callbackData> </receiptRequest> <outboundMMSMessage> <subject>hello from the rest of us!</subject> <priority>High</priority> </outboundMMSMessage> <clientCorrelator>567895</clientCorrelator> </msg:outboundMessageRequest>" } }, part1: { headers: { "Content-Type": "multipart/mixed; boundary=\"------=_Part_2_3815517668157287202\"", "Content-Length": "1602", "Content-ID": "<attachment>" }, content: { parts: { part0: { headers: { "Content-Type": "text/plain; name=text1.txt", "Content-Length": "1602", "Content-ID": "<text1.txt>", "Content-Location": "bundled/text1.txt" }, content: "This is the text part I want to access\n" }, part1: { headers: { "Content-Type": "image/png", "Content-Transfer-Encoding": "base64", "Content-Length": "1602", "Content-ID": "<image.png>", "Content-Location": "bundled/image.jpg" }, content: "aGk=" } } } } } } ]' />
</munit:set-event>