When you are working in integration technologies, you always need to connect other systems. When you are building api’s it may not be possible to test with live downstream endpoint. Recently, I came across wiremock api which acts as mocking server. Let see how to configure it.

  • Download the standalone jar.
  • Place it in one new folder.
  • Create two new folders __files, mappings under the new folder.

    Now let see mocking REST API details.
  • Create mock.json(anyname) in mappings folder with following details
    {
      "request": {
     "method": "GET",
     "urlPathPattern": "/students.*"
      },
      "response": {
     "status": 200,
     "bodyFileName": "getStudents.json",
     "headers": {
       "Content-Type": "application/json"
     }
      }
    }
    
  • As mentioned above, create file getStudents.json with the expected response in __files folder.