FakeKeyedAppStatesReporter

public class FakeKeyedAppStatesReporter extends KeyedAppStatesReporter


A fake KeyedAppStatesReporter for testing.

Example usage:

  FakeKeyedAppStatesReporter reporter = new FakeKeyedAppStatesReporter();
  // Inject the reporter to the part of your code it will be used.
  assertThat(reporter.getKeyedAppStatesByKey().get("myKey").getMessage()).isEqualTo("expected");

Summary

Public constructors

Public methods

@NonNull List<KeyedAppState>

Get a list of all KeyedAppState instances that have been set.

@NonNull Map<StringKeyedAppState>

Get a map of the latest KeyedAppState set for each key.

int

Get the number of times setStatesImmediate has been called.

@NonNull List<KeyedAppState>

Get a list of KeyedAppState instances that have been set but not yet uploaded.

@NonNull Map<StringKeyedAppState>

Get a map of the latest KeyedAppState set for each key that has not yet uploaded.

@NonNull List<KeyedAppState>

Get a list of KeyedAppState instances that have been set and uploaded.

@NonNull Map<StringKeyedAppState>

Get a list of the latest KeyedAppState set for each key that has been uploaded.

void

This method is deprecated.

see setStates.

void

Record the states set.

void

This method is deprecated.

See setStatesImmediate.

void

Record the set states and immediately mark all states as having been uploaded.

Inherited methods

From androidx.enterprise.feedback.KeyedAppStatesReporter
static @NonNull KeyedAppStatesReporter

Create a reporter that binds to device owners, profile owners, and the Play store.

static @NonNull KeyedAppStatesReporter
create(@NonNull Context context, @NonNull Executor executor)

Create a reporter using the specified executor.

Public constructors

FakeKeyedAppStatesReporter

Added in 1.0.0
public FakeKeyedAppStatesReporter()

Public methods

getKeyedAppStates

Added in 1.0.0
public @NonNull List<KeyedAppStategetKeyedAppStates()

Get a list of all KeyedAppState instances that have been set.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

getKeyedAppStatesByKey

Added in 1.0.0
public @NonNull Map<StringKeyedAppStategetKeyedAppStatesByKey()

Get a map of the latest KeyedAppState set for each key.

getNumberOfUploads

Added in 1.0.0
public int getNumberOfUploads()

Get the number of times setStatesImmediate has been called.

getOnDeviceKeyedAppStates

Added in 1.0.0
public @NonNull List<KeyedAppStategetOnDeviceKeyedAppStates()

Get a list of KeyedAppState instances that have been set but not yet uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

Once uploaded (using setStatesImmediate) instances will no longer be returned by this method.

getOnDeviceKeyedAppStatesByKey

Added in 1.0.0
public @NonNull Map<StringKeyedAppStategetOnDeviceKeyedAppStatesByKey()

Get a map of the latest KeyedAppState set for each key that has not yet uploaded.

Once uploaded (using setStatesImmediate) instances will no longer be returned by this method.

getUploadedKeyedAppStates

Added in 1.0.0
public @NonNull List<KeyedAppStategetUploadedKeyedAppStates()

Get a list of KeyedAppState instances that have been set and uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

States will be returned by this method if they were set using setStatesImmediate or if setStatesImmediate has been called since they were set.

getUploadedKeyedAppStatesByKey

Added in 1.0.0
public @NonNull Map<StringKeyedAppStategetUploadedKeyedAppStatesByKey()

Get a list of the latest KeyedAppState set for each key that has been uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

States will be returned by this method if they were set using setStatesImmediate or if setStatesImmediate has been called since they were set.

setStates

Added in 1.0.0
Deprecated in 1.1.0-rc01
public void setStates(@NonNull Collection<KeyedAppState> states)

setStates

public void setStates(
    @NonNull Collection<KeyedAppState> states,
    @Nullable KeyedAppStatesCallback callback
)

Record the states set.

Does not enforce any limit on total size of states collection.

setStatesImmediate

Added in 1.0.0
Deprecated in 1.1.0-rc01
public void setStatesImmediate(@NonNull Collection<KeyedAppState> states)

setStatesImmediate

public void setStatesImmediate(
    @NonNull Collection<KeyedAppState> states,
    @Nullable KeyedAppStatesCallback callback
)

Record the set states and immediately mark all states as having been uploaded.

Does not enforce any quota on uploading, or limit on total size of states collection.