Skip to content

Commit

Permalink
Make namespaces UUIDs not strings
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianReeves committed Oct 9, 2024
1 parent 7bc6b77 commit 98d452c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions morphir/sdk/core/jvm/src/morphir/sdk/UUID.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ object UUID {

val Nil: UUID = MUUID.Nil

val dnsNamespace = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
val urlNamespace = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
val oidNamespace = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
val x500Namespace = "6ba7b814-9dad-11d1-80b4-00c04fd430c8"
val dnsNamespace: UUID = memeid.UUID.fromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
val urlNamespace: UUID = memeid.UUID.fromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
val oidNamespace: UUID = memeid.UUID.fromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
val x500Namespace: UUID = memeid.UUID.fromString("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)
Expand Down
18 changes: 18 additions & 0 deletions morphir/sdk/core/test/jvm/src/UUIDSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ object UUIDSpec extends MorphirBaseSpec {
val u2 = UUID.forName(name2)(namespace)
assertTrue(u1 != u2)
}
),
suite("Known namespaces")(
test("dnsNamespace should be a valid UUID") {
val uuid = UUID.dnsNamespace
assertTrue(uuid.isInstanceOf[UUID.UUID])
},
test("urlNamespace should be a valid UUID") {
val uuid = UUID.urlNamespace
assertTrue(uuid.isInstanceOf[UUID.UUID])
},
test("oidNamespace should be a valid UUID") {
val uuid = UUID.oidNamespace
assertTrue(uuid.isInstanceOf[UUID.UUID])
},
test("x500Namespace should be a valid UUID") {
val uuid = UUID.x500Namespace
assertTrue(uuid.isInstanceOf[UUID.UUID])
}
)
)

Expand Down

0 comments on commit 98d452c

Please sign in to comment.