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

# MUnit 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 MUnit Set Event processor defines the initial Mule event, including payload, attributes, and
variables that a MUnit test sends to the flow under test. Use it at the beginning of an MUnit test
to set up the input conditions for your flow.

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

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

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