I have a flow I wish to test. The flow has an HTTP inbound connector, and the flow itself acts as a RESTful service.
The flow expects a few URL parameters to be set, and accesses these throughout using the standard notation: #[message.inboundProperties.'http.query.params'.test]
.
I am wanting to test this flow using MUnit. When I create a default MUnit test against the flow, MUnit creates a flow-ref to call my original flow. Running this test immediately fails however, because the flow expects to be called by HTTP, and expects the URL parameters set.
This is where I'm at now. I wish to set these variables before calling the flow-ref, so that my flow can process normally.
I have tried a few things:
- using the
munit:set
component, which allows one to set various properties - manually instantiating a
MessagePropertyMapContext
and assigning it to thehttp.query.params
variable - replacing the
flow-ref
component with anHTTP
component and calling the flow with an actual HTTP message
These all do not seem to work properly.
The variable setting seems to always fail, and results in NullPointerException
when trying to access the variables.
Calling the flow using an HTTP
component doesn't work because Mule randomly assigns a port for testing, and I can't seem to get access to this port at runtime. Thus I have no way to call the endpoint.
I have looked elsewhere for similar questions here and here, but they do not seem to help me.
So my basic question is: how can I set URL parameters that can be accessed by a flow, when being tested from an MUnit test. Is there instead a better way to achieve what I'm trying to achieve here?
Thank you!