# FakeKeyedAppStatesReporter

Artifact: [androidx.enterprise:enterprise-feedback-testing](https://developer.android.com/jetpack/androidx/releases/enterprise) [View Source](https://cs.android.com/search?q=file:androidx/enterprise/feedback/FakeKeyedAppStatesReporter.java+class:androidx.enterprise.feedback.FakeKeyedAppStatesReporter) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

*** ** * ** ***


```
public class FakeKeyedAppStatesReporter extends KeyedAppStatesReporter
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.enterprise.feedback.KeyedAppStatesReporter](https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter) ||
|   | ↳ | [androidx.enterprise.feedback.FakeKeyedAppStatesReporter](https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter) |

*** ** * ** ***

A fake `https://developer.android.com/reference/androidx/enterprise/feedback/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 |
|---|
| `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#FakeKeyedAppStatesReporter()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getKeyedAppStates()()` Get a list of all `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` instances that have been set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getKeyedAppStatesByKey()()` Get a map of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` set for each key. |
| `int` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getNumberOfUploads()()` Get the number of times `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` has been called. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getOnDeviceKeyedAppStates()()` Get a list of `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` instances that have been set but not yet uploaded. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getOnDeviceKeyedAppStatesByKey()()` Get a map of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` set for each key that has not yet uploaded. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getUploadedKeyedAppStates()()` Get a list of `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` instances that have been set and uploaded. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState>` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getUploadedKeyedAppStatesByKey()()` Get a list of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` set for each key that has been uploaded. |
| `void` | `[setStates](https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState> states)` **This method is deprecated.** see `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`. <br /> |
| `void` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState> states, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesCallback callback )` Record the states set. |
| `void` | `[setStatesImmediate](https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState> states)` **This method is deprecated.** See `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`. <br /> |
| `void` | `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Collection.html<https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState> states, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesCallback callback )` Record the set states and immediately mark all states as having been uploaded. |

### Inherited methods

From [androidx.enterprise.feedback.KeyedAppStatesReporter](https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter) `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter` `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)`

Create a reporter that binds to device owners, profile owners, and the Play store.
`static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter` `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context,java.util.concurrent.Executor)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html 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](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull List<KeyedAppState> getKeyedAppStates()
```

Get a list of all `https://developer.android.com/reference/androidx/enterprise/feedback/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](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull Map<String, KeyedAppState> getKeyedAppStatesByKey()
```

Get a map of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` set for each key.

### getNumberOfUploads

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public int getNumberOfUploads()
```

Get the number of times `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` has been called.

### getOnDeviceKeyedAppStates

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull List<KeyedAppState> getOnDeviceKeyedAppStates()
```

Get a list of `https://developer.android.com/reference/androidx/enterprise/feedback/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 `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)`) instances will no longer be returned by this method.

### getOnDeviceKeyedAppStatesByKey

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull Map<String, KeyedAppState> getOnDeviceKeyedAppStatesByKey()
```

Get a map of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/KeyedAppState` set for each key that has not yet uploaded.

Once uploaded (using `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)`) instances will no longer be returned by this method.

### getUploadedKeyedAppStates

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull List<KeyedAppState> getUploadedKeyedAppStates()
```

Get a list of `https://developer.android.com/reference/androidx/enterprise/feedback/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 `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` or if `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` has been called since they were set.

### getUploadedKeyedAppStatesByKey

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0)

```
public @NonNull Map<String, KeyedAppState> getUploadedKeyedAppStatesByKey()
```

Get a list of the latest `https://developer.android.com/reference/androidx/enterprise/feedback/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 `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` or if `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` has been called since they were set.

### setStates

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
public void [setStates](https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(@NonNull Collection<KeyedAppState> states)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> see `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`.

### 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](https://developer.android.com/jetpack/androidx/releases/enterprise#1.0.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/enterprise#1.1.0)

```
public void [setStatesImmediate](https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(@NonNull Collection<KeyedAppState> states)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> See `https://developer.android.com/reference/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`.

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