Skip to content
Open
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
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.17.4</quarkus.platform.version>
<quarkus.platform.version>3.20.0</quarkus.platform.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.0</surefire-plugin.version>
<org.mapstruct.version>1.6.3</org.mapstruct.version>
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>io.quarkiverse.resteasy-problem</groupId>
<artifactId>quarkus-resteasy-problem</artifactId>
<version>3.15.0</version>
<version>3.21.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down Expand Up @@ -113,7 +113,6 @@
<artifactId>archunit-junit5</artifactId>
<version>${archunit-junit5.version}</version>
</dependency>

</dependencies>

<build>
Expand All @@ -129,7 +128,6 @@
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
<goal>native-image-agent</goal>
</goals>
</execution>
</executions>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ quarkus.rest-client.extensions-api.verify-host=false
# --------------------------
## KAFKA Client configuration
# --------------------------

quarkus.kafka.devservices.topic-partitions.guitar-requests=1
mp.messaging.outgoing.guitar-requests-out.connector=smallrye-kafka
mp.messaging.outgoing.guitar-requests-out.topic=guitar-requests
Expand Down
59 changes: 59 additions & 0 deletions src/main/resources/asyncapi/supplychain-asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
asyncapi: 3.0.0
info:
title: Guitar Supply Chain API
version: 1.0.0
description: This API is notified whenever the stock is too low

servers:
dev:
host: kafka://localhost:8092
description: Kafka broker running in a Quarkus Dev Service
protocol: kafka

operations:
onGuitarRequestOut:
action: send
channel:
$ref: '#/channels/guitar-requests-out'
onGuitarRequestIn:
action: receive
channel:
$ref: '#/channels/guitar-requests-in'

channels:
guitar-requests-out:
description: This channel is used to broadcast guitars supply requests
address: guitar-requests
messages:
guitarRequest:
$ref: '#/components/messages/guitarRequest'
guitar-requests-in:
description: This channel is used to fetch guitar requests
address: guitar-requests
messages:
guitarRequest:
$ref: '#/components/messages/guitarRequest'
components:
messages:
guitarRequest:
name: guitarRequest
title: Guitar Request
contentType: application/json
payload:
$id: "GuitarRequest"
$ref: '#/components/schemas/guitarRequest'
schemas:
guitarRequest:
additionalProperties: false
type: object
properties:
requestId:
type: string
format: uuid
description: This property describes the UUID of the request
guitarName:
type: string
description: This property describes the name of the guitar
quantity:
type: integer
description: The quantity to order and supply
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
asyncapi: 3.0.0
info:
title: Guitar Supply Chain API
version: 1.0.0
description: This API is notified whenever the stock is too low

defaultContentType: application/json
channels:
guitar-requests-out:
address: guitar-requests
description: Requests
messages:
guitarRequest.message:
description: Event to ask a guitar
payload:
type: object
additionalProperties: false
properties:
requestId:
type: string
format: uuid
guitarName:
type: string
quantity:
type: integer
examples:
- name: "Gibson ES 335"
summary: "Example for Gibson ES 335"
payload:
requestId: ba4bf043-ee08-47c7-8b4f-75427d7213bf
guitarName: "Gibson ES 335"
quantity: 10
- name: "Fender Stratocaster"
summary: "Example for Fender Stratocaster"
payload:
requestId: ba4bf043-ee08-47c7-8b4f-75427d7213be
guitarName: "Fender Stratocaster"
quantity: 5
guitar-requests-in:
address: guitar-requests
description: Requests
messages:
guitarRequest.message:
description: Event to ask a guitar
payload:
type: object
additionalProperties: false
properties:
requestId:
type: string
format: uuid
guitarName:
type: string
quantity:
type: integer
examples:
- name: "Gibson ES 335"
summary: "Example for Gibson ES 335"
payload:
requestId: ba4bf043-ee08-47c7-8b4f-75427d7213bf
guitarName: "Gibson ES 335"
quantity: 10
- name: "Fender Stratocaster"
summary: "Example for Fender Stratocaster"
payload:
requestId: ba4bf043-ee08-47c7-8b4f-75427d7213be
guitarName: "Fender Stratocaster"
quantity: 5
operations:
onGuitarRequestOut:
action: send
channel:
$ref: '#/channels/guitar-requests-out'
summary: Send command
messages:
- $ref: '#/channels/guitar-requests-out/messages/guitarRequest.message'
onGuitarRequestin:
action: receive
channel:
$ref: '#/channels/guitar-requests-in'
summary: Fetches command
messages:
- $ref: '#/channels/guitar-requests-in/messages/guitarRequest.message'


servers:
dev:
host: kafka://localhost:8092
description: Kafka broker running in a Quarkus Dev Service
protocol: kafka
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package info.touret.guitarheaven.test.application;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.microcks.testcontainers.MicrocksContainer;
import io.github.microcks.testcontainers.model.TestRequest;
import io.github.microcks.testcontainers.model.TestResult;
import io.github.microcks.testcontainers.model.TestRunnerType;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.jupiter.api.Assertions.assertTrue;

@QuarkusTest
public class APIContractTest {
private final static Logger LOGGER = LoggerFactory.getLogger(APIContractTest.class);

@ConfigProperty(name = "quarkus.http.test-port")
int quarkusHttpPort;

@ConfigProperty(name = "quarkus.microcks.default.http")
String microcksContainerUrl;

@Inject
ObjectMapper mapper;

@Test
public void testOpenAPIContract() throws Exception {
TestRequest testRequest = new TestRequest.Builder()
.serviceId("Guitar Heaven API with Examples:1.0.1")
.runnerType(TestRunnerType.OPEN_API_SCHEMA.name())
.testEndpoint("http://host.testcontainers.internal:" + quarkusHttpPort)
.build();
TestResult testResult = MicrocksContainer.testEndpoint(microcksContainerUrl, testRequest);
LOGGER.error(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testResult));
assertTrue(testResult.isSuccess());
}
}
Loading