---
schema_version: "1"
id: 788915b6c51272097ce6c2a583683f2cf7454bf4453c8311528aaf0d3eb75f10
title: Run Custom Event Processor
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/2.3/run-custom-event-processor.md
canonical_url: https://docs.mulesoft.com/munit/2.3/run-custom-event-processor
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7d5c9a80ad90a4bbee561b6668a4aa80d05cbd0989a34f27446bf66dc11db4ad
description: MuleSoft Documentation Site
release: "2.3"
latest: false
---
---
product: MUnit
version: 2.3
keywords: mule, esb, tests, qa, quality assurance, verify, functional testing, unit testing, stress testing
---

# Run Custom Event Processor

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

The **Run Custom event processor** enables you to assert the Mule event content against a custom
assertion.

To add the **Run Custom processor** to your project, add the following dependency to your `pom.xml`
file:

```xml
<dependency>
    <groupId>com.mulesoft.munit</groupId>
    <artifactId>munit-assert</artifactId>
    <version>${munit.version}</version>
    <scope>test</scope>
</dependency>
```

You also have to add your custom assertion class to the `mule-artifact.json` file as an exported
resource.

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

```java
package org.mule.custom;
import org.mule.munit.assertion.api.MunitAssertion;
import org.mule.munit.assertion.api.TypedValue;

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");
        }
     }

}
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>Implement the only method in the interface <code>public void execute(TypedValue expression, Object params) throws AssertionError</code>.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>Run your custom logic, which in this case validates that the message payload is <code>Hello World</code>.</td></tr></tbody></table>

The `CustomAssertion` class must be located in the scr/test/java directory.

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

```xml
<munit-tools:run-custom
  assertion="org.mule.custom.CustomAssertion" (1)
  expression="#[payload]"/>
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>The assertion field needs to have the canonical class name of your custom assertion and the class needs to be exported.</td></tr></tbody></table>

To export it when packaging your application, add the `org.mule.custom` package to your
`mule-artifact.json`

```json
{
  "name": "mule-application",
  "minMuleVersion": "4.2.0",
  "classLoaderModelLoaderDescriptor": {
    "id": "mule",
    "attributes": {
      "exportedPackages": ["org.mule.custom"]
    }
  }
}
```

> [!NOTE] You only need to configure the package name in the `exportedPackages` collection.

## See Also

- [MUnit Matchers](https://docs.mulesoft.com/munit/2.3/munit-matchers)

- [Assert That Event Processor](https://docs.mulesoft.com/munit/2.3/assertion-event-processor)

- [Set Event Processor](https://docs.mulesoft.com/munit/2.3/set-event-processor)

- [Mock When Event Processor](https://docs.mulesoft.com/munit/2.3/mock-event-processor)

- [Verify Event Processor](https://docs.mulesoft.com/munit/2.3/verify-event-processor)

- [Fail Event Processor](https://docs.mulesoft.com/munit/2.3/fail-event-processor)
