I have several mocks with responses. But for some of them I want to create response based on additional query parameter. For example: I have mock for REST request such as "GET /order/item" and it works fine. But I tried to create mock for "GET /order/item?status=queued" and created response for it, but I get the same response as for "GET /order/item" when I test it out.
Is it possible to create REST Mock with Query in SoapUI Pro (5.1.2)?
Thanks for answers in advance.
You have to add script dispatch to your mock action GET /order/item
as it is shown on below picture:
Additionally, You have to define two MockResponse for above mock action:
queuedItem
item
Then the script will dispatch to queuedItem
if http parameter status = queued
if("queued".equals(mockRequest.getHttpRequest().getParameter("status"))) {
log.info("queued");
mockRequest.getHttpResponse().getWriter().write("queued");
} else {
log.info("nope");
mockRequest.getHttpResponse().getWriter().write("nope");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With