Add test for multi-valued response
This commit is contained in:
@@ -374,6 +374,25 @@ public class RestApplicationTests {
|
||||
assertThat(rest.getForObject("/wrap/123", String.class)).isEqualTo("..123..");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertPost() throws Exception {
|
||||
ResponseEntity<String> result = rest.exchange(RequestEntity.post(new URI("/wrap"))
|
||||
.contentType(MediaType.TEXT_PLAIN).body("123"), String.class);
|
||||
assertThat(result.getBody()).isEqualTo("..123..");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertPostJson() throws Exception {
|
||||
// If you POST a single value to a Function<Flux<Integer>,Flux<Integer>> it can't
|
||||
// determine if the output is single valued, so it has to send an array back
|
||||
ResponseEntity<String> result = rest
|
||||
.exchange(
|
||||
RequestEntity.post(new URI("/doubler"))
|
||||
.contentType(MediaType.TEXT_PLAIN).body("123"),
|
||||
String.class);
|
||||
assertThat(result.getBody()).isEqualTo("[246]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void supplierFirst() {
|
||||
assertThat(rest.getForObject("/not/a/function", String.class))
|
||||
@@ -458,6 +477,11 @@ public class RestApplicationTests {
|
||||
return flux -> flux.log().map(value -> ".." + value + "..");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Integer>, Flux<Integer>> doubler() {
|
||||
return flux -> flux.log().map(value -> 2 * value);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Integer>, Flux<Map<String, Object>>> entity() {
|
||||
return flux -> flux.log()
|
||||
|
||||
Reference in New Issue
Block a user