I am using wiremock (to mock our Rest API) for selenium tests. I have a rest end point like http://localhost:8080/compare-date?from=2018-03-01&to=2018-03-10
For this, we are trying to create some intelligent mock using Java, which will be invoked only when to date is less than the from date. Ex: http://localhost:8080/compare-date?from=2018-03-01&to=2018-02-10
But, i am unable to achieve this. Kindly suggest how this can be done. Thanks in advance.
Thanks, Dharani
Ideally you should already expect the response as part of your test. That being said, if you want this functionality from your stub, then you will have to extend it.
There are a number of ways you can extend WireMock, most of them are found on this page: http://wiremock.org/docs/extending-wiremock/.
Honestly, I would probably use specific years for particular response and create rules for them.