In this section, you will test both workflows. The OrderProcessor workflow manages the overall path of an individual drink order. The OrderManager workflow handles drink updates and status changes. By interacting with both, you can complete an order from start to finish.
There are 3 steps:
This section moves between different workflows and services. To prepare, open multiple tabs in your browser:
The instructions below will use all of these tabs, so leave these open for the duration of this section.
First, create a new workflow execution to simulate an incoming order caused by a customer scanning a QR code.
To start a new workflow, from the AWS EventBridge Console, under Events:
Choose Event busses.
Choose the Serverlesspresso event bus
Choose Send events
Check that the serverlesspresso event bus is selected
Copy the following into the Event source input:
awsserverlessda.serverlesspresso
Validator.NewOrder
{"userId":"1","orderId":"2"}
Choose Send
Go to the OrderProcessorWorkflow tab. In the Executions panel, open the most recent execution in a Running state.
The Workflow is paused at the WorkflowStarted state. The first TaskToken
has been saved to the serverlesspresso-order-table in DynamoDB
.
Go to the serverlesspresso-order-table.
Find the entry where SK is “2”. Choose Orders from the PK column to open the item detail.
The TaskToken
is stored here together with the unique order ID. The application uses this to resume the workflow later.
In the previous section, you discovered how the OrderManager workflow is used to sanitize, update, cancel orders, and resume the OrderProcessor workflow by returning the correct TaskToken
.
Here, you will add detail to the drink order, simulating a customer configuring their order in the Customer App. You do this by running an OrderManager workflow to update the OrderProcessor state machine.
Go to the OrderManager workflow tab.
Choose Start execution. Enter the following into the input text area and choose Start execution:
{"action":"","body":{"userId":"1","drink":"Cappuccino","modifiers":[],"icon":"barista-icons_cappuccino-alternative"},"orderId":"2","baristaUserId":"3"}
In the OrderManager workflow for this execution, this execution is now completed.
In the OrderProcessor tab, the workflow has resumed, allowing it to progress to the next TaskToken
step.
The WaitingCompletion event is emitted to the Serverlesspresso event bus. The event is routed to the WaitingCompletion Lambda function, which updates the serverlesspresso-order-table with the newly generated orderNumber and TaskToken
.
To verify this, go to the serverlesspresso-order-table. You can see a new column orderNumber, containing the human-readable order number.
In the OrderProcessor tab, the workflow has paused at this step until the barista notifies the application that the order has been completed.
Next, use the OrderManager workflow to simulate the barista claiming the order.
Go to the OrderManager workflow tab.
Choose Start execution. Enter the following into the input text area and choose Start execution:
{
"action": "make",
"body": {},
"orderId": "2",
"baristaUserId": "3"
}
Finally, use the OrderManager workflow to simulate the barista completing the order.
Go to the OrderManager workflow tab.
Choose Start execution. Enter the following into the input text area and choose Start execution. Notice that the input payload contains the action:complete
.
{"action":"complete","body":{"userId":"1","drink":"Cappuccino","modifiers":[],"icon":"barista-icons_cappuccino-alternative"},"orderId":"2","baristaUserId":"3"}
In the OrderProcessor tab, the execution also completes:
You have completed the end-to-end backend test for the workflows. In the next module, you will configure a new rule to route events back to the frontend applications. You will be able to run a complete test from the frontend applications.