Skip to content

Commit

Permalink
Merge pull request quarkusio#1462 from jcarranzan/api-replacement
Browse files Browse the repository at this point in the history
Fix and replace external API fruityvice.com by swapi.dev
  • Loading branch information
rsvoboda authored and jcarranzan committed Oct 21, 2024
1 parent ca5cd61 commit 582ca1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<JsonObject> getFruitData(String name) {
return client.get("/api/fruit/" + name)
@Path("/{id}")
public Uni<JsonObject> getStarWarsData(String id) {
return client.get("/api/people/" + id)
.send()
.map(resp -> {
if (resp.statusCode() == 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

}

}

0 comments on commit 582ca1e

Please sign in to comment.