Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

About Run Custom Event Processor

The Run Custom Event Processor allows you to assert the Mule Event content against a custom assertion.

For example, you can define the following assertion in JAVA:


         
      
1
2
3
4
5
6
7
8
9
10
public class CustomAssertion implements MunitAssertion {

    @Override
    public void execute(TypedValue expression, Object params) throws AssertionError { (1)
        if (!"Hello World".equals(expression.getValue())) { (2)
            throw new AssertionError("Error the payload is incorrect");
        }
     }

}
1 Implement the only method in the interface public void execute(TypedValue expression, Object params) throws AssertionError
2 Run your custom logic, which in this case validates that the message’s payload is Hello World.

And then use the Run Custom Event Processor to run it:


         
      
1
2
3
<munit-tools:run-custom
  assertion="com.example.CustomAssertion" (1)
  expression="#[payload]"/>
1 The assertion field needs to have the canonical class name of your custom assertion.

In this topic: