DataSourceContractTest.TestResource


public final class DataSourceContractTest.TestResource


Information about a resource that can be used to test the DataSource instance.

Summary

Nested types

Builder for TestResource instances.

Public methods

DataSourceContractTest.TestResource.Builder

Returns a Builder initialized with the values of this instance.

byte[]

Returns the expected contents of this resource.

int

The HTTP method that should be used to request the resource.

@Nullable String

Returns a human-readable name for the resource, for use in test failure messages.

byte[]

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

ImmutableMap<StringString>

The headers that should be included in a request for the resource.

Uri

Returns the URI where the resource is served from.

Map<StringList<String>>

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

Set<String>

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

Uri

Returns the URI where the resource should be requested from.

boolean

Returns whether this resource may not report a length.

Public fields

expectedBytes

public final byte[] expectedBytes

httpMethod

@DataSpec.HttpMethod
public final int httpMethod

name

public final @Nullable String name

requestBody

public final byte[] requestBody

requestHeaders

public final ImmutableMap<StringStringrequestHeaders

resolvedUri

public final Uri resolvedUri

responseHeaders

public final Map<StringList<String>> responseHeaders

unexpectedResponseHeaderKeys

public final Set<StringunexpectedResponseHeaderKeys

uri

public final Uri uri

Public methods

buildUpon

public DataSourceContractTest.TestResource.Builder buildUpon()

Returns a Builder initialized with the values of this instance.

getExpectedBytes

public byte[] getExpectedBytes()

Returns the expected contents of this resource.

getHttpMethod

@DataSpec.HttpMethod
public int getHttpMethod()

The HTTP method that should be used to request the resource.

getName

public @Nullable String getName()

Returns a human-readable name for the resource, for use in test failure messages.

getRequestBody

public byte[] getRequestBody()

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

This will be empty if getHttpMethod is HTTP_METHOD_GET.

getRequestHeaders

public ImmutableMap<StringStringgetRequestHeaders()

The headers that should be included in a request for the resource.

This is not an exhaustive list, extra headers may be included.

getResolvedUri

public Uri getResolvedUri()

Returns the URI where the resource is served from. This is equal to getUri unless redirection occurred when opening the resource.

getResponseHeaders

public Map<StringList<String>> getResponseHeaders()

Returns 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.

getUnexpectedResponseHeaderKeys

public Set<StringgetUnexpectedResponseHeaderKeys()

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

getUri

public Uri getUri()

Returns the URI where the resource should be requested from.

mayResolveToUnknownLength

public boolean mayResolveToUnknownLength()

Returns whether this resource may not report a length.