Search code examples
javaregexmulemunit

How to use regular expression in Mule MUnit java test attribute withValue


I have java Munit test in which I am verifying call to <file:outbound-endpoint> like this:

verifyCallOfMessageProcessor("outbound-endpoint")
    .ofNamespace("file")
    .withAttributes(attribute("path").withValue("/data/local/"),
                    attribute("outputPattern").withValue("vendor_customer_*"))
    .times(1)
    ;

This snippet is supposed to test below Mule code:

<file:outbound-endpoint path="${root.drive}"
                outputPattern="vendor_customer_#[server.dateTime.format('YYYY_MM_dd_hh_mm_ss.sss')].csv" />

How to use regular expression in attribute("outputPattern").withValue("vendor_customer_*")) to say that attribute value startsWith vendor_customer_

I am using MUnit 3.5 with Mule 3.4.2


Solution

  • There is no RegEx support for the attribute value. You need put exactly what the value will be. Please take a look at: https://docs.mulesoft.com/mule-user-guide/v/3.7/the-mock-message-processor#matchers

    As a side note, please notice that MUnit provides no support for testing Mule 3.4.

    HTH