mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 08:29:22 +08:00
Standardize (almost) all tests on Truth (#1242)
* Replace assertj calls with Truth where possible * Update test dependencies * adapters * reflect * codegen * moshi * Add missing inOrder() * Spotless
This commit is contained in:
@@ -76,7 +76,6 @@ dependencies {
|
||||
testImplementation(Dependencies.KotlinPoet.metadataSpecs)
|
||||
testImplementation(Dependencies.KotlinPoet.elementsClassInspector)
|
||||
testImplementation(Dependencies.Testing.junit)
|
||||
testImplementation(Dependencies.Testing.assertj)
|
||||
testImplementation(Dependencies.Testing.truth)
|
||||
testImplementation(Dependencies.Testing.compileTesting)
|
||||
testImplementation(Dependencies.okio2)
|
||||
|
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.squareup.moshi.kotlin.codegen
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.JsonReader
|
||||
import com.tschuchort.compiletesting.KotlinCompilation
|
||||
import com.tschuchort.compiletesting.SourceFile
|
||||
import com.tschuchort.compiletesting.SourceFile.Companion.kotlin
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -616,7 +616,7 @@ class JsonClassCodegenProcessorTest {
|
||||
|
||||
result.generatedFiles.filter { it.extension == "pro" }.forEach { generatedFile ->
|
||||
when (generatedFile.nameWithoutExtension) {
|
||||
"moshi-testPackage.Aliases" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.Aliases" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.Aliases
|
||||
-keepnames class testPackage.Aliases
|
||||
@@ -626,7 +626,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.Simple" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.Simple" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.Simple
|
||||
-keepnames class testPackage.Simple
|
||||
@@ -636,7 +636,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.Generic" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.Generic" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.Generic
|
||||
-keepnames class testPackage.Generic
|
||||
@@ -646,7 +646,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.UsingQualifiers" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.UsingQualifiers" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.UsingQualifiers
|
||||
-keepnames class testPackage.UsingQualifiers
|
||||
@@ -659,7 +659,7 @@ class JsonClassCodegenProcessorTest {
|
||||
-keep @interface testPackage.MyQualifier
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.MixedTypes" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.MixedTypes" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.MixedTypes
|
||||
-keepnames class testPackage.MixedTypes
|
||||
@@ -669,7 +669,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.DefaultParams" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.DefaultParams" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.DefaultParams
|
||||
-keepnames class testPackage.DefaultParams
|
||||
@@ -685,7 +685,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.Complex" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.Complex" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.Complex
|
||||
-keepnames class testPackage.Complex
|
||||
@@ -704,7 +704,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.MultipleMasks" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.MultipleMasks" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.MultipleMasks
|
||||
-keepnames class testPackage.MultipleMasks
|
||||
@@ -720,7 +720,7 @@ class JsonClassCodegenProcessorTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
"moshi-testPackage.NestedType.NestedSimple" -> assertThat(generatedFile).hasContent(
|
||||
"moshi-testPackage.NestedType.NestedSimple" -> assertThat(generatedFile.readText()).contains(
|
||||
"""
|
||||
-if class testPackage.NestedType${'$'}NestedSimple
|
||||
-keepnames class testPackage.NestedType${'$'}NestedSimple
|
||||
|
@@ -25,5 +25,5 @@ dependencies {
|
||||
|
||||
testImplementation(kotlin("test"))
|
||||
testImplementation(Dependencies.Testing.junit)
|
||||
testImplementation(Dependencies.Testing.assertj)
|
||||
testImplementation(Dependencies.Testing.truth)
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@
|
||||
*/
|
||||
package com.squareup.moshi.kotlin.reflect
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.squareup.moshi.Moshi
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Test
|
||||
|
||||
class KotlinJsonAdapterTest {
|
||||
|
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.squareup.moshi.kotlin
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
@@ -26,7 +27,6 @@ import com.squareup.moshi.ToJson
|
||||
import com.squareup.moshi.Types
|
||||
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
|
||||
import com.squareup.moshi.kotlin.reflect.adapter
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
@@ -87,7 +87,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("""{"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Required value 'b' missing at $")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Required value 'b' missing at $")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("""{"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Required value 'b' (JSON name 'bPrime') missing at \$")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Required value 'b' (JSON name 'bPrime') missing at \$")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"a\":null}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' was null at \$.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' was null at \$.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"a\":\"hello\"}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' was null at \$.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' was null at \$.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"aPrime\":null}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' (JSON name 'aPrime') was null at \$.aPrime")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' (JSON name 'aPrime') was null at \$.aPrime")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"aPrime\":\"hello\"}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' (JSON name 'aPrime') was null at \$.aPrime")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' (JSON name 'aPrime') was null at \$.aPrime")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"a\":null}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' was null at \$.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' was null at \$.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class DualKotlinTest(useReflection: Boolean) {
|
||||
jsonAdapter.fromJson("{\"a\":\"hello\"}")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Non-null value 'a' was null at \$.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Non-null value 'a' was null at \$.a")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,10 +17,10 @@
|
||||
|
||||
package com.squareup.moshi.kotlin.codegen
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.kotlin.reflect.adapter
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.Test
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.squareup.moshi.kotlin.codegen
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
@@ -28,7 +29,6 @@ import com.squareup.moshi.ToJson
|
||||
import com.squareup.moshi.Types
|
||||
import com.squareup.moshi.internal.NullSafeJsonAdapter
|
||||
import com.squareup.moshi.kotlin.reflect.adapter
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.fail
|
||||
@@ -177,7 +177,7 @@ class GeneratedAdaptersTest {
|
||||
"""{"data":[null,"why"]}"""
|
||||
|
||||
val instance = adapter.fromJson(json)!!
|
||||
assertThat(instance.data).containsExactly(null, "why")
|
||||
assertThat(instance.data).asList().containsExactly(null, "why").inOrder()
|
||||
assertThat(adapter.toJson(instance)).isEqualTo(json)
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class GeneratedAdaptersTest {
|
||||
"""{"ints":[0,1]}"""
|
||||
|
||||
val instance = adapter.fromJson(json)!!
|
||||
assertThat(instance.ints).containsExactly(0, 1)
|
||||
assertThat(instance.ints).asList().containsExactly(0, 1).inOrder()
|
||||
assertThat(adapter.toJson(instance)).isEqualTo(json)
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ class GeneratedAdaptersTest {
|
||||
adapter.fromJson(invalidJson)
|
||||
fail("The invalid json should have failed!")
|
||||
} catch (e: JsonDataException) {
|
||||
assertThat(e).hasMessageContaining("foo")
|
||||
assertThat(e).hasMessageThat().contains("foo")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,7 +933,7 @@ class GeneratedAdaptersTest {
|
||||
jsonAdapter.fromJson("""{"a":4,"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Multiple values for 'a' at $.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Multiple values for 'a' at $.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,7 +948,7 @@ class GeneratedAdaptersTest {
|
||||
jsonAdapter.fromJson("""{"a":4,"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Multiple values for 'a' at $.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Multiple values for 'a' at $.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1272,7 +1272,7 @@ class GeneratedAdaptersTest {
|
||||
moshi.adapter<CustomGeneratedClassMissing>()
|
||||
fail()
|
||||
} catch (e: RuntimeException) {
|
||||
assertThat(e).hasMessageContaining("Failed to find the generated JsonAdapter class")
|
||||
assertThat(e).hasMessageThat().contains("Failed to find the generated JsonAdapter class")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1349,7 +1349,7 @@ class GeneratedAdaptersTest {
|
||||
moshi.adapter(MultipleGenerics::class.java)
|
||||
fail("Should have failed to construct the adapter due to missing generics")
|
||||
} catch (e: RuntimeException) {
|
||||
assertThat(e).hasMessage("Failed to find the generated JsonAdapter constructor for 'class com.squareup.moshi.kotlin.codegen.GeneratedAdaptersTest\$MultipleGenerics'. Suspiciously, the type was not parameterized but the target class 'com.squareup.moshi.kotlin.codegen.GeneratedAdaptersTest_MultipleGenericsJsonAdapter' is generic. Consider using Types#newParameterizedType() to define these missing type variables.")
|
||||
assertThat(e).hasMessageThat().isEqualTo("Failed to find the generated JsonAdapter constructor for 'class com.squareup.moshi.kotlin.codegen.GeneratedAdaptersTest\$MultipleGenerics'. Suspiciously, the type was not parameterized but the target class 'com.squareup.moshi.kotlin.codegen.GeneratedAdaptersTest_MultipleGenericsJsonAdapter' is generic. Consider using Types#newParameterizedType() to define these missing type variables.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1361,7 +1361,7 @@ class GeneratedAdaptersTest {
|
||||
)
|
||||
fail("Should have failed to construct the adapter due to wrong number of generics")
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage("TypeVariable mismatch: Expecting 4 types for generic type variables [A, B, C, D], but received 1")
|
||||
assertThat(e).hasMessageThat().isEqualTo("TypeVariable mismatch: Expecting 4 types for generic type variables [A, B, C, D], but received 1")
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.squareup.moshi.kotlin.reflect
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.squareup.moshi.FromJson
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
@@ -26,7 +27,7 @@ import com.squareup.moshi.JsonWriter
|
||||
import com.squareup.moshi.Moshi
|
||||
import com.squareup.moshi.ToJson
|
||||
import com.squareup.moshi.Types
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
import java.io.ByteArrayOutputStream
|
||||
@@ -141,7 +142,7 @@ class KotlinJsonAdapterTest {
|
||||
jsonAdapter.fromJson("""{"a":4,"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Multiple values for 'a' at $.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Multiple values for 'a' at $.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ class KotlinJsonAdapterTest {
|
||||
jsonAdapter.fromJson("""{"a":4,"a":4}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Multiple values for 'a' at $.a")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Multiple values for 'a' at $.a")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +203,7 @@ class KotlinJsonAdapterTest {
|
||||
jsonAdapter.fromJson("""{"a":4,"b":null,"b":6}""")
|
||||
fail()
|
||||
} catch (expected: JsonDataException) {
|
||||
assertThat(expected).hasMessage("Multiple values for 'b' at $.b")
|
||||
assertThat(expected).hasMessageThat().isEqualTo("Multiple values for 'b' at $.b")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +316,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<RequiredTransientConstructorParameter>()
|
||||
fail()
|
||||
} catch (expected: IllegalArgumentException) {
|
||||
assertThat(expected).hasMessage(
|
||||
assertThat(expected).hasMessageThat().isEqualTo(
|
||||
"No default value for transient constructor parameter #0 " +
|
||||
"a of fun <init>(kotlin.Int): " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest.RequiredTransientConstructorParameter"
|
||||
@@ -359,7 +360,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<ConstructorParameterWithSameNameAsPropertyButDifferentType>()
|
||||
fail()
|
||||
} catch (expected: IllegalArgumentException) {
|
||||
assertThat(expected).hasMessage(
|
||||
assertThat(expected).hasMessageThat().isEqualTo(
|
||||
"'a' has a constructor parameter of type " +
|
||||
"kotlin.Int but a property of type kotlin.String."
|
||||
)
|
||||
@@ -446,7 +447,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<Triple<*, *, *>>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Platform class kotlin.Triple in kotlin.Triple<java.lang.Object, java.lang.Object, java.lang.Object> requires explicit JsonAdapter to be registered"
|
||||
)
|
||||
}
|
||||
@@ -590,7 +591,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<NonPropertyConstructorParameter>()
|
||||
fail()
|
||||
} catch (expected: IllegalArgumentException) {
|
||||
assertThat(expected).hasMessage(
|
||||
assertThat(expected).hasMessageThat().isEqualTo(
|
||||
"No property for required constructor parameter #0 a of fun <init>(" +
|
||||
"kotlin.Int, kotlin.Int): ${NonPropertyConstructorParameter::class.qualifiedName}"
|
||||
)
|
||||
@@ -618,7 +619,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<Interface>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"No JsonAdapter for interface " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$Interface (with no annotations)"
|
||||
)
|
||||
@@ -633,7 +634,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<AbstractClass>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Cannot serialize abstract class " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$AbstractClass"
|
||||
)
|
||||
@@ -648,7 +649,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<InnerClass>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Cannot serialize inner class " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$InnerClass"
|
||||
)
|
||||
@@ -664,7 +665,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<LocalClass>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Cannot serialize local class or object expression " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$localClassesNotSupported\$LocalClass"
|
||||
)
|
||||
@@ -677,7 +678,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<ObjectDeclaration>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Cannot serialize object declaration " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$ObjectDeclaration"
|
||||
)
|
||||
@@ -704,7 +705,7 @@ class KotlinJsonAdapterTest {
|
||||
} else {
|
||||
"anonymous class"
|
||||
}
|
||||
assertThat(e).hasMessage(
|
||||
assertThat(e).hasMessageThat().isEqualTo(
|
||||
"Cannot serialize $type " +
|
||||
"com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterTest\$anonymousClassesNotSupported" +
|
||||
"\$expression$1"
|
||||
@@ -989,7 +990,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<PlainKotlinClass>()
|
||||
fail("Should not pass here")
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessageContaining("Reflective serialization of Kotlin classes")
|
||||
assertThat(e).hasMessageThat().contains("Reflective serialization of Kotlin classes")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1142,7 +1143,7 @@ class KotlinJsonAdapterTest {
|
||||
moshi.adapter<SealedClass>()
|
||||
fail()
|
||||
} catch (e: IllegalArgumentException) {
|
||||
assertThat(e).hasMessageContaining("Cannot reflectively serialize sealed class")
|
||||
assertThat(e).hasMessageThat().contains("Cannot reflectively serialize sealed class")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1158,7 +1159,7 @@ class KotlinJsonAdapterTest {
|
||||
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build()
|
||||
val adapter = moshi.adapter(type)
|
||||
|
||||
assertThat(adapter.fromJson(json)).isEqualToComparingFieldByFieldRecursively(value)
|
||||
Assertions.assertThat(adapter.fromJson(json)).isEqualToComparingFieldByFieldRecursively(value)
|
||||
assertThat(adapter.toJson(value)).isEqualTo(json)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user