Package net.officefloor.server.http.mock
Interface MockHttpResponse
- All Known Subinterfaces:
MockWoofResponse
- All Known Implementing Classes:
MockHttpServer.MockHttpResponseImpl,MockWoofServer.MockWoofResponseImpl
public interface MockHttpResponse
Mock
HttpResponse.- Author:
- Daniel Sagenschneider
-
Method Summary
Modifier and TypeMethodDescriptionvoidassertCookie(HttpResponseCookie cookie) Asserts contains theWritableHttpCookie.voidassertHeader(String name, String value) Asserts contains theHttpHeader.voidassertJson(int statusCode, Object entity, String... headerNameValuePairs) Asserts the JSON response.voidassertJson(int statusCode, Object entity, tools.jackson.databind.ObjectMapper mapper, String... headerNameValuePairs) Asserts the JSON response providing customObjectMapper.voidassertResponse(int statusCode, String entity, String... headerNameValuePairs) Asserts the contents of theHttpResponse.voidassertStatus(int statusCode) Assets the status of theHttpResponse.voidassertStatus(HttpStatus status) Assets theHttpStatusof theHttpResponse.Obtains theWritableHttpCookieby the name.Obtains the responseWritableHttpCookieinstances.ObtainsInputStreamto the response HTTP entity.Obtains the HTTP entity as text.Obtains the firstWritableHttpHeaderby the name.Obtains the responseWritableHttpHeaderinstances.<T> TObtains the JSON object from HTTP payload.<T> TObtains the JSON object from HTTP payload using customObjectMapper.Obtains theHttpStatus.Obtains theHttpVersion.
-
Method Details
-
getVersion
HttpVersion getVersion()Obtains theHttpVersion.- Returns:
HttpVersion.
-
getStatus
HttpStatus getStatus()Obtains theHttpStatus.- Returns:
HttpStatus.
-
getHeader
Obtains the firstWritableHttpHeaderby the name.- Parameters:
name- Name of theWritableHttpHeader.- Returns:
- First
WritableHttpHeaderby the name, ornullif noWritableHttpHeaderby the name.
-
assertStatus
void assertStatus(int statusCode) Assets the status of theHttpResponse.- Parameters:
statusCode- Status code.
-
assertStatus
Assets theHttpStatusof theHttpResponse.- Parameters:
status-HttpStatus.
-
getHeaders
List<WritableHttpHeader> getHeaders()Obtains the responseWritableHttpHeaderinstances.- Returns:
WritableHttpHeaderinstances.
-
assertResponse
Asserts the contents of theHttpResponse.- Parameters:
statusCode- Expected status code.entity- Expected entity.headerNameValuePairs- ExpectedHttpHeadername/value pairs. This only confirms they exist on theHttpResponse. It is not inclusive to check if these are the onlyHttpHeaderinstances.
-
assertHeader
Asserts contains theHttpHeader.- Parameters:
name- Expected name.value- Expected value.
-
getCookie
Obtains theWritableHttpCookieby the name.- Parameters:
name- Name of theWritableHttpCookie.- Returns:
WritableHttpCookieby the name, ornullif noWritableHttpCookieby the name.
-
getCookies
List<WritableHttpCookie> getCookies()Obtains the responseWritableHttpCookieinstances.- Returns:
WritableHttpCookieinstances.
-
assertCookie
Asserts contains theWritableHttpCookie.- Parameters:
cookie- ExpectedWritableHttpCookie.- See Also:
-
getEntity
InputStream getEntity()ObtainsInputStreamto the response HTTP entity.- Returns:
InputStreamto the response HTTP entity.
-
getEntity
Obtains the HTTP entity as text. -
getJson
Obtains the JSON object from HTTP payload.- Type Parameters:
T- Type of object.- Parameters:
statusCode-HttpStatus.clazz-Classfor the JSON object.- Returns:
- JSON object.
-
getJson
Obtains the JSON object from HTTP payload using customObjectMapper.- Type Parameters:
T- Type of object.- Parameters:
statusCode-HttpStatus.clazz-Classfor the JSON object.mapper- CustomObjectMapper.- Returns:
- JSON object.
-
assertJson
Asserts the JSON response.- Parameters:
statusCode-HttpStatus.entity-Objectto be written as JSON.headerNameValuePairs- ExpectedHttpHeadername/value pairs.
-
assertJson
void assertJson(int statusCode, Object entity, tools.jackson.databind.ObjectMapper mapper, String... headerNameValuePairs) Asserts the JSON response providing customObjectMapper.- Parameters:
statusCode-HttpStatus.entity-Objectto be written as JSON.mapper- CustomObjectMapper.headerNameValuePairs- ExpectedHttpHeadername/value pairs.
-