Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.notNullValue;

public class OrchestrationTutorialTest extends AbstractOrchestrationTutorialTest {

Expand All @@ -27,23 +30,17 @@ protected String getTutorialYaml() {
}

@Test
void books_areReturnedById() {
void latestProductCopy_isCreatedWithFixedPrice() {
// @formatter:off
given()
.when()
.get("http://localhost:2000/books/{id}", "OL29474405M")
.post("http://localhost:2000/products/latest/copy")
.then()
.statusCode(200)
.body("title", equalTo("So Long, and Thanks for All the Fish"))
.body("author", equalTo("Douglas Adams"));

given()
.when()
.get("http://localhost:2000/books/{id}", "OL26333978M")
.then()
.statusCode(200)
.body("title", equalTo("Foucault's pendulum"))
.body("author", equalTo("Umberto Eco"));
.statusCode(201)
.body("id", notNullValue())
.body("name", notNullValue())
.body("price", equalTo(5))
.body("name", containsString("Copy"));
// @formatter:on
}

Expand Down
29 changes: 12 additions & 17 deletions distribution/tutorials/orchestration/30-Orchestration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,30 @@
#
# Tutorial: Orchestration
#
# Shows how to create an API that combines two backend calls into one API.
# 1) Fetch a book by id.
# 2) Use the author key from the book payload to fetch the author.
# Shows how to create an API that combines multiple backend calls into one API.
# 1) Fetch the newest product from fruitshop.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep the book example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How flaky is it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails sometimes due to a wrong status code

# 2) Create a new product with a copy of this product and a fixed price of 5.
#
# Try:
# curl localhost:2000/books/OL29474405M
# curl localhost:2000/books/OL26333978M
# curl -X POST localhost:2000/products/latest/copy

api:
port: 2000
path:
uri: /books/{id}
uri: /products/latest/copy
flow:
- request:
- call:
url: https://openlibrary.org/books/${pathParam.id}.json
- setProperty:
name: title
value: ${$.title}
language: jsonpath
- call:
url: https://openlibrary.org${$.authors[0].key}.json
language: jsonpath
url: https://api.predic8.de/shop/v2/products?sort=id&order=desc&limit=1
- template:
contentType: application/json
src: |
{
"title": ${property.title},
"author": ${jsonPath('$.name')}
"name": ${jsonPath('$.products[0].name') + ' Copy'},
"price": 5
}
- call:
method: POST
url: https://api.predic8.de/shop/v2/products
- return:
status: 200
status: 201
Loading