Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and replace external API fruityvice.com by swapi.dev #1462

Merged
merged 1 commit into from
Oct 21, 2024
Merged
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
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"));

}

}
Loading