to mocked the behavior of the message processor. Basically, MUnit replace the actual behavior of message processor with the behavior define by us. There are various scenarios where we can use the Mock Message processor. We have completed the development of your mule application and need to test the application but in our application there is database connector in message processor region and database is not ready to accept the any request and we still want to test the application. In such cases, we can mock the normal database connector behavior.
are connecting to JMS queue but JMS is not ready and want to test the application. In such cases again, we can make use of mock message processor. Let's walkthrough how to use mock component in MUnit test. Below is the flow for which we will going to create MUnit tests and will mock set-payload component.
Drop Mock component in the setup region of MUnit test. when messageProcessor is used to specify the message processor to be mocked. In this case, we have mock set-payload component.
more than one similar component (i.e. 2 set-payload) in our mule flow but we want to mock only one set payload. In that case we need to add attributes in Mock component which accept name and value of message processor. Below is the Mule flow having 2 set-payload and we need to mock only one component.
and it cannot be MEL expressions. • whereValue is the value that the attribute of the real message processor should contain. It accepts MEL expressions.