---
schema_version: "1"
id: 8c1c666e6dbd837543b50dafe4c2bd1fe67bdd8e61ae697032392b16552d5eea
title: Set Event Processor
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/munit/3.6/set-event-processor.md
canonical_url: https://docs.mulesoft.com/munit/3.6/set-event-processor
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2b9c388fd62db5c27e99f2c65814c1324bb165acaf9275730942bd0d435dbca6
description: MuleSoft Documentation Site
release: "3.6"
latest: false
---
---
product: MUnit
version: 3.6
keywords: munit, testing, unit testing
---

# Set Event Processor

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

![logo acb active](/mulesoft/current/en-us/_/img/icons/anypoint-code-builder.svg "Anypoint Code Builder")Anypoint Code
Builder

![logo studio active](/mulesoft/current/en-us/_/img/icons/studio.svg "Anypoint Studio")Anypoint Studio

The Set Event Processor allows you to define a Mule Event.  
This message processor is normally used at the beginning of an MUnit test, to define the first
message to send to the flow being tested.

The example below shows how to define a simple payload of a Mule Message:

```xml
<munit:set-event cloneOriginalEvent="false">
  <munit:payload value="#['payload_value']" mediaType="text/plain" encoding="UTF-8"/>
</munit:set-event>
```

The set-event has the cloneOriginalEvent property. If set to true, it clones the event produced by
your code.  
By default, the value of this property is false.

The payload element in the Set Event processor has the following attributes:

<table><colgroup><col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>value</code></p></td><td><p>Defines the value of the payload’s message.</p></td></tr><tr><td><p><code>encoding</code></p></td><td><p>Defines the encoding of the message. This attribute is optional.</p></td></tr><tr><td><p><code>mediaType</code></p></td><td><p>Defines the mime type of the message. This attribute is optional.</p></td></tr></tbody></table>

You can also use the Set Event processor to define message attributes and event variables:

```xml
<munit:set-event cloneOriginalEvent="false">
  <munit:payload value="#['Example Body']" mediaType="text/plain" encoding="UTF-8"/>

  <munit:attributes value="#[{ method : 'GET', queryParams : { page : '1'}}]" />

  <munit:variables>
    <munit:variable key="variable_key" value="#['example']" mediaType="text/plain" encoding="UTF-8"/>
  </munit:variables>
</munit:set-event>
```

All the properties have the same set of attributes:

<table><caption>Table 1. Property Message Processor’s Attributes</caption> <colgroup><col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>key</code></p></td><td><p>The key of the property being set.</p></td></tr><tr><td><p><code>value</code></p></td><td><p>The content of the property.</p></td></tr><tr><td><p><code>encoding</code></p></td><td><p>Defines the encoding of the message. This attribute is optional.</p></td></tr><tr><td><p><code>mediaType</code></p></td><td><p>Defines the mime type of the message. This attribute is optional.</p></td></tr></tbody></table>

You can define as many properties per each scope as you need for your test.

> [!WARNING] If you define two properties in the same scope with the _same_ key, be aware that one
> would end up overwriting the other.

## See Also

- [Testing and Mocking Errors](https://docs.mulesoft.com/munit/3.6/test-mock-errors-cookbook)

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

- [Run Custom Event Processor](https://docs.mulesoft.com/munit/3.6/run-custom-event-processor)
