Skip to content

Commit

Permalink
chore: sync main (#158)
Browse files Browse the repository at this point in the history
* fix(core): remove unused dynamic nav dependency (#2132)

* fix(datastore): remove typename from ModelMetadata (#2122)

* fix(datastore): remove typename from ModelMetadata

* Test a potential fix

* Test a potential fix

* fix: callbacks not invoked when attached using getTransfer api (#2111)

* fix: listener not invoked when attached using getTransfer api

* address PR comments

* default state to unknown

* add comment

* add comment

* override getRequest in storage operation & make SocketExcpetion retryable

* add nullable annotation

* address nullable request

Co-authored-by: Tyler Roach <[email protected]>

* Prevent attempting to read backed up EncryptedSharedPreferences that are no longer readable (#2113)

* fix(auth): device metadata migration (#2114)

* Number of attributes being too high is not retryable (#2112)

* Number of attributes being too high is not retryable

* Match iOS at not retrying bad request error -- covering multiple 400 errors

* Fix lint

* Fix lint

* Update Kotlin SDK version

Co-authored-by: Thomas Leing <[email protected]>

* Change errors returned on some apis while federated (#2116)

* release: Amplify Android 2.0.0 (#2115)

* release: Amplify Android 2.0.0

* add core-kotlin changelog

* add more info in changelog

* revert unintended change

* remove breaking change for analytics

* fix(datastore): remove typename from ModelMetadata

* fix(datastore): remove typename from ModelMetadata

* remove unneeded file

* small cleanup

* remove print statements

* fix comment

* force tests

* force tests

* force tests

Co-authored-by: Michael Law <[email protected]>
Co-authored-by: Michael Schneider <[email protected]>
Co-authored-by: Saijad Dhuka <[email protected]>
Co-authored-by: Tyler Roach <[email protected]>
Co-authored-by: Divyesh Chitroda <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Sunil Timalsina <[email protected]>

* chore: Remove deprecated maven plugin (#2137)

* Remove deprecated maven project

* Fix task name grep

* chore: Remove Javadoc tasks (#2139)

* Remove deprecated maven project

* Fix task name grep

* Remove Javadoc tasks

* fix: Change order of updating state in local cache (#2141)

* fix: fix integration test and added logger to integration test (#2143)

* fix: Change order of updating state in local cache

* change order for updating status and add logger to integ tests

* change log level to debug

* Fix for when move to idle state is called twice (#2152)

* Update README.md (#2120)

remove dev-preview APIs note.

* Dengdan stress test (#2153)

* Initial commit

* Work in progress

* finish codes

* change build

* update build

* test excludeStressTest

* Revert "Merge branch 'main' into dengdan-stress-test"

This reverts commit b50840e, reversing
changes made to 3bacf1b.

* remove categories

* remove external changes

* remove external changes

* remove more changes

* Update copyright and refactor

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* linting

* Update StorageStressTest.kt

* Delete StorageStressTest.kt

* Delete amplifyconfigurationupdated.json

* Delete amplifyconfigurationupdated.json

* Update DataStoreStressTest.kt

* Fix(Auth): Sign up if successful should return DONE instead of Confirm sign up (#2130)

* If sign up is successful in the first try return DONE

* Sign up should send DONE if it is successful

* revert jsongenerator cleandir fun

* lint fix

* Feat(Auth Test): Custom party testing for Custom Test without SRP (#2149)

* Adding custom auth test cases

* Updating test cases for Custom Auth to ensure they pass

* lint format

* Fix for phone number

* Recreate all tests

* Unignore storage and pinpoint tests (#2156)

* unignore tests

* extend timeout to 60s

Co-authored-by: Saijad Dhuka <[email protected]>

* feat(Geo): Add Kotlin Geo Facade (#2155)

* Add Kotlin Geo Facade

* Add return docs to the function comments

* Add tests to verify options are passed

* fix: Add missing apis in storage Kotlin & RxJava facade (#2160)

* fix: Add pause, resume api to kotlin and rxJava facade

* add unit tests

* remove irrelevant code changes

* add assertion

* Update DeviceFarm build config (#2168)

* fix: user metadata was persisted empty in the database (#2165)

* fix: usermeta was persisted as empty in the database

* fix compilation error

* fix compilation error

* avoid adding metadata if it is null

* Add Geo Rx Bindings (#2159)

* chore: Re-add storage tests (#2163)

* Readd storage tests

* rename file

* reduce stress

Co-authored-by: Saijad Dhuka <[email protected]>

* Add a network status listener to restart DataStore after the network … (#2148)

* Add a network status listener to restart DataStore after the network comes back online.

* Add Reachability monitor

* working pretty well

* cleanup

* update test

* fix: fix integration test and added logger to integration test (#2143)

* fix: Change order of updating state in local cache

* change order for updating status and add logger to integ tests

* change log level to debug

* Fix for when move to idle state is called twice (#2152)

* Update README.md (#2120)

remove dev-preview APIs note.

* Dengdan stress test (#2153)

* Initial commit

* Work in progress

* finish codes

* change build

* update build

* test excludeStressTest

* Revert "Merge branch 'main' into dengdan-stress-test"

This reverts commit b50840e, reversing
changes made to 3bacf1b.

* remove categories

* remove external changes

* remove external changes

* remove more changes

* Update copyright and refactor

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* Update StorageStressTest.kt

* linting

* Update StorageStressTest.kt

* Delete StorageStressTest.kt

* Delete amplifyconfigurationupdated.json

* Delete amplifyconfigurationupdated.json

* Update DataStoreStressTest.kt

* force build

* force build

* force build

* fix typo

* Add a network status listener to restart DataStore after the network comes back online.

* Add Reachability monitor

* working pretty well

* cleanup

* update test

* force build

* force build

* force build

* fix typo

* reply to comments

* Add testImplementation lin eto compile tests correctly in intellij

* reply to comments

* make ReachabilityMonitor expose the observable

* Update datastore plugin to use the reachability monitor

* cleanup

* cleanup

* cleanup

* force tests

Co-authored-by: Michael Schneider <[email protected]>
Co-authored-by: Saijad Dhuka <[email protected]>
Co-authored-by: gpanshu <[email protected]>
Co-authored-by: Divyesh Chitroda <[email protected]>
Co-authored-by: dengdan154 <[email protected]>

* chore: Upgrade Gradle, AGP, and KtLint (#2172)

* Remove deprecated maven project

* Fix task name grep

* Upgrade Gradle to 7.5.1

* Upgrade AGP

* Add VERSION_NAME back to BuildConfig

This was removed for library projects in AGP 4.1. We may consider renaming this in the future to disambiguate the Amplify version and the application version.

* Update KtLint and fix all new lint errors

* Use JDK11 on codebuild

* Use JDK11 in workflows

* Upgrade compileSdkVersion to 31

* Try using custom commands to install Android SDK 31

* Update device farm buildspec with manual Android SDK install

* Fix additional ktlint errors

* Upgrade Desugar to JDK11-compatible version

* Upgrade Robolectric

* Set locale explicitly to match expectation

* fix(geo): Increase Geo timeout so that it runs successfully on a Pixel 3a XL (#2177)

* Increase Geo timeout so that it runs successfully on a Pixel 3a XL

* Fix lint

Co-authored-by: Thomas Leing <[email protected]>

* Add a buildspec file for nightly tests (#2180)

* Chore(Auth): Implementation of the custom auth with SRP parity testing use case (#2167)

* Added the test case for custom auth with SRP

* ktlint

* release: Amplify Android 2.1.0 (manually created) (#2185)

Co-authored-by: Thomas Leing <[email protected]>

* chore: Add PR checker workflow (#2188)

* fix(Auth): Fix for when loading credentials the success/error is fired twice (#2184)

* chore: update changelog for Amplify Android 2.1.0 (#2193)

* feat(Auth): Overriding sign in when the State machine is already in the signing in state (#2187)

* chore: fix inconsistency with endpointWithAttributes test (#2196)

* chore: update changelog for v2.1.0 (#2198)

* chore: replace md5 with sha-256 for file data validation (#2199)

* chore: Remove unused version and group properties (#2186)

* chore: Add a label that will disable the PR title check (#2195)

Co-authored-by: gpanshu <[email protected]>

* chore: add release tag to PR title checker config (#2194)

Co-authored-by: Matt Creaser <[email protected]>

* fix(datastore): Fix lock contention issue when running DataStore.start() from the callback of DataStore.stop() (#2208)

Co-authored-by: Michael Schneider <[email protected]>

* chore: Add group and version back to all subprojects (#2213)

* chore: Remove the release-kotlin_v block from prepare release script (#2231)

* fix(core): Remove unused dependencies (#2207)

Co-authored-by: Matt Creaser <[email protected]>

* chore: Modify the bump_version branch name to be specific to the base branch (#2240)

* fix(geo): Bump MapLibre SDK to 9.6.0 (#2254)

* release: Amplify Android 2.1.1 (#2257)

Co-authored-by: amplify-android-dev+ghops <[email protected]>

* fix(analytics): Remove test dependencies from implementation configuration (#2253)

* chore: Ignore clearStopsSyncAndDeletesDatabase test (#2262)

* fix(auth): Fix Authorization header for HostedUI fetchToken when appSecret is used (#2264)

* chore: Supply base_branch when calling `create_next_release_pr` lane (#2245)

* chore: Update PR template to include security checklist item (#2251)

* feat(auth): add required hash param to cognito api calls (#2266)

Co-authored-by: Banji Jolaoso <[email protected]>
Co-authored-by: AWS Mobile SDK Bot <[email protected]>
Co-authored-by: Saijad Dhuka <[email protected]>
Co-authored-by: Tyler Roach <[email protected]>

* feat(datastore): Add recoverability improvements (#2201)

Co-authored-by: Matt Creaser <[email protected]>

* feat(auth): Added parity test for fetchDevices,rememberDevice,forgetDevice and fetchUserAttributes (#2174)

Co-authored-by: Sunil Timalsina <[email protected]>
Co-authored-by: Banji Jolaoso <[email protected]>
Co-authored-by: Divyesh Chitroda <[email protected]>
Co-authored-by: Matt Creaser <[email protected]>
Co-authored-by: Saijad Dhuka <[email protected]>
Co-authored-by: Tyler Roach <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: gpanshu <[email protected]>
Co-authored-by: AWS Mobile SDK Bot <[email protected]>

* release: Amplify Android 2.2.0 (#2269)

Co-authored-by: amplify-android-dev+ghops <[email protected]>

* chore: Convert build.gradle files to Kotlin (#2183)

* Convert build.gradle files to Kotlin

* Fix missing test dependency

* Update copyright year

* chore: Set the signing information in project extras (#2277)

* fix(auth): Moving credential provider to main (#2273)

* chore(analytics): Simplify error code checking, uniformly across platforms (#2274)

Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Matt Creaser <[email protected]>

* feat(auth): added kover plugin for coverage (#2267)

Co-authored-by: Banji Jolaoso <[email protected]>
Co-authored-by: gpanshu <[email protected]>

* release: Amplify Android 2.2.1 (#2285)

Co-authored-by: amplify-android-dev+ghops <[email protected]>
Co-authored-by: Matt Creaser <[email protected]>

* chore: Remove circleci configuration file (#2279)

Co-authored-by: gpanshu <[email protected]>

* fix(auth): fix npe in initialize fetch auth session (#2284)

Co-authored-by: Banji Jolaoso <[email protected]>

* fix(auth): Fix confirm signin when incorrect MFA code is entered (#2286)

* release: Amplify Android 2.2.2 (#2292)

Co-authored-by: amplify-android-dev+ghops <[email protected]>

* chore: Fix using amplify-android in a composite build (#2294)

* chore: update device farm configuration for nightly build (#2281)

* chore: remove buildspec files (#2308)

* chore: remove amplify-data from codeowners (#2252)

Co-authored-by: Saijad Dhuka <[email protected]>

* fix(datastore): Fix aliasing of column names (#2312)

* fix gradle build config after merge

---------

Co-authored-by: Erica Eaton <[email protected]>
Co-authored-by: Michael Schneider <[email protected]>
Co-authored-by: Michael Law <[email protected]>
Co-authored-by: Michael Schneider <[email protected]>
Co-authored-by: Saijad Dhuka <[email protected]>
Co-authored-by: Tyler Roach <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Thomas Leing <[email protected]>
Co-authored-by: Sunil Timalsina <[email protected]>
Co-authored-by: Matt Creaser <[email protected]>
Co-authored-by: gpanshu <[email protected]>
Co-authored-by: dengdan154 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: amplify-android-dev+ghops <[email protected]>
Co-authored-by: banji180 <[email protected]>
Co-authored-by: Banji Jolaoso <[email protected]>
Co-authored-by: AWS Mobile SDK Bot <[email protected]>
Co-authored-by: Manuel Iglesias <[email protected]>
Co-authored-by: Dane Pilcher <[email protected]>
  • Loading branch information
20 people authored Mar 8, 2023
1 parent 37254b4 commit 2524e21
Show file tree
Hide file tree
Showing 159 changed files with 3,437 additions and 2,253 deletions.
56 changes: 0 additions & 56 deletions .circleci/config.yml

This file was deleted.

8 changes: 0 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
* @aws-amplify/amplify-android
/aws-api-appsync @aws-amplify/amplify-android @aws-amplify/amplify-data
/aws-api @aws-amplify/amplify-android @aws-amplify/amplify-data
/aws-datastore @aws-amplify/amplify-android @aws-amplify/amplify-data
/aws-core @aws-amplify/amplify-android @aws-amplify/amplify-data
/.github @aws-amplify/amplify-android @aws-amplify/amplify-data
/.circleci @aws-amplify/amplify-android @aws-amplify/amplify-data
/testmodels @aws-amplify/amplify-android @aws-amplify/amplify-data
/testutils @aws-amplify/amplify-android @aws-amplify/amplify-data
8 changes: 5 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*How did you test these changes?*
(Please add a line here how the changes were tested)

- [ ] Added Unit Tests
- [ ] Added Integration Tests

*Documentation update required?*
- [ ] No
- [ ] Yes (Please include a PR link for the documentation update)

*General Checklist*
- [ ] Added Unit Tests
- [ ] Added Integration Tests
- [ ] Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
2 changes: 1 addition & 1 deletion .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"prefixes": ["chore: ", "refactor: ", "perf: ", "test: ", "docs: ", "release: "],
"regexp": "(fix|feat)\\((all|analytics|api|auth|core|datastore|geo|predictions|storage|notifications)\\): ",
"regexpFlags": "",
"ignoreLabels" : ["ignore-pr-title"]
"ignoreLabels" : ["ignore-pr-title"]
},
"MESSAGES": {
"success": "All OK",
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codecov_code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:
java-version: '11'
distribution: 'corretto'

- name: Run test and generate jacoco report
run: ./gradlew jacocoTestReport
- name: Run test and generate kover report
run: ./gradlew koverReport

- name: create temp directory
run: mkdir /home/runner/work/amplify-android/amplify-android/code-coverage

- name: copy jacoco test report to temp directory
run: cp -r /home/runner/work/amplify-android/amplify-android/**/build/coverage-report/*.xml /home/runner/work/amplify-android/amplify-android/code-coverage/
- name: copy kover test report to temp directory
run: cp -r /home/runner/work/amplify-android/amplify-android/**/build/reports/kover/xml/*.xml /home/runner/work/amplify-android/amplify-android/code-coverage/

- name: Upload Test Report
uses: codecov/codecov-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
bundle exec fastlane android configure_git_options git_user_email:$GIT_USER_EMAIL git_user_name:$GIT_USER_NAME
- name: Create/checkout a branch for the release
run: |
branch_name=bump_version
branch_name=bump_version_${{ env.BASE_BRANCH }}
git fetch --all
(git branch -D $branch_name &>/dev/null) && (echo 'Existing $branch_name branch deleted') || (echo 'No existing $branch_name branch to delete.')
git checkout -b $branch_name
Expand All @@ -48,7 +48,7 @@ jobs:
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
run: |
cd scripts
bundle exec fastlane android create_next_release_pr release_tag:"$RELEASE_TAG"
bundle exec fastlane android create_next_release_pr release_tag:"$RELEASE_TAG" base_branch:"$BASE_BRANCH"
- name: Check modified file content
run: |
cat gradle.properties
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
## [Release 2.2.2](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.2.2)

### Bug Fixes
- **auth:** fix npe in initialize fetch auth session ([#2284](https://github.com/aws-amplify/amplify-android/issues/2284))
- **auth:** Fix confirm signin when incorrect MFA code is entered ([#2286](https://github.com/aws-amplify/amplify-android/issues/2286))

[See all changes between 2.2.1 and 2.2.2](https://github.com/aws-amplify/amplify-android/compare/release_v2.2.1...release_v2.2.2)

## [Release 2.2.1](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.2.1)

### Bug Fixes
- **auth:** Moving credential provider to main (#2273)

[See all changes between 2.2.0 and 2.2.1](https://github.com/aws-amplify/amplify-android/compare/release_v2.2.0...release_v2.2.1)

## [Release 2.2.0](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.2.0)

### Features
- **auth:** add required hash param to cognito api calls (#2266)
- **datastore:** Add recoverability improvements (#2201)
- **auth:** Added parity test for fetchDevices,rememberDevice,forgetDevice and fetchUserAttributes (#2174)

### Bug Fixes
- **analytics:** Remove test dependencies from implementation configuration (#2253)
- **auth:** Fix Authorization header for HostedUI fetchToken when appSecret is used (#2264)

[See all changes between 2.1.1 and 2.2.0](https://github.com/aws-amplify/amplify-android/compare/release_v2.1.1...release_v2.2.0)

## [Release 2.1.1](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.1.1)

### Bug Fixes
- **datastore:** Fix lock contention issue when running DataStore.start() from the callback of DataStore.stop() (#2208)
- **core:** Remove unused dependencies (#2207)
- **geo:** Bump MapLibre SDK to 9.6.0 (#2254)

[See all changes between 2.1.0 and 2.1.1](https://github.com/aws-amplify/amplify-android/compare/release_v2.1.0...release_v2.1.1)

## [Release 2.1.0](https://github.com/aws-amplify/amplify-android/releases/tag/release_v2.1.0)

### Features
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ dependencies section:
```groovy
dependencies {
// Only specify modules that provide functionality your app will use
implementation 'com.amplifyframework:aws-analytics-pinpoint:2.1.0'
implementation 'com.amplifyframework:aws-api:2.1.0'
implementation 'com.amplifyframework:aws-auth-cognito:2.1.0'
implementation 'com.amplifyframework:aws-datastore:2.1.0'
implementation 'com.amplifyframework:aws-predictions:2.1.0'
implementation 'com.amplifyframework:aws-storage-s3:2.1.0'
implementation 'com.amplifyframework:aws-analytics-pinpoint:2.2.2'
implementation 'com.amplifyframework:aws-api:2.2.2'
implementation 'com.amplifyframework:aws-auth-cognito:2.2.2'
implementation 'com.amplifyframework:aws-datastore:2.2.2'
implementation 'com.amplifyframework:aws-predictions:2.2.2'
implementation 'com.amplifyframework:aws-storage-s3:2.2.2'
}
```

Expand Down
44 changes: 0 additions & 44 deletions aws-analytics-pinpoint-targeting/build.gradle

This file was deleted.

47 changes: 47 additions & 0 deletions aws-analytics-pinpoint-targeting/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

plugins {
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.10"
id("com.android.library")
id("kotlin-android")
id("org.jlleitschuh.gradle.ktlint")
}

apply(from = rootProject.file("configuration/checkstyle.gradle"))
apply(from = rootProject.file("configuration/publishing.gradle"))

group = properties["POM_GROUP"].toString()

dependencies {
implementation(project(":core"))

implementation(dependency.androidx.appcompat)
implementation(dependency.aws.pinpoint)
implementation(dependency.kotlin.serializationJson)
// implementation("androidx.test.ext:junit-ktx:1.1.5")

testImplementation(testDependency.junit)
testImplementation(testDependency.mockk)
testImplementation(testDependency.mockito)
testImplementation(testDependency.mockitoinline)
testImplementation(testDependency.robolectric)
testImplementation(testDependency.androidx.test.core)
testImplementation(testDependency.kotlin.test.coroutines)

androidTestImplementation(testDependency.androidx.test.core)
androidTestImplementation(testDependency.androidx.test.runner)
androidTestImplementation(testDependency.androidx.test.junit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class EventRecorder(
logger.info("Successfully submitted event with eventId ${pinpointEvent.eventId}")
eventIdToDelete.add(pinpointEvent)
} else {
if (isRetryableError(message, pinpointEventResponse.statusCode)) {
if (isRetryableError(pinpointEventResponse.statusCode)) {
logger.error(
"Failed to deliver event with ${pinpointEvent.eventId}," +
" will be re-delivered later"
Expand All @@ -196,13 +196,8 @@ class EventRecorder(
return eventIdToDelete
}

private fun isRetryableError(message: String, code: Int): Boolean {
return !(
message.equals("ValidationException", ignoreCase = true) ||
message.equals("SerializationException", ignoreCase = true) ||
message.equals("BadRequestException", ignoreCase = true) ||
code == badRequestCode
)
private fun isRetryableError(code: Int): Boolean {
return code in 500..599
}

private fun processEndpointResponse(endpointResponse: EndpointItemResponse?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,52 @@ class EventRecorderTest {
}
}

@Test
fun `test retryable errors`() = runTest {
val pinpointEvent1 = getPinpointEvent("testEvent1")
val pinpointEvent2 = getPinpointEvent("testEvent2")

// setup database
val pinpointEvents = listOf(
arrayOf(1, pinpointEvent1.toJsonString().length, pinpointEvent1.toJsonString()),
arrayOf(2, pinpointEvent2.toJsonString().length, pinpointEvent2.toJsonString())
)
val matrixCursor = MatrixCursor(arrayOf(EventTable.COLUMN_ID, EventTable.COLUMN_SIZE, EventTable.COLUMN_JSON))
pinpointEvents.forEach {
matrixCursor.addRow(it)
}
coEvery { pinpointDatabaseMock.queryAllEvents() }.answers { matrixCursor }

// setup pinpoint client
val endpointId = UUID.randomUUID().toString()
coEvery { endpointProfile.endpointId }.answers { endpointId }
coEvery { targetingClient.currentEndpoint() }.answers { endpointProfile }
val itemResponse = ItemResponse {
eventsItemResponse = mapOf(
pinpointEvent1.eventId to EventItemResponse {
message = "Internal Server Error"
statusCode = 500
},
pinpointEvent2.eventId to EventItemResponse {
message = "Not real, but 599 should be retryable as well"
statusCode = 599
}
)
}
val putEventResponse = PutEventsResponse {
eventsResponse = EventsResponse {
results = mapOf(endpointId to itemResponse)
}
}
coEvery { pinpointClient.putEvents(any<PutEventsRequest>()) }.answers { putEventResponse }

eventRecorder.submitEvents()

coVerify(exactly = 0) {
pinpointDatabaseMock.deleteEventById(any())
}
}

private fun getPinpointEvent(eventType: String): PinpointEvent {
return PinpointEvent(
eventType = eventType,
Expand Down
Loading

0 comments on commit 2524e21

Please sign in to comment.