[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
'extedDomain' 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: extedDomain
       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 successfully run `sbuilder.rb generate extedDomain`
And I cd to "gen/extedDomain/tla"
And I successfully run command `java -cp $TLATOOLS pcal.trans model`
And the stdout should contain "Translation completed.\nNew file model.tla written."
And I run command `java -cp $TLATOOLS tlc2.TLC setup`
And the stdout should contain "Model checking completed. No error has been found."
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:108
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 successfully run `sbuilder.rb generate extedDomain`
And I cd to "gen/extedDomain/tla"
And I successfully run command `java -cp $TLATOOLS pcal.trans model`
And the stdout should contain "Translation completed.\nNew file model.tla written."
And I run command `java -cp $TLATOOLS tlc2.TLC setup`
And the stdout should contain "Model checking completed. No error has been found."
Then I can observe domain assignement:
Field Domain
name "name1"
name "name2"
name Nil
- Scenario: Set domain type 'integer'
link

Domain extension defines type: Int

Int domain cannot be enumarated, and have to use 'bindExact' to
define values. See 'input' and 'validators' define values in
'step-extension'
features/030-extend-domain/extend-domains.feature:141
And a file named "cnf/extensions.yaml" with:
#

# define domain id_domain type : Int
#
#

- domain-extension:

        - domain: id_domain
          type: Int

- step-extension:

  - interface: "/customer(post)"
    bindExact: true
    input: 
       customer: 
           _default: 1
           id: 1000

  - interface: "/customer(post)"
    bindExact: true
    validators:
         - rule: path
           rule_value: [customer, id]
           action: domain
           action_value: 4000
         - rule: default
           action: domain
           action_value: 1
When I successfully run `sbuilder.rb generate extedDomain`
And I cd to "gen/extedDomain/tla"
And I successfully run command `java -cp $TLATOOLS pcal.trans model`
And the stdout should contain "Translation completed.\nNew file model.tla written."
And I run command `java -cp $TLATOOLS tlc2.TLC setup`
And the stdout should contain "Model checking completed. No error has been found."
Then I can observe domain assignement:
Field Domain
id 1000
name "d_name_domain_1"