I am writing MUnit for a flow like below
My Munit looks like
But when try to run i ma getting an exception like below . The XML in exception is the sample response given as thre payload value in mock response.
INFO 2021-02-16 21:31:22,142 [munit.01] org.mule.munit.runner.remote.api.server.RunnerServer: Client connection received from 127.0.0.1 - true
INFO 2021-02-16 21:31:22,495 [munit.01] org.mule.runtime.api.message.AbstractMuleMessageBuilderFactory: Loaded MuleMessageBuilderFactory implementation 'org.mule.runtime.core.internal.message.DefaultMessageBuilderFactory' from classloader 'java.net.URLClassLoader@42c28305'
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'abc-project-test-suiteTest':
Cannot create inner bean '(inner bean)#7f9a36d9' of type [org.mule.munit.runner.component.factory.TestProcessorChainFactory$$EnhancerByCGLIB$$7a5c86fd]
while setting bean property 'processorChains' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#7f9a36d9': Cannot create inner bean '(inner bean)#6d2da6c0' of
type [org.mule.runtime.module.extension.internal.config.dsl.operation.OperationMessageProcessorObjectFactory$$EnhancerByCGLIB$$7938fabb]
while setting bean property 'messageProcessors' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#6d2da6c0': Cannot create inner bean '(inner bean)#40ded42b' of type
[org.mule.runtime.module.extension.internal.config.dsl.parameter.TopLevelParameterObjectFactory$$EnhancerByCGLIB$$56b31a01]
while setting bean property 'parameters' with key [<<thenReturn>>]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#40ded42b': Cannot create inner bean '(inner bean)#138ef058' of type
[org.mule.runtime.module.extension.internal.config.dsl.parameter.TopLevelParameterObjectFactory$$EnhancerByCGLIB$$56b31a01]
while setting bean property 'parameters' with key [<<payload>>]; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name '(inner bean)#138ef058': FactoryBean threw exception on object creation;
nested exception is org.mule.runtime.core.api.config.ConfigurationException:
Element '<DRIVEResponse ResponseDateTime="2/15/2021 10:50:20 AM" TimeZone="EST">
<Mortgage appId="123456789">
<Errors>
<Error ErrorCode="1200" ErrorDesc="Another request is in Process .Please try after Some time." />
</Errors>
</Mortgage>
</DRIVEResponse>' is not defined in the Mule Registry
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:327)
Shekh Muenuddeen (NTTData) Forum Ambassador
Hey,
Thank you for your Munit Test Case, as I have store both request and response in the src/test/resources as below
Request
<?xml version='1.0' encoding='UTF-8'?>
<DRIVERequest Version="1.00">
<Authentication ID="****" Password="****" Username="******"/>
<BatchRequest>
<Mortgage id="123456789" Amount="1000">
<Property StreetAddress="Oaks Ave"/>
</Mortgage>
</BatchRequest>
</DRIVERequest>
Response
<?xml version='1.0' encoding='UTF-8'?>
<DRIVEResponse ResponseDateTime="2/15/2021 10:50:20 AM" TimeZone="EST">
<Mortgage appId="123456789">
<Errors>
<Error ErrorCode="1200" ErrorDesc="Another request is in Process .Please try after Some time."/>
</Errors>
</Mortgage>
</DRIVEResponse>
Used below expression in set event and mock component
#[MunitTools::getResourceAsString('DRIVERequest.xml')]#[MunitTools::getResourceAsString('DRIVEResponse.xml')]Please refer attached Munit Test case.
Regards,
Shekh