diff --git a/samples/wire-codegen-sample/build.gradle.kts b/samples/wire-codegen-sample/build.gradle.kts index 2d8fa4d97d..00fab7bdbc 100644 --- a/samples/wire-codegen-sample/build.gradle.kts +++ b/samples/wire-codegen-sample/build.gradle.kts @@ -11,5 +11,5 @@ dependencies { implementation(libs.guava) implementation(libs.javapoet) testImplementation(libs.junit) - testImplementation(libs.assertj) + testImplementation(libs.assertk) } diff --git a/samples/wire-codegen-sample/src/test/java/com/squareup/wire/sample/ServiceGeneratorTest.kt b/samples/wire-codegen-sample/src/test/java/com/squareup/wire/sample/ServiceGeneratorTest.kt index 42f5fd8c7d..0a82bdf84e 100644 --- a/samples/wire-codegen-sample/src/test/java/com/squareup/wire/sample/ServiceGeneratorTest.kt +++ b/samples/wire-codegen-sample/src/test/java/com/squareup/wire/sample/ServiceGeneratorTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire.sample +import assertk.assertThat +import assertk.assertions.isEqualTo import com.palantir.javapoet.JavaFile import com.palantir.javapoet.TypeSpec import com.squareup.wire.java.JavaGenerator @@ -26,7 +28,6 @@ import java.io.IOException import java.nio.file.FileSystems import okio.buffer import okio.sink -import org.assertj.core.api.Assertions.assertThat import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder diff --git a/wire-compiler/build.gradle.kts b/wire-compiler/build.gradle.kts index 3f0c232cf8..d61bfdeb38 100644 --- a/wire-compiler/build.gradle.kts +++ b/wire-compiler/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { implementation(libs.kotlin.serialization) implementation(libs.kaml) testImplementation(libs.junit) - testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(libs.kotlin.test.junit) testImplementation(projects.wireTestUtils) } diff --git a/wire-compiler/src/test/java/com/squareup/wire/CommandLineOptionsTest.kt b/wire-compiler/src/test/java/com/squareup/wire/CommandLineOptionsTest.kt index 81525e1251..0962a9a716 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/CommandLineOptionsTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/CommandLineOptionsTest.kt @@ -15,12 +15,17 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.containsOnly +import assertk.assertions.hasMessage +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo import com.squareup.wire.schema.WireRun import java.io.File import java.io.FileOutputStream import java.io.PrintWriter import kotlin.test.assertFailsWith -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class CommandLineOptionsTest { diff --git a/wire-compiler/src/test/java/com/squareup/wire/ManifestParseTest.kt b/wire-compiler/src/test/java/com/squareup/wire/ManifestParseTest.kt index 9ff90bc6b9..491c93e882 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/ManifestParseTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/ManifestParseTest.kt @@ -15,7 +15,10 @@ */ package com.squareup.wire -import org.assertj.core.api.Assertions.assertThat +import assertk.assertThat +import assertk.assertions.containsExactlyInAnyOrder +import assertk.assertions.containsOnly +import assertk.assertions.messageContains import org.junit.Assert.fail import org.junit.Test @@ -56,7 +59,7 @@ class ManifestParseTest { parseManifestModules(yaml) fail() } catch (e: Exception) { - assertThat(e).hasMessageContaining("Unknown property 'includes'") + assertThat(e).messageContains("Unknown property 'includes'") } } @@ -69,7 +72,7 @@ class ManifestParseTest { """.trimMargin() val modules = parseManifestModules(yaml) - assertThat(modules.keys).containsExactly("one", "two") - assertThat(modules.getValue("one").dependencies).containsExactly("two") + assertThat(modules.keys).containsOnly("one", "two") + assertThat(modules.getValue("one").dependencies).containsOnly("two") } } diff --git a/wire-compiler/src/test/java/com/squareup/wire/WireCompilerErrorTest.kt b/wire-compiler/src/test/java/com/squareup/wire/WireCompilerErrorTest.kt index 24ed1f7206..8b2a3441e2 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/WireCompilerErrorTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/WireCompilerErrorTest.kt @@ -15,12 +15,15 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.doesNotContain +import assertk.assertions.hasMessage import com.squareup.wire.schema.SchemaException import kotlin.test.assertFailsWith import okio.Path import okio.Path.Companion.toPath import okio.fakefilesystem.FakeFileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class WireCompilerErrorTest { diff --git a/wire-compiler/src/test/java/com/squareup/wire/WireCompilerTest.kt b/wire-compiler/src/test/java/com/squareup/wire/WireCompilerTest.kt index b12362092b..0f6ec16dfd 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/WireCompilerTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/WireCompilerTest.kt @@ -17,13 +17,17 @@ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty +import assertk.assertions.size import com.squareup.wire.schema.ProtoType import java.util.Collections import okio.FileSystem import okio.Path import okio.Path.Companion.toOkioPath import okio.Path.Companion.toPath -import org.assertj.core.api.Assertions.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test @@ -826,8 +830,8 @@ class WireCompilerTest { private fun assertOutputs(target: TargetLanguage, outputs: Array, suffix: String = "") { val filesAfter = paths - assertThat(filesAfter.size) - .overridingErrorMessage(filesAfter.toString()) + assertThat(filesAfter) + .size() .isEqualTo(outputs.size) for (output in outputs) { diff --git a/wire-compiler/src/test/java/com/squareup/wire/schema/CycleCheckerTest.kt b/wire-compiler/src/test/java/com/squareup/wire/schema/CycleCheckerTest.kt index eae321ad78..cd7e00d17a 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/schema/CycleCheckerTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/schema/CycleCheckerTest.kt @@ -17,11 +17,12 @@ package com.squareup.wire.schema +import assertk.assertThat +import assertk.assertions.hasMessage import com.squareup.wire.testing.add import kotlin.test.assertFailsWith import okio.Path import okio.fakefilesystem.FakeFileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class CycleCheckerTest { diff --git a/wire-compiler/src/test/java/com/squareup/wire/schema/LinkerTest.kt b/wire-compiler/src/test/java/com/squareup/wire/schema/LinkerTest.kt index aba242a899..835743a5c3 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/schema/LinkerTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/schema/LinkerTest.kt @@ -17,13 +17,18 @@ package com.squareup.wire.schema +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull +import assertk.assertions.isNull +import assertk.assertions.messageContains import com.squareup.wire.testing.add import kotlin.test.assertFailsWith import okio.ForwardingFileSystem import okio.Path import okio.Path.Companion.toPath import okio.fakefilesystem.FakeFileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class LinkerTest { @@ -144,7 +149,7 @@ class LinkerTest { val exception = assertFailsWith { loadAndLinkSchema(opaqueTypes = listOf(ProtoType.get("cafe.Roast"))) } - assertThat(exception).hasMessageContaining( + assertThat(exception).messageContains( """ |Enums like cafe.Roast cannot be opaqued | for field roast (source-path/cafe/cafe.proto:11:3) @@ -297,7 +302,7 @@ class LinkerTest { val exception = assertFailsWith { loadAndLinkSchema(opaqueTypes = listOf(ProtoType.INT32)) } - assertThat(exception).hasMessageContaining( + assertThat(exception).messageContains( """ |Scalar types like int32 cannot be opaqued | for field size_ounces (source-path/cafe/cafe.proto:6:3) diff --git a/wire-compiler/src/test/java/com/squareup/wire/schema/OptionsLinkingTest.kt b/wire-compiler/src/test/java/com/squareup/wire/schema/OptionsLinkingTest.kt index fdab2b5d62..3fc4052783 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/schema/OptionsLinkingTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/schema/OptionsLinkingTest.kt @@ -17,11 +17,13 @@ package com.squareup.wire.schema +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull import com.squareup.wire.testing.add import okio.Path import okio.Path.Companion.toPath import okio.fakefilesystem.FakeFileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class OptionsLinkingTest { diff --git a/wire-compiler/src/test/java/com/squareup/wire/schema/WireRunTest.kt b/wire-compiler/src/test/java/com/squareup/wire/schema/WireRunTest.kt index 128dd49136..5a45d8e520 100644 --- a/wire-compiler/src/test/java/com/squareup/wire/schema/WireRunTest.kt +++ b/wire-compiler/src/test/java/com/squareup/wire/schema/WireRunTest.kt @@ -15,6 +15,14 @@ */ package com.squareup.wire.schema +import assertk.all +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.doesNotContain +import assertk.assertions.hasMessage +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isNotEmpty import com.squareup.wire.StringWireLogger import com.squareup.wire.WireLogger import com.squareup.wire.WireLogger.Companion.NONE @@ -30,7 +38,6 @@ import kotlin.test.assertFailsWith import okio.Path import okio.Path.Companion.toPath import okio.fakefilesystem.FakeFileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test @@ -145,12 +152,13 @@ class WireRunTest { assertThat(fs.findFiles("generated")).containsExactlyInAnyOrderAsRelativePaths( "generated/kt/squareup/routes/RouteBlockingServer.kt", ) - assertThat(fs.readUtf8("generated/kt/squareup/routes/RouteBlockingServer.kt")) - .contains( + assertThat(fs.readUtf8("generated/kt/squareup/routes/RouteBlockingServer.kt")).all { + contains( "interface RouteBlockingServer : Service", "fun GetUpdatedRed", ) - .doesNotContain("suspend fun GetUpdatedRed") + doesNotContain("suspend fun GetUpdatedRed") + } } @Test @@ -182,16 +190,18 @@ class WireRunTest { .contains("interface RouteGetUpdatedBlueClient : Service") assertThat(fs.readUtf8("generated/kt/squareup/routes/RouteGetUpdatedRedClient.kt")) .contains("interface RouteGetUpdatedRedClient : Service") - assertThat(fs.readUtf8("generated/kt/squareup/routes/GrpcRouteGetUpdatedBlueClient.kt")) - .contains( + assertThat(fs.readUtf8("generated/kt/squareup/routes/GrpcRouteGetUpdatedBlueClient.kt")).all { + contains( "class GrpcRouteGetUpdatedBlueClient(\n private val client: GrpcClient,\n) : RouteGetUpdatedBlueClient", ) - .doesNotContain("RouteGetUpdatedRedClient") - assertThat(fs.readUtf8("generated/kt/squareup/routes/GrpcRouteGetUpdatedRedClient.kt")) - .contains( + doesNotContain("RouteGetUpdatedRedClient") + } + assertThat(fs.readUtf8("generated/kt/squareup/routes/GrpcRouteGetUpdatedRedClient.kt")).all { + contains( "class GrpcRouteGetUpdatedRedClient(\n private val client: GrpcClient,\n) : RouteGetUpdatedRedClient", ) - .doesNotContain("RouteGetUpdatedBlueClient") + doesNotContain("RouteGetUpdatedBlueClient") + } } @Test @@ -290,10 +300,11 @@ class WireRunTest { assertThat(fs.findFiles("generated")).containsExactlyInAnyOrderAsRelativePaths( "generated/kt/squareup/colors/Blue.kt", ) - assertThat(fs.readUtf8("generated/kt/squareup/colors/Blue.kt")) - .contains("class Blue") + assertThat(fs.readUtf8("generated/kt/squareup/colors/Blue.kt")).all { + contains("class Blue") // The type `Triangle` has been opaqued. - .contains("public val triangle: ByteString? = null") + contains("public val triangle: ByteString? = null") + } } @Test diff --git a/wire-gradle-plugin-playground/build.gradle.kts b/wire-gradle-plugin-playground/build.gradle.kts index 36b53ad279..b0d5ed1bf4 100644 --- a/wire-gradle-plugin-playground/build.gradle.kts +++ b/wire-gradle-plugin-playground/build.gradle.kts @@ -74,7 +74,7 @@ dependencies { implementation(projects.wireSchema) implementation(projects.wireGsonSupport) implementation(projects.wireMoshiAdapter) - implementation(libs.assertj) + implementation(libs.assertk) implementation(libs.junit) implementation(libs.protobuf.javaUtil) implementation(projects.wireTestUtils) diff --git a/wire-gradle-plugin/build.gradle.kts b/wire-gradle-plugin/build.gradle.kts index feca52ac5e..20e3ef2bf9 100644 --- a/wire-gradle-plugin/build.gradle.kts +++ b/wire-gradle-plugin/build.gradle.kts @@ -42,7 +42,7 @@ dependencies { implementation(libs.pluginz.kotlin) testImplementation(libs.junit) - testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(projects.wireTestUtils) } diff --git a/wire-gradle-plugin/src/test/kotlin/com/squareup/wire/gradle/WirePluginTest.kt b/wire-gradle-plugin/src/test/kotlin/com/squareup/wire/gradle/WirePluginTest.kt index dc8c084d81..4f743af0bb 100644 --- a/wire-gradle-plugin/src/test/kotlin/com/squareup/wire/gradle/WirePluginTest.kt +++ b/wire-gradle-plugin/src/test/kotlin/com/squareup/wire/gradle/WirePluginTest.kt @@ -17,6 +17,21 @@ package com.squareup.wire.gradle +import assertk.Assert +import assertk.all +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.containsExactly +import assertk.assertions.doesNotContain +import assertk.assertions.exists +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isIn +import assertk.assertions.isNotNull +import assertk.assertions.isNull +import assertk.assertions.isTrue +import assertk.assertions.support.expected import com.squareup.wire.VERSION import com.squareup.wire.testing.withPlatformSlashes import java.io.File @@ -24,7 +39,6 @@ import java.io.IOException import java.util.zip.ZipFile import kotlin.text.RegexOption.DOT_MATCHES_ALL import kotlin.text.RegexOption.MULTILINE -import org.assertj.core.api.Assertions.assertThat import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome @@ -120,9 +134,10 @@ class WirePluginTest { val result = gradleRunner.runFixture(fixtureRoot) { withDebug(false).build() } assertThat(result.task(":copyProtos")).isNotNull() assertThat(result.task(":generateProtos")).isNotNull() - assertThat(result.output) - .contains("Writing com.squareup.geology.Period") - .contains("src/test/projects/sourcepath-build-dir/build/generated/source/wire".withPlatformSlashes()) + assertThat(result.output).all { + contains("Writing com.squareup.geology.Period") + contains("src/test/projects/sourcepath-build-dir/build/generated/source/wire".withPlatformSlashes()) + } } @Test @@ -240,19 +255,20 @@ class WirePluginTest { val fixtureRoot = File("src/test/projects/listener") val result = gradleRunner.runFixture(fixtureRoot) { build() } - assertThat(result.output) - .contains("runStart") - .contains("loadSchemaStart") - .contains("loadSchemaSuccess") - .contains("treeShakeStart") - .contains("treeShakeEnd") - .contains("moveTypesStart") - .contains("moveTypesEnd") - .contains("schemaHandlersStart") - .contains("schemaHandlerStart") - .contains("schemaHandlerEnd") - .contains("schemaHandlersEnd") - .contains("runSuccess") + assertThat(result.output).all { + contains("runStart") + contains("loadSchemaStart") + contains("loadSchemaSuccess") + contains("treeShakeStart") + contains("treeShakeEnd") + contains("moveTypesStart") + contains("moveTypesEnd") + contains("schemaHandlersStart") + contains("schemaHandlerStart") + contains("schemaHandlerEnd") + contains("schemaHandlersEnd") + contains("runSuccess") + } } @Test @@ -561,7 +577,7 @@ class WirePluginTest { assertThat(generatedProto).exists() val generatedProtoSource = generatedProto.readText() - assertThat(fieldsFromProtoSource(generatedProtoSource)).containsOnly("val name") + assertThat(fieldsFromProtoSource(generatedProtoSource)).containsExactly("val name") } @Test @@ -579,7 +595,7 @@ class WirePluginTest { val generatedProtoSource = generatedProto.readText() assertThat(fieldsFromProtoSource(generatedProtoSource)) - .containsOnly("val name", "val length_meters") + .containsExactly("val name", "val length_meters") } @Test @@ -590,9 +606,9 @@ class WirePluginTest { val result = gradleRunner.runFixture(fixtureRoot) { build() } assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt")) - .exists() - .content() + val actual = File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt") + assertThat(actual).exists() + assertThat(actual.readText()) .doesNotContain("val name") } @@ -604,8 +620,9 @@ class WirePluginTest { val result = gradleRunner.runFixture(fixtureRoot) { build() } assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt")) - .content() + val actual = File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt") + assertThat(actual).exists() + assertThat(actual.readText()) .doesNotContain("val name", "val length_meters") } @@ -623,7 +640,7 @@ class WirePluginTest { assertThat(generatedProto).exists() val generatedProtoSource = generatedProto.readText() - assertThat(fieldsFromProtoSource(generatedProtoSource)).containsOnly("val name") + assertThat(fieldsFromProtoSource(generatedProtoSource)).containsExactly("val name") } @Test @@ -635,9 +652,9 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() assertThat(File(outputRoot, "com/squareup/geology/Period.kt")).exists() - assertThat(File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt")) - .exists() - .content().doesNotContain("val name") + val actual = File(outputRoot, "com/squareup/dinosaurs/Dinosaur.kt") + assertThat(actual).exists() + assertThat(actual.readText()).doesNotContain("val name") } @Test @@ -938,11 +955,13 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "com/squareup/media/NewsFlash.kt")).exists() - .content() - .contains("val tv") - .contains("val website") - .doesNotContain("val radio") + val actual = File(outputRoot, "com/squareup/media/NewsFlash.kt") + assertThat(actual).exists() + assertThat(actual.readText()).all { + contains("val tv") + contains("val website") + doesNotContain("val radio") + } } @Test @@ -953,11 +972,13 @@ class WirePluginTest { val result = gradleRunner.runFixture(fixtureRoot) { build() } assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "com/squareup/media/NewsFlash.kt")).exists() - .content() - .contains("val tv") - .doesNotContain("val website") - .doesNotContain("val radio") + val actual = File(outputRoot, "com/squareup/media/NewsFlash.kt") + assertThat(actual).exists() + assertThat(actual.readText()).all { + contains("val tv") + doesNotContain("val website") + doesNotContain("val radio") + } } @Test @@ -978,10 +999,11 @@ class WirePluginTest { println(result.tasks.joinToString { it.toString() }) assertThat(result.task(":generateCommonMainProtos")).isNotNull() - assertThat(result.output) - .contains("Writing com.squareup.dinosaurs.Dinosaur") - .contains("Writing com.squareup.geology.Period") - .contains("src/test/projects/kotlin-multiplatform/build/generated/source/wire".withPlatformSlashes()) + assertThat(result.output).all { + contains("Writing com.squareup.dinosaurs.Dinosaur") + contains("Writing com.squareup.geology.Period") + contains("src/test/projects/kotlin-multiplatform/build/generated/source/wire".withPlatformSlashes()) + } val generatedProto1 = File(fixtureRoot, "build/generated/source/wire/com/squareup/dinosaurs/Dinosaur.kt") @@ -1066,12 +1088,10 @@ class WirePluginTest { val task = result.task(":generateProtos") assertThat(task).isNotNull() - assertThat(File(outputRoot, "squareup/dinosaurs/dinosaur.proto")) - .content() + assertThat(File(outputRoot, "squareup/dinosaurs/dinosaur.proto").readText()) .contains("import \"squareup/geology/geology.proto\";") - assertThat(File(outputRoot, "squareup/geology/geology.proto")) - .content() + assertThat(File(outputRoot, "squareup/geology/geology.proto").readText()) .contains("enum Period {") } @@ -1085,10 +1105,10 @@ class WirePluginTest { val task = result.task(":generateProtos") assertThat(task).isNotNull() - assertThat(File(outputRoot, "cafe/cafe.proto")) - .content() - .contains("repeated bytes shots") - .doesNotContain("repeated EspressoShot shots") + assertThat(File(outputRoot, "cafe/cafe.proto").readText()).all { + contains("repeated bytes shots") + doesNotContain("repeated EspressoShot shots") + } } @Test @@ -1100,8 +1120,7 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "squareup/polygons/Octagon.java")) - .content() + assertThat(File(outputRoot, "squareup/polygons/Octagon.java").readText()) .contains("""@DocumentationUrlOption("https://en.wikipedia.org/wiki/Octagon")""") } @@ -1114,8 +1133,7 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "squareup/polygons/Octagon.kt")) - .content() + assertThat(File(outputRoot, "squareup/polygons/Octagon.kt").readText()) .contains("""@DocumentationUrlOption("https://en.wikipedia.org/wiki/Octagon")""") } @@ -1128,10 +1146,10 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "squareup/polygons/Octagon.kt")) - .content() - .contains("""@DocumentationUrlOption("https://en.wikipedia.org/wiki/Octagon")""") - .contains("""@CustomerSupportUrlOption("https://en.wikipedia.org/wiki/Customer_support")""") + assertThat(File(outputRoot, "squareup/polygons/Octagon.kt").readText()).all { + contains("""@DocumentationUrlOption("https://en.wikipedia.org/wiki/Octagon")""") + contains("""@CustomerSupportUrlOption("https://en.wikipedia.org/wiki/Customer_support")""") + } assertThat(File(outputRoot, "squareup/other_options/CustomerSupportUrlOption.kt")) .doesNotExist() } @@ -1145,19 +1163,19 @@ class WirePluginTest { assertThat(result.task(":generateProtos")).isNotNull() - assertThat(File(outputRoot, "squareup/polygons/Octagon.kt")) - .content() - .contains( + assertThat(File(outputRoot, "squareup/polygons/Octagon.kt").readText()).all { + contains( """@DocumentationUrlOption("https://en.wikipedia.org/wiki/Octagon") |public class Octagon( """.trimMargin(), ) // Although we didn't generate the annotation, we still apply it! - .contains( + contains( """ @DocumentationUrlFieldOption("https://en.wikipedia.org/wiki/stop") | @field:WireField( """.trimMargin(), ) + } } @Test @@ -1172,23 +1190,17 @@ class WirePluginTest { // Wire has been configured so that `Continent` should always be the opposite of the global // setting while `Period` and `Drink` match it. - assertThat(File(outputRoot, "com/squareup/enum/geology/Period.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/enum/geology/Period.kt").readText()) .contains("enum class Period") - assertThat(File(outputRoot, "com/squareup/enum/geology/Continent.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/enum/geology/Continent.kt").readText()) .contains("sealed class Continent") - assertThat(File(outputRoot, "com/squareup/enum/geology/Drink.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/enum/geology/Drink.kt").readText()) .contains("enum class Drink") - assertThat(File(outputRoot, "com/squareup/sealed/geology/Period.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/sealed/geology/Period.kt").readText()) .contains("sealed class Period") - assertThat(File(outputRoot, "com/squareup/sealed/geology/Continent.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/sealed/geology/Continent.kt").readText()) .contains("enum class Continent") - assertThat(File(outputRoot, "com/squareup/sealed/geology/Drink.kt")) - .content() + assertThat(File(outputRoot, "com/squareup/sealed/geology/Drink.kt").readText()) .contains("sealed class Drink") } @@ -1448,3 +1460,11 @@ class WirePluginTest { } } } + +/** + * Asserts the file does not exists. + */ +private fun Assert.doesNotExist() = given { actual -> + if (!actual.exists()) return + expected("not to exist") +} diff --git a/wire-grpc-tests/build.gradle.kts b/wire-grpc-tests/build.gradle.kts index 155d659a40..1a03f0b9c1 100644 --- a/wire-grpc-tests/build.gradle.kts +++ b/wire-grpc-tests/build.gradle.kts @@ -65,7 +65,7 @@ dependencies { } compileOnly(libs.android) testImplementation(libs.junit) - testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(libs.grpc.netty) testImplementation(libs.grpc.protobuf) testImplementation(libs.grpc.stub) diff --git a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcCallsTest.kt b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcCallsTest.kt index 51773b73e0..0d7463f05e 100644 --- a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcCallsTest.kt +++ b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcCallsTest.kt @@ -15,13 +15,16 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.hasMessage +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo import java.util.Locale.US import java.util.concurrent.LinkedBlockingQueue import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.runBlocking import okio.IOException -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test diff --git a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcClientTest.kt b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcClientTest.kt index c30effb008..e4cb7f73f4 100644 --- a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcClientTest.kt +++ b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcClientTest.kt @@ -17,6 +17,22 @@ package com.squareup.wire +import assertk.all +import assertk.assertThat +import assertk.assertions.cause +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isIn +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import assertk.assertions.isNotNull +import assertk.assertions.isNotZero +import assertk.assertions.isNull +import assertk.assertions.isTrue +import assertk.assertions.message +import assertk.assertions.messageContains +import assertk.assertions.startsWith import com.google.common.util.concurrent.SettableFuture import com.squareup.wire.MockRouteGuideService.Action.Delay import com.squareup.wire.MockRouteGuideService.Action.ReceiveCall @@ -56,7 +72,6 @@ import okio.ByteString import okio.ForwardingSource import okio.IOException import okio.buffer -import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.Assert.assertThrows import org.junit.Assert.fail @@ -335,7 +350,7 @@ class GrpcClientTest { delay(200) responseChannel.cancel() mockService.awaitSuccess() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -348,7 +363,7 @@ class GrpcClientTest { Thread.sleep(200) responseDeferred.close() mockService.awaitSuccessBlocking() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test @@ -404,7 +419,7 @@ class GrpcClientTest { assertThat(responseChannel.receive()).isEqualTo(Feature(name = "tree")) responseChannel.cancel() mockService.awaitSuccess() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -424,7 +439,7 @@ class GrpcClientTest { assertThat(responseChannel.read()).isEqualTo(Feature(name = "tree")) responseChannel.close() mockService.awaitSuccessBlocking() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test @@ -459,7 +474,7 @@ class GrpcClientTest { val latch = Mutex(locked = true) requestChannel.invokeOnClose { expected -> - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected!!).isInstanceOf() latch.unlock() } @@ -473,7 +488,7 @@ class GrpcClientTest { requestChannel.send(RouteNote(message = "léo")) fail() } catch (expected: Throwable) { - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected).isInstanceOf() } } } @@ -489,7 +504,7 @@ class GrpcClientTest { val latch = Mutex(locked = true) requestChannel.invokeOnClose { expected -> - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected!!).isInstanceOf() latch.unlock() } @@ -503,7 +518,7 @@ class GrpcClientTest { requestChannel.send(RouteNote(message = "léo")) fail() } catch (expected: Throwable) { - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected).isInstanceOf() } } } @@ -519,7 +534,7 @@ class GrpcClientTest { val latch = Mutex(locked = true) requestChannel.invokeOnClose { expected -> - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected!!).isInstanceOf() latch.unlock() } @@ -536,7 +551,7 @@ class GrpcClientTest { requestChannel.send(RouteNote(message = "rené")) fail() } catch (expected: Throwable) { - assertThat(expected).isInstanceOf(CancellationException::class.java) + assertThat(expected).isInstanceOf() } } } @@ -593,14 +608,16 @@ class GrpcClientTest { runBlocking { val (_, responseChannel) = routeGuideService.RouteChat().executeIn(this) - try { + val expected = assertFailsWith { responseChannel.receive() - fail() - } catch (expected: IOException) { - assertThat(expected) - .hasMessage("gRPC transport failure (HTTP status=200, grpc-status=null, grpc-message=null)") - .cause() // Synthetic exception added by coroutines in StackTraceRecovery.kt. + } + assertThat(expected).all { + hasMessage("gRPC transport failure (HTTP status=200, grpc-status=null, grpc-message=null)") + // Synthetic exception added by coroutines in StackTraceRecovery.kt. + cause() + .isNotNull() .cause() + .isNotNull() .hasMessage("boom!") } @@ -624,7 +641,7 @@ class GrpcClientTest { responseChannel.receive() fail() } catch (expected: IOException) { - assertThat(expected.message).startsWith("gRPC transport failure") + assertThat(expected.message!!).startsWith("gRPC transport failure") } assertThat(responseChannel.isClosedForReceive).isTrue() @@ -706,7 +723,7 @@ class GrpcClientTest { assertThat((requestChannel as Channel).isClosedForReceive).isTrue() assertThat(requestChannel.isClosedForSend).isTrue() mockService.awaitSuccess() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -727,7 +744,7 @@ class GrpcClientTest { assertThat((requestChannel as Channel).isClosedForReceive).isTrue() assertThat(requestChannel.isClosedForSend).isTrue() mockService.awaitSuccess() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -753,7 +770,7 @@ class GrpcClientTest { assertThat((requestChannel as Channel).isClosedForReceive).isTrue() assertThat(requestChannel.isClosedForSend).isTrue() mockService.awaitSuccess() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -782,7 +799,7 @@ class GrpcClientTest { responseChannel.cancel() assertThat((requestChannel as Channel).isClosedForReceive).isTrue() assertThat(requestChannel.isClosedForSend).isTrue() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } } @@ -794,7 +811,7 @@ class GrpcClientTest { Thread.sleep(500) responseChannel.close() mockService.awaitSuccessBlocking() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test fun cancelDuplexBlockingAfterRequestCompletes() { @@ -810,7 +827,7 @@ class GrpcClientTest { responseChannel.close() mockService.awaitSuccessBlocking() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test fun cancelDuplexBlockingBeforeResponseCompletes() { @@ -831,7 +848,7 @@ class GrpcClientTest { responseChannel.close() mockService.awaitSuccessBlocking() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test fun cancelDuplexBlockingAfterResponseCompletes() { @@ -855,7 +872,7 @@ class GrpcClientTest { Thread.sleep(500) responseChannel.close() - assertThat(callReference.get()?.isCanceled()).isTrue() + assertThat(callReference.get()!!.isCanceled()).isTrue() } @Test @@ -1247,7 +1264,7 @@ class GrpcClientTest { fail() } catch (expected: GrpcException) { assertThat(expected.grpcStatus).isEqualTo(GrpcStatus.INTERNAL) - assertThat(expected).hasMessageMatching( + assertThat(expected).messageContains( "grpc-status=13 grpc-status-name=INTERNAL grpc-message=boom url=" + mockService.url + "routeguide.RouteGuide/GetFeature", ) @@ -1272,7 +1289,7 @@ class GrpcClientTest { assertThat(expected).hasMessage( "gRPC transport failure (HTTP status=200, grpc-status=null, grpc-message=null)", ) - assertThat(expected.cause).hasMessage("stream was reset: CANCEL") + assertThat(expected.cause!!).hasMessage("stream was reset: CANCEL") } } @@ -1297,7 +1314,7 @@ class GrpcClientTest { "gRPC transport failure (HTTP status=200, grpc-status=0, grpc-message=null)", "gRPC transport failure (HTTP status=200, grpc-status=null, grpc-message=null)", ) - assertThat(expected.cause).hasMessage("expected 1 message but got multiple") + assertThat(expected.cause!!).hasMessage("expected 1 message but got multiple") } } @@ -1317,7 +1334,7 @@ class GrpcClientTest { assertThat(expected).hasMessage( "gRPC transport failure (HTTP status=200, grpc-status=0, grpc-message=null)", ) - assertThat(expected.cause).hasMessage("expected 1 message but got none") + assertThat(expected.cause!!).hasMessage("expected 1 message but got none") } } @@ -1635,7 +1652,7 @@ class GrpcClientTest { grpcCall.execute(Point(latitude = 5, longitude = 6)) fail() } catch (expected: Throwable) { - assertThat(expected).isInstanceOf(IOException::class.java) + assertThat(expected).isInstanceOf() assertThat(grpcCall.isCanceled()).isTrue() } } @@ -1657,7 +1674,7 @@ class GrpcClientTest { receive.receive() fail() } catch (expected: Throwable) { - assertThat(expected).isInstanceOf(IOException::class.java) + assertThat(expected).isInstanceOf() assertThat(grpcCall.isCanceled()).isTrue() } } @@ -1684,7 +1701,7 @@ class GrpcClientTest { fail() } catch (expected: GrpcException) { assertThat(expected.grpcStatus).isEqualTo(GrpcStatus.INTERNAL) - assertThat(expected).hasMessageMatching( + assertThat(expected).messageContains( "grpc-status=13 grpc-status-name=INTERNAL grpc-message=boom url=" + mockService.url + "routeguide.RouteGuide/GetFeature", ) @@ -1713,7 +1730,7 @@ class GrpcClientTest { responses.receive() fail() } catch (expected: IOException) { - assertThat(expected).isInstanceOf(IOException::class.java) + assertThat(expected).isInstanceOf() assertThat(expected.message).isEqualTo("expected gRPC but was HTTP status=520, content-type=application/grpc") assertThat(call.isCanceled()).isTrue() } diff --git a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcOnMockWebServerTest.kt b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcOnMockWebServerTest.kt index 6ec495fa2d..94b75c8b82 100644 --- a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcOnMockWebServerTest.kt +++ b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcOnMockWebServerTest.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.isEqualTo import com.squareup.wire.mockwebserver.GrpcDispatcher import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicReference @@ -26,7 +29,6 @@ import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Protocol import okhttp3.mockwebserver.MockWebServer -import org.assertj.core.api.Assertions.assertThat import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcStreamingCallsTest.kt b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcStreamingCallsTest.kt index 5edaece10d..f2bda2d078 100644 --- a/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcStreamingCallsTest.kt +++ b/wire-grpc-tests/src/test/java/com/squareup/wire/GrpcStreamingCallsTest.kt @@ -15,6 +15,10 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isNull import java.util.Locale.US import kotlinx.coroutines.CancellationException import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -25,7 +29,6 @@ import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.consumeEach import kotlinx.coroutines.runBlocking import okio.IOException -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test diff --git a/wire-grpc-tests/src/test/java/com/squareup/wire/MockRouteGuideService.kt b/wire-grpc-tests/src/test/java/com/squareup/wire/MockRouteGuideService.kt index 8c2d12bc1b..a72a9f6aff 100644 --- a/wire-grpc-tests/src/test/java/com/squareup/wire/MockRouteGuideService.kt +++ b/wire-grpc-tests/src/test/java/com/squareup/wire/MockRouteGuideService.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.message import com.squareup.wire.MockRouteGuideService.Action.ReceiveCall import io.grpc.ForwardingServerCall.SimpleForwardingServerCall import io.grpc.Metadata @@ -35,7 +38,6 @@ import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout import okhttp3.HttpUrl -import org.assertj.core.api.Assertions.assertThat import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement diff --git a/wire-gson-support/build.gradle.kts b/wire-gson-support/build.gradle.kts index 777a06a031..33ccdedb8b 100644 --- a/wire-gson-support/build.gradle.kts +++ b/wire-gson-support/build.gradle.kts @@ -8,5 +8,6 @@ dependencies { api(libs.okio.core) testImplementation(libs.junit) testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(projects.wireTestUtils) } diff --git a/wire-kotlin-generator/build.gradle.kts b/wire-kotlin-generator/build.gradle.kts index ed527ec2db..ac8d8501cb 100644 --- a/wire-kotlin-generator/build.gradle.kts +++ b/wire-kotlin-generator/build.gradle.kts @@ -12,5 +12,5 @@ dependencies { api(libs.kotlinpoet) testImplementation(projects.wireTestUtils) testImplementation(libs.kotlin.test.junit) - testImplementation(libs.truth) + testImplementation(libs.assertk) } diff --git a/wire-kotlin-generator/src/test/java/com/squareup/wire/kotlin/KotlinGeneratorTest.kt b/wire-kotlin-generator/src/test/java/com/squareup/wire/kotlin/KotlinGeneratorTest.kt index f1a21cfc91..697feb1598 100644 --- a/wire-kotlin-generator/src/test/java/com/squareup/wire/kotlin/KotlinGeneratorTest.kt +++ b/wire-kotlin-generator/src/test/java/com/squareup/wire/kotlin/KotlinGeneratorTest.kt @@ -15,8 +15,11 @@ */ package com.squareup.wire.kotlin -import com.google.common.truth.Truth.assertThat -import com.google.common.truth.Truth.assertWithMessage +import assertk.all +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.containsMatch +import assertk.assertions.doesNotContain import com.squareup.kotlinpoet.FileSpec import com.squareup.wire.buildSchema import com.squareup.wire.kotlin.EnumMode.SEALED_CLASS @@ -201,14 +204,17 @@ class KotlinGeneratorTest { val kotlinGenerator = KotlinGenerator.invoke(pruned) val typeSpec = kotlinGenerator.generateType(pruned.getType("A")!!) - val code = FileSpec.get("", typeSpec).toString() - assertThat(code).contains( - """ + assertThat(FileSpec.get("", typeSpec).toString()).all { + contains( + """ |@WireEnclosingType |public class A private constructor() { - """.trimMargin(), - ) - assertWithMessage(code).that(code.contains("class B(.*) : Message".toRegex(DOT_MATCHES_ALL))).isTrue() + """.trimMargin(), + ) + containsMatch( + "class B(.*) : Message".toRegex(DOT_MATCHES_ALL), + ) + } } @Test fun requestResponse() { diff --git a/wire-moshi-adapter/build.gradle.kts b/wire-moshi-adapter/build.gradle.kts index 249a408398..441adf5c25 100644 --- a/wire-moshi-adapter/build.gradle.kts +++ b/wire-moshi-adapter/build.gradle.kts @@ -7,6 +7,7 @@ dependencies { api(libs.moshi) testImplementation(projects.wireTestUtils) testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(libs.junit) testImplementation(libs.moshiKotlin) } diff --git a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiNoAdapterTest.kt b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiNoAdapterTest.kt index 47a5ba7f68..49d8cc93a9 100644 --- a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiNoAdapterTest.kt +++ b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiNoAdapterTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import com.squareup.wire.json.assertJsonEquals @@ -24,7 +26,6 @@ import com.squareup.wire.proto2.dinosaurs.kotlin.Dinosaur as DinosaurKotlin import com.squareup.wire.proto2.geology.java.Period as PeriodJava import com.squareup.wire.proto2.geology.javainteropkotlin.Period as PeriodInterop import com.squareup.wire.proto2.geology.kotlin.Period as PeriodKotlin -import org.assertj.core.api.Assertions.assertThat import org.junit.Ignore import org.junit.Test diff --git a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPersonTest.kt b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPersonTest.kt index 0cc5444672..f4223f50ce 100644 --- a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPersonTest.kt +++ b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPersonTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.moshi.Moshi import com.squareup.wire.json.assertJsonEquals import com.squareup.wire.proto2.kotlin.Getters @@ -22,7 +24,6 @@ import com.squareup.wire.proto2.person.java.Person as JavaPerson import com.squareup.wire.proto2.person.javainteropkotlin.Person as JavaInteropKotlinPerson import com.squareup.wire.proto2.person.kotlin.Person as KotlinPerson import com.squareup.wire.proto2.person.kotlin.Person.PhoneNumber -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class MoshiPersonTest { diff --git a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPizzaTest.kt b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPizzaTest.kt index 34846cacd9..625112066a 100644 --- a/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPizzaTest.kt +++ b/wire-moshi-adapter/src/test/java/com/squareup/wire/MoshiPizzaTest.kt @@ -15,8 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.moshi.Moshi -import org.assertj.core.api.Assertions.assertThat import org.junit.Test import squareup.proto3.BuyOneGetOnePromotion diff --git a/wire-protoc-compatibility-tests/build.gradle.kts b/wire-protoc-compatibility-tests/build.gradle.kts index 2194a84a36..3f244fadbb 100644 --- a/wire-protoc-compatibility-tests/build.gradle.kts +++ b/wire-protoc-compatibility-tests/build.gradle.kts @@ -72,7 +72,7 @@ dependencies { testImplementation(projects.wireCompiler) testImplementation(projects.wireGsonSupport) testImplementation(projects.wireMoshiAdapter) - testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(libs.junit) testImplementation(libs.protobuf.javaUtil) testImplementation(projects.wireTestUtils) diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/DurationRoundTripTest.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/DurationRoundTripTest.kt index 784d3b2439..dc4b725578 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/DurationRoundTripTest.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/DurationRoundTripTest.kt @@ -15,8 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.google.protobuf.Duration -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class DurationRoundTripTest { diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/EmptyRoundTripTest.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/EmptyRoundTripTest.kt index d2c119760e..254de2ec31 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/EmptyRoundTripTest.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/EmptyRoundTripTest.kt @@ -15,8 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.google.protobuf.Empty -import org.assertj.core.api.Assertions.assertThat import org.junit.Test import squareup.proto3.java.alltypes.AllEmpty as AllEmptyJ import squareup.proto3.kotlin.alltypes.AllEmpty as AllEmptyK diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InstantRoundTripTest.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InstantRoundTripTest.kt index 56158e16ad..5555c3f8eb 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InstantRoundTripTest.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InstantRoundTripTest.kt @@ -15,8 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.google.protobuf.Timestamp -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class InstantRoundTripTest { diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InteropChecker.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InteropChecker.kt index b09fb26a40..76b8b3a075 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InteropChecker.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/InteropChecker.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.message import com.google.gson.GsonBuilder import com.google.gson.TypeAdapter import com.google.protobuf.Message @@ -23,7 +26,6 @@ import com.squareup.moshi.JsonAdapter import com.squareup.moshi.Moshi import okio.ByteString import okio.ByteString.Companion.toByteString -import org.assertj.core.api.Assertions.assertThat class InteropChecker( private val protocMessage: Message, @@ -106,13 +108,12 @@ class InteropChecker( assertThat(adapter.toJson(message)).isEqualTo(wireCanonicalJson) val fromJson = adapter.fromJson(wireCanonicalJson) - assertThat(fromJson) - .overridingErrorMessage { - """ - |Expected :$message (unknownFields: `${(message as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) - |Actual :$fromJson (unknownFields: `${(fromJson as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) - """.trimMargin() - } + assertThat(fromJson, displayActual = { + """ + |Expected :$message (unknownFields: `${(message as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) + |Actual :$fromJson (unknownFields: `${(fromJson as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) + """.trimMargin() + }) .isEqualTo(message) for (json in alternateJsons + wireAlternateJsons) { assertThat(adapter.fromJson(json)).isEqualTo(message) @@ -125,13 +126,13 @@ class InteropChecker( assertThat(adapter.toJson(message)).isEqualTo(wireCanonicalJson) val fromJson = adapter.fromJson(wireCanonicalJson) - assertThat(fromJson) - .overridingErrorMessage { - """ - |Expected :$message (unknownFields: `${(message as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) - |Actual :$fromJson (unknownFields: `${(fromJson as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) - """.trimMargin() - }.isEqualTo(message) + assertThat(fromJson, displayActual = { + """ + |Expected :$message (unknownFields: `${(message as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) + |Actual :$fromJson (unknownFields: `${(fromJson as com.squareup.wire.Message<*, *>).unknownFields.hex()}`) + """.trimMargin() + }) + .isEqualTo(message) for (json in alternateJsons + wireAlternateJsons) { assertThat(adapter.fromJson(json)).isEqualTo(message) } diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto2WireProtocCompatibilityTests.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto2WireProtocCompatibilityTests.kt index f03c47ee2e..6b907c1ce0 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto2WireProtocCompatibilityTests.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto2WireProtocCompatibilityTests.kt @@ -15,12 +15,15 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull import com.google.protobuf.ExtensionRegistry import com.squareup.wire.proto2.kotlin.simple.SimpleMessage as SimpleMessageK import com.squareup.wire.proto2.kotlin.simple.SimpleMessageOuterClass import okio.ByteString import okio.ByteString.Companion.decodeHex -import org.assertj.core.api.Assertions.assertThat import org.junit.Test import squareup.proto2.java.interop.InteropMessage as InteropMessageJ import squareup.proto2.java.interop.type.EnumProto2 as EnumProto2J diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto3WireProtocCompatibilityTests.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto3WireProtocCompatibilityTests.kt index 8973777b67..f435c8bf85 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto3WireProtocCompatibilityTests.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/Proto3WireProtocCompatibilityTests.kt @@ -17,6 +17,10 @@ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull import com.google.protobuf.Any import com.google.protobuf.DescriptorProtos import com.google.protobuf.Duration @@ -34,7 +38,6 @@ import okio.ByteString import okio.ByteString.Companion.decodeHex import okio.buffer import okio.source -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test import squareup.proto2.java.interop.type.MessageProto2 as MessageProto2J diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/SchemaEncoderInteropTest.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/SchemaEncoderInteropTest.kt index 1f1de1c488..7ab85acedf 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/SchemaEncoderInteropTest.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/SchemaEncoderInteropTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.google.protobuf.DescriptorProtos.FileDescriptorProto import com.google.protobuf.ExtensionRegistry import com.squareup.wire.schema.Location @@ -22,7 +24,6 @@ import com.squareup.wire.schema.ProtoFile import com.squareup.wire.schema.SchemaLoader import com.squareup.wire.schema.internal.SchemaEncoder import java.nio.file.FileSystems -import org.assertj.core.api.Assertions.assertThat import org.junit.Test import squareup.proto2.kotlin.alloptions.AllOptions as AllOptionsP2 import squareup.proto2.kotlin.alltypes.AllTypesOuterClass as AllTypesOuterClassP2 diff --git a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/StructTest.kt b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/StructTest.kt index 5e52f0ee0d..17751a9794 100644 --- a/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/StructTest.kt +++ b/wire-protoc-compatibility-tests/src/test/java/com/squareup/wire/StructTest.kt @@ -15,10 +15,14 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.containsOnly +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isTrue import com.google.protobuf.ListValue import com.google.protobuf.NullValue -import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.entry import org.junit.Assert.fail import org.junit.Test import squareup.proto3.java.alltypes.AllStructs as AllStructsJ @@ -377,7 +381,7 @@ class StructTest { (list[1] as MutableList<*>).clear() list.clear() - assertThat(allStructs.list) + assertThat(allStructs.list!!) .containsExactly(mapOf("a" to "b"), listOf("c"), "d", 5.0, false, null) } @@ -401,13 +405,13 @@ class StructTest { (map["b"] as MutableList<*>).clear() map.clear() - assertThat(allStructs.struct).containsExactly( - entry("a", mapOf("g" to "h")), - entry("b", listOf("i")), - entry("c", "j"), - entry("d", 5.0), - entry("e", false), - entry("f", null), + assertThat(allStructs.struct!!).containsOnly( + "a" to mapOf("g" to "h"), + "b" to listOf("i"), + "c" to "j", + "d" to 5.0, + "e" to false, + "f" to null, ) } @@ -431,13 +435,13 @@ class StructTest { (map["b"] as MutableList<*>).clear() map.clear() - assertThat(allStructs.struct).containsExactly( - entry("a", mapOf("g" to "h")), - entry("b", listOf("i")), - entry("c", "j"), - entry("d", 5.0), - entry("e", false), - entry("f", null), + assertThat(allStructs.struct!!).containsOnly( + "a" to mapOf("g" to "h"), + "b" to listOf("i"), + "c" to "j", + "d" to 5.0, + "e" to false, + "f" to null, ) } @@ -465,7 +469,7 @@ class StructTest { // Mutate the values used to create the map. Wire should have defensive copies. map.clear() - assertThat(allStructs.map_int32_struct).containsExactly(entry(5, mapOf("a" to "b"))) + assertThat(allStructs.map_int32_struct!!).containsOnly(5 to mapOf("a" to "b")) } @Test fun kotlinStructsInMapValuesAreDeeplyImmutable() { @@ -479,7 +483,7 @@ class StructTest { // Mutate the values used to create the map. Wire should have defensive copies. map.clear() - assertThat(allStructs.map_int32_struct).containsExactly(entry(5, mapOf("a" to "b"))) + assertThat(allStructs.map_int32_struct).containsOnly(5 to mapOf("a" to "b")) } @Test fun javaStructsInListValuesAreDeeplyImmutable() { diff --git a/wire-reflector/build.gradle.kts b/wire-reflector/build.gradle.kts index 9f642b8983..3a2a66930b 100644 --- a/wire-reflector/build.gradle.kts +++ b/wire-reflector/build.gradle.kts @@ -20,7 +20,7 @@ dependencies { testImplementation(projects.wireTestUtils) testImplementation(libs.junit) testImplementation(libs.kotlin.test.junit) - testImplementation(libs.assertj) + testImplementation(libs.assertk) testImplementation(libs.jimfs) } diff --git a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto2InteropTest.kt b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto2InteropTest.kt index c6d924ab18..4673b22365 100644 --- a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto2InteropTest.kt +++ b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto2InteropTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire.reflector +import assertk.assertThat +import assertk.assertions.isEqualTo import com.google.protobuf.DescriptorProtos.FileDescriptorProto import com.squareup.wire.schema.Location import com.squareup.wire.schema.Schema @@ -24,7 +26,6 @@ import grpc.reflection.v1alpha.ServerReflectionRequest import grpc.reflection.v1alpha.ServerReflectionResponse import okio.ByteString.Companion.decodeBase64 import okio.FileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test // Reference golang reflection tests https://github.com/juliaogris/reflect diff --git a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto3InteropTest.kt b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto3InteropTest.kt index 33077c6e1e..335266518a 100644 --- a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto3InteropTest.kt +++ b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/GrpcurlProto3InteropTest.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire.reflector +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNull import com.google.protobuf.DescriptorProtos.FileDescriptorProto import com.squareup.wire.schema.Location import com.squareup.wire.schema.Schema @@ -26,7 +29,6 @@ import grpc.reflection.v1alpha.ServerReflectionRequest import grpc.reflection.v1alpha.ServerReflectionResponse import okio.ByteString.Companion.decodeBase64 import okio.FileSystem -import org.assertj.core.api.Assertions.assertThat import org.junit.Test // Reference golang reflection tests https://github.com/juliaogris/reflect diff --git a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/SchemaReflectorTest.kt b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/SchemaReflectorTest.kt index 61c2eb41ae..44455bb01c 100644 --- a/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/SchemaReflectorTest.kt +++ b/wire-reflector/src/test/kotlin/com/squareup/wire/reflector/SchemaReflectorTest.kt @@ -15,6 +15,11 @@ */ package com.squareup.wire.reflector +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull +import assertk.assertions.prop import com.google.protobuf.DescriptorProtos import com.squareup.wire.buildSchema import com.squareup.wire.schema.addLocal @@ -23,7 +28,6 @@ import grpc.reflection.v1alpha.ServerReflectionRequest import grpc.reflection.v1alpha.ServerReflectionResponse import grpc.reflection.v1alpha.ServiceResponse import okio.Path.Companion.toPath -import org.assertj.core.api.Assertions.assertThat import org.junit.Test internal class SchemaReflectorTest { @@ -57,7 +61,7 @@ internal class SchemaReflectorTest { file_by_filename = "src/test/proto/RouteGuideProto.proto", ), ), - ).extracting { it.file_descriptor_response }.isNotNull() + ).prop(ServerReflectionResponse::file_descriptor_response).isNotNull() } @Test @@ -72,7 +76,7 @@ internal class SchemaReflectorTest { file_containing_symbol = "routeguide.RouteGuide", ), ), - ).extracting { it.file_descriptor_response }.isNotNull() + ).prop(ServerReflectionResponse::file_descriptor_response).isNotNull() } @Test diff --git a/wire-runtime/build.gradle.kts b/wire-runtime/build.gradle.kts index 330de16feb..b014ca6cfc 100644 --- a/wire-runtime/build.gradle.kts +++ b/wire-runtime/build.gradle.kts @@ -47,6 +47,7 @@ kotlin { } val commonTest by getting { dependencies { + implementation(libs.assertk) implementation(libs.kotlin.test.common) implementation(libs.kotlin.test.annotations) } @@ -58,7 +59,6 @@ kotlin { } val jvmTest by getting { dependencies { - implementation(libs.assertj) implementation(libs.kotlin.test.junit) } } diff --git a/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReader32Test.kt b/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReader32Test.kt index 8b1f74035c..e4ffc8f0d6 100644 --- a/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReader32Test.kt +++ b/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReader32Test.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.ReverseProtoWriterTest.Person import kotlin.test.Test import kotlin.test.assertEquals diff --git a/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReaderTest.kt b/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReaderTest.kt index 18e54f4067..3fbdd37720 100644 --- a/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReaderTest.kt +++ b/wire-runtime/src/commonTest/kotlin/com/squareup/wire/ProtoReaderTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.ReverseProtoWriterTest.Person import kotlin.test.Test import kotlin.test.assertEquals diff --git a/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt b/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt index 3e071f6033..fdc0ab6a85 100644 --- a/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt +++ b/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt @@ -18,6 +18,7 @@ package com.squareup.wire import assertk.assertThat import assertk.assertions.containsExactlyInAnyOrder import assertk.assertions.isEqualTo +import assertk.assertions.message import com.squareup.wire.schema.Location import com.squareup.wire.schema.SchemaException import kotlin.test.Test diff --git a/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/recipes/ErrorReportingSchemaHandlerTest.kt b/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/recipes/ErrorReportingSchemaHandlerTest.kt index dd3a76fb6b..ac0fc5f44e 100644 --- a/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/recipes/ErrorReportingSchemaHandlerTest.kt +++ b/wire-schema-tests/src/commonTest/kotlin/com/squareup/wire/recipes/ErrorReportingSchemaHandlerTest.kt @@ -16,6 +16,7 @@ package com.squareup.wire.recipes import assertk.assertThat +import assertk.assertions.message import assertk.assertions.startsWith import com.squareup.wire.WireTestLogger import com.squareup.wire.addFakeRuntimeProtos diff --git a/wire-schema-tests/src/jvmTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt b/wire-schema-tests/src/jvmTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt index e2bc3fce8b..31eb61aa04 100644 --- a/wire-schema-tests/src/jvmTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt +++ b/wire-schema-tests/src/jvmTest/kotlin/com/squareup/wire/SchemaBuilderTest.kt @@ -18,6 +18,7 @@ package com.squareup.wire import assertk.assertThat import assertk.assertions.containsExactlyInAnyOrder import assertk.assertions.isEqualTo +import assertk.assertions.message import com.squareup.wire.schema.Location import com.squareup.wire.schema.SchemaException import kotlin.test.Test diff --git a/wire-schema/build.gradle.kts b/wire-schema/build.gradle.kts index 0f9ff79c68..c84395e871 100644 --- a/wire-schema/build.gradle.kts +++ b/wire-schema/build.gradle.kts @@ -60,7 +60,7 @@ kotlin { } val jvmTest by getting { dependencies { - implementation(libs.assertj) + implementation(libs.assertk) implementation(libs.jimfs) implementation(libs.protobuf.java) } diff --git a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/MavenVersionsTest.kt b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/MavenVersionsTest.kt index 084aff89ae..bca2483eb2 100644 --- a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/MavenVersionsTest.kt +++ b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/MavenVersionsTest.kt @@ -19,7 +19,47 @@ package com.squareup.wire.schema import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.hasSize +import assertk.assertions.isEmpty import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import assertk.assertions.isNotNull +import assertk.assertions.isNull +import assertk.assertions.isTrue +import assertk.assertions.isSameInstanceAs +import assertk.assertions.isNotSameInstanceAs +import assertk.assertions.message +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.hasSize +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import assertk.assertions.isNotNull +import assertk.assertions.isNull +import assertk.assertions.isTrue +import assertk.assertions.isSameInstanceAs +import assertk.assertions.isNotSameInstanceAs +import assertk.assertions.message +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.hasSize +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isInstanceOf +import assertk.assertions.isNotEmpty +import assertk.assertions.isNotNull +import assertk.assertions.isNull +import assertk.assertions.isTrue +import assertk.assertions.isSameInstanceAs +import assertk.assertions.isNotSameInstanceAs +import assertk.assertions.message import assertk.assertions.isGreaterThan import assertk.assertions.isLessThan import kotlin.test.Test diff --git a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/PruningRulesTest.kt b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/PruningRulesTest.kt index 7bdd523c09..f0bb7b114d 100644 --- a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/PruningRulesTest.kt +++ b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/PruningRulesTest.kt @@ -16,6 +16,7 @@ package com.squareup.wire.schema import assertk.assertThat +import assertk.assertions.containsExactly import assertk.assertions.hasMessage import assertk.assertions.isEmpty import assertk.assertions.isEqualTo diff --git a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoFileElementTest.kt b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoFileElementTest.kt index 8586f983f4..9be3be5036 100644 --- a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoFileElementTest.kt +++ b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoFileElementTest.kt @@ -18,6 +18,7 @@ package com.squareup.wire.schema.internal.parser import assertk.assertThat import assertk.assertions.hasSize import assertk.assertions.isEqualTo +import assertk.assertions.message import com.squareup.wire.Syntax.PROTO_2 import com.squareup.wire.Syntax.PROTO_3 import com.squareup.wire.schema.Field diff --git a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt index 16aafb2064..de67150523 100644 --- a/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt +++ b/wire-schema/src/commonTest/kotlin/com/squareup/wire/schema/internal/parser/ProtoParserTest.kt @@ -20,6 +20,7 @@ import assertk.assertions.containsOnly import assertk.assertions.hasMessage import assertk.assertions.isEqualTo import assertk.assertions.isNull +import assertk.assertions.message import assertk.assertions.messageContains import com.squareup.wire.Syntax.PROTO_2 import com.squareup.wire.Syntax.PROTO_3 diff --git a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/OptionsTest.kt b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/OptionsTest.kt index a9e8036f17..ff9ef4aea3 100644 --- a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/OptionsTest.kt +++ b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/OptionsTest.kt @@ -19,6 +19,7 @@ import assertk.assertThat import assertk.assertions.containsExactly import assertk.assertions.isEqualTo import assertk.assertions.isNull +import assertk.assertions.message import com.squareup.wire.buildSchema import kotlin.test.Test import okio.Path.Companion.toPath diff --git a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/ProfileLoaderTest.kt b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/ProfileLoaderTest.kt index 17a9a8689d..2d728d0105 100644 --- a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/ProfileLoaderTest.kt +++ b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/ProfileLoaderTest.kt @@ -19,6 +19,7 @@ import assertk.assertThat import assertk.assertions.hasMessage import assertk.assertions.isEqualTo import assertk.assertions.isNull +import assertk.assertions.message import com.palantir.javapoet.ClassName import com.squareup.wire.testing.add import com.squareup.wire.testing.addZip diff --git a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/PrunerTest.kt b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/PrunerTest.kt index b7de2625ae..ea692902d3 100644 --- a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/PrunerTest.kt +++ b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/PrunerTest.kt @@ -27,6 +27,7 @@ import assertk.assertions.isNotEmpty import assertk.assertions.isNotNull import assertk.assertions.isNull import assertk.assertions.isTrue +import assertk.assertions.message import com.squareup.wire.buildSchema import com.squareup.wire.schema.Options.Companion.FIELD_OPTIONS import com.squareup.wire.schema.Options.Companion.MESSAGE_OPTIONS diff --git a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/SchemaTest.kt b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/SchemaTest.kt index dac9d537a1..625ec1e2b1 100644 --- a/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/SchemaTest.kt +++ b/wire-schema/src/jvmTest/kotlin/com/squareup/wire/schema/SchemaTest.kt @@ -26,6 +26,7 @@ import assertk.assertions.isFalse import assertk.assertions.isNotNull import assertk.assertions.isNull import assertk.assertions.isTrue +import assertk.assertions.message import com.squareup.wire.buildSchema import com.squareup.wire.schema.Options.Companion.FIELD_OPTIONS import com.squareup.wire.schema.Options.Companion.ONEOF_OPTIONS diff --git a/wire-test-utils/build.gradle.kts b/wire-test-utils/build.gradle.kts index 1501c30ac0..119157c1b6 100644 --- a/wire-test-utils/build.gradle.kts +++ b/wire-test-utils/build.gradle.kts @@ -67,7 +67,7 @@ kotlin { api(libs.javapoet) api(libs.kotlinpoet) implementation(libs.protobuf.java) - implementation(libs.assertj) + implementation(libs.assertk) } } } diff --git a/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/json/Json.kt b/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/json/Json.kt index c8ae17c593..a9bf64bbff 100644 --- a/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/json/Json.kt +++ b/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/json/Json.kt @@ -17,9 +17,10 @@ package com.squareup.wire.json +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.moshi.JsonReader import okio.Buffer -import org.assertj.core.api.Assertions.assertThat fun assertJsonEquals(expected: String, value: String) { assertThat(JsonReader.of(Buffer().writeUtf8(value)).readJsonValue()) diff --git a/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/testing/filesJvm.kt b/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/testing/filesJvm.kt index 607ec74de1..26ac68d1fe 100644 --- a/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/testing/filesJvm.kt +++ b/wire-test-utils/src/jvmMain/kotlin/com/squareup/wire/testing/filesJvm.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire.testing +import assertk.Assert +import assertk.assertions.contains import java.nio.charset.Charset import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream @@ -24,7 +26,6 @@ import okio.FileSystem import okio.Path.Companion.toPath import okio.buffer import okio.sink -import org.assertj.core.api.IterableAssert fun FileSystem.add( pathString: String, @@ -64,8 +65,8 @@ fun FileSystem.addZip(pathString: String, vararg contents: Pair) * This asserts that [this] contains exactly in any order all [values] regardless of the slash they * may contain. This is useful to write one assertion which can be run on both macOS and Windows. */ -fun IterableAssert.containsExactlyInAnyOrderAsRelativePaths(vararg values: String): IterableAssert { +fun Assert.containsExactlyInAnyOrderAsRelativePaths(vararg values: String) { @Suppress("NAME_SHADOWING") val values = values.map { it.withPlatformSlashes() } - return containsExactlyInAnyOrder(*values.toTypedArray()) + return this.contains(*values.toTypedArray()) } diff --git a/wire-tests/build.gradle.kts b/wire-tests/build.gradle.kts index 90711c63ba..986b5e184d 100644 --- a/wire-tests/build.gradle.kts +++ b/wire-tests/build.gradle.kts @@ -15,7 +15,7 @@ kotlin { dependencies { implementation(projects.wireRuntime) implementation(libs.kotlin.test.junit) - implementation(libs.assertj) + implementation(libs.assertk) implementation(libs.kotlin.reflect) } } @@ -38,6 +38,7 @@ kotlin { compileOnly(libs.android) implementation(libs.kotlin.test.junit) implementation(libs.assertj) + implementation(libs.assertk) } } val jvmKotlinAndroidTest by tasks.creating(Test::class) { @@ -55,6 +56,7 @@ kotlin { implementation(projects.wireRuntime) implementation(libs.kotlin.test.junit) implementation(libs.assertj) + implementation(libs.assertk) implementation(libs.kotlin.reflect) } } @@ -107,6 +109,7 @@ kotlin { val commonTest by getting { kotlin.srcDir("src/commonTest/proto-kotlin") dependencies { + implementation(libs.assertk) implementation(libs.kotlin.test.common) implementation(libs.kotlin.test.annotations) } @@ -231,18 +234,21 @@ for (target in kotlin.targets.matching { it.platformType.name == "jvm" }) { add("javaTestImplementation", libs.kotlin.test.junit) add("javaTestImplementation", libs.assertj) + add("javaTestImplementation", libs.assertk) add("javaTestImplementation", libs.jimfs) add("jsonJavaTestImplementation", projects.wireMoshiAdapter) add("jsonJavaTestImplementation", projects.wireGsonSupport) add("jsonJavaTestImplementation", projects.wireTestUtils) add("jsonJavaTestImplementation", libs.kotlin.test.junit) add("jsonJavaTestImplementation", libs.assertj) + add("jsonJavaTestImplementation", libs.assertk) add("jsonJavaTestImplementation", libs.jimfs) add("jsonKotlinTestImplementation", projects.wireMoshiAdapter) add("jsonKotlinTestImplementation", projects.wireGsonSupport) add("jsonKotlinTestImplementation", projects.wireTestUtils) add("jsonKotlinTestImplementation", libs.kotlin.test.junit) add("jsonKotlinTestImplementation", libs.assertj) + add("jsonKotlinTestImplementation", libs.assertk) add("jsonKotlinTestImplementation", libs.jimfs) add("jvmJavaTestImplementation", projects.wireMoshiAdapter) diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/AnyMessageTest.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/AnyMessageTest.kt index 9ce0576f0f..90fcdd90ae 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/AnyMessageTest.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/AnyMessageTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.protos.kotlin.edgecases.NoFields import com.squareup.wire.protos.kotlin.edgecases.OneField import com.squareup.wire.protos.usesany.UsesAny diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/BoxOneOfTest.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/BoxOneOfTest.kt index d87d0059af..2991de7192 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/BoxOneOfTest.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/BoxOneOfTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.protos.kotlin.Form import kotlin.test.Test import kotlin.test.assertEquals diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/OneOfTest.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/OneOfTest.kt index 7b99fa5a90..206dba31c1 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/OneOfTest.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/OneOfTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.protos.kotlin.OneOfMessage import kotlin.test.Test import kotlin.test.assertEquals diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/ParseTest.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/ParseTest.kt index 0779b75842..1caf5a4592 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/ParseTest.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/ParseTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.internal.ProtocolException import com.squareup.wire.protos.kotlin.edgecases.OneBytesField import com.squareup.wire.protos.kotlin.edgecases.OneField diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt index b2afa9c371..ccfd30ff3e 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.isTrue import com.squareup.wire.proto3.kotlin.person.Person import com.squareup.wire.protos.kotlin.bool.TrueBoolean import kotlin.test.Test diff --git a/wire-tests/src/commonTest/kotlin/com/squareup/wire/TestAllTypes.kt b/wire-tests/src/commonTest/kotlin/com/squareup/wire/TestAllTypes.kt index f36634d59e..6916c4845b 100644 --- a/wire-tests/src/commonTest/kotlin/com/squareup/wire/TestAllTypes.kt +++ b/wire-tests/src/commonTest/kotlin/com/squareup/wire/TestAllTypes.kt @@ -15,6 +15,7 @@ */ package com.squareup.wire +import assertk.assertions.message import com.squareup.wire.TestAllTypesData.list import com.squareup.wire.TestAllTypesData.message import com.squareup.wire.protos.kotlin.alltypes.AllTypes diff --git a/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MapTest.kt b/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MapTest.kt index a57a1e21c0..824ba5941f 100644 --- a/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MapTest.kt +++ b/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MapTest.kt @@ -15,13 +15,16 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isNotNull import com.squareup.wire.internal.createRuntimeMessageAdapter import com.squareup.wire.map.Mappy import com.squareup.wire.map.Thing import java.io.IOException import okio.ByteString import okio.ByteString.Companion.decodeHex -import org.assertj.core.api.Assertions.assertThat import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized diff --git a/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MoshiRedactedTest.kt b/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MoshiRedactedTest.kt index ae0622d4cd..520afd9f80 100644 --- a/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MoshiRedactedTest.kt +++ b/wire-tests/src/jvmJavaTest/java/com/squareup/wire/MoshiRedactedTest.kt @@ -15,11 +15,12 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.moshi.Moshi import com.squareup.wire.protos.redacted.NotRedacted import com.squareup.wire.protos.redacted.RedactedChild import com.squareup.wire.protos.redacted.RedactedFields -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class MoshiRedactedTest { diff --git a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/AnnotationsTestAgainstJava.kt b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/AnnotationsTestAgainstJava.kt index 0ef470541c..c7123be8f4 100644 --- a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/AnnotationsTestAgainstJava.kt +++ b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/AnnotationsTestAgainstJava.kt @@ -15,6 +15,10 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isTrue import com.squareup.wire.protos.custom_options.EnumOptionOption import com.squareup.wire.protos.custom_options.EnumValueOptionOption import com.squareup.wire.protos.custom_options.FooBar @@ -33,7 +37,6 @@ import com.squareup.wire.protos.custom_options.MyMessageOptionTwoOption import com.squareup.wire.protos.custom_options.RepeatedEnumValueOptionTwoOption import com.squareup.wire.protos.foreign.ForeignEnum import com.squareup.wire.protos.foreign.ForeignEnumValueOptionOption -import org.assertj.core.api.Assertions.assertThat import org.junit.Test // TODO(Benoit) This tests exactly match some others in `AnnotationsTestAgainstKotlin`. We should diff --git a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterIdentityTest.kt b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterIdentityTest.kt index ddfb83b4c0..4d5137b5ae 100644 --- a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterIdentityTest.kt +++ b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterIdentityTest.kt @@ -15,6 +15,11 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo +import assertk.assertions.isInstanceOf +import assertk.assertions.isNull import com.squareup.wire.FieldEncoding.LENGTH_DELIMITED import com.squareup.wire.protos.person.Person import com.squareup.wire.protos.person.Person.PhoneType @@ -23,7 +28,6 @@ import java.lang.reflect.Modifier import kotlin.reflect.KClass import kotlin.test.Test import okio.ByteString -import org.assertj.core.api.Assertions.assertThat class ProtoAdapterIdentityTest { @Test fun generatedAdaptersHaveNullIdentities() { @@ -37,16 +41,16 @@ class ProtoAdapterIdentityTest { assertThat(protoAdapter.identity).isNull() } protoAdapter.type == DoubleArray::class -> { - assertThat(protoAdapter.identity).isEqualTo(doubleArrayOf()) + assertThat(protoAdapter.identity!!).isInstanceOf().isEmpty() } protoAdapter.type == FloatArray::class -> { - assertThat(protoAdapter.identity).isEqualTo(floatArrayOf()) + assertThat(protoAdapter.identity!!).isInstanceOf().isEmpty() } protoAdapter.type == LongArray::class -> { - assertThat(protoAdapter.identity).isEqualTo(longArrayOf()) + assertThat(protoAdapter.identity!!).isInstanceOf().isEmpty() } protoAdapter.type == IntArray::class -> { - assertThat(protoAdapter.identity).isEqualTo(intArrayOf()) + assertThat(protoAdapter.identity!!).isInstanceOf().isEmpty() } protoAdapter.type.isPrimitive && protoAdapter.syntax === Syntax.PROTO_2 -> { // All other primitive types are numbers and must have 0 as their identity value. diff --git a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterTypeUrlTest.kt b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterTypeUrlTest.kt index 03ae310cbd..ea025a71c0 100644 --- a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterTypeUrlTest.kt +++ b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/ProtoAdapterTypeUrlTest.kt @@ -15,13 +15,16 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNull +import assertk.assertions.startsWith import com.squareup.wire.protos.person.Person import com.squareup.wire.protos.person.Person.PhoneType import java.lang.reflect.Modifier import kotlin.reflect.KClass import kotlin.test.Test import okio.ByteString -import org.assertj.core.api.Assertions.assertThat class ProtoAdapterTypeUrlTest { @Test fun allBuiltInAdaptersHaveReasonableTypeUrls() { @@ -46,7 +49,7 @@ class ProtoAdapterTypeUrlTest { assertThat(protoAdapter.typeUrl).isNull() } else -> { - assertThat(protoAdapter.typeUrl).startsWith("type.googleapis.com/") + assertThat(protoAdapter.typeUrl!!).startsWith("type.googleapis.com/") } } } diff --git a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/WireKotlinTest.kt b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/WireKotlinTest.kt index c5708ec7fa..0804418798 100644 --- a/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/WireKotlinTest.kt +++ b/wire-tests/src/jvmJavaTest/kotlin/com/squareup/wire/WireKotlinTest.kt @@ -17,10 +17,11 @@ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isSameInstanceAs import com.squareup.wire.protos.person.Person import com.squareup.wire.protos.person.Person.PhoneNumber import com.squareup.wire.protos.person.Person.PhoneType -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test @@ -42,10 +43,10 @@ class WireKotlinTest { } catch (expected: UnsupportedOperationException) { } - assertThat(personNoPhone.phone).isSameAs(emptyList()) + assertThat(personNoPhone.phone).isSameInstanceAs(emptyList()) // Round-trip these instances through the builder and ensure the lists are the same instances. - assertThat(personWithPhone.newBuilder().build().phone).isSameAs(personWithPhone.phone) - assertThat(personNoPhone.newBuilder().build().phone).isSameAs(personNoPhone.phone) + assertThat(personWithPhone.newBuilder().build().phone).isSameInstanceAs(personWithPhone.phone) + assertThat(personNoPhone.newBuilder().build().phone).isSameInstanceAs(personNoPhone.phone) } } diff --git a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/WireJsonTest.kt b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/WireJsonTest.kt index 69c0cdf897..b8ef67612b 100644 --- a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/WireJsonTest.kt +++ b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/WireJsonTest.kt @@ -15,6 +15,11 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.contains +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.messageContains import com.google.gson.GsonBuilder import com.google.gson.JsonIOException import com.google.gson.JsonSyntaxException @@ -28,7 +33,6 @@ import java.util.Collections import okio.ByteString import okio.buffer import okio.source -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test import org.junit.runner.RunWith @@ -274,7 +278,7 @@ class WireJsonTest { } catch (expected: JsonSyntaxException) { // Gson. assertThat(expected) - .hasMessageContaining( + .messageContains( "Cannot resolve type: " + "type.googleapis.com/squareup.proto3.FreeGarlicBreadPromotion in \$.promotion", ) @@ -307,7 +311,7 @@ class WireJsonTest { } catch (expected: JsonIOException) { // Gson. assertThat(expected) - .hasMessageContaining( + .messageContains( "Cannot find type for url: " + "type.googleapis.com/squareup.proto3.FreeGarlicBreadPromotion", ) @@ -323,7 +327,7 @@ class WireJsonTest { assertThat(expected).hasMessage("expected @type in \$.promotion") } catch (expected: JsonSyntaxException) { // Gson. - assertThat(expected).hasMessageContaining("expected @type in \$.promotion") + assertThat(expected).messageContains("expected @type in \$.promotion") } } diff --git a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/DurationJsonFormatterTest.kt b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/DurationJsonFormatterTest.kt index 10afa58953..101e13b9ec 100644 --- a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/DurationJsonFormatterTest.kt +++ b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/DurationJsonFormatterTest.kt @@ -15,10 +15,11 @@ */ package com.squareup.wire.internal +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.wire.durationOfSeconds import com.squareup.wire.internal.DurationJsonFormatter.fromString import com.squareup.wire.internal.DurationJsonFormatter.toStringOrNumber -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class DurationJsonFormatterTest { diff --git a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/InstantJsonFormatterTest.kt b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/InstantJsonFormatterTest.kt index 8743002996..b2008abe7a 100644 --- a/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/InstantJsonFormatterTest.kt +++ b/wire-tests/src/jvmJsonTest/kotlin/com/squareup/wire/internal/InstantJsonFormatterTest.kt @@ -15,10 +15,11 @@ */ package com.squareup.wire.internal +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.wire.internal.InstantJsonFormatter.fromString import com.squareup.wire.internal.InstantJsonFormatter.toStringOrNumber import com.squareup.wire.ofEpochSecond -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class InstantJsonFormatterTest { diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/AnnotationsTestAgainstKotlin.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/AnnotationsTestAgainstKotlin.kt index cf4abea5c7..87a0f15869 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/AnnotationsTestAgainstKotlin.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/AnnotationsTestAgainstKotlin.kt @@ -17,6 +17,10 @@ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isFalse +import assertk.assertions.isTrue import com.squareup.wire.protos.custom_options.EnumOptionOption import com.squareup.wire.protos.custom_options.EnumValueOptionOption import com.squareup.wire.protos.custom_options.FooBar @@ -35,7 +39,6 @@ import com.squareup.wire.protos.custom_options.MyMessageOptionTwoOption import com.squareup.wire.protos.custom_options.RepeatedEnumValueOptionTwoOption import com.squareup.wire.protos.kotlin.foreign.ForeignEnum import com.squareup.wire.protos.kotlin.foreign.ForeignEnumValueOptionOption -import org.assertj.core.api.Assertions.assertThat import org.junit.Test // TODO(Benoit) This tests exactly match some others in `AnnotationsTestAgainstJava`. We should diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/OneOfTest.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/OneOfTest.kt index 4b7c58d425..664b7a8a65 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/OneOfTest.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/OneOfTest.kt @@ -15,10 +15,14 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.hasMessage +import assertk.assertions.isEqualTo +import assertk.assertions.isNull +import assertk.assertions.message import com.squareup.wire.protos.kotlin.Form import com.squareup.wire.protos.kotlin.OneOfMessage import kotlin.test.assertEquals -import org.assertj.core.api.Assertions.assertThat import org.junit.Assert.fail import org.junit.Test diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt index aa0bf2bc72..fefd64ed57 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/ProtoAdapterTest.kt @@ -15,11 +15,13 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isSameInstanceAs import com.squareup.wire.protos.kotlin.person.Person import kotlin.test.Test import okio.ByteString.Companion.decodeHex import okio.ByteString.Companion.toByteString -import org.assertj.core.api.Assertions.assertThat class ProtoAdapterTest { @Test fun fromClass() { @@ -40,6 +42,6 @@ class ProtoAdapterTest { .build() val instanceAdapter = ProtoAdapter.get(person) val classAdapter = ProtoAdapter.get(Person::class.java) - assertThat(instanceAdapter).isSameAs(classAdapter) + assertThat(instanceAdapter).isSameInstanceAs(classAdapter) } } diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/RecursiveMapTest.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/RecursiveMapTest.kt index 53a8fff066..c1f4c61436 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/RecursiveMapTest.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/RecursiveMapTest.kt @@ -18,7 +18,8 @@ package com.squareup.wire import ModelEvaluation -import org.assertj.core.api.Assertions.assertThat +import assertk.assertThat +import assertk.assertions.isEqualTo import org.junit.Test class RecursiveMapTest { diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/SerializableTest.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/SerializableTest.kt index 0459a9e580..aeb6a4aa00 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/SerializableTest.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/SerializableTest.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.message import com.squareup.wire.protos.kotlin.NoFields import com.squareup.wire.protos.kotlin.person.Person import com.squareup.wire.protos.kotlin.simple.SimpleMessage @@ -23,7 +26,6 @@ import java.io.ObjectOutputStream import okio.Buffer import okio.ByteString import okio.ByteString.Companion.decodeBase64 -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class SerializableTest { diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/TestAllTypes.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/TestAllTypes.kt index bc0cc73e66..81165eab5b 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/TestAllTypes.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/TestAllTypes.kt @@ -15,6 +15,9 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo +import assertk.assertions.isNotSameInstanceAs import com.squareup.wire.protos.kotlin.alltypes.AllTypes import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream @@ -24,7 +27,6 @@ import okio.ByteString import okio.ForwardingSource import okio.Source import okio.buffer -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class TestAllTypes { @@ -116,7 +118,7 @@ class TestAllTypes { val builder = allTypes.newBuilder() assertThat(builder.build()).isEqualTo(allTypes) builder.opt_bool = false - assertThat(builder.build()).isNotSameAs(allTypes) + assertThat(builder.build()).isNotSameInstanceAs(allTypes) } @Test fun testWriteStream() { diff --git a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/UnknownFieldsTest.kt b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/UnknownFieldsTest.kt index c2dd86fb4c..383f472abc 100644 --- a/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/UnknownFieldsTest.kt +++ b/wire-tests/src/jvmKotlinInteropTest/kotlin/com/squareup/wire/UnknownFieldsTest.kt @@ -15,10 +15,13 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.containsExactly +import assertk.assertions.isEmpty +import assertk.assertions.isEqualTo import com.squareup.wire.protos.kotlin.unknownfields.VersionOne import com.squareup.wire.protos.kotlin.unknownfields.VersionTwo import okio.ByteString -import org.assertj.core.api.Assertions.assertThat import org.junit.Test class UnknownFieldsTest { diff --git a/wire-tests/src/jvmKotlinProtoReader32Test/kotlin/com/squareup/wire/ProtoReader32AdapterTest.kt b/wire-tests/src/jvmKotlinProtoReader32Test/kotlin/com/squareup/wire/ProtoReader32AdapterTest.kt index affaf17c29..f39e145438 100644 --- a/wire-tests/src/jvmKotlinProtoReader32Test/kotlin/com/squareup/wire/ProtoReader32AdapterTest.kt +++ b/wire-tests/src/jvmKotlinProtoReader32Test/kotlin/com/squareup/wire/ProtoReader32AdapterTest.kt @@ -15,6 +15,8 @@ */ package com.squareup.wire +import assertk.assertThat +import assertk.assertions.isEqualTo import com.squareup.wire.Syntax.PROTO_2 import com.squareup.wire.protos.kotlin.alltypes.AllTypes import com.squareup.wire.protos.kotlin.alltypes.AllTypes.NestedMessage @@ -22,7 +24,6 @@ import kotlin.test.Test import kotlin.test.assertEquals import okio.Buffer import okio.ByteString -import org.assertj.core.api.Assertions.assertThat class ProtoReader32AdapterTest { private val bytes = ByteString.of(125.toByte(), 225.toByte())