[More Detail] [Collapse All]
Feature: Pass input using array of body records

Interface operation '/customers(post)' accepts body parameter of
type 'Customers', which is an array of 'Customer' records. Customer
record defines field 'addresses', which is an array of 'Address'
records.

The scenarios demonstrate calling '/customers(post)' with paramter
various parameter bindings using 'bindExact' -property.
features/045-pass-input-parameters/020-body-array.feature
- Background:
link
features/045-pass-input-parameters/020-body-array.feature:12
Given I use a fixture named "fixture-resolver"
# ------------------------------------------------------------------
# Swagger
And YAML configuration file `cnf/interface_customer.yaml` in path `paths./customers.post`
      operationId: postCustomers
      parameters:
        - name: customers
          in: body
          description: Customers to enter
          required: true
          schema:
              $ref: '#/definitions/Customers'
      responses:
         200:
            description: OK
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Customer`
#
# Customer with a number of addresses

         properties:
           id:
              type: string
           name:
              type: string
           addresses:
              type: array
              items:
                  $ref: '#/definitions/Address'
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Customers`
#
# Customer with a number of addresses

         type: array
         allOf: 
             - $ref: '#/definitions/Customer'
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Address`
         properties:
           street:
            type: string
           city:
            type: string
And YAML configuration file `cnf/interface_customer.yaml` in path `paths./customers.post`
      operationId: postCustomers
      parameters:
        - name: customers
          in: body
          description: Customers to enter
          required: true
          schema:
              $ref: '#/definitions/Customers'
      responses:
         200:
            description: OK
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Customer`
#
# Customer with a number of addresses

         properties:
           id:
              type: string
           name:
              type: string
           addresses:
              type: array
              items:
                  $ref: '#/definitions/Address'
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Customers`
#
# Customer with a number of addresses

         type: array
         allOf: 
             - $ref: '#/definitions/Customer'
And YAML configuration file `cnf/interface_customer.yaml` in path `definitions.Address`
         properties:
           street:
            type: string
           city:
            type: string
# Swagger
# ------------------------------------------------------------------
And YAML configuration file `cnf/sbuilder.yaml`
#
# 'resolvers' section loads resolvers from file
# 'cnf/resolver_customer.yaml'

resolvers:
     - url: cnf/resolver.yaml
And a file named "cnf/resolver.yaml" with:
# default resolver with one regexp rule
-    Name: default-relsolver
     Matcher: !ruby/regexp /.*/
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: dommi
- Scenario: Use one row as input
link

Interface operation '/customers(post)' called with 'exactBind' to
avoid state space explosion in parameter bindings.
features/045-pass-input-parameters/020-body-array.feature:154
Given YAML configuration file `cnf/sbuilder.yaml`
#
# 'setups' section defines a setup 'demo' 

setups:
- setupDirectory: setup1
  extensions:
       - url: cnf/extend_setup1.yaml
And a file named "cnf/extend_setup1.yaml" with:
#
# Setup1:
# - set cardinality for domain 'dommi'
#
- domain-extension:
     - domain: dommi
       cardinality: 100

- step-extension:
       - interface: /customers(post)
         bindExact: true
         input:
                customers:
                     -  _default: 1
                        addresses:
                             -  _default: 9
When I generate TLA+ model setup `setup1`
And I do PLC transformation for setup `setup1`
And I run TLC for setup `setup1`
Then I can observe operation `/customers(post)` called on time tick `0`
And I can observe domain assignement:
Field Domain
id "d_dommi_1"
name "d_dommi_1"
street "d_dommi_9"
city "d_dommi_9"
- Scenario: Use two rows as input
link

Interface operation '/customers(post)' called with 'exactBind' to
avoid state space explosion in parameter bindings.
features/045-pass-input-parameters/020-body-array.feature:203
Given YAML configuration file `cnf/sbuilder.yaml`
#

setups:
- setupDirectory: setup2
  extensions:
      -  url: cnf/extend_setup2.yaml
And a file named "cnf/extend_setup2.yaml" with:
# Setup2:
# - set cardinality for domain 'dommi'

- domain-extension:
     - domain: dommi
       cardinality: 100

- step-extension:
       - interface: /customers(post)
         bindExact: true
         input:
                customers:
                     -  _default: 2
                        addresses:
                             -  _default: 10
                                city: 42

                     -  _default: 3
                        addresses:
                             -  _default: 12
When I generate TLA+ model setup `setup2`
And I do PLC transformation for setup `setup2`
And I run TLC for setup `setup2`
And I can observe operation `/customers(post)` called on time tick `0`
And I can observe domain assignement:
Field Domain
id "d_dommi_2"
name "d_dommi_2"
id "d_dommi_3"
name "d_dommi_3"
street "d_dommi_10"
street "d_dommi_12"
city "d_dommi_42"
city "d_dommi_12"