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 🙂

By Manish Kumar

I am having around 10 years of IT experience in Integration Architecture, Requirement gathering, Effort Estimation, Application Design\Development\Testing and Deployment including 5+ years of experience in MuleSoft ESB and Hybrid Integrations. DevOps and Cloud Integration is my area of interest.

One thought on “Munit validation for Multipart message – Mule4”
  1. Hello! I could have sworn I’ve been to this site before but after checking through some of the post I realized it’s new to me. Nonetheless, I’m definitely glad I found it and I’ll be book-marking and checking back often!

Leave a Reply

Your email address will not be published. Required fields are marked *