Adsense

April 05, 2020

Munit validation for Multipart message - Mule4


In this article, I will try to show how we can write and execute MUnit validation for Multipart messages.

Mulesoft provide functions for creating MultiPart and formats and parts (including fields and boundaries) of MultiPart formats.

Below header needs to be added while using dataweave scripts to create multipart messages.

%dw 2.0
import dw::module::Multipart
output multipart/form-data




You will find a github link for sample project at the end of this article.

Now let us understand how we can parse and validate Multipart messages using Munit.

Multipart message formats doesn't provide flexibility for normal traversing to validate the transformation or output. To validate multipart message we need to transform the message with "application/java" format as highlighted below.

%dw 2.0 output application/java input payload multipart/form-data --- payload.parts


Validate size with function sizeOf():




Validate content:




https://github.com/manishkumarsah/multipart-munit-validation-mule4

Happy Learning :)

No comments:

Post a Comment