munit

Munit 2.1 mock a Map response


I am writing a MUnit testcase and I need to mock the response normally achieved from an external system. Therefor I have created a mock-when:

        <munit-tools:mock-when doc:name="Mock when" doc:id="310d8979-9451-4767-a344-dfa190fb9c79" processor="dummy">
            <munit-tools:then-return >
                <munit-tools:payload value="#[['a':'1000013','b':'900154196']]" mediaType="application/java"/>                  
            </munit-tools:then-return>
        </munit-tools:mock-when>

I would like to achieve to goal of having a map with these key value pairs: key a having value 1000013 key b having value 900154196 as payload

Question: How do I need to write this in the munit-tools:payload

What I have currently allows my dataweave to select the first value, but it's not picking up the second value. This I have tested by changing #[['a':'1000013','b':'900154196']] to #[['b':'900154196','a':'1000013']] in the munit-tools:payload...

I am using Munit 2.1 in AnypointStudio 7.


Solution

  • The issue might be your syntax. Have you tried this instead:

    #[[{'a':'1000013'}, {'b':'900154196'}]]