spring-framework / org.springframework.test.web.client.response / MockRestResponseCreators

MockRestResponseCreators

abstract class MockRestResponseCreators

Static factory methods for obtaining a ResponseCreator instance.

Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".

Author
Rossen Stoyanchev

Since
3.2

Constructors

<init>

MockRestResponseCreators()

Static factory methods for obtaining a ResponseCreator instance.

Eclipse users: consider adding this class as a Java editor favorite. To navigate, open the Preferences and type "favorites".

Functions

withBadRequest

open static fun withBadRequest(): DefaultResponseCreator

ResponseCreator for a 400 response (BAD_REQUEST).

withCreatedEntity

open static fun withCreatedEntity(location: URI): DefaultResponseCreator

ResponseCreator for a 201 response (CREATED) with a 'Location' header.

withNoContent

open static fun withNoContent(): DefaultResponseCreator

ResponseCreator for a 204 response (NO_CONTENT).

withServerError

open static fun withServerError(): DefaultResponseCreator

ResponseCreator for a 500 response (SERVER_ERROR).

withStatus

open static fun withStatus(status: HttpStatus): DefaultResponseCreator

ResponseCreator with a specific HTTP status.

withSuccess

open static fun withSuccess(): DefaultResponseCreator

ResponseCreator for a 200 response (OK).

open static fun withSuccess(body: String, contentType: MediaType): DefaultResponseCreator

ResponseCreator for a 200 response (OK) with String body.

open static fun withSuccess(body: ByteArray, contentType: MediaType): DefaultResponseCreator

ResponseCreator for a 200 response (OK) with byte[] body.

open static fun withSuccess(body: Resource, contentType: MediaType): DefaultResponseCreator

ResponseCreator for a 200 response (OK) content with Resource-based body.

withUnauthorizedRequest

open static fun withUnauthorizedRequest(): DefaultResponseCreator

ResponseCreator for a 401 response (UNAUTHORIZED).