<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sivashanmugam Ayyadurai on Medium]]></title>
        <description><![CDATA[Stories by Sivashanmugam Ayyadurai on Medium]]></description>
        <link>https://medium.com/@asiva_shanmugam?source=rss-13c044b2fdbd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sivashanmugam Ayyadurai on Medium</title>
            <link>https://medium.com/@asiva_shanmugam?source=rss-13c044b2fdbd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 00:57:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@asiva_shanmugam/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[WireMock — JSON Sample Implementations]]></title>
            <link>https://medium.com/toyota-connected-india/wiremock-json-sample-implementations-79e828ebdee4?source=rss-13c044b2fdbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/79e828ebdee4</guid>
            <category><![CDATA[integration-testing]]></category>
            <category><![CDATA[wiremock]]></category>
            <dc:creator><![CDATA[Sivashanmugam Ayyadurai]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 04:14:13 GMT</pubDate>
            <atom:updated>2024-02-02T04:14:54.792Z</atom:updated>
            <content:encoded><![CDATA[<h3>WireMock — JSON Sample Implementations</h3><h3><strong>Introduction</strong></h3><p>WireMock is a mocking environment designed specifically for integration testing. It becomes particularly useful when a system or service engages with one or more external or internal dependencies or services, and more crucially when integration testing is being conducted.</p><p>It operates by creating an HTTP server mimicking the behaviour of an online service. This server facilitates seamless connections, akin to those experienced with live online services. It allows us to define expectations, interact with the service, and check its behaviour when a WireMock server is active.</p><figure><img alt="In real-world situations, the system we create typically calls on other systems to supply the requested response. However, in the event that Other Systems are inert or inactive, we must simulate them in order to test our system." src="https://cdn-images-1.medium.com/max/1024/1*e5fb8DOIo85fgC5USQFt5w.png" /></figure><h3>Why WireMock?</h3><p>In real-world scenarios, the system we develop typically calls other systems to provide the requested response. However, if other systems are inert or inactive, we need a way to simulate them to test our system. This is where WireMock comes in to play — it enables us to simulate the behaviour of these external systems, allowing us to test our system’s functionality under various conditions.</p><figure><img alt="To obtain the mock response in this scenario, our systems will call the wire mock server, which will invoke the mock APIs of the mocked system." src="https://cdn-images-1.medium.com/max/1024/1*YwwActoQ5HldkMpyaAWN4Q.png" /><figcaption>WireMock Example</figcaption></figure><p>In this scenario, to obtain the mock response, our systems will make requests to the WireMock server. The WireMock server, in turn, will trigger the mock APIs of the system being mocked, allowing us to simulate the desired responses for testing purposes.</p><h3>Sample WireMock JSONs</h3><h4>Mock: POST</h4><p>Here’s a sample WireMock JSON configuration for the request and response for the POST /v1/customer-details API:</p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;POST&quot;,<br>    &quot;url&quot;: &quot;/v1/customer-details&quot;,<br>    &quot;port&quot;: 8081,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: {<br>        &quot;contains&quot;: &quot;application/json&quot;<br>      }<br>    },<br>    &quot;bodyPatterns&quot;: [<br>      {<br>        &quot;equalToJson&quot;: &quot;{\n  \&quot;firstName\&quot;: \&quot;${json-unit.any-string}\&quot;,\n  \&quot;lastName\&quot;: \&quot;${json-unit.any-string}\&quot;}&quot;,<br>        &quot;ignoreArrayOrder&quot;: true,<br>        &quot;ignoreExtraElements&quot;: true<br>      }<br>    ]<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;<br>    },<br>    &quot;jsonBody&quot;: {<br>      &quot;status&quot;: &quot;Success&quot;<br>    }<br>  }<br>}</pre><p>This configuration specifies that when a POST request is made to the /v1/customer-details endpoint, WireMock will respond with a status code of 200 (Created) and a JSON body containing a success message along with the newly created customer ID.</p><blockquote><strong><em>${json-unit.any-string}: </em></strong>This feature allows WireMock to accept dynamic data for corresponding parameters.</blockquote><blockquote><strong><em>ignoreArrayOrder: </em></strong>WireMock will not consider the sequence in which the JSON request body is provided.</blockquote><blockquote><strong><em>ignoreExtraElements: </em></strong>Similar to <a href="http://twitter.com/JsonIgnoreProperties">@JsonIgnoreProperties</a>, this setting instructs to disregard any additional properties in the request body while stubbing.</blockquote><h4>Mock: GET</h4><p>We typically communicate the customer ID to a third-party or other systems that store the customer details when a GET API call is made to retrieve the customer details based on the customer ID. Below is a WireMock JSON which contains the request and response for GET /v1/customer-details API to send the mock customer information response to the request.</p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;url&quot;: &quot;/v1/customer-details&quot;,<br>    &quot;port&quot;: 8081,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: {<br>        &quot;contains&quot;: &quot;application/json&quot;<br>      },<br>      &quot;X-CUSTOMER-ID&quot;: {<br>        &quot;matches&quot;: &quot;.*&quot;<br>      },<br>      &quot;X-CORRELATIONID&quot;: {<br>        &quot;matches&quot;: &quot;.*&quot;<br>      }<br>    },<br>    &quot;bodyPatterns&quot;: []<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;<br>    },<br>    &quot;jsonBody&quot;: {<br>      &quot;status&quot;: &quot;Success&quot;,<br>      &quot;payload&quot;: {<br>        &quot;customerId&quot;: &quot;a3be9d0fc37e44e0be5e5c122d3c2453&quot;,<br>        &quot;firstName&quot;: &quot;FirstName&quot;,<br>        &quot;lastName&quot;: &quot;LastName&quot;<br>      }<br>    }<br>  }<br>}</pre><h4>Mock: PUT</h4><p>Here’s a sample WireMock JSON configuration for handling the request and response for the PUT /v1/customer-details/a3be9d0fc37e44e0be5e5c122d3c2453 API:</p><p>In case, if we want to alter the customer details like firstName or lastName, the below JSON can be used.</p><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;PUT&quot;,<br>    &quot;url&quot;: &quot;/v1/customer-details/a3be9d0fc37e44e0be5e5c122d3c2453&quot;,<br>    &quot;port&quot;: 8081,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: {<br>        &quot;contains&quot;: &quot;application/json&quot;<br>      }<br>    },<br>    &quot;bodyPatterns&quot;: [<br>      {<br>        &quot;equalToJson&quot;: &quot;{  &quot;firstName&quot; : &quot;NewFirstName&quot;,  &quot;lastName&quot; : &quot;NewLastName&quot;}&quot;,<br>        &quot;ignoreArrayOrder&quot;: true,<br>        &quot;ignoreExtraElements&quot;: true<br>      }<br>    ]<br>  },<br>  &quot;response&quot;: {<br>    &quot;jsonBody&quot;: {<br>      &quot;status&quot;: &quot;Success&quot;<br>    }<br>  }<br>}</pre><h4>Mock: DELETE</h4><blockquote>A wiremock sample JSON which contains the request and response for DELETE /v1/customer-details/a3be9d0fc37e44e0be5e5c122d3c2453 API to remove the specified customer information from the system.</blockquote><pre>{<br>  &quot;request&quot;: {<br>    &quot;method&quot;: &quot;DELETE&quot;,<br>    &quot;url&quot;: &quot;/v1/customer-details/a3be9d0fc37e44e0be5e5c122d3c2453&quot;,<br>    &quot;port&quot;: 8081,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: {<br>        &quot;contains&quot;: &quot;application/json&quot;<br>      }<br>    },<br>    &quot;bodyPatterns&quot;: []<br>  },<br>  &quot;response&quot;: {<br>    &quot;status&quot;: 200,<br>    &quot;headers&quot;: {<br>      &quot;Content-Type&quot;: &quot;application/json&quot;<br>    },<br>    &quot;jsonBody&quot;: {<br>      &quot;status&quot;: &quot;Success&quot;<br>    }<br>  }<br>}</pre><p>WireMock is a powerful tool for facilitating integration testing by simulating the behaviour of external systems. It empowers developers to thoroughly test their systems’ interactions, leading to more reliable and resilient software products.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79e828ebdee4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/toyota-connected-india/wiremock-json-sample-implementations-79e828ebdee4">WireMock — JSON Sample Implementations</a> was originally published in <a href="https://medium.com/toyota-connected-india">Toyota Connected India</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>