requests are not getting mocked through wiremock server

899 views
Skip to first unread message

nitin bansal

unread,
Dec 11, 2019, 7:54:24 AM12/11/19
to wiremock-user
I have this API requests:

/mpp-pricing/v1/agreements?accountId=a00194a5-22f4-40bc-ae38-036d060a97fd

mpp-pricing/v1/revenue/transactionfees/1589967b-d350-4b08-80d7-50e269492fe3


And json Stubbing : 
{
 
"mappings" : [
 
{
   
"request": {
   
"method": "GET",
   
"urlPattern": "/mpp-pricing/v1/agreements(?(([\\w-]+?),?)*?)?"
 
},
   
"response": {
   
"jsonBody": [{
     
"id": "a00194a5-22f4-40bc-ae38-036d060a97fd"
   
}]
 
}},
 
{
   
"request": {
   
"method": "GET",
   
"urlPattern": "/mpp-pricing/v1/revenue/transactionfees(/([\\w]+?)*?)?"
 
},
   
"response": {
   
"status": 200,
       
"jsonBody": {
                 
"accountId": "12321321"
                             
}}
 
}]
}

I am getting this error 
Request was not matched as there were no stubs registered:

I am not sure what I am doing wrong here. Any help will be appreciated. 

Thank you 

nitin bansal

unread,
Dec 11, 2019, 8:27:37 AM12/11/19
to wiremock-user
tried with different approaches as well like
 
"urlPattern" : "/mpp-pricing/v1/agreements"
"queryParameters" : {
   
"accountId" :{
   
"matches" : "(.*)"
   
}
   
}

Still not working. I am new to the Wiremock. I went through http://wiremock.org/docs/request-matching/ as well. I am not sure what am i doing wrong here. Need Help!!

Thank You
Nitin Kumar 

Tom Akehurst

unread,
Dec 11, 2019, 8:29:03 AM12/11/19
to wiremock-user
The message suggests you're not putting the JSON file where WireMock is expecting to read it.

nitin bansal

unread,
Dec 11, 2019, 10:17:08 AM12/11/19
to wiremock-user
Hello Tom,

I changed the request to 
 "request": {
   
"urlPath": "/mpp-pricing/v1/agreements/",
   
"method": "GET",
   
"queryParameters" : {
   
"accountId" : {
     
"matches" : ".*"
   
}
 
}

Now I am getting this error. param is expecting ei
                                               Request was not matched
                                               =======================

-----------------------------------------------------------------------------------------------------------------------
| Closest stub                                             | Request                                                  |
-----------------------------------------------------------------------------------------------------------------------
                                                           
|
GET                                                        
| GET
/mpp-pricing/v1/agreements/                                | /mpp-pricing/v1/agreements?accountId=e4343eef-5495-4b83-b<<<<< URL does not match
                                                           
| a46-49a509757fe7
                                                           
|
Query: accountId [matches]  .*                          | accountId: e4343eef-5495-4b83-ba46-49a509757fe7


If I use urlPattern , it will give me Request was not matched as there were no stubs registered:


nitin bansal

unread,
Dec 11, 2019, 10:29:17 AM12/11/19
to wiremock-user
Its a Spring Boot app. I am using SprintBootTest for testing my apis. Right now I am using Mockito for mocking but I want to move all mocks to json based mocking. But I got stuck here.

Tom Akehurst

unread,
Dec 11, 2019, 10:32:59 AM12/11/19
to wiremock-user
I think the trailing / on your urlPath is the problem here, as there's no trailing slash in the actual request.
Reply all
Reply to author
Forward
0 new messages