6

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.

Di Grey
  • 61
  • 1
  • 3

2 Answers2

3

You have to add script dispatch to your mock action GET /order/item as it is shown on below picture: enter image description here 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

snieguu
  • 2,073
  • 2
  • 20
  • 39
2
if("queued".equals(mockRequest.getHttpRequest().getParameter("status"))) {
  log.info("queued");
  mockRequest.getHttpResponse().getWriter().write("queued");
} else {
  log.info("nope");
  mockRequest.getHttpResponse().getWriter().write("nope");  
}
William
  • 21
  • 2