I have an API on Anypoint Platform, it's important specs are:
- http scheme
- request endpoint = "retrieveInformation"
- queryParams = {"key": "value", isAllow: true}
I built the Mule flows using the RAML v1.0 having the above specs, and all functionality works fine. Now, I am trying to develop the mUnit for the mule flows. For a test case I set the below event and call flowReference to Mule flow.
#[{
headers: {
'client_space': 'ABCD-1234',
'client_code': 'XYZ-0001'
},
'queryParams': {
'key': '12345678',
'isAllow': true
},
'requestPath': '/api/retrieveInformation',
'rawRequestPath': '/api/retrieveInformation',
'requestUri': '',
'listenerPath': '/api/*',
'relativePath': '/retrieveInformation',
'method': 'GET',
'scheme': 'HTTP',
'version': 'HTTP/1.1',
'localAddress': '/127.0.0.1:8091',
'remoteAddress': ''
} as Object {
class: 'org.mule.extension.http.api.HttpRequestAttributes'
}]
Now running the units, APIKit:Router throws error i.e., cannot cast case from Boolean to String. If I change to " 'isAllow': 'true' ", then APIKit:Router throws valid error APIKIT:NOT_IMPLEMENTED.
Can anyone help how to achieve this scenario without changing API Specs?
Internal classes from the connector (
class: 'org.mule.extension.http.api.HttpRequestAttributes'
) are not meant to be used directly in tests. This is not a good idea to implement tests. It is better to try to resolve what error you had originally with the test creation. Be sure to be using the latest version of Studio.There may be a problem with the API. If it still fails you can create a test suite for a simpler API and then use it as an example on how to build your test cases manually using the HTTP Requester instead of trying to mock the requests. Example: