[More Detail] [Collapse All]
Feature: Interface model is used to initiaze symbol table


Sbuilder creates initial symbol table comprising for mapping names
in application domain to names in specification code.

Entries in the symbol table are created using the data model
created, using interface configuration, and domain model.

Later, api interface may add own symbols to the symbol table.

Initial symbol table contains

| Data model element     | Source          | Specification model |
| domains                | Domain model    | domains             |
| definitions            | Interface model | definitions         |
| interfaces             | Interface model | interface_types     |
| interfaces             | Interface model | processes           |
| infrastructureServices | Interface model | infra_services      |
features/200-metamodel/0100-default-symbol-table-metamodel.feature
- Background: Initialize example application model
link
features/200-metamodel/0100-default-symbol-table-metamodel.feature:22
When I successfully run `sbuilder.rb init`
When I successfully run `sbuilder.rb extend`
# ------------------------------------------------------------------
# Configure  interface
And a file named "cnf/sbuilder.yaml" with:
# Setup1:
#
# Setup1:
# - set cardinality for domain 'dommi'
# - lauch /customer(get)
#
interfaces:
    -  className: Sbuilder::ParamSetLoaderSwagger
       file: public_interface.yaml
    -  className: Sbuilder::ParamSetLoaderSwagger
       infrastructureServices: true
       url: cnf/infra_interface.yaml
And a file named "cnf/public_interface.yaml" with:
swagger: "2.0"
info:
 version: 1.0.0
 title: Sbuild demo customer

#
# Interface operation /customer(post) 
#

paths: 
 /customer:
   post: 
     operationId: postCustomer
     parameters:
       - name: customer
         in: body
         description: Customers to enter
         required: true
         schema:
             $ref: '#/definitions/Customer'
     responses:
        200:
           description: OK

definitions: 
#
# Definition 'Customer'
#
   Customer:
        properties:
          id:
           type: string
          name:
           type: string
And a file named "cnf/infra_interface.yaml" with:
swagger: "2.0"
info:
 version: 1.0.0
 title: Infra services
paths: 
 /id:
   get:
     operationId: postCustomer
     responses:
             200:
               description: OK
               schema:
                  $ref: '#/definitions/Id'

               description: OK
               schema:
                  $ref: '#/definitions/Id'
definitions:
    Id:
       properties:
          id:
             type: string
# ------------------------------------------------------------------
# Configure  step
And YAML configuration file `cnf/sbuilder.yaml`
#
# Define only setup 'example' - no extensions.

setups:
  - setupDirectory: example
    extensions:
      -  url: cnf/extend-implementation.yaml
      -  url: cnf/extend-steps.yaml
And YAML configuration file `cnf/sbuilder.yaml`
resolvers:
      - url: cnf/example_resolver.yaml
And YAML configuration file `cnf/sbuilder.yaml`
#
# Map service implementation 

snippets:

  - className: Sbuilder::SnippetLoaderSimple 
    snippets:

        # interface /customer(post) calls customer_post
      - metatype: service_implementation
        appName: /customer(post)
        name: customer_post
And a file named "cnf/extend-implementation.yaml" with:
#
# interface-extension: define implemehtation for interface
# operation '/customer(post)'

# - interface-extension:
#    - matcher: /customer(post)
#      implementation: customer_post
And a file named "cnf/extend-steps.yaml" with:

# Define steps, which environment will take. In this case,
# environment call interface '/customer(post)', and because no
# input constaint is defined, environment uses all input
# combination for 'id', 'name', and 'type' parameters in the
# operation.
#
- step-extension:
       - interface: /customer(post)
         input:
            customer: 
               _default: 1
And a file named "cnf/example_resolver.yaml" with:
# catch all resolver
-    Name: default-relsover
     Matcher: !ruby/regexp /.*/
     Rules: 
      - Matcher: !ruby/regexp /.*/
        Domain: dommi
      - Matcher: Id
        Domain: id_domain
When I append to "src/interface" with:
  {{>customer_post.code }}
- Scenario: Maps application names in sbuilder metamodel to specification domain
link

Create interface implementation for /customer(post) in file
src/customer_post.code, which outputs name in specification code
for

- processes name to which interface /customer(post) is mapped to
- type name of the input for interface /customer(post)
- type name of Customer definition
- type name of domain 'dommi'

Notice that this test is going to fail if mapping rules for
sbuilder meta model are changed.
features/200-metamodel/0100-default-symbol-table-metamodel.feature:196
Given a file named "src/customer_post.code" with:
  (* This macro is called for interface /customer(post)  *)
   macro customer_post( input ) {
       print << "/customer(post) called!!!" >>;
       print << "Interface/public service process /customer(post) --> {{#SPEC_NAME}}processes./customer(post){{/SPEC_NAME}}" >>;
       print << "Infraservice /id(get) --> {{#SPEC_NAME}}infra_services./id(get){{/SPEC_NAME}}" >>;
       print << "Interface type /customer(post) --> {{#SPEC_NAME}}interface_types./customer(post){{/SPEC_NAME}}" >>;
       print << "Interface response type /customer(post) --> {{#SPEC_NAME}}interface_response_types./customer(post){{/SPEC_NAME}}" >>;
       print << "Domain dommi --> {{#SPEC_NAME}}domains.dommi{{/SPEC_NAME}}" >>;
       print << "Domain id_domain --> {{#SPEC_NAME}}domains.id_domain{{/SPEC_NAME}}" >>;
       print << "Type/definition Customer --> {{#SPEC_NAME}}definitions.Customer{{/SPEC_NAME}}" >>;
   }
When I successfully run `sbuilder.rb generate example`
And I cd to "gen/example/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."
And the stdout should contain "Interface/public service process /customer(post) --> p__customer_post_"
And the stdout should contain "Interface type /customer(post) --> t_req__customer_post_"
And the stdout should contain "Interface response type /customer(post) --> t_resp__customer_post_"
And the stdout should contain "Infraservice /id(get) --> i__id_get_"
And the stdout should contain "Domain dommi --> d_dommi"
And the stdout should contain "Domain id_domain --> d_id_domain"
And the stdout should contain "Type/definition Customer --> t_Customer"