diff --git a/nio-server/test/models/ModelValidationSpec.scala b/nio-server/test/models/ModelValidationSpec.scala index de99179..5cf909f 100644 --- a/nio-server/test/models/ModelValidationSpec.scala +++ b/nio-server/test/models/ModelValidationSpec.scala @@ -14,6 +14,7 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { val now: LocalDateTime = LocalDateTime.now(Clock.systemUTC) "Validation ConsentFact" should { + val consentFact: ConsentFact = ConsentFact( _id = "1", userId = "user1", @@ -30,7 +31,8 @@ class ModelValidationSpec extends AnyWordSpecLike with Matchers { Consent( key = "g1c1", label = "group 1 consent 1", - checked = false + checked = false, + expiredAt = Some(LocalDateTime.now().plusMinutes(20)) ), Consent( key = "g1c2", diff --git a/nio-server/test/models/OrganisationSpec.scala b/nio-server/test/models/OrganisationSpec.scala index f919945..584809a 100644 --- a/nio-server/test/models/OrganisationSpec.scala +++ b/nio-server/test/models/OrganisationSpec.scala @@ -4,6 +4,9 @@ import org.scalatest.wordspec.AnyWordSpecLike import org.scalatestplus.play.PlaySpec import play.api.libs.json.Json +import java.util.concurrent.TimeUnit +import scala.concurrent.duration.FiniteDuration + class OrganisationSpec extends PlaySpec with AnyWordSpecLike { "Organisation" should { @@ -189,4 +192,69 @@ println(Json.prettyPrint(json)) fromJson.map(_.key) mustBe Right(org.key) } + + "serialize/deserialize from XML with validity" in { + val org = Organisation( + _id = "cf", + key = "maif", + label = "test org", + version = VersionInfo(), + groups = Seq( + PermissionGroup( + key = "a", + label = "a", + permissions = Seq( + Permission( + key = "a1", + label = "a1", + validityPeriod = Some(FiniteDuration(1, TimeUnit.DAYS)) + ), + Permission( + key = "a2", + label = "a2" + ) + ) + ) + ) + ) + + val xml = org.asXml() + + val fromXml = Organisation.fromXml(xml) + + fromXml.map(_.key) mustBe Right(org.key) + } + + "serialize/deserialize from JSON with validity" in { + val org = Organisation( + _id = "cf", + key = "maif", + label = "test org", + version = VersionInfo(), + groups = Seq( + PermissionGroup( + key = "a", + label = "a", + permissions = Seq( + Permission( + key = "a1", + label = "a1", + validityPeriod = Some(FiniteDuration(1, TimeUnit.DAYS)) + ), + Permission( + key = "a2", + label = "a2" + ) + ) + ) + ) + ) + + val json = org.asJson() + + val fromJson = Organisation.fromJson(json) + + fromJson.map(_.key) mustBe Right(org.key) + } + }