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
ConstructorsConstructorDescriptionMockMvcHttpClient(org.springframework.test.web.servlet.MockMvc mockMvc) Creates a new MockMvcHttpClient with the specified MockMvc instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.test.web.servlet.ResultActionsinvokeAPI(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.
-
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 ExceptionDescription copied from interface:HttpClientInvoke an HTTP API call with the given parameters.- Specified by:
invokeAPIin interfaceHttpClient<org.springframework.test.web.servlet.ResultActions>- Parameters:
path- The sub-path of the HTTP URLmethod- The request methodqueryParams- The query parametersbody- The request body objectheaderParams- The header parameters- Returns:
- ResponseEntity with the response
- Throws:
org.springframework.web.client.RestClientException- if the HTTP call failsException
-