# FakeHealthConnectClientOverrides

Artifact: [androidx.health.connect:connect-testing](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/testing/FakeHealthConnectClientOverrides.kt+class:androidx.health.connect.client.testing.FakeHealthConnectClientOverrides) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

*** ** * ** ***


```
class FakeHealthConnectClientOverrides
```

<br />

*** ** * ** ***

Used to override or intercept responses to emulate scenarios that `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient` doesn't support.

Every call in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient` can be overridden.

For example:

```kotlin
import androidx.health.connect.client.testing.stubs.stub

// Sets a default return value for client.aggregate() and a queue with one item.
client.overrides.aggregate = stub(queue = listOf(resultOnce)) { result }
```

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.MutableStub
import androidx.health.connect.client.testing.stubs.enqueue

// Sets a default exception that will be thrown for client.aggregate().
val aggregationStub = MutableStub<AggregationResult>(exception)
client.overrides.aggregate = aggregationStub

// Only the first call to client.aggregate() will return this result. Subsequent calls will
// throw the default.
aggregationStub.enqueue(result)

// Setting a default response removes the default exception.
aggregationStub.defaultHandler = { AggregationResult() }
```

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.records.ExerciseSessionRecord
import androidx.health.connect.client.records.HeartRateRecord
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result =
    AggregationResult(
        metrics =
            buildMap {
                put(HeartRateRecord.BPM_AVG, 74.0)
                put(ExerciseSessionRecord.EXERCISE_DURATION_TOTAL, Duration.ofMinutes(30))
            }
    )
client.overrides.aggregate = stub(result)
```

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result = buildList {
    add(
        AggregationResultGroupedByDuration(
            aggregationResult1,
            startTime1,
            endTime1,
            ZoneOffset.UTC,
        )
    )
    add(
        AggregationResultGroupedByDuration(
            aggregationResult2,
            startTime2,
            endTime2,
            ZoneOffset.UTC,
        )
    )
}
client.overrides.aggregateGroupByDuration = stub(default = result)
```

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result = buildList {
    add(AggregationResultGroupedByPeriod(aggregationResult1, startTime1, endTime1))
    add(AggregationResultGroupedByPeriod(aggregationResult2, startTime2, endTime2))
}
client.overrides.aggregateGroupByPeriod = stub(default = result)
```

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.records.ExerciseSessionRecord
import androidx.health.connect.client.records.HeartRateRecord
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result =
    AggregationResult(
        metrics =
            buildMap {
                put(HeartRateRecord.BPM_AVG, 74.0)
                put(ExerciseSessionRecord.EXERCISE_DURATION_TOTAL, Duration.ofMinutes(30))
            }
    )
client.overrides.aggregate = stub(result)
```

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#FakeHealthConnectClientOverrides(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)( getChanges: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ChangesResponse>?, getChangesToken: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ChangesTokenRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>?, readRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ReadRecordsRequest<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordsResponse<*>>?, readRecord: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordResponse<*>>?, insertRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/InsertRecordsResponse>?, updateRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>?, deleteRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>?, aggregate: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateRequest, https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResult>?, aggregateGroupByDuration: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByDurationRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration>>?, aggregateGroupByPeriod: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByPeriodRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod>>? )` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateRequest, https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResult>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#aggregate()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregate(androidx.health.connect.client.request.AggregateRequest)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByDurationRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration>>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#aggregateGroupByDuration()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByDuration(androidx.health.connect.client.request.AggregateGroupByDurationRequest)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByPeriodRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod>>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#aggregateGroupByPeriod()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByPeriod(androidx.health.connect.client.request.AggregateGroupByPeriodRequest)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#deleteRecords()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ChangesResponse>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#getChanges()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ChangesTokenRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#getChangesToken()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/InsertRecordsResponse>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#insertRecords()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordResponse<*>>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#readRecord()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ReadRecordsRequest<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordsResponse<*>>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#readRecords()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#updateRecords()` A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`. |

## Public constructors

### FakeHealthConnectClientOverrides

```
FakeHealthConnectClientOverrides(
    getChanges: Stub<String, ChangesResponse>? = null,
    getChangesToken: Stub<ChangesTokenRequest, String>? = null,
    readRecords: Stub<ReadRecordsRequest<*>, ReadRecordsResponse<*>>? = null,
    readRecord: Stub<String, ReadRecordResponse<*>>? = null,
    insertRecords: Stub<List<*>, InsertRecordsResponse>? = null,
    updateRecords: Stub<Any, Nothing>? = null,
    deleteRecords: Stub<Any, Nothing>? = null,
    aggregate: Stub<AggregateRequest, AggregationResult>? = null,
    aggregateGroupByDuration: Stub<AggregateGroupByDurationRequest, List<AggregationResultGroupedByDuration>>? = null,
    aggregateGroupByPeriod: Stub<AggregateGroupByPeriodRequest, List<AggregationResultGroupedByPeriod>>? = null
)
```

| Parameters |
|---|---|
| `getChanges: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ChangesResponse>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#getChanges()`. |
| `getChangesToken: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ChangesTokenRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#getChangesToken()`. |
| `readRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/ReadRecordsRequest<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordsResponse<*>>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#readRecords()`. |
| `readRecord: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/ReadRecordResponse<*>>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#readRecord()`. |
| `insertRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<*>, https://developer.android.com/reference/kotlin/androidx/health/connect/client/response/InsertRecordsResponse>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#insertRecords()`. |
| `updateRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#updateRecords()`. |
| `deleteRecords: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-nothing/index.html>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#deleteRecords()`. |
| `aggregate: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateRequest, https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResult>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregate(androidx.health.connect.client.request.AggregateRequest)`. |
| `aggregateGroupByDuration: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByDurationRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByDuration>>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByDuration(androidx.health.connect.client.request.AggregateGroupByDurationRequest)`. |
| `aggregateGroupByPeriod: https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub<https://developer.android.com/reference/kotlin/androidx/health/connect/client/request/AggregateGroupByPeriodRequest, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/health/connect/client/aggregate/AggregationResultGroupedByPeriod>>? = null` | A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByPeriod(androidx.health.connect.client.request.AggregateGroupByPeriodRequest)`. |

## Public properties

### aggregate

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var aggregate: Stub<AggregateRequest, AggregationResult>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregate(androidx.health.connect.client.request.AggregateRequest)`.

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.records.ExerciseSessionRecord
import androidx.health.connect.client.records.HeartRateRecord
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result =
    AggregationResult(
        metrics =
            buildMap {
                put(HeartRateRecord.BPM_AVG, 74.0)
                put(ExerciseSessionRecord.EXERCISE_DURATION_TOTAL, Duration.ofMinutes(30))
            }
    )
client.overrides.aggregate = stub(result)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |

### aggregateGroupByDuration

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var aggregateGroupByDuration: Stub<AggregateGroupByDurationRequest, List<AggregationResultGroupedByDuration>>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByDuration(androidx.health.connect.client.request.AggregateGroupByDurationRequest)`.

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result = buildList {
    add(
        AggregationResultGroupedByDuration(
            aggregationResult1,
            startTime1,
            endTime1,
            ZoneOffset.UTC,
        )
    )
    add(
        AggregationResultGroupedByDuration(
            aggregationResult2,
            startTime2,
            endTime2,
            ZoneOffset.UTC,
        )
    )
}
client.overrides.aggregateGroupByDuration = stub(default = result)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |

### aggregateGroupByPeriod

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var aggregateGroupByPeriod: Stub<AggregateGroupByPeriodRequest, List<AggregationResultGroupedByPeriod>>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClient#aggregateGroupByPeriod(androidx.health.connect.client.request.AggregateGroupByPeriodRequest)`.

```kotlin
import androidx.health.connect.client.aggregate.AggregationResult
import androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod
import androidx.health.connect.client.testing.AggregationResult
import androidx.health.connect.client.testing.stubs.stub

val result = buildList {
    add(AggregationResultGroupedByPeriod(aggregationResult1, startTime1, endTime1))
    add(AggregationResultGroupedByPeriod(aggregationResult2, startTime2, endTime2))
}
client.overrides.aggregateGroupByPeriod = stub(default = result)
```

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)` |   |

### deleteRecords

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var deleteRecords: Stub<Any, Nothing>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### getChanges

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var getChanges: Stub<String, ChangesResponse>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### getChangesToken

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var getChangesToken: Stub<ChangesTokenRequest, String>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### insertRecords

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var insertRecords: Stub<List<*>, InsertRecordsResponse>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### readRecord

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var readRecord: Stub<String, ReadRecordResponse<*>>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### readRecords

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var readRecords: Stub<ReadRecordsRequest<*>, ReadRecordsResponse<*>>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used to set the next responses used in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.

### updateRecords

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/health-connect#1.0.0-alpha04)

```
var updateRecords: Stub<Any, Nothing>?
```

A `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/stubs/Stub` used only to throw exceptions in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides#(androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub,androidx.health.connect.client.testing.stubs.Stub)`.