From ff646f7bab8fe03c7d70cf19c70846d2dde049f1 Mon Sep 17 00:00:00 2001 From: jcarranzan Date: Mon, 14 Oct 2024 12:14:12 +0200 Subject: [PATCH] Fix enpoint path to match character starwars data API --- .../java/org/acme/extra/ResourceUsingWebClient.java | 10 +++++----- .../org/acme/extra/ResourceUsingWebClientTest.java | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/vertx-quickstart/src/main/java/org/acme/extra/ResourceUsingWebClient.java b/vertx-quickstart/src/main/java/org/acme/extra/ResourceUsingWebClient.java index ffb2bbafb5..8f0a37b321 100644 --- a/vertx-quickstart/src/main/java/org/acme/extra/ResourceUsingWebClient.java +++ b/vertx-quickstart/src/main/java/org/acme/extra/ResourceUsingWebClient.java @@ -9,21 +9,21 @@ import io.vertx.mutiny.core.Vertx; import io.vertx.mutiny.ext.web.client.WebClient; -@Path("/fruit-data") +@Path("/character-data") public class ResourceUsingWebClient { private final WebClient client; public ResourceUsingWebClient(Vertx vertx) { this.client = WebClient.create(vertx, - new WebClientOptions().setDefaultHost("fruityvice.com").setDefaultPort(443).setSsl(true) + new WebClientOptions().setDefaultHost("swapi.dev").setDefaultPort(443).setSsl(true) .setTrustAll(true)); } @GET - @Path("/{name}") - public Uni getFruitData(String name) { - return client.get("/api/fruit/" + name) + @Path("/{id}") + public Uni getStarWarsData(String id) { + return client.get("/api/people/" + id) .send() .map(resp -> { if (resp.statusCode() == 200) { diff --git a/vertx-quickstart/src/test/java/org/acme/extra/ResourceUsingWebClientTest.java b/vertx-quickstart/src/test/java/org/acme/extra/ResourceUsingWebClientTest.java index 0ee7e34848..fd1ff62f9c 100644 --- a/vertx-quickstart/src/test/java/org/acme/extra/ResourceUsingWebClientTest.java +++ b/vertx-quickstart/src/test/java/org/acme/extra/ResourceUsingWebClientTest.java @@ -11,12 +11,13 @@ class ResourceUsingWebClientTest { @Test - void testBananaData() { + void testStarWarsData() { given() - .when().get("/fruit-data/banana") + .when().get("/character-data/1") .then() .statusCode(200) - .body(containsString("Musaceae")); + .body(containsString("Luke Skywalker")); + } }