public static class StubResponse.Builder extends Object
StubResponse
instances.Modifier and Type | Method and Description |
---|---|
StubResponse.Builder |
body(byte[] body)
Sets the response body as an array of bytes.
|
StubResponse.Builder |
body(String body,
Charset encoding)
Sets the response body as a string.
|
StubResponse |
build() |
StubResponse.Builder |
delay(long delayValue,
TimeUnit delayUnit)
Sets the response delay.
|
StubResponse.Builder |
header(String name,
String value)
Adds a new stub response header.
|
StubResponse.Builder |
headers(KeyValues headers)
Sets new stub response headers (all previously set headers are discarded).
|
StubResponse.Builder |
status(int status)
Sets the stub response http status.
|
public StubResponse.Builder status(int status)
200
will be used as a default.status
- stub response status (cannot be negative)public StubResponse.Builder body(byte[] body)
body(String, Charset)
. If the response body is not set at all, an empty
body is used.body
- stub response body as an array of bytes (cannot be null).public StubResponse.Builder body(String body, Charset encoding)
body(byte[])
. If the response body is not set at all, an empty body is used.body
- stub response body as a string (cannot be null
)encoding
- encoding of the body (cannot be null
)public StubResponse.Builder headers(KeyValues headers)
headers
- stub response headers (cannot be null
)public StubResponse.Builder header(String name, String value)
name
- header name (cannot be empty)value
- header value (cannot be null
, however can be empty for valueless headers)public StubResponse.Builder delay(long delayValue, TimeUnit delayUnit)
0
will be used as a default.delayValue
- a delay (in units defined by the delayUnit
parameter)
this stub response will be returned afterdelayUnit
- unit of the delay parameterpublic StubResponse build()
StubResponse
instance built from values stored in this builderCopyright © 2016. All Rights Reserved.