From a368894d15c0b0428b9484ac01f0b2657b0cc442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6rdes?= Date: Mon, 11 May 2026 15:45:52 +0200 Subject: [PATCH 1/2] Fix flaky OrchestrationTutorialTest: Update orchestration tutorial to fetch latest product details instead of books --- .../OrchestrationTutorialTest.java | 21 ++++++---------- .../orchestration/30-Orchestration.yaml | 25 ++++++------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java b/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java index 11fbdd6e86..b24702b40b 100644 --- a/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java +++ b/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java @@ -17,7 +17,9 @@ import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.notNullValue; public class OrchestrationTutorialTest extends AbstractOrchestrationTutorialTest { @@ -27,23 +29,16 @@ protected String getTutorialYaml() { } @Test - void books_areReturnedById() { + void latestProduct_isReturned() { // @formatter:off given() .when() - .get("http://localhost:2000/books/{id}", "OL29474405M") + .get("http://localhost:2000/products/latest") .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")); + .body("id", notNullValue()) + .body("name", notNullValue()) + .body("price", greaterThan(0f)); // @formatter:on } diff --git a/distribution/tutorials/orchestration/30-Orchestration.yaml b/distribution/tutorials/orchestration/30-Orchestration.yaml index 816026d662..9ea3ae07f0 100644 --- a/distribution/tutorials/orchestration/30-Orchestration.yaml +++ b/distribution/tutorials/orchestration/30-Orchestration.yaml @@ -3,34 +3,25 @@ # 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. +# 1) Fetch the newest product id from the fruitshop product list. +# 2) Use that id to fetch full product details. # # Try: -# curl localhost:2000/books/OL29474405M -# curl localhost:2000/books/OL26333978M +# curl localhost:2000/products/latest api: port: 2000 path: - uri: /books/{id} + uri: /products/latest flow: - request: - call: - url: https://openlibrary.org/books/${pathParam.id}.json + url: https://api.predic8.de/shop/v2/products?sort=id&order=desc&limit=1 - setProperty: - name: title - value: ${$.title} + name: id + value: ${$.products[0].id} language: jsonpath - call: - url: https://openlibrary.org${$.authors[0].key}.json - language: jsonpath - - template: - contentType: application/json - src: | - { - "title": ${property.title}, - "author": ${jsonPath('$.name')} - } + url: https://api.predic8.de/shop/v2/products/${properties.id} - return: status: 200 From fb6e1bb941b2f8c286352ad8d63e8213634e2267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6rdes?= Date: Mon, 11 May 2026 15:55:53 +0200 Subject: [PATCH 2/2] Enhance orchestration tutorial: Add API to create a product copy with fixed price --- .../OrchestrationTutorialTest.java | 10 ++++--- .../orchestration/30-Orchestration.yaml | 26 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java b/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java index b24702b40b..c500d1f4a9 100644 --- a/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java +++ b/distribution/src/test/java/com/predic8/membrane/tutorials/orchestration/OrchestrationTutorialTest.java @@ -18,6 +18,7 @@ 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; @@ -29,16 +30,17 @@ protected String getTutorialYaml() { } @Test - void latestProduct_isReturned() { + void latestProductCopy_isCreatedWithFixedPrice() { // @formatter:off given() .when() - .get("http://localhost:2000/products/latest") + .post("http://localhost:2000/products/latest/copy") .then() - .statusCode(200) + .statusCode(201) .body("id", notNullValue()) .body("name", notNullValue()) - .body("price", greaterThan(0f)); + .body("price", equalTo(5)) + .body("name", containsString("Copy")); // @formatter:on } diff --git a/distribution/tutorials/orchestration/30-Orchestration.yaml b/distribution/tutorials/orchestration/30-Orchestration.yaml index 9ea3ae07f0..8da2e19c01 100644 --- a/distribution/tutorials/orchestration/30-Orchestration.yaml +++ b/distribution/tutorials/orchestration/30-Orchestration.yaml @@ -2,26 +2,30 @@ # # Tutorial: Orchestration # -# Shows how to create an API that combines two backend calls into one API. -# 1) Fetch the newest product id from the fruitshop product list. -# 2) Use that id to fetch full product details. +# Shows how to create an API that combines multiple backend calls into one API. +# 1) Fetch the newest product from fruitshop. +# 2) Create a new product with a copy of this product and a fixed price of 5. # # Try: -# curl localhost:2000/products/latest +# curl -X POST localhost:2000/products/latest/copy api: port: 2000 path: - uri: /products/latest + uri: /products/latest/copy flow: - request: - call: url: https://api.predic8.de/shop/v2/products?sort=id&order=desc&limit=1 - - setProperty: - name: id - value: ${$.products[0].id} - language: jsonpath + - template: + contentType: application/json + src: | + { + "name": ${jsonPath('$.products[0].name') + ' Copy'}, + "price": 5 + } - call: - url: https://api.predic8.de/shop/v2/products/${properties.id} + method: POST + url: https://api.predic8.de/shop/v2/products - return: - status: 200 + status: 201