From ff050477791a884f4e13aefe2459a77b9c87e6da Mon Sep 17 00:00:00 2001 From: Juul Mobile Bot Date: Fri, 1 Nov 2024 09:05:27 +0000 Subject: [PATCH 1/2] Update dependency com.squareup:kotlinpoet to v2 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 123ff20..b5e1e68 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ kotlin = "2.0.21" assertj = { module = "org.assertj:assertj-core", version = "3.26.3" } khronicle = { module = "com.juul.khronicle:khronicle-core", version = "0.3.0" } kotlin-parcelize-runtime = { module = "org.jetbrains.kotlin:kotlin-parcelize-runtime", version.ref = "kotlin" } -kotlinpoet = { module = "com.squareup:kotlinpoet", version = "1.18.1" } +kotlinpoet = { module = "com.squareup:kotlinpoet", version = "2.0.0" } ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version = "2.0.21-1.0.26" } ksp-testing = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" } robolectric = { module = "org.robolectric:robolectric", version = "4.13" } From 50af3d78e9d8ce686dd84cc58ecb0d9075cf2865 Mon Sep 17 00:00:00 2001 From: Cedrick Cooke Date: Fri, 1 Nov 2024 10:03:52 -0700 Subject: [PATCH 2/2] Fix failing tests --- .../kotlin/ExerciseProcessorActivityTests.kt | 18 ++++------- .../kotlin/ExerciseProcessorFragmentTests.kt | 3 +- .../kotlin/ExerciseProcessorServiceTests.kt | 30 +++++++------------ 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/compile/src/test/kotlin/ExerciseProcessorActivityTests.kt b/compile/src/test/kotlin/ExerciseProcessorActivityTests.kt index 3976e5e..aa623d3 100644 --- a/compile/src/test/kotlin/ExerciseProcessorActivityTests.kt +++ b/compile/src/test/kotlin/ExerciseProcessorActivityTests.kt @@ -295,13 +295,11 @@ public class ExerciseProcessorActivityTests : ExerciseProcessorTests() { import kotlin.Int import kotlin.String - public fun bundleForOptionalsActivity(context: Context, optionalInt: Int? = null): Bundle = - bundleOf( + public fun bundleForOptionalsActivity(context: Context, optionalInt: Int? = null): Bundle = bundleOf( "${"$"}{context.packageName}.optionalInt" to optionalInt ) - public fun bundleForOptionalsActivity(packageName: String, optionalInt: Int? = null): Bundle = - bundleOf( + public fun bundleForOptionalsActivity(packageName: String, optionalInt: Int? = null): Bundle = bundleOf( "${"${'$'}"}{packageName}.optionalInt" to optionalInt ) @@ -329,8 +327,7 @@ public class ExerciseProcessorActivityTests : ExerciseProcessorTests() { public val optionalInt: Int? get() = instance.intent?.extras?.get("${"$"}{instance.packageName}.optionalInt") as Int? - public fun optionalInt(default: Int): Int = - (instance.intent?.extras?.get("${"$"}{instance.packageName}.optionalInt") as? Int?) ?: default + public fun optionalInt(default: Int): Int = (instance.intent?.extras?.get("${"$"}{instance.packageName}.optionalInt") as? Int?) ?: default } public val OptionalsActivity.extras: OptionalsActivityParams @@ -488,10 +485,8 @@ public class ExerciseProcessorActivityTests : ExerciseProcessorTests() { requiredValue: ThirdPartyType, optionalValue: ThirdPartyType? = null, ): Bundle = bundleOf( - "${"$"}{context.packageName}.requiredValue" to - ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), - "${"$"}{context.packageName}.optionalValue" to - ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) + "${"$"}{context.packageName}.requiredValue" to ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), + "${"$"}{context.packageName}.optionalValue" to ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) ) public fun bundleForParcelerActivity( @@ -500,8 +495,7 @@ public class ExerciseProcessorActivityTests : ExerciseProcessorTests() { optionalValue: ThirdPartyType? = null, ): Bundle = bundleOf( "${"$"}{packageName}.requiredValue" to ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), - "${"$"}{packageName}.optionalValue" to - ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) + "${"$"}{packageName}.optionalValue" to ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) ) public class ParcelerActivityIntent : Intent { diff --git a/compile/src/test/kotlin/ExerciseProcessorFragmentTests.kt b/compile/src/test/kotlin/ExerciseProcessorFragmentTests.kt index 22af5c0..32ec735 100644 --- a/compile/src/test/kotlin/ExerciseProcessorFragmentTests.kt +++ b/compile/src/test/kotlin/ExerciseProcessorFragmentTests.kt @@ -245,8 +245,7 @@ public class ExerciseProcessorFragmentTests : ExerciseProcessorTests() { public val optionalInt: Int? get() = instance.arguments?.get("optionalInt") as Int? - public fun optionalInt(default: Int): Int = (instance.arguments?.get("optionalInt") as? Int?) ?: - default + public fun optionalInt(default: Int): Int = (instance.arguments?.get("optionalInt") as? Int?) ?: default } public val OptionalsFragment.args: OptionalsFragmentParams diff --git a/compile/src/test/kotlin/ExerciseProcessorServiceTests.kt b/compile/src/test/kotlin/ExerciseProcessorServiceTests.kt index 5d8c79d..8ea9657 100644 --- a/compile/src/test/kotlin/ExerciseProcessorServiceTests.kt +++ b/compile/src/test/kotlin/ExerciseProcessorServiceTests.kt @@ -60,8 +60,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { private val intent: Intent, ) - public fun NoExtrasService.extras(intent: Intent): NoExtrasServiceParams = - NoExtrasServiceParams(this, intent) + public fun NoExtrasService.extras(intent: Intent): NoExtrasServiceParams = NoExtrasServiceParams(this, intent) """, ) } @@ -116,8 +115,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { get() = intent.extras?.get("${"$"}{instance.packageName}.fromSuperclass") as Int } - public fun SuperclassService.extras(intent: Intent): SuperclassServiceParams = - SuperclassServiceParams(this, intent) + public fun SuperclassService.extras(intent: Intent): SuperclassServiceParams = SuperclassServiceParams(this, intent) """, ) @@ -190,8 +188,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { get() = intent.extras?.get("${"$"}{instance.packageName}.fromSubclass") as String } - public fun SubclassService.extras(intent: Intent): SubclassServiceParams = - SubclassServiceParams(this, intent) + public fun SubclassService.extras(intent: Intent): SubclassServiceParams = SubclassServiceParams(this, intent) """, ) } @@ -310,8 +307,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { "${"$"}{context.packageName}.optionalInt" to optionalInt ) - public fun bundleForOptionalsService(packageName: String, optionalInt: Int? = null): Bundle = - bundleOf( + public fun bundleForOptionalsService(packageName: String, optionalInt: Int? = null): Bundle = bundleOf( "${"$"}{packageName}.optionalInt" to optionalInt ) @@ -340,12 +336,10 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { public val optionalInt: Int? get() = intent.extras?.get("${"$"}{instance.packageName}.optionalInt") as Int? - public fun optionalInt(default: Int): Int = - (intent.extras?.get("${"$"}{instance.packageName}.optionalInt") as? Int?) ?: default + public fun optionalInt(default: Int): Int = (intent.extras?.get("${"$"}{instance.packageName}.optionalInt") as? Int?) ?: default } - public fun OptionalsService.extras(intent: Intent): OptionalsServiceParams = - OptionalsServiceParams(this, intent) + public fun OptionalsService.extras(intent: Intent): OptionalsServiceParams = OptionalsServiceParams(this, intent) """, ) } @@ -408,10 +402,8 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { requiredValue: ThirdPartyType, optionalValue: ThirdPartyType? = null, ): Bundle = bundleOf( - "${"$"}{context.packageName}.requiredValue" to - ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), - "${"$"}{context.packageName}.optionalValue" to - ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) + "${"$"}{context.packageName}.requiredValue" to ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), + "${"$"}{context.packageName}.optionalValue" to ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) ) public fun bundleForParcelerService( @@ -420,8 +412,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { optionalValue: ThirdPartyType? = null, ): Bundle = bundleOf( "${"$"}{packageName}.requiredValue" to ThirdPartyTypeParceler.writeToMarshalledBytes(requiredValue), - "${"$"}{packageName}.optionalValue" to - ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) + "${"$"}{packageName}.optionalValue" to ThirdPartyTypeParceler.writeToMarshalledBytesOrNull(optionalValue) ) public class ParcelerServiceIntent : Intent { @@ -474,8 +465,7 @@ public class ExerciseProcessorServiceTests : ExerciseProcessorTests() { } } - public fun ParcelerService.extras(intent: Intent): ParcelerServiceParams = - ParcelerServiceParams(this, intent) + public fun ParcelerService.extras(intent: Intent): ParcelerServiceParams = ParcelerServiceParams(this, intent) """, ) }