Nav

Migrating the Mock Processor (MUnit)

  1. The name of the processor has changed from when to mock-when.

  2. The attribute messageProcessor has change to processor.

  3. In the child node with attribute the attribute name has changed to attributeName.

  4. In the child node then-return the attribute payload must now be a child node.

  5. The child node invocation-properties has changed variables.

  6. We’ve added support for session properties, attributes, errors.

Mock Processor Syntax for MUnit 1.x

         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<mock:when messageProcessor="mule:set-payload">
  <mock:with-attributes>
    <mock:with-attribute name="doc:name" whereValue="#['Hello world!']" />
  </mock:with-attributes>
  <mock:then-return payload="#['mocked_payload']">
    <mock:invocation-properties>
      <mock:invocation-property key="property_name" value="#['property_value']"/>
    </mock:invocation-properties>
    <mock:inbound-properties>
      <mock:inbound-property key="property" value="#['propertyValue']"/>
    </mock:inbound-properties>
    <mock:outbound-properties>
          <mock:outbound-property key="property" value="#['propertyValue']"/>
        </mock:outbound-properties>
  </mock:then-return>
</mock:when>
Mock Processor Syntax for MUnit 2.x

         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<munit-tools:mock-when processor="mule:set-payload">
  <munit-tools:with-attributes>
    <munit-tools:with-attribute attributeName="value" whereValue="#['Hello world!']"/>
  </munit-tools:with-attributes>
  <munit-tools:then-return>
    <munit-tools:payload value="#['expectedPayload']"/>
    <munit-tools:attributes value=""/>
    <munit-tools:error id="" exception=""/>
    <munit-tools:variables>
       <munit-tools:variable key="#['aVariable']" value="#['aVariableValue']"/>
    </munit-tools:variables>
    <munit-tools:session-properties>
            <munit-tools:property key="#['aSessionProperty']" value="#['aSessionPropertyValue']"/>
    </munit-tools:session-properties>
    <munit-tools:inbound-properties>
       <munit-tools:property key="#['aInboundProperty']" value="#['aInboundPropertyValue']"/>
    </munit-tools:inbound-properties>
    <munit-tools:outbound-properties>
      <munit-tools:property key="#['aOutboundProperty']" value="#['aOutboundPropertyValue']"/>
    </munit-tools:outbound-properties>
    <munit-tools:inbound-attachments>
      <munit-tools:attachment key="#['aInboundAttachment']" value="#['aInboundAttachmentValue']"/>
    </munit-tools:inbound-attachments>
    <munit-tools:outbound-attachments>
      <munit-tools:attachment key="#['aOutboundAttachment']" value="#['aOutboundAttachmentValue']"/>
    </munit-tools:outbound-attachments>
  </munit-tools:then-return>
</munit-tools:mock-when>

In this topic: