[More Detail] [Collapse All]
Feature: Default values for input parameters

All interface operation parameters can set to a default value.

Implementation uses pseudo parameter name, '_default', which sets
domain value for interface parameter not configured in
'step-extension.input'.
features/040-extend-steps/005-use-default-bind.feature
- Background: Configure setup1, setup2
link

Define domain resolver, which maps interface parameter 'id' to
domain 'id_domain', and 'name' to 'name_domain'.

Extend domain 'id_domain' to have cardinality 2, and domain
'name_domain' with fixed values 'name1' and 'name2'.
features/040-extend-steps/005-use-default-bind.feature:12
Given I use a fixture named "fixture-resolver"
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'setups' section defines a setup 'demo' 

setups:
- setupDirectory: setup
  extensions:
      -  url: cnf/extend-domains.yaml
      -  url: cnf/extend-steps.yaml
And a file named "cnf/resolver_customer.yaml" with:
# Common domain resolver
#
-    Name: default-relsover
     Matcher: !ruby/regexp /.*/
     Rules: 
          - Matcher: id
            Domain: id_domain
          - Matcher: name
            Domain: name_domain
          - Matcher: !ruby/regexp /.*/
            Domain: default_domain
And a file named "cnf/extend-domains.yaml" with:
# Common domain mapper

#
- domain-extension:
       - domain: id_domain
         cardinality: 2
       - domain: name_domain
         values:
             - name1
             - name2
- Scenario: setup1: _default applies to all parameters
link

setup1: _default applies to all parameters in /customer(post)
interface, and set domain index 1.
features/040-extend-steps/005-use-default-bind.feature:65
Given a file named "cnf/extend-steps.yaml" with:
# Setup1:
#
- step-extension:
       - interface: /customer(post)
         input:
           customer:
               _default: 1
When I generate TLA+ model setup `setup`
And I do PLC transformation for setup `setup`
And I run TLC for setup `setup`
Then the stdout should contain "Model checking completed. No error has been found."
And I can observe operation `/customer(post)` called on time tick `0`
And I can observe domain assignement:
Field Domain
id "d_id_domain_1"
name "name1"
- Scenario: setup2: _default does not set value if separately assigned
link

setup2: parameter "name" bound to fixed value 'name2', all other
fields use default domain index 1.
features/040-extend-steps/005-use-default-bind.feature:93
Given a file named "cnf/extend-steps.yaml" with:
# Setup2:
#
- step-extension:
       - interface: /customer(post)
         input:
           customer:
               _default: 1
               name: name2
When I generate TLA+ model setup `setup`
And I do PLC transformation for setup `setup`
And I run TLC for setup `setup`
Then the stdout should contain "Model checking completed. No error has been found."
And I can observe operation `/customer(post)` called on time tick `0`
And I can observe domain assignement:
Field Domain
id "d_id_domain_1"
name "name2"