use of io.vertx.ext.web.client.jackson.WineAndCheese in project vertx-web by vert-x3.
the class WebClientTest method testResponseUnknownContentTypeBodyAsJsonMapped.
@Test
public void testResponseUnknownContentTypeBodyAsJsonMapped() throws Exception {
JsonObject expected = new JsonObject().put("cheese", "Goat Cheese").put("wine", "Condrieu");
server.requestHandler(req -> req.response().end(expected.encode()));
startServer();
HttpRequest<Buffer> get = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath");
get.send(onSuccess(resp -> {
assertEquals(200, resp.statusCode());
assertEquals(new WineAndCheese().setCheese("Goat Cheese").setWine("Condrieu"), resp.bodyAsJson(WineAndCheese.class));
testComplete();
}));
await();
}
use of io.vertx.ext.web.client.jackson.WineAndCheese in project vertx-web by vert-x3.
the class WebClientTest method testResponseBodyAsAsJsonMapped.
@Test
public void testResponseBodyAsAsJsonMapped() throws Exception {
JsonObject expected = new JsonObject().put("cheese", "Goat Cheese").put("wine", "Condrieu");
server.requestHandler(req -> req.response().end(expected.encode()));
startServer();
HttpRequest<Buffer> get = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath");
get.as(BodyCodec.json(WineAndCheese.class)).send(onSuccess(resp -> {
assertEquals(200, resp.statusCode());
assertEquals(new WineAndCheese().setCheese("Goat Cheese").setWine("Condrieu"), resp.body());
testComplete();
}));
await();
}
use of io.vertx.ext.web.client.jackson.WineAndCheese in project vertx-web by vert-x3.
the class WebClientTest method testSendJsonPojoBody.
@Test
public void testSendJsonPojoBody() throws Exception {
testSendBody(new WineAndCheese().setCheese("roquefort").setWine("Chateauneuf Du Pape"), (contentType, buff) -> {
assertEquals("application/json", contentType);
assertEquals(new JsonObject().put("wine", "Chateauneuf Du Pape").put("cheese", "roquefort"), buff.toJsonObject());
});
}
Aggregations