keiro-dsl-0.15.0.0: test/conformance-mapped-readmodel/Generated/MappedReadmodel/StructuralConformance.hs
-- @generated by keiro-dsl 0.15.0.0 (language keiro-dsl 5) from context mapped-readmodel structural conformance; do not edit.
module Generated.MappedReadmodel.StructuralConformance
( structuralConformanceAssertions
) where
import Data.List (nub)
import Data.List.NonEmpty qualified as NonEmpty
import Data.Maybe (isJust, isNothing)
import Data.Proxy (Proxy (..))
import Data.Text qualified as T
import Keiki.Core (fieldWitnessAgrees)
import Keiki.Shape (CanonicalTypeName (..))
import Keiro.Codec.Structural (FixtureCases (..), bindingDomainRoundTrip, bindingShapeRoundTrip, bindingToShape)
import Generated.MappedReadmodel.StructuralProjections qualified as StructuralProjections
import Generated.MappedReadmodel.Structural.Shape.AccountLookup (AccountLookupShape(accountId, tenant))
import Generated.MappedReadmodel.Structural.Shape.AccountProfile (AccountProfileShape(displayName))
import Generated.MappedReadmodel.Structural.Shape.AccountSummary (AccountSummaryShape(accountId, profile, tenant))
import Generated.MappedReadmodel.Structural.Shape.TenantKey (TenantKeyShape(tenantId))
import Generated.MappedReadmodel.Structural.Shape.UnusedFilter (UnusedFilterShape(prefix))
import Conformance.MappedReadModel.Bindings qualified as Bindings
import Conformance.MappedReadModel.Domain (AccountLookup, AccountProfile, AccountSummary, TenantKey, UnusedFilter)
structuralConformanceAssertions :: [(String, Bool)]
structuralConformanceAssertions =
concat
[ accountLookupBindingAssertions
, accountProfileBindingAssertions
, accountSummaryBindingAssertions
, tenantKeyBindingAssertions
, unusedFilterBindingAssertions
, [("fixture coverage: conformance.mapped-readmodel.AccountLookup.v1", coverageAccountLookup)]
, [("fixture coverage: conformance.mapped-readmodel.AccountProfile.v1", coverageAccountProfile)]
, [("fixture coverage: conformance.mapped-readmodel.AccountSummary.v1", coverageAccountSummary)]
, [("fixture coverage: conformance.mapped-readmodel.TenantKey.v1", coverageTenantKey)]
, [("fixture coverage: conformance.mapped-readmodel.UnusedFilter.v1", coverageUnusedFilter)]
, structuralProjectionAssertions
]
validFixtureLabels :: NonEmpty.NonEmpty (T.Text, value) -> Bool
validFixtureLabels cases =
all (not . T.null) labels && length labels == length (nub labels)
where
labels = map fst (NonEmpty.toList cases)
accountLookupBindingAssertions :: [(String, Bool)]
accountLookupBindingAssertions =
("fixture labels: conformance.mapped-readmodel.AccountLookup.v1", validFixtureLabels cases) :
("canonical identity: conformance.mapped-readmodel.AccountLookup.v1", canonicalTypeName (Proxy @AccountLookup) == "conformance.mapped-readmodel.AccountLookup.v1") :
concat
[ [ ("binding domain round-trip: conformance.mapped-readmodel.AccountLookup.v1/" <> T.unpack label, bindingDomainRoundTrip Bindings.accountLookupBinding value)
, ("binding shape round-trip: conformance.mapped-readmodel.AccountLookup.v1/" <> T.unpack label, bindingShapeRoundTrip Bindings.accountLookupBinding (bindingToShape Bindings.accountLookupBinding value))
]
| (label, value) <- NonEmpty.toList cases
]
where
cases = fixtureCases Bindings.accountLookupCases
accountProfileBindingAssertions :: [(String, Bool)]
accountProfileBindingAssertions =
("fixture labels: conformance.mapped-readmodel.AccountProfile.v1", validFixtureLabels cases) :
("canonical identity: conformance.mapped-readmodel.AccountProfile.v1", canonicalTypeName (Proxy @AccountProfile) == "conformance.mapped-readmodel.AccountProfile.v1") :
concat
[ [ ("binding domain round-trip: conformance.mapped-readmodel.AccountProfile.v1/" <> T.unpack label, bindingDomainRoundTrip Bindings.accountProfileBinding value)
, ("binding shape round-trip: conformance.mapped-readmodel.AccountProfile.v1/" <> T.unpack label, bindingShapeRoundTrip Bindings.accountProfileBinding (bindingToShape Bindings.accountProfileBinding value))
]
| (label, value) <- NonEmpty.toList cases
]
where
cases = fixtureCases Bindings.accountProfileCases
accountSummaryBindingAssertions :: [(String, Bool)]
accountSummaryBindingAssertions =
("fixture labels: conformance.mapped-readmodel.AccountSummary.v1", validFixtureLabels cases) :
("canonical identity: conformance.mapped-readmodel.AccountSummary.v1", canonicalTypeName (Proxy @AccountSummary) == "conformance.mapped-readmodel.AccountSummary.v1") :
concat
[ [ ("binding domain round-trip: conformance.mapped-readmodel.AccountSummary.v1/" <> T.unpack label, bindingDomainRoundTrip Bindings.accountSummaryBinding value)
, ("binding shape round-trip: conformance.mapped-readmodel.AccountSummary.v1/" <> T.unpack label, bindingShapeRoundTrip Bindings.accountSummaryBinding (bindingToShape Bindings.accountSummaryBinding value))
]
| (label, value) <- NonEmpty.toList cases
]
where
cases = fixtureCases Bindings.accountSummaryCases
tenantKeyBindingAssertions :: [(String, Bool)]
tenantKeyBindingAssertions =
("fixture labels: conformance.mapped-readmodel.TenantKey.v1", validFixtureLabels cases) :
("canonical identity: conformance.mapped-readmodel.TenantKey.v1", canonicalTypeName (Proxy @TenantKey) == "conformance.mapped-readmodel.TenantKey.v1") :
concat
[ [ ("binding domain round-trip: conformance.mapped-readmodel.TenantKey.v1/" <> T.unpack label, bindingDomainRoundTrip Bindings.tenantKeyBinding value)
, ("binding shape round-trip: conformance.mapped-readmodel.TenantKey.v1/" <> T.unpack label, bindingShapeRoundTrip Bindings.tenantKeyBinding (bindingToShape Bindings.tenantKeyBinding value))
]
| (label, value) <- NonEmpty.toList cases
]
where
cases = fixtureCases Bindings.tenantKeyCases
unusedFilterBindingAssertions :: [(String, Bool)]
unusedFilterBindingAssertions =
("fixture labels: conformance.mapped-readmodel.UnusedFilter.v1", validFixtureLabels cases) :
("canonical identity: conformance.mapped-readmodel.UnusedFilter.v1", canonicalTypeName (Proxy @UnusedFilter) == "conformance.mapped-readmodel.UnusedFilter.v1") :
concat
[ [ ("binding domain round-trip: conformance.mapped-readmodel.UnusedFilter.v1/" <> T.unpack label, bindingDomainRoundTrip Bindings.unusedFilterBinding value)
, ("binding shape round-trip: conformance.mapped-readmodel.UnusedFilter.v1/" <> T.unpack label, bindingShapeRoundTrip Bindings.unusedFilterBinding (bindingToShape Bindings.unusedFilterBinding value))
]
| (label, value) <- NonEmpty.toList cases
]
where
cases = fixtureCases Bindings.unusedFilterCases
coverageAccountLookup :: Bool
coverageAccountLookup = True
coverageAccountProfile :: Bool
coverageAccountProfile = True
coverageAccountSummary :: Bool
coverageAccountSummary = any (isNothing . (.profile)) shapes && any (isJust . (.profile)) shapes
where
shapes = map (bindingToShape Bindings.accountSummaryBinding . snd) (NonEmpty.toList (fixtureCases Bindings.accountSummaryCases))
coverageTenantKey :: Bool
coverageTenantKey = True
coverageUnusedFilter :: Bool
coverageUnusedFilter = True
structuralProjectionAssertions :: [(String, Bool)]
structuralProjectionAssertions =
[ ("projection witness agreement: conformance.mapped-readmodel.AccountLookup.v1/account_id", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.accountLookupAccountIdWitness (\referenceOwner -> (bindingToShape Bindings.accountLookupBinding referenceOwner).accountId) owner) (NonEmpty.toList (fixtureCases Bindings.accountLookupCases)))
, ("projection witness agreement: conformance.mapped-readmodel.AccountLookup.v1/tenant/tenant_id", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.accountLookupTenantTenantIdWitness (\referenceOwner -> ((bindingToShape Bindings.accountLookupBinding referenceOwner).tenant).tenantId) owner) (NonEmpty.toList (fixtureCases Bindings.accountLookupCases)))
, ("projection witness agreement: conformance.mapped-readmodel.AccountProfile.v1/display_name", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.accountProfileDisplayNameWitness (\referenceOwner -> (bindingToShape Bindings.accountProfileBinding referenceOwner).displayName) owner) (NonEmpty.toList (fixtureCases Bindings.accountProfileCases)))
, ("projection witness agreement: conformance.mapped-readmodel.AccountSummary.v1/account_id", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.accountSummaryAccountIdWitness (\referenceOwner -> (bindingToShape Bindings.accountSummaryBinding referenceOwner).accountId) owner) (NonEmpty.toList (fixtureCases Bindings.accountSummaryCases)))
, ("projection witness agreement: conformance.mapped-readmodel.AccountSummary.v1/tenant/tenant_id", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.accountSummaryTenantTenantIdWitness (\referenceOwner -> ((bindingToShape Bindings.accountSummaryBinding referenceOwner).tenant).tenantId) owner) (NonEmpty.toList (fixtureCases Bindings.accountSummaryCases)))
, ("projection witness agreement: conformance.mapped-readmodel.TenantKey.v1/tenant_id", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.tenantKeyTenantIdWitness (\referenceOwner -> (bindingToShape Bindings.tenantKeyBinding referenceOwner).tenantId) owner) (NonEmpty.toList (fixtureCases Bindings.tenantKeyCases)))
, ("projection witness agreement: conformance.mapped-readmodel.UnusedFilter.v1/prefix", all (\(_, owner) -> fieldWitnessAgrees StructuralProjections.unusedFilterPrefixWitness (\referenceOwner -> (bindingToShape Bindings.unusedFilterBinding referenceOwner).prefix) owner) (NonEmpty.toList (fixtureCases Bindings.unusedFilterCases)))
]