diff --git a/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala b/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala index f82da7f9..b0b66aaa 100644 --- a/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala +++ b/core/src/test/scala/app/softnetwork/elastic/client/LicenseExecutorSpec.scala @@ -177,7 +177,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers { licenseType = LicenseType.Pro, features = Feature.values.toSet, expiresAt = Some(Instant.now().plusSeconds(15 * 86400)), - metadata = Map("trial" -> "true") + trial = true ) } val executor = new LicenseExecutor(strategy = mkStrategy(trialManager)) @@ -302,7 +302,7 @@ class LicenseExecutorSpec extends AnyFlatSpec with Matchers { licenseType = LicenseType.Pro, features = Feature.values.toSet, expiresAt = Some(Instant.parse("2026-07-08T23:59:59Z")), - metadata = Map("trial" -> "true") + trial = true ) val executor = new LicenseExecutor( strategy = mkStrategy(proManager, refreshResult = Right(trialKey)) diff --git a/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala b/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala index 9a061fac..4c75d44b 100644 --- a/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala +++ b/licensing/src/main/scala/app/softnetwork/elastic/licensing/package.scala @@ -102,11 +102,12 @@ package object licensing { metadata: Map[String, String] = Map.empty, quota: Option[Quota] = None, usage: Option[LicenseUsage] = None, - platform: Option[Platform] = None + platform: Option[Platform] = None, + trial: Boolean = false ) { /** Whether this is a trial license (Pro trial via API key). */ - def isTrial: Boolean = metadata.get("trial").contains("true") + def isTrial: Boolean = trial /** Days remaining until expiration, or None if no expiry. Positive = not yet expired. */ def daysRemaining: Option[Long] = daysRemainingAt(java.time.Instant.now()) diff --git a/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala b/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala index 372d4cfc..22442acd 100644 --- a/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala +++ b/licensing/src/test/scala/app/softnetwork/elastic/licensing/LicenseKeySpec.scala @@ -87,13 +87,13 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers { key.metadata shouldBe empty } - "isTrial" should "return true when trial metadata is set" in { + "isTrial" should "return true when trial field is set" in { val key = LicenseKey( id = "org-123", licenseType = LicenseType.Pro, features = Set(Feature.MaterializedViews), expiresAt = Some(Instant.now().plus(Duration.ofDays(30))), - metadata = Map("trial" -> "true") + trial = true ) key.isTrial shouldBe true } @@ -103,13 +103,12 @@ class LicenseKeySpec extends AnyFlatSpec with Matchers { id = "org-123", licenseType = LicenseType.Pro, features = Set(Feature.MaterializedViews), - expiresAt = Some(Instant.now().plus(Duration.ofDays(365))), - metadata = Map("trial" -> "false") + expiresAt = Some(Instant.now().plus(Duration.ofDays(365))) ) key.isTrial shouldBe false } - it should "return false when trial metadata is absent" in { + it should "return false when trial defaults to false" in { LicenseKey.Community.isTrial shouldBe false }