public abstract class MockRestResponseCreators extends Object
ResponseCreator instance.
Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".
| Constructor and Description |
|---|
MockRestResponseCreators() |
| Modifier and Type | Method and Description |
|---|---|
static DefaultResponseCreator |
withBadRequest()
ResponseCreator for a 400 response (BAD_REQUEST). |
static DefaultResponseCreator |
withCreatedEntity(URI location)
ResponseCreator for a 201 response (CREATED) with a 'Location' header. |
static ResponseCreator |
withException(IOException ex)
ResponseCreator with an internal application IOException. |
static DefaultResponseCreator |
withNoContent()
ResponseCreator for a 204 response (NO_CONTENT). |
static DefaultResponseCreator |
withRawStatus(int status)
Variant of
withStatus(HttpStatus) for a custom HTTP status code. |
static DefaultResponseCreator |
withServerError()
ResponseCreator for a 500 response (SERVER_ERROR). |
static DefaultResponseCreator |
withStatus(org.springframework.http.HttpStatus status)
ResponseCreator with a specific HTTP status. |
static DefaultResponseCreator |
withSuccess()
ResponseCreator for a 200 response (OK). |
static DefaultResponseCreator |
withSuccess(byte[] body,
org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) with byte[] body. |
static DefaultResponseCreator |
withSuccess(org.springframework.core.io.Resource body,
org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) content with Resource-based body. |
static DefaultResponseCreator |
withSuccess(String body,
org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) with String body. |
static DefaultResponseCreator |
withUnauthorizedRequest()
ResponseCreator for a 401 response (UNAUTHORIZED). |
public static DefaultResponseCreator withSuccess()
ResponseCreator for a 200 response (OK).public static DefaultResponseCreator withSuccess(String body, @Nullable org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) with String body.body - the response body, a "UTF-8" stringcontentType - the type of the content (may be null)public static DefaultResponseCreator withSuccess(byte[] body, @Nullable org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) with byte[] body.body - the response bodycontentType - the type of the content (may be null)public static DefaultResponseCreator withSuccess(org.springframework.core.io.Resource body, @Nullable org.springframework.http.MediaType contentType)
ResponseCreator for a 200 response (OK) content with Resource-based body.body - the response bodycontentType - the type of the content (may be null)public static DefaultResponseCreator withCreatedEntity(URI location)
ResponseCreator for a 201 response (CREATED) with a 'Location' header.location - the value for the Location headerpublic static DefaultResponseCreator withNoContent()
ResponseCreator for a 204 response (NO_CONTENT).public static DefaultResponseCreator withBadRequest()
ResponseCreator for a 400 response (BAD_REQUEST).public static DefaultResponseCreator withUnauthorizedRequest()
ResponseCreator for a 401 response (UNAUTHORIZED).public static DefaultResponseCreator withServerError()
ResponseCreator for a 500 response (SERVER_ERROR).public static DefaultResponseCreator withStatus(org.springframework.http.HttpStatus status)
ResponseCreator with a specific HTTP status.status - the response statuspublic static DefaultResponseCreator withRawStatus(int status)
withStatus(HttpStatus) for a custom HTTP status code.status - the response statuspublic static ResponseCreator withException(IOException ex)
ResponseCreator with an internal application IOException.
For example, one could use this to simulate a SocketTimeoutException.
ex - the Exception to be thrown at HTTP call time