Draft! This page is a draft - a work in progress!

The simplest way to mock a microservice Subscribe Pub Share

Let's say you have to develop a monitor service, and you need a heartbeat or ping API. Something simple that returns an error code and some more info, so you can take decisions and do something about the process being monitored...

And then you need a mock, so you can test your api...

$msg wmq.ping : (errCode, errMsg, tcpStatus)

$mock wmq.ping => (errCode="1000", errMsg="Oopsie", tcpStatus = "FAIL" )

{{template wmq.ping:response:content-type="application/text"}}
{
    "errCode" : "$errCode",
    "errMsg" : "$errMsg",
    "tcpStatus" : "$tcpStatus"
}
{{/template}}

It's fairly straight forward: the first line defines the ping service API and the second line mocks it. Then it's just the formatting of the actual payload.


Was this useful?    

By: Razie | 2017-11-21 | Tags: post


See more in: Cool Scala Subscribe

Viewed 594 times ( | History | Print ) this page.

You need to log in to post a comment!