[More Detail] [Collapse All]
Feature: Extend domain cardinalities and values

Domain resolvers set default cardinality 1, and adds a special value
'Nil' for resolved domains.

Domain extension allows configuring domain cardinality, or defining
constant domain values.
features/030-extend-domain/extend-domains.feature
- Background:
link

Resolver configuration in 'cnf/sbuilder.yaml' points to a file
'cnf/resolver_customer.yaml'.

Resolver 'resolver_customer.yaml' uses "catch all" regular
expression matcher (/.*/) to apply to all parameter sets. The
resolver rules map domains as follows

- id --> id_domain
- name --> name domain
- default rule find 'default_domain'

Section 'setups' in 'cnf/sbuilder.yaml' defines a setup
'setupDomainCardinality' using 'cnf/extensions.yaml' configuration
file.
features/030-extend-domain/extend-domains.feature:10
Given I use a fixture named "fixture-resolver"
# ------------------------------------------------------------------
# Define domain resolver
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'resolvers' section loads resolvers from file
# 'cnf/resolver_customer.yaml'

resolvers:
     - url: cnf/resolver_customer.yaml
And a file named "cnf/resolver_customer.yaml" with:
# Map domain 
#  id     --->        id_domain
#  name   --->        name_domain
#  default--->        default_domain
#
-    Name: default-relsover
     Matcher: !ruby/regexp /.*/
     Rules: 
          - Matcher: id
            Domain: id_domain
          - Matcher: name
            Domain: name_domain
          - Matcher: !ruby/regexp /.*/
            Domain: default_domain
# ------------------------------------------------------------------
# Define domain extensions
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'setups' section defines a setup 'demoDomainCardinality' 
# using extensions defined in file 'cnf/extensions.yaml'

setups:
     - setupDirectory: setupDomainCardinality
       extensions: 
          - url: cnf/extensions.yaml
- Scenario: Set domain cardinality
link

Domain extension configuration sets 'id_domain' cardinality to 2
# ------------------------------------------------------------------
features/030-extend-domain/extend-domains.feature:78
Given YAML configuration file `cnf/extensions.yaml`
#
# domain 'id_domain' has cardinality 2. Sbuilder add domain 'Nil'
#
- domain-extension:
      - domain: id_domain
        cardinality: 2
When I generate TLA+ model setup `setupDomainCardinality`
And I do PLC transformation for setup `setupDomainCardinality`
And I run TLC for setup `setupDomainCardinality`
Then I can observe domain assignement:
Field Domain
id "d_id_domain_1"
id "d_id_domain_2"
id Nil
- Scenario: Set (fixed) domain values
link

Domain extension defines fixed values ('name1', 'name2') for
'domain_name'. Sbuilder adds domain value 'Nil'.
# ------------------------------------------------------------------     
features/030-extend-domain/extend-domains.feature:104
And YAML configuration file `cnf/extensions.yaml`
#
# domain 'name_domain' defines two values 'name1' and 'name2'
#
- domain-extension:
        - domain: name_domain
          values:
           - name1
           - name2
When I generate TLA+ model setup `setupDomainCardinality`
And I do PLC transformation for setup `setupDomainCardinality`
And I run TLC for setup `setupDomainCardinality`
Then I can observe domain assignement:
Field Domain
name "name1"
name "name2"
name Nil