concept imposter in category microservice

This is an excerpt from Manning's book Testing Microservices with Mountebank.
Mountebank is a standalone application that provides a REST API to create and configure virtual services, which are called imposters in the API (figure 1.13). Rather than configuring the service that you are testing to point to URLs of real services, you configure it to point to the imposters you create through mountebank.
Each imposter represents a socket that acts as the virtual service and accepts connections from the real service you are testing. Spinning up and shutting down imposters is a lightweight operation, so it’s common to use the arrange step of automated tests to create the imposter, then shut it down in the cleanup stage of each test. Although we will use HTTP/S for most examples in this book, mountebank supports other protocols, including binary messages over TCP, and more protocols are expected soon.
Remember, an imposter is the mountebank term for a virtual service. Mountebank ships with a REST API that lets you create imposters and write tests against them in any language.
Mountebanks, imposters, and funny sounding docs
Much of the mountebank documentation is written in the voice of a true mountebank, prone to hyperbole and false modesty, where even the word “mountebank” shifts from describing the tool itself to the author of the documentation (yours truly). When I originally wrote the tool, I made imposters the core domain concept, in part because it fit the theme of using synonyms for charlatans to describe fake services, and in part because it self-deprecatingly made fun of my own Impostor Syndrome, a chronic ailment of consultants like myself. And yes, as Paul Hammant (one of the original creators of the popular Selenium testing tool and one of the first users of mountebank) pointed out to me, impostor (with an “or” instead of “er” at the end) is the “proper” spelling. Now that mountebank is a popular tool used all over the world, complete with a best-selling book (the one you are holding), Paul also helpfully suggested that I change the docs to remove the hipster humor. Unfortunately, he has yet to indicate where I’m supposed to find the time for such pursuits.
Let’s write a service test that validates that if the product catalog and content services return the given data, then the web façade will combine the data as shown above. Although mountebank’s HTTP API allows you to use it in any language, you will use JavaScript for the example. The first thing you will need to do is make it easy to create imposters from your tests. A common approach to make building a complex configuration easier is to use what is known as a fluent interface, which allows you to chain function calls together to build a complex configuration incrementally.
The code in listing 2.5 uses a fluent interface to build up the imposter configuration in code. Each withStub call creates a new stub on the imposter, and each matchingRequest and respondingWith call adds a predicate and response, respectively, to the stub. When you are done, you call create to use mountebank’s REST API to create the imposter.
Listing 2.5. Using a fluent interface to build imposters in code
require('any-promise/register/q'); #1 var request = require('request-promise-any'); #1 module.exports = function (options) { #2 var config = options || {}; config.stubs = []; function create () { #3 return request({ method: "POST", uri: "http://localhost:2525/imposters", json: true, body: config }); } function withStub () { #4 var stub = { responses: [], predicates: [] }, builders = { matchingRequest: function (predicate) { #5 stub.predicates.push(predicate); return builders; }, respondingWith: function (response) { #6 stub.responses.push({ is: response }); return builders; }, create: create, withStub: withStub }; config.stubs.push(stub); return builders; } return { withStub: withStub, create: create }; };