use of org.springframework.http.codec.Pojo in project spring-framework by spring-projects.
the class WebClientIntegrationTests method jsonPojoMono.
@Test
public void jsonPojoMono() throws Exception {
this.server.enqueue(new MockResponse().setHeader("Content-Type", "application/json").setBody("{\"bar\":\"barbar\",\"foo\":\"foofoo\"}"));
Mono<Pojo> result = this.webClient.get().uri("/pojo").accept(MediaType.APPLICATION_JSON).exchange().then(response -> response.bodyToMono(Pojo.class));
StepVerifier.create(result).consumeNextWith(p -> assertEquals("barbar", p.getBar())).expectComplete().verify(Duration.ofSeconds(3));
RecordedRequest recordedRequest = server.takeRequest();
Assert.assertEquals(1, server.getRequestCount());
Assert.assertEquals("/pojo", recordedRequest.getPath());
Assert.assertEquals("application/json", recordedRequest.getHeader(HttpHeaders.ACCEPT));
}
Aggregations