Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This wiki explains how the content mock API service is used to make the development environment seamless and easy to start working on, without relying on the content service APIs.

Jira Legacy
serverSystem JIRA
serverId2207a759-5bc8-39c5-9cd2-aa9ccc1f65dd
keyLR-556

Background & Problem Statement

...

The class has a static method setup() which sets up the mock server by creating a MockWebServer instance and setting up a Dispatcher to handle incoming requests. The Dispatcher maps the request paths to the corresponding MockResponse instances, which are stored in a HashMap.The setup() method also sets up a proxy for Unirest by calling Unirest.setProxy() with the hostname and port of the mock server.

The ContentSearchMock class has a static method teardown() which shuts down the mock server.The Dispatcher instance is created using a lambda expression that implements the dispatch() method, which receives the incoming request and returns the corresponding MockResponse.

The lambda expression extracts the request path is extracted from the RecordedRequest object using a regular expression pattern. The path is used to look up the corresponding MockResponse in the HashMap. If no MockResponse is found for the path, a default MockResponse with a 404 status code is returned.

...