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

*** ** * ** ***


```
class FakeKeyedAppStatesReporter : KeyedAppStatesReporter
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.enterprise.feedback.KeyedAppStatesReporter](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter) ||
|   | ↳ | [androidx.enterprise.feedback.FakeKeyedAppStatesReporter](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter) |

*** ** * ** ***

A fake `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` for testing.

Example usage:

```kotlin
  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/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#FakeKeyedAppStatesReporter()()` |

| ### Public functions |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getKeyedAppStates()()` Get a list of all `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` instances that have been set. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getKeyedAppStatesByKey()()` Get a map of the latest `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` set for each key. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getNumberOfUploads()()` Get the number of times `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>)` has been called. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getOnDeviceKeyedAppStates()()` Get a list of `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` instances that have been set but not yet uploaded. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getOnDeviceKeyedAppStatesByKey()()` Get a map of the latest `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` set for each key that has not yet uploaded. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getUploadedKeyedAppStates()()` Get a list of `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` instances that have been set and uploaded. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#getUploadedKeyedAppStatesByKey()()` Get a list of the latest `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState` set for each key that has been uploaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setStates](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>)` **This function is deprecated.** see `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>, callback: https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback? )` Record the states set. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[setStatesImmediate](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>)` **This function is deprecated.** See `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)`. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>,androidx.enterprise.feedback.KeyedAppStatesCallback)( states: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppState!>, callback: https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesCallback? )` Record the set states and immediately mark all states as having been uploaded. |

### Inherited functions

From [androidx.enterprise.feedback.KeyedAppStatesReporter](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter) `java-static https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context)(context: https://developer.android.com/reference/android/content/Context.html)`

Create a reporter that binds to device owners, profile owners, and the Play store.
`java-static https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter` `https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/KeyedAppStatesReporter#create(android.content.Context,java.util.concurrent.Executor)(context: https://developer.android.com/reference/android/content/Context.html, executor: https://developer.android.com/reference/java/util/concurrent/Executor.html)`

Create a reporter using the specified executor.

## Public constructors

### FakeKeyedAppStatesReporter

Added in 1.0.0

```
FakeKeyedAppStatesReporter()
```

## Public functions

### getKeyedAppStates

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

```
fun getKeyedAppStates(): (Mutable)List<KeyedAppState!>
```

Get a list of all `https://developer.android.com/reference/kotlin/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)

```
fun getKeyedAppStatesByKey(): (Mutable)Map<String!, KeyedAppState!>
```

Get a map of the latest `https://developer.android.com/reference/kotlin/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)

```
fun getNumberOfUploads(): Int
```

Get the number of times `https://developer.android.com/reference/kotlin/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)

```
fun getOnDeviceKeyedAppStates(): (Mutable)List<KeyedAppState!>
```

Get a list of `https://developer.android.com/reference/kotlin/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/kotlin/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)

```
fun getOnDeviceKeyedAppStatesByKey(): (Mutable)Map<String!, KeyedAppState!>
```

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

Once uploaded (using `https://developer.android.com/reference/kotlin/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)

```
fun getUploadedKeyedAppStates(): (Mutable)List<KeyedAppState!>
```

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

```
fun getUploadedKeyedAppStatesByKey(): (Mutable)Map<String!, KeyedAppState!>
```

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

```
fun [setStates](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStates(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (Mutable)Collection<KeyedAppState!>): Unit
```

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

### setStates

```
fun setStates(
    states: (Mutable)Collection<KeyedAppState!>,
    callback: KeyedAppStatesCallback?
): Unit
```

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)

```
fun [setStatesImmediate](https://developer.android.com/reference/kotlin/androidx/enterprise/feedback/FakeKeyedAppStatesReporter#setStatesImmediate(java.util.Collection<androidx.enterprise.feedback.KeyedAppState>))(states: (Mutable)Collection<KeyedAppState!>): Unit
```

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

### setStatesImmediate

```
fun setStatesImmediate(
    states: (Mutable)Collection<KeyedAppState!>,
    callback: KeyedAppStatesCallback?
): Unit
```

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.