DataSourceContractTest.TestResource.Builder


class DataSourceContractTest.TestResource.Builder


Builder for TestResource instances.

Summary

Public constructors

Public functions

DataSourceContractTest.TestResource!
DataSourceContractTest.TestResource.Builder!

Sets the expected contents of this resource.

DataSourceContractTest.TestResource.Builder!

Sets the HTTP method that should be used for the request for this resource.

DataSourceContractTest.TestResource.Builder!

Sets whether open may return LENGTH_UNSET when passed the URI of this resource and a DataSpec with length == C.LENGTH_UNSET.

DataSourceContractTest.TestResource.Builder!

Sets a human-readable name for this resource which will be shown in test failure messages.

DataSourceContractTest.TestResource.Builder!

Sets the body that should be included in a request for this resource.

DataSourceContractTest.TestResource.Builder!

Sets the headers that should be included when making a request for this resource.

DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource is served from.

DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource is served from.

DataSourceContractTest.TestResource.Builder!

Sets the headers associated with this resource that are expected to be present in getResponseHeaders.

DataSourceContractTest.TestResource.Builder!
@CanIgnoreReturnValue
setUnexpectedResponseHeaderKeys(
    unexpectedResponseHeaderKeys: (Mutable)Set<String!>!
)

Sets the keys that must not be present in getResponseHeaders when reading this resource.

DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource should be requested from.

DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource should be requested from.

Public constructors

Builder

Builder()

Public functions

setExpectedBytes

@CanIgnoreReturnValue
fun setExpectedBytes(expectedBytes: ByteArray!): DataSourceContractTest.TestResource.Builder!

Sets the expected contents of this resource. Defaults to an empty byte array.

setHttpMethod

@CanIgnoreReturnValue
fun setHttpMethod(@DataSpec.HttpMethod httpMethod: Int): DataSourceContractTest.TestResource.Builder!

Sets the HTTP method that should be used for the request for this resource.

Tests will fail if the wrong method is used.

Defaults to HTTP_METHOD_GET.

setMayResolveToUnknownLength

@CanIgnoreReturnValue
fun setMayResolveToUnknownLength(value: Boolean): DataSourceContractTest.TestResource.Builder!

Sets whether open may return LENGTH_UNSET when passed the URI of this resource and a DataSpec with length == C.LENGTH_UNSET.

This may be because the underlying resource doesn't have an end (e.g. a 'live' MP3 file that is constantly appended to) or because the resource supports compression that means the 'true' length cannot be initially determined.

Defaults to false.

setName

@CanIgnoreReturnValue
fun setName(name: String!): DataSourceContractTest.TestResource.Builder!

Sets a human-readable name for this resource which will be shown in test failure messages.

setRequestBody

@CanIgnoreReturnValue
fun setRequestBody(requestBody: ByteArray!): DataSourceContractTest.TestResource.Builder!

Sets the body that should be included in a request for this resource.

Tests will fail if a request is made without including this body.

Must only be set if setHttpMethod is HTTP_METHOD_POST or HTTP_METHOD_HEAD.

Defaults to an empty array.

setRequestHeaders

@CanIgnoreReturnValue
fun setRequestHeaders(requestHeaders: (Mutable)Map<String!, String!>!): DataSourceContractTest.TestResource.Builder!

Sets the headers that should be included when making a request for this resource.

Tests will fail if a request is made without including these headers.

This doesn't have to be an exhaustive list, extra headers included in the request will not cause a failure. Defaults to an empty map.

setResolvedUri

@CanIgnoreReturnValue
fun setResolvedUri(uri: String!): DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource is served from. This only needs to be explicitly set if it's different to setUri. See getResolvedUri.

setResolvedUri

@CanIgnoreReturnValue
fun setResolvedUri(uri: Uri!): DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource is served from. This only needs to be explicitly set if it's different to setUri. See getResolvedUri.

setResponseHeaders

@CanIgnoreReturnValue
fun setResponseHeaders(
    responseHeaders: (Mutable)Map<String!, (Mutable)List<String!>!>!
): DataSourceContractTest.TestResource.Builder!

Sets the headers associated with this resource that are expected to be present in getResponseHeaders.

This doesn't have to be an exhaustive list, extra headers in getResponseHeaders are ignored. Defaults to an empty map.

setUnexpectedResponseHeaderKeys

@CanIgnoreReturnValue
fun setUnexpectedResponseHeaderKeys(
    unexpectedResponseHeaderKeys: (Mutable)Set<String!>!
): DataSourceContractTest.TestResource.Builder!

Sets the keys that must not be present in getResponseHeaders when reading this resource. Defaults to an empty set.

setUri

@CanIgnoreReturnValue
fun setUri(uri: String!): DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource should be requested from.

setUri

@CanIgnoreReturnValue
fun setUri(uri: Uri!): DataSourceContractTest.TestResource.Builder!

Sets the URI where this resource should be requested from.