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

# Set Event Processor

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

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/2.3/test-mock-errors-cookbook)

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

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