From e70c6020cbd0d986fcd0b2316bcf4375cee766b0 Mon Sep 17 00:00:00 2001 From: Jens Klingenberg Date: Sat, 7 Oct 2023 13:58:24 +0200 Subject: [PATCH] Improve testing (#448) --- compiler-plugin/build.gradle.kts | 1 - .../ktorfit/FunctionTransformerTest.kt | 13 ++-- gradle/libs.versions.toml | 1 - ktorfit-ksp/build.gradle.kts | 1 - .../ktorfit/BodyAnnotationsTest.kt | 28 ++++---- .../ktorfit/CompilationErrorsTest.kt | 18 ++--- .../ktorfit/FieldAnnotationsTest.kt | 71 +++++++++---------- .../ktorfit/FormUrlEncodedAnnotationsTest.kt | 18 ++--- .../ktorfit/HeaderAnnotationsTest.kt | 21 +++--- .../ktorfit/HttpAnnotationTest.kt | 30 ++++---- .../ktorfit/PartAnnotationsTest.kt | 49 +++++++------ .../ktorfit/QueryAnnotationsTest.kt | 21 +++--- .../ktorfit/ReqBuilderAnnotationsTest.kt | 25 ++++--- .../ktorfit/RequestConverterTextKtTest.kt | 4 +- .../ktorfit/RequestTypeTest.kt | 7 +- .../ktorfit/ReturnTypeDataTest.kt | 11 +-- .../ktorfit/StreamingAnnotationTest.kt | 17 ++--- .../de/jensklingenberg/ktorfit/UrlTest.kt | 56 ++++++++------- .../GetBodyDataTextKtTest.kt | 5 +- .../GetRequestBuilderTextKtTest.kt | 5 +- .../PartsArgumentTextKtTest.kt | 24 +++---- .../ReturnTypeInfoKtTest.kt | 4 +- .../UrlArgumentTextKtTest.kt | 16 ++--- .../de/jensklingenberg/ktorfit/BodyTest.kt | 6 +- .../de/jensklingenberg/ktorfit/BuilderTest.kt | 5 +- .../ktorfit/internal/KtorfitClientTest.kt | 18 ++--- 26 files changed, 248 insertions(+), 227 deletions(-) diff --git a/compiler-plugin/build.gradle.kts b/compiler-plugin/build.gradle.kts index af4a45101..f4e52fa41 100644 --- a/compiler-plugin/build.gradle.kts +++ b/compiler-plugin/build.gradle.kts @@ -36,7 +36,6 @@ dependencies { compileOnly(libs.kotlin.compiler.embeddable) testImplementation(libs.kctfork.core) testImplementation(libs.junit) - testImplementation(libs.truth) testImplementation(kotlin("reflect")) } diff --git a/compiler-plugin/src/test/kotlin/de/jensklingenberg/ktorfit/FunctionTransformerTest.kt b/compiler-plugin/src/test/kotlin/de/jensklingenberg/ktorfit/FunctionTransformerTest.kt index 6a4386e86..8bce89414 100644 --- a/compiler-plugin/src/test/kotlin/de/jensklingenberg/ktorfit/FunctionTransformerTest.kt +++ b/compiler-plugin/src/test/kotlin/de/jensklingenberg/ktorfit/FunctionTransformerTest.kt @@ -1,12 +1,14 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth + import com.tschuchort.compiletesting.JvmCompilationResult import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.PluginOption import com.tschuchort.compiletesting.SourceFile import org.jetbrains.kotlin.config.JvmTarget import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder @@ -54,8 +56,9 @@ fun Ktorfit.create(ktorfitService: KtorfitService = Default()): T { val result = compile(listOf(source2, source)) - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - Truth.assertThat(result.messages.contains("_TestServiceImpl")).isEqualTo(true) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + + assertTrue(result.messages.contains("_TestServiceImpl")) } @@ -98,8 +101,8 @@ fun Ktorfit.create(ktorfitService: KtorfitService = Default()): T { ) val result = compile(listOf(source2, source)) - Assert.assertEquals(KotlinCompilation.ExitCode.INTERNAL_ERROR,result.exitCode) - Truth.assertThat(result.messages.contains(CreateFuncTransformer.ERROR_TYPE_ARGUMENT_NOT_INTERFACE("T"))).isEqualTo(true) + assertEquals(KotlinCompilation.ExitCode.INTERNAL_ERROR,result.exitCode) + assertTrue(result.messages.contains(CreateFuncTransformer.ERROR_TYPE_ARGUMENT_NOT_INTERFACE("T"))) } private fun prepareCompilation( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5980bda57..eb1be4331 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -58,7 +58,6 @@ licensee-gradle-plugin = "app.cash.licensee:licensee-gradle-plugin:1.8.0" logbackClassic = "ch.qos.logback:logback-classic:1.4.11" mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } mockk = { module = "io.mockk:mockk", version.ref = "mockk" } -truth = "com.google.truth:truth:1.1.5" [plugins] binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibilityValidator" } diff --git a/ktorfit-ksp/build.gradle.kts b/ktorfit-ksp/build.gradle.kts index 54c869b10..7caa33995 100644 --- a/ktorfit-ksp/build.gradle.kts +++ b/ktorfit-ksp/build.gradle.kts @@ -47,7 +47,6 @@ dependencies { /* TEST */ testImplementation(libs.junit) - testImplementation(libs.truth) testImplementation(libs.kctfork.core) testImplementation(libs.kctfork.ksp) testImplementation(libs.mockito.kotlin) diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/BodyAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/BodyAnnotationsTest.kt index 13268b480..6c3edb9a2 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/BodyAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/BodyAnnotationsTest.kt @@ -1,11 +1,11 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth + import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -30,12 +30,11 @@ interface TestService { """ ) - val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.NON_BODY_HTTP_METHOD_CANNOT_CONTAIN_BODY)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.NON_BODY_HTTP_METHOD_CANNOT_CONTAIN_BODY)) } @Test @@ -60,8 +59,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.BODY_PARAMETERS_CANNOT_BE_USED_WITH_FORM_OR_MULTI_PART_ENCODING)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.BODY_PARAMETERS_CANNOT_BE_USED_WITH_FORM_OR_MULTI_PART_ENCODING)) } @Test @@ -85,15 +84,14 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(KotlinCompilation.ExitCode.OK,result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(expectedBodyDataArgumentText)).isTrue() + assertTrue(generatedFile.exists()) + assertTrue(generatedFile.readText().contains(expectedBodyDataArgumentText)) } @Test @@ -117,15 +115,15 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(KotlinCompilation.ExitCode.OK,result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(notExpectedBodyDataArgumentText)).isFalse() + + assertTrue(generatedFile.exists()) + assertFalse(generatedFile.readText().contains(notExpectedBodyDataArgumentText)) } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/CompilationErrorsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/CompilationErrorsTest.kt index 5d527bea0..01c6ae9e8 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/CompilationErrorsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/CompilationErrorsTest.kt @@ -1,13 +1,13 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test -class CompilationErrorsTest() { +class CompilationErrorsTest { @Test fun whenJavaInterface_ThrowCompilationError() { @@ -26,8 +26,8 @@ class CompilationErrorsTest() { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.JAVA_INTERFACES_ARE_NOT_SUPPORTED)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.JAVA_INTERFACES_ARE_NOT_SUPPORTED)) } @Test @@ -60,8 +60,8 @@ interface GithubService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.INTERFACE_NEEDS_TO_HAVE_A_PACKAGE)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.INTERFACE_NEEDS_TO_HAVE_A_PACKAGE)) } @@ -95,8 +95,8 @@ interface GithubService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.TYPE_PARAMETERS_ARE_UNSUPPORTED_ON)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.TYPE_PARAMETERS_ARE_UNSUPPORTED_ON)) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FieldAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FieldAnnotationsTest.kt index 2f7d87063..966b3fbd8 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FieldAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FieldAnnotationsTest.kt @@ -1,11 +1,10 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -32,15 +31,15 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(expectedFieldsBuilderText)).isFalse() + assertTrue(generatedFile.exists()) + assertFalse(generatedFile.readText().contains(expectedFieldsBuilderText)) } @@ -62,8 +61,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FIELD_PARAMETERS_CAN_ONLY_BE_USED_WITH_FORM_ENCODING)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FIELD_PARAMETERS_CAN_ONLY_BE_USED_WITH_FORM_ENCODING)) } @@ -86,20 +85,20 @@ interface TestService { ) val expectedFieldsBuilderText = """val _formParameters = Parameters.build { - testField?.let{ append("name", "ä{it}") } + testField?.let{ append("name", "$/{it}") } } - setBody(FormDataContent(_formParameters))""".trimMargin().replace("ä", "$") + setBody(FormDataContent(_formParameters))""".trimMargin().replace("$/", "$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue( actualSource.contains(expectedFieldsBuilderText)) } @Test @@ -121,20 +120,20 @@ interface TestService { ) val expectedFieldsBuilderText = """val _formParameters = Parameters.build { - name?.let{ append("name", "ä{it}") } + name?.let{ append("name", "$/{it}") } } - setBody(FormDataContent(_formParameters))""".trimMargin().replace("ä", "$") + setBody(FormDataContent(_formParameters))""".trimMargin().replace("$/", "$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue(actualSource.contains(expectedFieldsBuilderText)) } @Test @@ -156,20 +155,20 @@ interface TestService { ) val expectedFieldsBuilderText = """val _formParameters = Parameters.build { - testField?.filterNotNull()?.forEach { append("name", "äit") } + testField?.filterNotNull()?.forEach { append("name", "$/it") } } - setBody(FormDataContent(_formParameters))""".trimMargin().replace("ä", "$") + setBody(FormDataContent(_formParameters))""".trimMargin().replace("$/", "$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue(actualSource.contains(expectedFieldsBuilderText)) } @Test @@ -191,20 +190,20 @@ interface TestService { ) val expectedFieldsBuilderText = """val _formParameters = Parameters.build { - testField?.filterNotNull()?.forEach { append("name", "äit") } + testField?.filterNotNull()?.forEach { append("name", "$/it") } } - setBody(FormDataContent(_formParameters))""".trimMargin().replace("ä", "$") + setBody(FormDataContent(_formParameters))""".trimMargin().replace("$/", "$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue(actualSource.contains(expectedFieldsBuilderText)) } @Test @@ -233,16 +232,15 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue(actualSource.contains(expectedFieldsBuilderText)) } @@ -268,21 +266,21 @@ interface TestService { ) val expectedFieldsBuilderText = """val _formParameters = Parameters.build { - testField?.let{ append("name", "ä{it}") } - name?.forEach { entry -> entry.value?.let{ append(entry.key, "ä{entry.value}") } } + testField?.let{ append("name", "$/{it}") } + name?.forEach { entry -> entry.value?.let{ append(entry.key, "$/{entry.value}") } } } - setBody(FormDataContent(_formParameters))""".trimMargin().replace("ä", "$") + setBody(FormDataContent(_formParameters))""".trimMargin().replace("$/", "$") val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFieldsBuilderText)) + assertTrue(actualSource.contains(expectedFieldsBuilderText)) } @Test @@ -308,8 +306,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FIELD_MAP_PARAMETER_TYPE_MUST_BE_MAP)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FIELD_MAP_PARAMETER_TYPE_MUST_BE_MAP)) } @Test @@ -335,10 +333,9 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FIELD_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FIELD_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) } - } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FormUrlEncodedAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FormUrlEncodedAnnotationsTest.kt index 035b3ef7f..e73d3daa4 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FormUrlEncodedAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/FormUrlEncodedAnnotationsTest.kt @@ -1,11 +1,13 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth + import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -32,8 +34,8 @@ suspend fun test(@Body id: String): String val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FORM_URL_ENCODED_CAN_ONLY_BE_SPECIFIED_ON_HTTP_METHODS_WITH_REQUEST_BODY)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FORM_URL_ENCODED_CAN_ONLY_BE_SPECIFIED_ON_HTTP_METHODS_WITH_REQUEST_BODY)) } @Test @@ -57,8 +59,8 @@ suspend fun test(@Body id: String): String val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FORM_ENCODED_METHOD_MUST_CONTAIN_AT_LEAST_ONE_FIELD_OR_FIELD_MAP)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FORM_ENCODED_METHOD_MUST_CONTAIN_AT_LEAST_ONE_FIELD_OR_FIELD_MAP)) } @@ -94,7 +96,7 @@ suspend fun test(@Field("id") id: String): String? "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actual = generatedFile.readText() - Assert.assertEquals(true, actual.contains(expectedHeaderCode)) + assertTrue( actual.contains(expectedHeaderCode)) } @Test @@ -121,8 +123,8 @@ suspend fun test(@Field("id") id: String): String val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_ENCODING_ANNOTATION_IS_ALLOWED)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_ENCODING_ANNOTATION_IS_ALLOWED)) } } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HeaderAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HeaderAnnotationsTest.kt index b9617981b..23a0bdc27 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HeaderAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HeaderAnnotationsTest.kt @@ -5,8 +5,7 @@ import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError.Companion.HEADER_MAP_KEYS_MUST_BE_OF_TYPE_STRING import de.jensklingenberg.ktorfit.model.KtorfitError.Companion.HEADER_MAP_PARAMETER_TYPE_MUST_BE_MAP -import org.junit.Assert -import org.junit.Assert.assertEquals +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -48,7 +47,7 @@ suspend fun test(): List> "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - assertEquals(false, actualSource.contains(notExpectedHeadersArgumentText)) + assertFalse(actualSource.contains(notExpectedHeadersArgumentText)) } @@ -85,7 +84,7 @@ suspend fun test(): String "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @Test @@ -125,7 +124,7 @@ suspend fun test(@Header("testHeader") testParameter: String?, @HeaderMap("testH ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @@ -162,7 +161,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @Test @@ -199,7 +198,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @Test @@ -236,7 +235,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @Test @@ -272,7 +271,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedHeadersArgumentText)) + assertTrue(actualSource.contains(expectedHeadersArgumentText)) } @Test @@ -297,7 +296,7 @@ interface TestService { val result = compilation.compile() assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) - Assert.assertTrue(result.messages.contains(HEADER_MAP_PARAMETER_TYPE_MUST_BE_MAP)) + assertTrue(result.messages.contains(HEADER_MAP_PARAMETER_TYPE_MUST_BE_MAP)) } @Test @@ -321,7 +320,7 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) - Assert.assertTrue(result.messages.contains(HEADER_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) + assertTrue(result.messages.contains(HEADER_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HttpAnnotationTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HttpAnnotationTest.kt index 403dc7066..4d8f6b057 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HttpAnnotationTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/HttpAnnotationTest.kt @@ -1,13 +1,12 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat -import com.tschuchort.compiletesting.KotlinCompilation + import com.tschuchort.compiletesting.KotlinCompilation.ExitCode import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -33,16 +32,15 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - assertThat(result.exitCode).isEqualTo(ExitCode.OK) - + assertEquals(ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedSource)) + assertTrue(actualSource.contains(expectedSource)) } @Test @@ -67,15 +65,14 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedSource)) + assertTrue(actualSource.contains(expectedSource)) } @Test @@ -106,16 +103,15 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) val actualSource = generatedFile.readText() - assertThat(actualSource.contains(expectedFunctionText)).isTrue() + assertTrue(actualSource.contains(expectedFunctionText)) } @Test @@ -147,7 +143,7 @@ interface GithubService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - assertThat(result.exitCode).isEqualTo(ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_HTTP_METHOD_IS_ALLOWED)) + assertEquals(ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_HTTP_METHOD_IS_ALLOWED)) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/PartAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/PartAnnotationsTest.kt index 3832bb0fb..1bf4fcb1e 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/PartAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/PartAnnotationsTest.kt @@ -1,11 +1,10 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -32,15 +31,14 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) - + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(expectedPartsArgumentText)).isFalse() + assertTrue(generatedFile.exists()) + assertFalse(generatedFile.readText().contains(expectedPartsArgumentText)) } @Test @@ -67,16 +65,17 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedPartsArgumentText)).isTrue() + assertTrue(actualSource.contains(expectedPartsArgumentText)) } @Test @@ -103,16 +102,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedPartsArgumentText)).isTrue() + assertTrue(actualSource.contains(expectedPartsArgumentText)) } @Test @@ -141,16 +142,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedPartsArgumentText)).isTrue() + assertTrue(actualSource.contains(expectedPartsArgumentText)) } @@ -181,16 +184,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedPartsArgumentText)).isTrue() + assertTrue(actualSource.contains(expectedPartsArgumentText)) } @Test @@ -212,8 +217,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.PART_MAP_PARAMETER_TYPE_MUST_BE_MAP)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.PART_MAP_PARAMETER_TYPE_MUST_BE_MAP)) } @Test @@ -235,8 +240,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.PART_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR, result.exitCode) + assertTrue(result.messages.contains(KtorfitError.PART_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE)) } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/QueryAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/QueryAnnotationsTest.kt index 144862d32..aaefd6996 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/QueryAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/QueryAnnotationsTest.kt @@ -1,12 +1,13 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth + import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError import org.junit.Assert import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -45,7 +46,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedQueriesArgumentText)) + assertTrue( actualSource.contains(expectedQueriesArgumentText)) } @Test @@ -80,7 +81,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedQueriesArgumentText)) + assertTrue( actualSource.contains(expectedQueriesArgumentText)) } @Test @@ -115,7 +116,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedQueriesArgumentText)) + assertTrue( actualSource.contains(expectedQueriesArgumentText)) } @@ -155,7 +156,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedQueriesArgumentText)) + assertTrue( actualSource.contains(expectedQueriesArgumentText)) } @@ -195,7 +196,7 @@ fun example(@Query("name") testQuery: String, @QueryName testQueryName: String, ) val actualSource = generatedFile.readText() - assertEquals(true, actualSource.contains(expectedQueriesArgumentText)) + assertTrue( actualSource.contains(expectedQueriesArgumentText)) } @Test @@ -219,8 +220,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.QUERY_MAP_PARAMETER_TYPE_MUST_BE_MAP)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.QUERY_MAP_PARAMETER_TYPE_MUST_BE_MAP)) } @Test @@ -244,8 +245,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.QUERY_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.QUERY_MAP_KEYS_MUST_BE_OF_TYPE_STRING)) } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReqBuilderAnnotationsTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReqBuilderAnnotationsTest.kt index 4a402ef3c..bca600fd9 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReqBuilderAnnotationsTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReqBuilderAnnotationsTest.kt @@ -1,9 +1,9 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.* import de.jensklingenberg.ktorfit.model.KtorfitError import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -41,15 +41,16 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(expectedRequestBuilderArgumentText)).isFalse() + assertTrue(generatedFile.exists()) + assertFalse(generatedFile.readText().contains(expectedRequestBuilderArgumentText)) } @@ -80,15 +81,17 @@ interface TestService { kspIncremental = true } val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() - Truth.assertThat(generatedFile.readText().contains(expectedRequestBuilderArgumentText)).isTrue() + assertTrue(generatedFile.exists()) + + assertTrue(generatedFile.readText().contains(expectedRequestBuilderArgumentText)) } @Test @@ -118,8 +121,8 @@ interface TestService { } val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_REQUEST_BUILDER_IS_ALLOWED)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.ONLY_ONE_REQUEST_BUILDER_IS_ALLOWED)) } @Test @@ -149,8 +152,8 @@ interface TestService { } val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.REQ_BUILDER_PARAMETER_TYPE_NEEDS_TO_BE_HTTP_REQUEST_BUILDER)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.REQ_BUILDER_PARAMETER_TYPE_NEEDS_TO_BE_HTTP_REQUEST_BUILDER)) } } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestConverterTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestConverterTextKtTest.kt index c8be3182a..a16d8af53 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestConverterTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestConverterTextKtTest.kt @@ -9,7 +9,7 @@ import de.jensklingenberg.ktorfit.model.ReturnTypeData import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.RequestType import de.jensklingenberg.ktorfit.requestData.addRequestConverterText -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test import org.mockito.kotlin.mock import org.mockito.kotlin.whenever @@ -64,6 +64,6 @@ class RequestConverterTextKtTest { val actualSource = FunSpec.builder("TestFunction").addRequestConverterText(params).build().toString() - Assert.assertEquals(expected, actualSource) + assertEquals(expected, actualSource) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestTypeTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestTypeTest.kt index 87ba7f783..276c6e626 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestTypeTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/RequestTypeTest.kt @@ -1,9 +1,10 @@ -import com.google.common.truth.Truth + import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.getCompilation import org.junit.Assert +import org.junit.Assert.* import org.junit.Test import java.io.File @@ -30,7 +31,7 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( @@ -38,6 +39,6 @@ interface TestService { "/kotlin/com/example/api/_TestServiceImpl.kt" ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFunctionSource)) + assertTrue(actualSource.contains(expectedFunctionSource)) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReturnTypeDataTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReturnTypeDataTest.kt index 9e842186b..8969bdd72 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReturnTypeDataTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/ReturnTypeDataTest.kt @@ -1,9 +1,10 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -38,15 +39,17 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedBodyDataArgumentText)).isTrue() + assertTrue(actualSource.contains(expectedBodyDataArgumentText)) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt index dd1dfcc47..318da0c81 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/StreamingAnnotationTest.kt @@ -1,12 +1,11 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -44,16 +43,18 @@ interface TestService { val compilation = getCompilation(listOf(httpStatement, source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - assertThat(actualSource.contains(expectedFunctionText)).isTrue() + assertTrue(actualSource.contains(expectedFunctionText)) } @Test @@ -76,8 +77,8 @@ interface TestService { val compilation = getCompilation(listOf(httpStatement, source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.FOR_STREAMING_THE_RETURN_TYPE_MUST_BE_HTTP_STATEMENT)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.FOR_STREAMING_THE_RETURN_TYPE_MUST_BE_HTTP_STATEMENT)) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt index 282c9d2e3..a3fe008e0 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/UrlTest.kt @@ -1,11 +1,11 @@ package de.jensklingenberg.ktorfit -import com.google.common.truth.Truth import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile import com.tschuchort.compiletesting.kspSourcesDir import de.jensklingenberg.ktorfit.model.KtorfitError -import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test import java.io.File @@ -31,16 +31,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedFunctionSource)).isTrue() + assertTrue(actualSource.contains(expectedFunctionSource)) } @Test @@ -68,16 +70,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedFunctionText)).isTrue() + assertTrue(actualSource.contains(expectedFunctionText)) } @Test @@ -105,16 +109,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedFunctionText)).isTrue() + assertTrue(actualSource.contains(expectedFunctionText)) } @Test @@ -139,7 +145,7 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Assert.assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, @@ -147,7 +153,7 @@ interface TestService { ) val actualSource = generatedFile.readText() - Assert.assertEquals(true, actualSource.contains(expectedFunctionSource)) + assertTrue(actualSource.contains(expectedFunctionSource)) } @@ -171,8 +177,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.MISSING_EITHER_KEYWORD_URL_OrURL_PARAMETER("GET"))) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.MISSING_EITHER_KEYWORD_URL_OrURL_PARAMETER("GET"))) } @Test @@ -195,8 +201,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.MULTIPLE_URL_METHOD_ANNOTATIONS_FOUND)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.MULTIPLE_URL_METHOD_ANNOTATIONS_FOUND)) } @Test @@ -223,16 +229,18 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK) + assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) + val generatedSourcesDir = compilation.kspSourcesDir val generatedFile = File( generatedSourcesDir, "/kotlin/com/example/api/_TestServiceImpl.kt" ) - Truth.assertThat(generatedFile.exists()).isTrue() + assertTrue(generatedFile.exists()) + val actualSource = generatedFile.readText() - Truth.assertThat(actualSource.contains(expectedFunctionText)).isTrue() + assertTrue(actualSource.contains(expectedFunctionText)) } @Test @@ -257,8 +265,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.PATH_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.PATH_PARAMETER_TYPE_MAY_NOT_BE_NULLABLE)) } @Test @@ -283,8 +291,8 @@ interface TestService { val compilation = getCompilation(listOf(source)) val result = compilation.compile() - Truth.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.COMPILATION_ERROR) - Assert.assertTrue(result.messages.contains(KtorfitError.PATH_CAN_ONLY_BE_USED_WITH_RELATIVE_URL_ON)) + assertEquals(KotlinCompilation.ExitCode.COMPILATION_ERROR,result.exitCode) + assertTrue(result.messages.contains(KtorfitError.PATH_CAN_ONLY_BE_USED_WITH_RELATIVE_URL_ON)) } } diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetBodyDataTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetBodyDataTextKtTest.kt index 56535a55d..1c87abfeb 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetBodyDataTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetBodyDataTextKtTest.kt @@ -4,6 +4,7 @@ import de.jensklingenberg.ktorfit.model.ParameterData import de.jensklingenberg.ktorfit.model.ReturnTypeData import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.Body import org.junit.Assert +import org.junit.Assert.* import org.junit.Test class GetBodyDataTextKtTest { @@ -13,7 +14,7 @@ class GetBodyDataTextKtTest { val parameterData = ParameterData("test1", ReturnTypeData("String", "kotlin.String", null)) val params = listOf(parameterData) val text = getBodyDataText(params) - Assert.assertEquals("", text) + assertEquals("", text) } @Test @@ -23,6 +24,6 @@ class GetBodyDataTextKtTest { ParameterData("test1", ReturnTypeData("Map<*,String>", "kotlin.Map", null), annotations = listOf(bodyAnno)) val params = listOf(parameterData) val text = getBodyDataText(params) - Assert.assertEquals("setBody(test1)", text) + assertEquals("setBody(test1)", text) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetRequestBuilderTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetRequestBuilderTextKtTest.kt index a594e7a27..320deb7d9 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetRequestBuilderTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/GetRequestBuilderTextKtTest.kt @@ -4,6 +4,7 @@ import de.jensklingenberg.ktorfit.model.ParameterData import de.jensklingenberg.ktorfit.model.ReturnTypeData import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.RequestBuilder import org.junit.Assert +import org.junit.Assert.* import org.junit.Test class GetRequestBuilderTextKtTest { @@ -13,7 +14,7 @@ class GetRequestBuilderTextKtTest { val parameterData = ParameterData("test1", ReturnTypeData("String", "kotlin.String", null)) val params = listOf(parameterData) val text = getCustomRequestBuilderText(params) - Assert.assertEquals("", text) + assertEquals("", text) } @Test @@ -23,6 +24,6 @@ class GetRequestBuilderTextKtTest { ParameterData("test1", ReturnTypeData("String", "kotlin.String", null), annotations = listOf(bodyAnno)) val params = listOf(parameterData) val text = getCustomRequestBuilderText(params) - Assert.assertEquals("test1(this)", text) + assertEquals("test1(this)", text) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/PartsArgumentTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/PartsArgumentTextKtTest.kt index a42d59be2..f8c62f3ad 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/PartsArgumentTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/PartsArgumentTextKtTest.kt @@ -5,7 +5,7 @@ import de.jensklingenberg.ktorfit.model.ParameterData import de.jensklingenberg.ktorfit.model.ReturnTypeData import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.Part import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.PartMap -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test import org.mockito.kotlin.mock @@ -19,7 +19,7 @@ class PartsArgumentTextKtTest { val parameterData = ParameterData("test1", ReturnTypeData("String", "kotlin.String", null)) val params = listOf(parameterData) val text = getPartsCode(params, listType, arrayType) - Assert.assertEquals("", text) + assertEquals("", text) } @Test @@ -33,12 +33,12 @@ class PartsArgumentTextKtTest { val params = listOf(parameterData) val text = getPartsCode(params, listType, arrayType) val expected = """|val _formData = formData { - |test1?.let{ append("world", "ä{it}") } + |test1?.let{ append("world", "$/{it}") } |} |setBody(MultiPartFormDataContent(_formData)) | - """.trimMargin().replace("ä", "$") - Assert.assertEquals(expected, text) + """.trimMargin().replace("$/", "$") + assertEquals(expected, text) } @Test @@ -54,12 +54,12 @@ class PartsArgumentTextKtTest { val params = listOf(parameterData1, parameterData2) val text = getPartsCode(params, listType, arrayType) val expected = """val _formData = formData { -test1?.forEach { entry -> entry.value?.let{ append(entry.key, "ä{entry.value}") } } +test1?.forEach { entry -> entry.value?.let{ append(entry.key, "$/{entry.value}") } } } setBody(MultiPartFormDataContent(_formData)) -""".trimMargin().replace("ä", "$") - Assert.assertEquals(expected, text) +""".trimMargin().replace("$/", "$") + assertEquals(expected, text) } @Test @@ -81,13 +81,13 @@ setBody(MultiPartFormDataContent(_formData)) val params = listOf(parameterData1, parameterData2) val text = getPartsCode(params, listType, arrayType) val expected = """|val _formData = formData { - |test2?.let{ append("world", "ä{it}") } - |test1?.forEach { entry -> entry.value?.let{ append(entry.key, "ä{entry.value}") } } + |test2?.let{ append("world", "$/{it}") } + |test1?.forEach { entry -> entry.value?.let{ append(entry.key, "$/{entry.value}") } } |} |setBody(MultiPartFormDataContent(_formData)) | - """.trimMargin().replace("ä", "$") + """.trimMargin().replace("$/", "$") - Assert.assertEquals(expected, text) + assertEquals(expected, text) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/ReturnTypeInfoKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/ReturnTypeInfoKtTest.kt index 94a70f386..f7da98a7b 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/ReturnTypeInfoKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/ReturnTypeInfoKtTest.kt @@ -1,7 +1,7 @@ package de.jensklingenberg.ktorfit.reqBuilderExtension import de.jensklingenberg.ktorfit.requestData.getReturnTypeInfoText -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test class ReturnTypeInfoKtTest { @@ -9,6 +9,6 @@ class ReturnTypeInfoKtTest { @Test fun testWithReturnTypeInfo() { val text = getReturnTypeInfoText("String") - Assert.assertEquals("returnTypeInfo = typeInfo()", text) + assertEquals("returnTypeInfo = typeInfo()", text) } } \ No newline at end of file diff --git a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlArgumentTextKtTest.kt b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlArgumentTextKtTest.kt index e7b15d724..1bdd4a31f 100644 --- a/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlArgumentTextKtTest.kt +++ b/ktorfit-ksp/src/test/kotlin/de/jensklingenberg/ktorfit/reqBuilderExtension/UrlArgumentTextKtTest.kt @@ -6,7 +6,7 @@ import de.jensklingenberg.ktorfit.model.annotations.HttpMethod import de.jensklingenberg.ktorfit.model.annotations.HttpMethodAnnotation import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.Path import de.jensklingenberg.ktorfit.model.annotations.ParameterAnnotation.Url -import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test class UrlArgumentTextKtTest { @@ -19,7 +19,7 @@ class UrlArgumentTextKtTest { val expected = "url{\n" + "takeFrom(ktorfitClient.baseUrl + \"posts\")\n" + "}".trimMargin() - Assert.assertEquals( + assertEquals( expected, text ) } @@ -31,7 +31,7 @@ class UrlArgumentTextKtTest { ParameterData("test1", ReturnTypeData("String", "kotlin.String", null), annotations = listOf(urlAnnotation)) val params = listOf(parameterData) val text = getUrlCode(params, HttpMethodAnnotation("posts", HttpMethod.GET), "") - Assert.assertEquals( + assertEquals( "url{\n" + "takeFrom((ktorfitClient.baseUrl.takeIf{ !test1.startsWith(\"http\")} ?: \"\") + \"posts\")\n" + "}", @@ -52,7 +52,7 @@ class UrlArgumentTextKtTest { "}", "$" ) - Assert.assertEquals(expected, text) + assertEquals(expected, text) } @Test @@ -60,7 +60,7 @@ class UrlArgumentTextKtTest { val parameterData = ParameterData("test1", ReturnTypeData("String", "kotlin.String", null)) val params = listOf(parameterData) val text = getUrlCode(params, HttpMethodAnnotation("", HttpMethod.GET), "") - Assert.assertEquals("url{\ntakeFrom(ktorfitClient.baseUrl + \"\")\n}", text) + assertEquals("url{\ntakeFrom(ktorfitClient.baseUrl + \"\")\n}", text) } @Test @@ -70,10 +70,10 @@ class UrlArgumentTextKtTest { ParameterData("test1", ReturnTypeData("String", "kotlin.String", null), annotations = listOf(path)) val params = listOf(parameterData) val text = getUrlCode(params, HttpMethodAnnotation("user/{testValue}", HttpMethod.GET), "") - Assert.assertEquals( + assertEquals( """url{ -takeFrom(ktorfitClient.baseUrl + "user/ä{"ätest1".encodeURLPath()}") -}""".replace("ä", "$"), +takeFrom(ktorfitClient.baseUrl + "user/$/{"$/test1".encodeURLPath()}") +}""".replace("$/", "$"), text ) } diff --git a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BodyTest.kt b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BodyTest.kt index bd46c6c02..1acd68a28 100644 --- a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BodyTest.kt +++ b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BodyTest.kt @@ -7,6 +7,8 @@ import io.ktor.client.request.* import io.ktor.content.* import kotlinx.coroutines.runBlocking import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test interface BodyTestApi { @@ -22,8 +24,8 @@ class BodyTest { val engine = object : TestEngine() { override fun getRequestData(data: HttpRequestData) { - Assert.assertEquals(true, (data.body is TextContent)) - Assert.assertEquals("testBody", (data.body as TextContent).text) + assertTrue((data.body is TextContent)) + assertEquals("testBody", (data.body as TextContent).text) return } diff --git a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BuilderTest.kt b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BuilderTest.kt index 4d55961ae..5a7b19d83 100644 --- a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BuilderTest.kt +++ b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/BuilderTest.kt @@ -7,6 +7,7 @@ import io.ktor.client.* import io.ktor.client.request.* import kotlinx.coroutines.runBlocking import org.junit.Assert +import org.junit.Assert.assertEquals import org.junit.Test @@ -63,8 +64,8 @@ class BuilderTest { val engine = object : TestEngine() { override fun getRequestData(data: HttpRequestData) { - Assert.assertEquals(expectedHTTPMethod, data.method.value) - Assert.assertEquals(expectedUrl, data.url.toString()) + assertEquals(expectedHTTPMethod, data.method.value) + assertEquals(expectedUrl, data.url.toString()) } } diff --git a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClientTest.kt b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClientTest.kt index 5b9e96dd4..e4b01e815 100644 --- a/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClientTest.kt +++ b/ktorfit-lib-common/src/jvmTest/kotlin/de/jensklingenberg/ktorfit/internal/KtorfitClientTest.kt @@ -7,6 +7,8 @@ import io.ktor.client.request.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import org.junit.Assert +import org.junit.Assert.assertEquals +import org.junit.Assert.assertTrue import org.junit.Test interface ClientTestApi { @@ -32,8 +34,8 @@ class ClientTest { val engine = object : TestEngine() { override fun getRequestData(data: HttpRequestData) { - Assert.assertEquals(expectedHTTPMethod, data.method.value) - Assert.assertEquals(expectedUrl, data.url.toString()) + assertEquals(expectedHTTPMethod, data.method.value) + assertEquals(expectedUrl, data.url.toString()) } } @@ -60,8 +62,8 @@ class ClientTest { } } catch (exception: Exception) { - Assert.assertTrue(exception is IllegalArgumentException) - Assert.assertTrue(exception.message?.startsWith("Add a ResponseConverter") ?: false) + assertTrue(exception is IllegalArgumentException) + assertTrue(exception.message?.startsWith("Add a ResponseConverter") ?: false) } } @@ -72,11 +74,11 @@ class ClientTest { val ktorfit = Ktorfit.Builder().baseUrl("http://www.test.de/").build() val converted = (KtorfitClient(ktorfit) as Client).convertParameterType("4", String::class, Int::class) - Assert.assertEquals(4, converted) + assertEquals(4, converted) } catch (ex: Exception) { - Assert.assertTrue(ex is IllegalArgumentException) - Assert.assertEquals(true, ex.message!!.contains("No RequestConverter found to convert ")) + assertTrue(ex is IllegalArgumentException) + assertEquals(true, ex.message!!.contains("No RequestConverter found to convert ")) } } @@ -89,7 +91,7 @@ class ClientTest { val engine = object : TestEngine() { override fun getRequestData(data: HttpRequestData) { val url = data.url.toString() - Assert.assertEquals(expectedUrl, url) + assertEquals(expectedUrl, url) } }