Skip to content

Commit e6563dd

Browse files
tjleingThomas Leinggpanshumattcreaser
authored
fix(core): use returns instead of answers on coEvery (#2653)
Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: Matt Creaser <[email protected]>
1 parent 7eecf2e commit e6563dd

File tree

25 files changed

+88
-26
lines changed

25 files changed

+88
-26
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ block inside your app's `build.gradle`, as below:
9191
android {
9292
compileOptions {
9393
coreLibraryDesugaringEnabled true
94-
sourceCompatibility JavaVersion.VERSION_1_8
95-
targetCompatibility JavaVersion.VERSION_1_8
94+
sourceCompatibility JavaVersion.VERSION_11
95+
targetCompatibility JavaVersion.VERSION_11
9696
}
9797
}
9898
```

aws-analytics-pinpoint/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ dependencies {
5151
androidTestImplementation(libs.test.androidx.junit)
5252
androidTestImplementation(project(":aws-analytics-pinpoint"))
5353
}
54+
55+
android.kotlinOptions {
56+
jvmTarget = "11"
57+
}

aws-api-appsync/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ dependencies {
3737
testImplementation(project(":testmodels"))
3838
testImplementation(project(":testutils"))
3939
}
40+
41+
android.kotlinOptions {
42+
jvmTarget = "11"
43+
}

aws-api/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ dependencies {
6969

7070
androidTestUtil(libs.test.androidx.orchestrator)
7171
}
72+
73+
android.kotlinOptions {
74+
jvmTarget = "11"
75+
}

aws-auth-cognito/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ dependencies {
6767
androidTestImplementation(project(":aws-api"))
6868
androidTestImplementation(project(":testutils"))
6969
}
70+
71+
android.kotlinOptions {
72+
jvmTarget = "11"
73+
}

aws-auth-cognito/src/test/java/featureTest/utilities/APICaptorFactory.kt

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class APICaptorFactory(
6060
val errorCaptor = slot<AuthException>()
6161
val actionCaptor = slot<Map<String, Any>>().apply {
6262
captured = emptyMap()
63-
isCaptured = true
6463
}
6564
}
6665

aws-auth-plugins-core/build.gradle.kts

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ apply(from = rootProject.file("configuration/publishing.gradle"))
2424

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

27+
android {
28+
kotlinOptions {
29+
jvmTarget = JavaVersion.VERSION_11.toString()
30+
}
31+
}
32+
2733
dependencies {
2834
implementation(project(":core"))
2935
implementation(project(":aws-core"))

aws-datastore/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ dependencies {
5858
}
5959

6060
afterEvaluate {
61-
android.kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
61+
android.kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
6262
}

aws-datastore/src/test/java/com/amplifyframework/datastore/storage/sqlite/SQLCommandProcessorTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ public void rawQueryReturnsResults() throws AmplifyException {
116116

117117
// Query for all BlogOwners, and verify that there is one result.
118118
SqlCommand queryCommand = sqlCommandFactory.queryFor(blogOwnerSchema, Where.matchesAll());
119-
Cursor cursor = sqlCommandProcessor.rawQuery(queryCommand);
119+
Cursor cursor = null;
120+
try {
121+
cursor = sqlCommandProcessor.rawQuery(queryCommand);
122+
} catch (Exception exc) {
123+
throw new AmplifyException("DB already closed", exc, "Wait until DB is reopened");
124+
}
120125
List<BlogOwner> results = new ArrayList<>();
121126

122127
SQLiteModelFieldTypeConverter converter = new SQLiteModelFieldTypeConverter(blogOwnerSchema,

aws-geo-location/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ dependencies {
4040
}
4141

4242
afterEvaluate {
43-
android.kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
43+
android.kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
4444
}

aws-logging-cloudwatch/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ dependencies {
4747
testImplementation(libs.test.androidx.workmanager)
4848
testImplementation(project(":aws-logging-cloudwatch"))
4949
}
50+
51+
android.kotlinOptions {
52+
jvmTarget = "11"
53+
}

aws-logging-cloudwatch/src/test/kotlin/com/amplifyframework/logging/cloudwatch/AWSCloudWatchLoggingPluginImplementationTest.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ internal class AWSCloudWatchLoggingPluginImplementationTest {
6060
region = "REGION",
6161
logGroupName = "LOG_GROUP"
6262
)
63-
every { loggingConstraintsResolver::localLoggingConstraint.set(capture(loggingConstraintsSlot)) }.answers { }
64-
coEvery { cloudWatchLogManager.startSync() }.answers { }
63+
every { loggingConstraintsResolver::localLoggingConstraint.set(capture(loggingConstraintsSlot)) } returns Unit
64+
coEvery { cloudWatchLogManager.startSync() } returns Unit
6565
awsCloudWatchLoggingPluginImplementation.configure(
6666
awsLoggingConfig
6767
)
@@ -77,8 +77,8 @@ internal class AWSCloudWatchLoggingPluginImplementationTest {
7777
region = "REGION",
7878
logGroupName = "LOG_GROUP"
7979
)
80-
every { loggingConstraintsResolver::localLoggingConstraint.set(any()) }.answers { }
81-
coEvery { cloudWatchLogManager.startSync() }.answers { }
80+
every { loggingConstraintsResolver::localLoggingConstraint.set(any()) } returns Unit
81+
coEvery { cloudWatchLogManager.startSync() } returns Unit
8282
awsCloudWatchLoggingPluginImplementation.configure(
8383
awsLoggingConfig
8484
)
@@ -88,15 +88,15 @@ internal class AWSCloudWatchLoggingPluginImplementationTest {
8888

8989
@Test
9090
fun `on enable`() = runTest {
91-
coEvery { cloudWatchLogManager.startSync() }.answers { }
91+
coEvery { cloudWatchLogManager.startSync() } returns Unit
9292
awsCloudWatchLoggingPluginImplementation.enable()
9393
assertTrue(awsCloudWatchLoggingPluginImplementation.isPluginEnabled)
9494
coVerify(exactly = 1) { cloudWatchLogManager.startSync() }
9595
}
9696

9797
@Test
9898
fun `on disable`() {
99-
every { cloudWatchLogManager.stopSync() }.answers { }
99+
every { cloudWatchLogManager.stopSync() } returns Unit
100100
awsCloudWatchLoggingPluginImplementation.disable()
101101
assertFalse(awsCloudWatchLoggingPluginImplementation.isPluginEnabled)
102102
verify(exactly = 1) { cloudWatchLogManager.stopSync() }
@@ -106,8 +106,8 @@ internal class AWSCloudWatchLoggingPluginImplementationTest {
106106
fun `on flush logs success`() = runTest {
107107
val onSuccess = mockk<Action>()
108108
val onError = mockk<Consumer<AmplifyException>>()
109-
coEvery { cloudWatchLogManager.syncLogEventsWithCloudwatch() }.answers { }
110-
every { onSuccess.call() }.answers { }
109+
coEvery { cloudWatchLogManager.syncLogEventsWithCloudwatch() } returns Unit
110+
every { onSuccess.call() } returns Unit
111111
awsCloudWatchLoggingPluginImplementation.flushLogs(onSuccess, onError)
112112
coVerify(exactly = 1) { cloudWatchLogManager.syncLogEventsWithCloudwatch() }
113113
verify(exactly = 1) { onSuccess.call() }
@@ -120,7 +120,7 @@ internal class AWSCloudWatchLoggingPluginImplementationTest {
120120
val onError = mockk<Consumer<AmplifyException>>()
121121
val exception = slot<AmplifyException>()
122122
coEvery { cloudWatchLogManager.syncLogEventsWithCloudwatch() }.throws(IllegalStateException())
123-
every { onError.accept(capture(exception)) }.answers { }
123+
every { onError.accept(capture(exception)) } returns Unit
124124
awsCloudWatchLoggingPluginImplementation.flushLogs(onSuccess, onError)
125125
coVerify(exactly = 1) { cloudWatchLogManager.syncLogEventsWithCloudwatch() }
126126
verify(exactly = 0) { onSuccess.call() }

aws-pinpoint-core/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ dependencies {
4444
androidTestImplementation(libs.test.androidx.runner)
4545
androidTestImplementation(libs.test.androidx.junit)
4646
}
47+
48+
android.kotlinOptions {
49+
jvmTarget = "11"
50+
}

aws-pinpoint-core/src/test/java/com/amplifyframework/pinpoint/core/AnalyticsClientTest.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import java.util.UUID
3535
import kotlinx.coroutines.ExperimentalCoroutinesApi
3636
import kotlinx.coroutines.test.UnconfinedTestDispatcher
3737
import kotlinx.coroutines.test.runTest
38+
import org.junit.After
3839
import org.junit.Assert.assertEquals
3940
import org.junit.Before
4041
import org.junit.Test
@@ -60,8 +61,8 @@ class AnalyticsClientTest {
6061
fun setup() = runTest {
6162
mockkStatic("com.amplifyframework.pinpoint.core.util.SharedPreferencesUtilKt")
6263
every { sharedPrefs.getUniqueId() } answers { "UNIQUE_ID" }
63-
coEvery { sessionClient.setAnalyticsClient(any()) } answers { }
64-
coEvery { sessionClient.startSession() } answers { }
64+
coEvery { sessionClient.setAnalyticsClient(any()) } returns Unit
65+
coEvery { sessionClient.startSession() } returns Unit
6566

6667
analyticsClient = AnalyticsClient(
6768
ApplicationProvider.getApplicationContext(),
@@ -159,4 +160,9 @@ class AnalyticsClientTest {
159160
analyticsClient.addGlobalMetric(metricName, metricValue)
160161
assertEquals(metricValue, analyticsClient.getGlobalMetrics()[metricName])
161162
}
163+
164+
@After
165+
fun tearDown() {
166+
analyticsClient.disableEventSubmitter()
167+
}
162168
}

aws-predictions/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,7 @@ dependencies {
5151
androidTestImplementation(libs.test.mockk.android)
5252
androidTestImplementation(libs.rxjava)
5353
}
54+
55+
android.kotlinOptions {
56+
jvmTarget = "11"
57+
}

aws-push-notifications-pinpoint-common/build.gradle.kts

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ apply(from = rootProject.file("configuration/publishing.gradle"))
2323

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

26+
android {
27+
kotlinOptions {
28+
jvmTarget = JavaVersion.VERSION_11.toString()
29+
}
30+
}
31+
2632
dependencies {
2733
implementation(project(":annotations"))
2834
api(project(":common-core"))

aws-storage-s3/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ dependencies {
5252
androidTestImplementation(libs.test.androidx.workmanager)
5353
androidTestImplementation(project(":aws-storage-s3"))
5454
}
55+
56+
android.kotlinOptions {
57+
jvmTarget = "11"
58+
}

build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ fun Project.configureAndroid() {
156156

157157
compileOptions {
158158
isCoreLibraryDesugaringEnabled = true
159-
sourceCompatibility = JavaVersion.VERSION_1_8
160-
targetCompatibility = JavaVersion.VERSION_1_8
159+
sourceCompatibility = JavaVersion.VERSION_11
160+
targetCompatibility = JavaVersion.VERSION_11
161161
}
162162

163163
// Needed when running integration tests. The oauth2 library uses relies on two
164164
// dependencies (Apache's httpcore and httpclient), both of which include
165165
// META-INF/DEPENDENCIES. Tried a couple other options to no avail.
166166
packagingOptions {
167-
resources.excludes.add("META-INF/DEPENDENCIES")
167+
resources.excludes.add("META-INF/*")
168168
}
169169
}
170170

canaries/example/app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ android {
2424
}
2525
}
2626
compileOptions {
27-
sourceCompatibility JavaVersion.VERSION_1_8
28-
targetCompatibility JavaVersion.VERSION_1_8
27+
sourceCompatibility JavaVersion.VERSION_11
28+
targetCompatibility JavaVersion.VERSION_11
2929
}
3030
kotlinOptions {
3131
jvmTarget = '1.8'

core-kotlin/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ dependencies {
3636
}
3737

3838
android.kotlinOptions {
39-
jvmTarget = "1.8"
39+
jvmTarget = "11"
4040
freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
4141
}

core/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ dependencies {
6464
androidTestImplementation(libs.test.androidx.fragment)
6565
}
6666

67+
android.kotlinOptions {
68+
jvmTarget = "11"
69+
}
70+
6771
afterEvaluate {
6872
// Disables this warning:
6973
// warning: listOf(classfile) MethodParameters attribute

gradle/libs.versions.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ maplibre-annotations = "1.0.0"
3434
material = "1.8.0"
3535
mockito = "3.9.0"
3636
mockito-inline = "3.11.2"
37-
mockk = "1.12.3"
37+
mockk = "1.13.8"
3838
mockwebserver = "5.0.0-alpha.11"
3939
navigation = "2.3.4"
4040
oauth2 = "0.26.0"

maplibre-adapter/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ group = properties["POM_GROUP"].toString()
2525

2626
android {
2727
kotlinOptions {
28-
jvmTarget = JavaVersion.VERSION_1_8.toString()
28+
jvmTarget = JavaVersion.VERSION_11.toString()
2929
}
3030
lint {
3131
disable += "GradleDependency"

rxbindings/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ dependencies {
3838
testImplementation(libs.test.robolectric)
3939
testImplementation(project(":rxbindings"))
4040
}
41+
42+
android.kotlinOptions {
43+
jvmTarget = "11"
44+
}

rxbindings/src/test/java/com/amplifyframework/rx/RxStorageBindingTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
*/
8282
@RunWith(RobolectricTestRunner.class)
8383
public final class RxStorageBindingTest {
84-
private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(5);
84+
private static final long TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10);
8585
private RxStorageCategoryBehavior rxStorage;
8686
private StoragePlugin<?> delegate;
8787
private File localFile;

0 commit comments

Comments
 (0)