From 3e1e5663b5e4db8205a31af6eeb6febf0e906d1d Mon Sep 17 00:00:00 2001 From: Swordsteel Date: Sat, 23 Nov 2024 01:05:10 +0100 Subject: [PATCH] Add UUIDAssert --- build.gradle.kts | 1 + src/test/kotlin/ltd/hlaeja/assertj/UUIDAssert.kt | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/kotlin/ltd/hlaeja/assertj/UUIDAssert.kt diff --git a/build.gradle.kts b/build.gradle.kts index a3480e9..11ed4c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,7 @@ dependencies { runtimeOnly(hlaeja.org.postgresql) runtimeOnly(hlaeja.org.postgresql.r2dbc) + testImplementation(hlaeja.assertj.core) testImplementation(hlaeja.io.mockk) testImplementation(hlaeja.io.projectreactor.reactor.test) testImplementation(hlaeja.kotlin.test.junit5) diff --git a/src/test/kotlin/ltd/hlaeja/assertj/UUIDAssert.kt b/src/test/kotlin/ltd/hlaeja/assertj/UUIDAssert.kt new file mode 100644 index 0000000..427c71c --- /dev/null +++ b/src/test/kotlin/ltd/hlaeja/assertj/UUIDAssert.kt @@ -0,0 +1,15 @@ +package ltd.hlaeja.assertj + +import java.util.UUID +import org.assertj.core.api.AbstractAssert + +class UUIDAssert(actual: UUID) : AbstractAssert(actual, UUIDAssert::class.java) { + fun isUUID(expected: String): UUIDAssert { + objects.assertEqual(this.info, this.actual, UUID.fromString(expected)) + return this.myself + } +} + +fun assertThat(actual: UUID): UUIDAssert { + return UUIDAssert(actual) +}