@NotThreadSafe
public interface ResponseBuilder
Builds a response object after properties are set.
Concurrency notes. Builder instances are used in a single thread that
prepares requests expectations - typically main thread.
Implementations are not required to be thread safe.
| Modifier and Type | Method and Description |
|---|---|
HttpResponse |
build()
Builds response.
|
ResponseBuilder |
withBody(String body)
Specifies response body.
|
ResponseBuilder |
withDelay(TimeUnit timeUnit,
long delay)
Specifies response delay.
|
ResponseBuilder |
withHeader(String headerName,
String headerValue)
Specifies response header.
|
ResponseBuilder |
withStatus(int statusCode)
Specifies response status code.
|
HttpResponse build()
ResponseBuilder withStatus(int statusCode)
statusCode - Response status code.IllegalArgumentException - statusCode is not positive.ResponseBuilder withBody(String body)
body - Response body.ResponseBuilder withHeader(String headerName, String headerValue)
headerName - Header name.headerValue - Header value.NullPointerException - headerName is null.IllegalArgumentException - headerName is empty or blank.NullPointerException - headerValue is null.ResponseBuilder withDelay(TimeUnit timeUnit, long delay)
timeUnit - Time unit for delay.delay - Delay before sending response.NullPointerException - timeUnit is null.IllegalArgumentException - delay is negative.Copyright © 2016. All rights reserved.