Simulation file examples
Tosca Cloud provides sample simulation files in the Samples workspace. Select this workspace to explore them.
This topic walks you through each example.

The hello_world_test.yml file is a simple simulation that sends a request and verifies the response. It demonstrates the basics of how services and steps work.
How it works:
-
Send the request: The step with the Out direction specifies that the simulation sends a request to the /hello endpoint .
-
Verify the response: The verify rule step checks if the response includes the expected value: Hello world!.
schema: SimV1
name: default
includes:
- hello_world
services:
- steps:
- direction: Out
insert:
- uri: /hello
- verify:
- value: Hello world!

The hello_world.yml file is a basic simulation that listens for any incoming request and always responds with Hello world!.
How it works:
-
Define the connection: The simulation opens a connection named hello on port 17071. This is where it listens for incoming requests.
-
Trigger the service: The URI with the wildcard * means that the service handles any request path.
-
Send the response: The Out step specifies the simulation's response, which includes a message containing the text Hello world!.
schema: SimV1
name: default
connections:
- name: hello
port: 17071
services:
- steps:
- direction: In
trigger:
- uri: '*'
- direction: Out
message:
payload: Hello world!

The bank_account.yml is a simulation that models a basic bank account service with simple operations, such as creating an account and making deposits.
How it works:
-
Create account: When a request is sent to /create, the service generates a random account ID {RND} and stores it as a buffer. It then responds with: “Thank you for opening an account! Your account ID is {B[id]}”. The value {B[id]} is the random number from the buffer that was stored before.
-
First deposit: A request to /deposit/{B[id]} triggers the simulation and stores the deposit amount as the initial balance. It responds with the message: “Thank you for your first deposit! Your current balance is {B[balance]}”. The value {B[balance]} is the current balance from the buffer that was stored before.
-
Subsequent deposits: For each following deposit request, the service adds the deposit amount to the current balance using the math operation {MATH[{B[balance]} + {B[amount]}]}. It responds with the updated balance using the message: “Your current balance is {B[balance]}”.
-
Transaction limit: After three deposits, any additional /deposit/{B[id]} requests return the message: “Too many transactions for today. Please try again tomorrow.”
schema: SimV1
name: bank account
connections:
- name: bank
port: 17073
services:
- name: bank service
steps:
- direction: In
trigger:
- uri: /create
buffer:
- name: id
value: '{RND}'
- direction: Out
insert:
- value: Thank you for opening an account! Your account ID is {B[id]}
- direction: In
trigger:
- uri: /deposit/{B[id]}
buffer:
- name: balance
- direction: Out
insert:
- value: Thank you for your first deposit! Your current balance is {B[balance]}
- direction: In
trigger:
- uri: /deposit/{B[id]}
buffer:
- name: amount
- name: balance
value: '{MATH[{B[balance]} + {B[amount]}]}'
- direction: Out
insert:
- value: Your current balance is {B[balance]}
- direction: In
trigger:
- uri: /deposit/{B[id]}
buffer:
- name: amount
- name: balance
value: '{MATH[{B[balance]} + {B[amount]}]}'
- direction: Out
insert:
- value: Your current balance is {B[balance]}
- direction: In
trigger:
- uri: /deposit/{B[id]}
- direction: Out
insert:
- value: To many transactions for today. Please try again tomorrow.

The calculator_test.yml file is a simulation for a calculator service. It includes the calculator connection and verifies that the service performs the four basic operations correctly.
How it works:
-
Addition test: Sends a request with 7 + 77 and verifies that the response has the correct sum of 84.
-
Multiplication test: Sends a request with 7 × 7 and verifies that the response contains the correct product, 49.
-
Subtraction test: Sends a request with 7 – 7 and verifies that the response contains the correct difference, 0.
-
Division test: Sends a request with 7 ÷ 7 and verifies that the response contains the correct quotient, 1.
schema: SimV1
name: calculator contract test
includes:
- calculator
services:
- name: test addition
steps:
- direction: Out
to: calculator
message:
payload: '{ "augend": 7, "addend": 77 }'
insert:
- uri: /addition
- direction: In
verify:
- jsonPath: sum
value: 84
- name: test multiplication
steps:
- direction: Out
to: calculator
message:
payload: '{ "multiplier": 7, "multiplicand": 7 }'
insert:
- uri: /multiplication
- direction: In
verify:
- jsonPath: product
value: 49
- name: test subtraction
steps:
- direction: Out
to: calculator
message:
payload: '{ "minuend": 7, "subtrahend": 7 }'
insert:
- uri: /subtraction
- direction: In
verify:
- jsonPath: difference
value: 0
- name: test division
steps:
- direction: Out
to: calculator
message:
payload: '{ "dividend": 7, "divisor": 7 }'
insert:
- uri: /division
- direction: In
verify:
- jsonPath: quotient
value: 1

The calculator.yml file simulates a calculator service that performs the four basic arithmetic operations addition, subtraction, multiplication, and division. It uses buffer values and math expressions.
How it works:
-
Trigger the service: The trigger defines which endpoint (URI) activates the service. In this example, these are /addition, /subtraction, /multiplication and /division.
-
Extract values from the request: The incoming JSON request is expected to look like this: { "augend": 7, "addend": 77 }. The buffer uses the JsonPath expression to extract values from the request and store them as buffer variables. For example, the jsonPath augend means "find the property augend in the incoming JSON and store its value in a variable named augend".
-
Prepare the response payload: The payload defines how the response will be structured. For example, the payload value { "sum": 0 } sets up the response format with a placeholder field.
-
Insert the calculated result: The insert rule replaces the placeholder with the actual calculation. For example, the value {math[{b[augend]} + {b[addend]}]} means, "replace the field sum in the response with the sum of the buffered values augend and addend".
schema: SimV1
name: calculator2
connections:
- name: calculator
port: 17072
services:
- name: addition
steps:
- direction: In
trigger:
- uri: /addition
buffer:
- jsonPath: augend
name: augend
- jsonPath: addend
name: addend
- direction: Out
message:
payload: '{ "sum": 0 }'
insert:
- jsonPath: sum
value: '{math[{b[augend]} + {b[addend]}]}'
- name: subtraction
steps:
- direction: In
trigger:
- uri: /subtraction
buffer:
- jsonPath: minuend
name: minuend
- jsonPath: subtrahend
name: subtrahend
- direction: Out
message:
payload: '{ "difference": 0 }'
insert:
- jsonPath: difference
value: '{math[{b[minuend]} - {b[subtrahend]}]}'
- name: multiplication
steps:
- direction: In
trigger:
- uri: /multiplication
buffer:
- jsonPath: multiplier
name: multiplier
- jsonPath: multiplicand
name: multiplicand
- direction: Out
message:
payload: '{ "product": 0 }'
insert:
- jsonPath: product
value: '{math[{b[multiplier]} * {b[multiplicand]}]}'
- name: division
steps:
- direction: In
trigger:
- uri: /division
buffer:
- jsonPath: dividend
name: dividend
- jsonPath: divisor
name: divisor
- direction: Out
message:
payload: '{ "quotient": 0 }'
insert:
- jsonPath: quotient
value: '{math[{b[dividend]} / {b[divisor]}]}'