add assertion to compare uuid against string representation of an uuid

This commit is contained in:
2025-03-05 16:07:28 +01:00
parent be08c0c369
commit 902a2a2c0b
2 changed files with 12 additions and 1 deletions

View File

@@ -1,3 +1,3 @@
kotlin.code.style=official
version=0.2.0-SNAPSHOT
catalog=0.9.0
catalog=0.10.0-SNAPSHOT

View File

@@ -1,5 +1,7 @@
package ltd.hlaeja.test
import java.util.UUID
import org.assertj.core.api.AbstractAssert
import org.assertj.core.api.AbstractStringAssert
@Suppress("unused")
@@ -13,3 +15,12 @@ fun <SELF : AbstractStringAssert<SELF>?> AbstractStringAssert<SELF>.compareToFil
?: throw UnsupportedOperationException(
"Attempted to compare assertion object to context of a file but expected file was not found: $file",
)
@Suppress("unused")
fun <SELF : AbstractAssert<SELF, ACTUAL>?, ACTUAL> AbstractAssert<SELF, ACTUAL>.isEqualToUuid(
uuid: String,
): SELF = try {
UUID.fromString(uuid).let { expected -> this.isEqualTo(expected) }
} catch (e: IllegalArgumentException) {
throw UnsupportedOperationException("Invalid UUID string provided: $uuid", e)
}