Skip to content

Commit

Permalink
Make compare and forName curried as expected by the library (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianReeves authored Oct 9, 2024
1 parent 525148c commit 7bc6b77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions morphir/sdk/core/jvm/src/morphir/sdk/UUID.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ object UUID {
val oidNamespace = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
val x500Namespace = "6ba7b814-9dad-11d1-80b4-00c04fd430c8"

def compare(uuid1: UUID, uuid2: UUID): Int = uuid1.compareTo(uuid2)
def forName(s: String, uuid: UUID): UUID = MUUID.V5(uuid, s)
def compare(uuid1: UUID)(uuid2: UUID): Int = uuid1.compareTo(uuid2)
def forName(s: String)(uuid: UUID): UUID = MUUID.V5(uuid, s)

/** Creates a valid [[UUID]] from two [[_root_.scala.Long Long]] values representing the most/least significant bits.
*
Expand Down
16 changes: 8 additions & 8 deletions morphir/sdk/core/test/jvm/src/UUIDSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object UUIDSpec extends MorphirBaseSpec {
suite("parse Tests")(
test("Generate UUID from valid String using parse") {
val namespace = MUUID.V4.random
val uuid = UUID.forName("test", namespace)
val uuid = UUID.forName("test")(namespace)

assert(UUID.parse(uuid.toString))(isRight(equalTo(uuid)))
assertTrue(uuid.version == 5)
Expand All @@ -25,7 +25,7 @@ object UUIDSpec extends MorphirBaseSpec {
suite("fromString Tests")(
test("Generate UUID from valid String using fromString") {
val namespace = MUUID.V4.random
val uuid = UUID.forName("test", namespace)
val uuid = UUID.forName("test")(namespace)

assert(UUID.fromString(uuid.toString))(isSome(equalTo(uuid)))
assertTrue(uuid.version == 5)
Expand All @@ -49,24 +49,24 @@ object UUIDSpec extends MorphirBaseSpec {
test("Generate same V5 UUID for same namespace and name") {
val namespace = MUUID.V4.random
val name = "Test Name!"
val u1 = UUID.forName(name, namespace)
val u2 = UUID.forName(name, namespace)
val u1 = UUID.forName(name)(namespace)
val u2 = UUID.forName(name)(namespace)
assertEquals(u1, u2)
},
test("Generate unique V5 UUID for unique namespace") {
val namespace1 = MUUID.V4.random
val namespace2 = MUUID.V4.random
val name = "Test Name!"
val u1 = UUID.forName(name, namespace1)
val u2 = UUID.forName(name, namespace2)
val u1 = UUID.forName(name)(namespace1)
val u2 = UUID.forName(name)(namespace2)
assertTrue(u1 != u2)
},
test("Generate unique V5 UUID for unique names") {
val namespace = MUUID.V4.random
val name1 = "Test Name!"
val name2 = "Test Name 2!"
val u1 = UUID.forName(name1, namespace)
val u2 = UUID.forName(name2, namespace)
val u1 = UUID.forName(name1)(namespace)
val u2 = UUID.forName(name2)(namespace)
assertTrue(u1 != u2)
}
)
Expand Down

0 comments on commit 7bc6b77

Please sign in to comment.