Skip to content

Commit

Permalink
Migrate from AssertJ to AssertK in kotlin files.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldergod committed Nov 15, 2024
1 parent db02978 commit b933d1e
Show file tree
Hide file tree
Showing 84 changed files with 215 additions and 88 deletions.
2 changes: 1 addition & 1 deletion samples/wire-codegen-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencies {
implementation(libs.guava)
implementation(libs.javapoet)
testImplementation(libs.junit)
testImplementation(libs.assertj)
testImplementation(libs.assertk)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.squareup.wire.sample

import assertk.assertThat
import com.palantir.javapoet.JavaFile
import com.palantir.javapoet.TypeSpec
import com.squareup.wire.java.JavaGenerator
Expand All @@ -26,7 +27,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
Expand Down
2 changes: 1 addition & 1 deletion wire-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
*/
package com.squareup.wire

import assertk.assertThat
import assertk.assertions.containsExactly
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package com.squareup.wire

import org.assertj.core.api.Assertions.assertThat
import assertk.assertThat
import assertk.assertions.containsExactly
import org.junit.Assert.fail
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/
package com.squareup.wire

import assertk.assertThat
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package com.squareup.wire

import assertk.assertThat
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package com.squareup.wire.schema

import assertk.assertThat
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

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 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package com.squareup.wire.schema

import assertk.assertThat
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package com.squareup.wire.schema

import assertk.assertThat
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
Expand All @@ -30,7 +34,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

Expand Down
2 changes: 1 addition & 1 deletion wire-gradle-plugin-playground/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion wire-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies {
implementation(libs.pluginz.kotlin)

testImplementation(libs.junit)
testImplementation(libs.assertj)
testImplementation(libs.assertk)
testImplementation(projects.wireTestUtils)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@

package com.squareup.wire.gradle

import assertk.assertThat
import assertk.assertions.isEmpty
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isNotNull
import assertk.assertions.isNull
import assertk.assertions.isTrue
import com.squareup.wire.VERSION
import com.squareup.wire.testing.withPlatformSlashes
import java.io.File
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
Expand Down
2 changes: 1 addition & 1 deletion wire-grpc-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package com.squareup.wire

import assertk.assertThat
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

Expand Down
27 changes: 17 additions & 10 deletions wire-grpc-tests/src/test/java/com/squareup/wire/GrpcClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

package com.squareup.wire

import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isFalse
import assertk.assertions.isInstanceOf
import assertk.assertions.isNotEmpty
import assertk.assertions.isNull
import assertk.assertions.isTrue
import assertk.assertions.message
import com.google.common.util.concurrent.SettableFuture
import com.squareup.wire.MockRouteGuideService.Action.Delay
import com.squareup.wire.MockRouteGuideService.Action.ReceiveCall
Expand Down Expand Up @@ -56,7 +64,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
Expand Down Expand Up @@ -459,7 +466,7 @@ class GrpcClientTest {

val latch = Mutex(locked = true)
requestChannel.invokeOnClose { expected ->
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
latch.unlock()
}

Expand All @@ -473,7 +480,7 @@ class GrpcClientTest {
requestChannel.send(RouteNote(message = "léo"))
fail()
} catch (expected: Throwable) {
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
}
}
}
Expand All @@ -489,7 +496,7 @@ class GrpcClientTest {

val latch = Mutex(locked = true)
requestChannel.invokeOnClose { expected ->
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
latch.unlock()
}

Expand All @@ -503,7 +510,7 @@ class GrpcClientTest {
requestChannel.send(RouteNote(message = "léo"))
fail()
} catch (expected: Throwable) {
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
}
}
}
Expand All @@ -519,7 +526,7 @@ class GrpcClientTest {

val latch = Mutex(locked = true)
requestChannel.invokeOnClose { expected ->
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
latch.unlock()
}

Expand All @@ -536,7 +543,7 @@ class GrpcClientTest {
requestChannel.send(RouteNote(message = "rené"))
fail()
} catch (expected: Throwable) {
assertThat(expected).isInstanceOf(CancellationException::class.java)
assertThat(expected).isInstanceOf<CancellationException>()
}
}
}
Expand Down Expand Up @@ -1635,7 +1642,7 @@ class GrpcClientTest {
grpcCall.execute(Point(latitude = 5, longitude = 6))
fail()
} catch (expected: Throwable) {
assertThat(expected).isInstanceOf(IOException::class.java)
assertThat(expected).isInstanceOf<IOException>()
assertThat(grpcCall.isCanceled()).isTrue()
}
}
Expand All @@ -1657,7 +1664,7 @@ class GrpcClientTest {
receive.receive()
fail()
} catch (expected: Throwable) {
assertThat(expected).isInstanceOf(IOException::class.java)
assertThat(expected).isInstanceOf<IOException>()
assertThat(grpcCall.isCanceled()).isTrue()
}
}
Expand Down Expand Up @@ -1713,7 +1720,7 @@ class GrpcClientTest {
responses.receive()
fail()
} catch (expected: IOException) {
assertThat(expected).isInstanceOf(IOException::class.java)
assertThat(expected).isInstanceOf<IOException>()
assertThat(expected.message).isEqualTo("expected gRPC but was HTTP status=520, content-type=application/grpc")
assertThat(call.isCanceled()).isTrue()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.squareup.wire

import assertk.assertThat
import com.squareup.wire.mockwebserver.GrpcDispatcher
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicReference
Expand All @@ -26,7 +27,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.squareup.wire

import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNull
import java.util.Locale.US
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand All @@ -25,7 +28,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.squareup.wire

import assertk.assertThat
import com.squareup.wire.MockRouteGuideService.Action.ReceiveCall
import io.grpc.ForwardingServerCall.SimpleForwardingServerCall
import io.grpc.Metadata
Expand All @@ -35,7 +36,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
Expand Down
2 changes: 1 addition & 1 deletion wire-gson-support/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ dependencies {
api(libs.gson)
api(libs.okio.core)
testImplementation(libs.junit)
testImplementation(libs.assertj)
testImplementation(libs.assertk)
testImplementation(projects.wireTestUtils)
}
2 changes: 1 addition & 1 deletion wire-java-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ dependencies {
testImplementation(projects.wireTestUtils)
testImplementation(libs.junit)
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.truth)
testImplementation(libs.assertk)
testImplementation(libs.jimfs)
}
2 changes: 1 addition & 1 deletion wire-kotlin-generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dependencies {
api(libs.kotlinpoet)
testImplementation(projects.wireTestUtils)
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.truth)
testImplementation(libs.assertk)
}
Loading

0 comments on commit b933d1e

Please sign in to comment.