From 43ec4d726d9765b82ceedc5c5e051bd82105c526 Mon Sep 17 00:00:00 2001 From: Laurent Broudoux Date: Mon, 16 Dec 2024 16:55:43 +0100 Subject: [PATCH] chore: Update to microcks-quarkus 0.2.7 and add APIExamples illustration Signed-off-by: Laurent Broudoux --- pom.xml | 2 +- src/main/resources/order-events-examples.yaml | 23 +++++++++++++++++++ step-5-write-async-tests.md | 4 +++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/order-events-examples.yaml diff --git a/pom.xml b/pom.xml index 3879c08..a8a000d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 3.16.2 true 3.5.2 - 0.2.6 + 0.2.7 diff --git a/src/main/resources/order-events-examples.yaml b/src/main/resources/order-events-examples.yaml new file mode 100644 index 0000000..32dd0f6 --- /dev/null +++ b/src/main/resources/order-events-examples.yaml @@ -0,0 +1,23 @@ +apiVersion: mocks.microcks.io/v1alpha1 +kind: APIExamples +metadata: + name: Order Events API + version: '0.1.0' +operations: + PUBLISH orders-reviewed: + Validated OrderEvent 2: + eventMessage: + mediaType: application/json + payload: + timestamp: 1706087114346 + order: + id: abc-def-ghi + customerId: yadayac + status: VALIDATED + productQuantities: + - productName: Croissant + quantity: 1 + - productName: Pain Chocolat + quantity: 1 + totalPrice: 4.2 + changeReason: Validation diff --git a/step-5-write-async-tests.md b/step-5-write-async-tests.md index 57de41d..5586f8d 100644 --- a/step-5-write-async-tests.md +++ b/step-5-write-async-tests.md @@ -45,14 +45,16 @@ public class OrderServiceTests extends BaseTest { try { // Launch the Microcks test and wait a bit to be sure it actually connects to Kafka. // Because of Redpanda, it must be >3 sec to ensure the consumer get a refresh of metadata and actually receive messages. + // Update: with Redpanda > 24, this is no longer needed as metadata are refreshed on consumer creation. CompletableFuture testRequestFuture = MicrocksContainer.testEndpointAsync(microcksContainerUrl, kafkaTest); - TimeUnit.MILLISECONDS.sleep(3500L); + TimeUnit.MILLISECONDS.sleep(500L); // Invoke the application to create an order. Order createdOrder = service.placeOrder(info); // You may check additional stuff on createdOrder... + assertEquals(OrderStatus.CREATED, createdOrder.getStatus()); // Get the Microcks test result. TestResult testResult = testRequestFuture.get();