Class MockMvcHttpClient

java.lang.Object
com.github.silent.samurai.speedy.api.client.clients.MockMvcHttpClient
All Implemented Interfaces:
HttpClient<org.springframework.test.web.servlet.ResultActions>

public class MockMvcHttpClient extends Object implements HttpClient<org.springframework.test.web.servlet.ResultActions>
MockMvc implementation of HttpClient for testing purposes. This client uses Spring's MockMvc to simulate HTTP requests without starting a full web server.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MockMvcHttpClient(org.springframework.test.web.servlet.MockMvc mockMvc)
    Creates a new MockMvcHttpClient with the specified MockMvc instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.test.web.servlet.ResultActions
    invokeAPI(String path, org.springframework.http.HttpMethod method, org.springframework.util.MultiValueMap<String,String> queryParams, com.fasterxml.jackson.databind.JsonNode body, org.springframework.http.HttpHeaders headerParams)
    Invoke an HTTP API call with the given parameters.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MockMvcHttpClient

      public MockMvcHttpClient(org.springframework.test.web.servlet.MockMvc mockMvc)
      Creates a new MockMvcHttpClient with the specified MockMvc instance.
      Parameters:
      mockMvc - the MockMvc instance to use for HTTP requests
  • Method Details

    • invokeAPI

      public org.springframework.test.web.servlet.ResultActions invokeAPI(String path, org.springframework.http.HttpMethod method, org.springframework.util.MultiValueMap<String,String> queryParams, com.fasterxml.jackson.databind.JsonNode body, org.springframework.http.HttpHeaders headerParams) throws Exception
      Description copied from interface: HttpClient
      Invoke an HTTP API call with the given parameters.
      Specified by:
      invokeAPI in interface HttpClient<org.springframework.test.web.servlet.ResultActions>
      Parameters:
      path - The sub-path of the HTTP URL
      method - The request method
      queryParams - The query parameters
      body - The request body object
      headerParams - The header parameters
      Returns:
      ResponseEntity with the response
      Throws:
      org.springframework.web.client.RestClientException - if the HTTP call fails
      Exception