Hi Team, We want to respond with a "bad request" r...
# help
a
Hi Team, We want to respond with a "bad request" response if the request doesn't match a specific request, how can we simulate such a scenario? in java or Kotlin
l
I haven’t had much experience in this area so one of the other might need to jump in here. I think what you might need to do is utilise priorities in wiremock. Create a stub that matches anything (any url, and http method etc) and set it to return a bad request and also set it to a low priority. Make sure all your other stubs that match a specific url/method are set to a higher priority. More info can be found here - https://wiremock.org/docs/stubbing/#stub-priority
a
that works but I wonder if there is a better way, by using not(equaltToJson("requestbody"))
l
That certainly might work. Would you add that to the request matcher for the body ?
a
i tried it but it didn't work, it overrides the success case
l
Maybe worth giving the priorities a try ?
a
it's working
with priorities
l
Excellent.
m
Hi, @Abdelrahman Mohamed do you have an example in Kotlin? Thank you in advance, Maria