add assertion to compare uuid against string representation of an uuid
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
kotlin.code.style=official
|
||||
version=0.2.0-SNAPSHOT
|
||||
catalog=0.9.0
|
||||
catalog=0.10.0-SNAPSHOT
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user