Muzammal Nazir
Muzammal Nazir

Reputation: 1

How to mock "MuleSoft Anypoint Exchange" Custom API Connector using "Mock When" in MUnit?

I'm writing Munit for Proc-layer implementation flow which calls a sys-layer POST endpoint using Exchange API Connector (Sys-Layer RAML is published in Exchange for generating its connectors). When I add 'Mock when' for API Connector it does not mock the Connector and try to call the actual API endpoint.

I have tried the 'Mock When' by giving processor and doc:id and doc:name of API connector.

Following is my API connector XML code

<ol-smart-sys-property:create-announcement-by-code doc:name="Create announcement by code" doc:id="88b6e101-5999-4b11-b2ed-aeaee9ae5bd4" code="#[vars.code]" config-ref="Ol_smart_sys_property_Config"/>

Following is the Mock when XML code

<munit-tools:mock-when doc:name="Mock when" doc:id="8421e6fc-564e-44ea-94fe-78edbd1a979d" processor="ol-smart-sys-property:create-announcement-by-code">
    <munit-tools:with-attributes >
        <munit-tools:with-attribute attributeName="doc:id" whereValue="88b6e101-5999-4b11-b2ed-aeaee9ae5bd4" />
    </munit-tools:with-attributes>
    <munit-tools:then-return ></munit-tools:then-return>
</munit-tools:mock-when>

Upvotes: 0

Views: 342

Answers (1)

Diego Strubolini
Diego Strubolini

Reputation: 66

Does removing the with-attributes section of the mock work? I believe there is a bug currently in the runtime which makes a Raml-based connector unable to be mocked by MUnit when specifying attributes

Upvotes: 1

Related Questions