[More Detail] [Collapse All]
Feature: Find domain resolver

Resolvers map interface parameters to domain values.
 
The first resolver, where 'Matcher' property matches interface
oparation gets used. An error is raised, if resolver is not found.

Matcher property may be String, or an Regex.
features/005-domain-resolve/resolver-find.feature
- Background:
link
features/005-domain-resolve/resolver-find.feature:12
Given I use a fixture named "fixture-resolver"
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'resolvers' section loads resolvers from file
# 'cnf/resolver_customer.yaml'

resolvers:
     - url: cnf/resolver_customer.yaml

snippets:

  - className: Sbuilder::SnippetLoaderSimple 
    snippets:

        # interface /customer(post) calls 'test_output'
      - metatype: service_implementation
        appName: /customer(post)
        name: test_output
        appName: /customer(get)
        name: test_output
And YAML configuration file `cnf/interface_customer.yaml`
# Application interface '/customer(get)'
paths:
  /customer:
    get:
      operationId: findCustomers by id
      parameters:
        - name: id
          in: query
          description: tags to filter by
          required: false
          type: array
          collectionFormat: csv
          items:
            type: string
        - name: tag
          in: query
          description: maximum number of results to return
          required: false
          type: integer
          format: int32
      responses:
         200:
            description: OK
definitions: {}
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'setups' section defines a setup 'setup1' and uses configuration
#  file 'cnf/extend_setup1.yaml'

setups:
- setupDirectory: setup1
  extensions:
     -  url: cnf/extend_setup1.yaml
And a file named "cnf/extend_setup1.yaml" with:

#  Environment makes a call to intefafce '/customer(get)', and
#  passes all input combinations to the interface.
#

- step-extension:
       - interface: /customer(get)
- Scenario: Finds a resolver using regexp
link

In this scenario, catch-all matcher for 'default-relsover'
matches parameter set for '/customer(get)', and catch-all rule
sets domain 'deffi' for parameters 'id' and 'tag' in operation
'/customer(get)'.
features/005-domain-resolve/resolver-find.feature:90
Given a file named "cnf/resolver_customer.yaml" with:
# default resolver with default rule
-    Name: default-relsover
     Matcher: !ruby/regexp /.*/
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: deffi
When I generate TLA+ model setup `setup1`
And I do PLC transformation for setup `setup1`
And I run TLC for setup `setup1`
Then the stdout should contain "Model checking completed. No error has been found."
And I can observe domain assignement:
Field Domain
id {"d_deffi_1"}
tag "d_deffi_1"
- Scenario: Finds a resolver using operation identifier string
link

 In this scenario, matcher for 'customer-get-relsover' matches
 parameter set for operation '/customer(get)'.

 Particularly, matcher '/customers(get)' for
 'customers-get-relsover' does NOT catch. Catch-all rule sets
 domain 'defu' for parameters 'id' and 'tag'.
features/005-domain-resolve/resolver-find.feature:116
Given a file named "cnf/resolver_customer.yaml" with:
# default resolver with default rule
-    Name: customers-get-relsover
     Matcher: /customers(get)
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: SHOULD_NOT_BE_USED
-    Name: customer-get-relsover
     Matcher: /customer(get)
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: defu
-    Name: default-relsover
     Matcher: !ruby/regexp /.*/
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: SHOULD_NOT_BE_USED
When I generate TLA+ model setup `setup1`
And I do PLC transformation for setup `setup1`
And I run TLC for setup `setup1`
Then the stdout should contain "Model checking completed. No error has been found."
And I can observe domain assignement:
Field Domain
id {"d_defu_1"}
tag "d_defu_1"
- Scenario: No match for parameter set: "Could not locate resolver"
link

Resolver defines matcher for '/customers(get)', but not for
'/customer(get)' --> error 'Could not locate resolver'.
features/005-domain-resolve/resolver-find.feature:155
Given a file named "cnf/resolver_customer.yaml" with:
# no configuration
-   Name: customers-get-relsover
    Matcher: /customers(get)
    Rules: 
     - Matcher: !ruby/regexp /.*/
       Domain: SHOULD_NOT_BE_USED
When I run `sbuilder.rb generate setup1`
Then the stderr should contain "Could not locate resolver"
Then the exit status should be 1
- Scenario: Emtpy resolver file: "Could not locate resolver"
link

Empty resolver configured, raises error 'Could not locate
resolver'
features/005-domain-resolve/resolver-find.feature:177
Given a file named "cnf/resolver_customer.yaml" with:
# no configuration
When I run `sbuilder.rb generate setup1`
Then the stderr should contain "Could not locate resolver"
Then the exit status should be 1
- Scenario: Error: no resolver configuration file not found
link

Reference to non-existing resolver file results to error "No such
file or directory".
features/005-domain-resolve/resolver-find.feature:192
When I remove the file "cnf/resolver_customer.yaml" with full force
When I run `sbuilder.rb generate setup1`
Then the exit status should be 1
Then the stderr from "sbuilder.rb generate setup1" should contain "No such file or directory"