Versions Compared

Key

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

...

Overall, the ContentSearchMock class provides a convenient way to test HTTP requests made to the content service API by simulating the API behaviour with mock responses.

...


Implementation Steps:

  1. Check the value of the CONTENT_SERVICE_MOCK_ENABLED property in the configuration file using the ProjectUtil.getConfigValue() method.

  2. If the property value is true, then:
    a. Call the ContentSearchMock.setup() method to set up a mock server for testing HTTP requests made to the content service API.
    b. Get the mock URL from the configuration file using the ProjectUtil.getConfigValue() method and store it in the mockUrl variable.
    c. Send a GET request to the mock URL using the HttpUtil.sendGet/Post/PatchRequest() method with the specified headers and store the response in the response variable.
    d. Call the ContentSearchMock.teardown() method to shut down the mock server.

  3. If the property value is false, then:
    a. Send a GET request to the base content read URL using the HttpUtil.sendGet/Post/PatchRequest() method with the specified headers and store the response in the response variable.

  4. Continue with the rest of the code using the response variable.

Image Modified