TestListenableWorkerBuilder


public class TestListenableWorkerBuilder<W extends ListenableWorker>

Known direct subclasses
TestWorkerBuilder

Builds instances of Worker which can be used for testing.


Builds instances of androidx.work.ListenableWorker which can be used for testing.

Parameters
<W extends ListenableWorker>

The actual ListenableWorker subtype being built.

Summary

Public methods

@NonNull W

Builds the ListenableWorker.

static @NonNull TestListenableWorkerBuilder<ListenableWorker>
from(@NonNull Context context, @NonNull WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

static @NonNull TestListenableWorkerBuilder<W>
<W extends ListenableWorker> from(
    @NonNull Context context,
    @NonNull Class<W> workerClass
)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

@NonNull TestListenableWorkerBuilder<W>

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

@NonNull TestListenableWorkerBuilder<W>

Sets the id for this unit of work.

@NonNull TestListenableWorkerBuilder<W>

Adds input Data to the work.

@NonNull TestListenableWorkerBuilder<W>
@RequiresApi(value = 28)
setNetwork(@NonNull Network network)

Sets the network associated with this unit of work.

@NonNull TestListenableWorkerBuilder<W>

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

@NonNull TestListenableWorkerBuilder<W>
setRunAttemptCount(int runAttemptCount)

Sets the initial run attempt count for this work.

@NonNull TestListenableWorkerBuilder<W>

Sets the tags associated with this unit of work.

@NonNull TestListenableWorkerBuilder<W>

Sets the authorities for content Uri's associated with this unit of work.

@NonNull TestListenableWorkerBuilder<W>
@RequiresApi(value = 24)
setTriggeredContentUris(@NonNull List<Uri> contentUris)

Sets the list of Content Uris associated with this unit of work.

@NonNull TestListenableWorkerBuilder<W>

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Public methods

build

Added in 2.1.0
public @NonNullbuild()

Builds the ListenableWorker.

Returns
@NonNull W

the instance of a ListenableWorker.

from

Added in 2.1.0
public static @NonNull TestListenableWorkerBuilder<ListenableWorkerfrom(@NonNull Context context, @NonNull WorkRequest workRequest)

Creates a new instance of a TestListenableWorkerBuilder from a WorkRequest.

Parameters
@NonNull Context context

The Context

@NonNull WorkRequest workRequest

The WorkRequest

from

Added in 2.1.0
public static @NonNull TestListenableWorkerBuilder<W> <W extends ListenableWorker> from(
    @NonNull Context context,
    @NonNull Class<W> workerClass
)

Creates a new instance of a TestListenableWorkerBuilder the worker Class.

Parameters
@NonNull Context context

The Context

@NonNull Class<W> workerClass

The subtype of ListenableWorker being built

Returns
@NonNull TestListenableWorkerBuilder<W>

The new instance of a ListenableWorker

setForegroundUpdater

Added in 2.3.0
public @NonNull TestListenableWorkerBuilder<W> setForegroundUpdater(@NonNull ForegroundUpdater updater)

Sets the ForegroundUpdater to be used to construct the androidx.work.ListenableWorker.

Parameters
@NonNull ForegroundUpdater updater

The ForegroundUpdater which can handle notification updates.

setId

Added in 2.1.0
public @NonNull TestListenableWorkerBuilder<W> setId(@NonNull UUID id)

Sets the id for this unit of work.

Parameters
@NonNull UUID id

The UUID

setInputData

Added in 2.1.0
public @NonNull TestListenableWorkerBuilder<W> setInputData(@NonNull Data inputData)

Adds input Data to the work.

Parameters
@NonNull Data inputData

key/value pairs that will be provided to the worker

setNetwork

Added in 2.1.0
@RequiresApi(value = 28)
public @NonNull TestListenableWorkerBuilder<W> setNetwork(@NonNull Network network)

Sets the network associated with this unit of work.

Parameters
@NonNull Network network

The Network associated with this unit of work

setProgressUpdater

Added in 2.3.0
public @NonNull TestListenableWorkerBuilder<W> setProgressUpdater(@NonNull ProgressUpdater updater)

Sets the ProgressUpdater to be used to construct the androidx.work.ListenableWorker.

Parameters
@NonNull ProgressUpdater updater

The ProgressUpdater which can handle progress updates.

setRunAttemptCount

Added in 2.1.0
public @NonNull TestListenableWorkerBuilder<W> setRunAttemptCount(int runAttemptCount)

Sets the initial run attempt count for this work.

Parameters
int runAttemptCount

The initial run attempt count

setTags

Added in 2.1.0
public @NonNull TestListenableWorkerBuilder<W> setTags(@NonNull List<String> tags)

Sets the tags associated with this unit of work.

Parameters
@NonNull List<String> tags

The List of tags to be used

setTriggeredContentAuthorities

Added in 2.1.0
@RequiresApi(value = 24)
public @NonNull TestListenableWorkerBuilder<W> setTriggeredContentAuthorities(@NonNull List<String> authorities)

Sets the authorities for content Uri's associated with this unit of work.

Parameters
@NonNull List<String> authorities

The List of authorities

setTriggeredContentUris

Added in 2.1.0
@RequiresApi(value = 24)
public @NonNull TestListenableWorkerBuilder<W> setTriggeredContentUris(@NonNull List<Uri> contentUris)

Sets the list of Content Uris associated with this unit of work.

Parameters
@NonNull List<Uri> contentUris

The list of content Uris

setWorkerFactory

Added in 2.1.0
public @NonNull TestListenableWorkerBuilder<W> setWorkerFactory(@NonNull WorkerFactory workerFactory)

Sets the WorkerFactory to be used to construct the androidx.work.ListenableWorker.

Parameters
@NonNull WorkerFactory workerFactory

The WorkerFactory to use to construct the androidx.work.ListenableWorker