set parametermap in munit

335 Views Asked by At

am facing difficult to set ParameterMap in munit. when i set http.uri.params in munit and its working fine normally. but unable to access its values though ParameterMap. please refer the following the MUnit code(which is working fine when i access #[message.inboundProperties.'http.uri.params'.serviceName] ) and Java Code

<munit:inbound-property key="http.uri.params" value="#[['serviceName': 'services','loanNumber':'1111']]"/>

this is how i am accessing http.uri.params In My code

ParameterMap pMap = eventContext.getMessage().getInboundProperty("http.uri.params");

so when i run munit ,above line throws exception (java.util.HashMap cannot be cast to org.mule.module.http.internal.ParameterMap)

is there any way set parametermap in munit without changing my code?

1

There are 1 best solutions below

3
On

If you really cannot change your code to not depend on ParameterMap. Then you could try creating the ParameterMap instance in your Munit code. It has an overlaoded constructor that allows passing a map to it:

<munit:inbound-property key="http.uri.params" value="#[new org.mule.module.http.internal.ParameterMap((['serviceName': 'services','loanNumber':'1111']))]"/>

Java doc: https://www.mulesoft.org/docs/site/3.7.0/apidocs/org/mule/module/http/internal/ParameterMap.html