Extend support for simple types to Consumer and Supplier
The function catalog now always wraps beans that deal with non-flux generic types.
This commit is contained in:
@@ -115,6 +115,14 @@ public class RestApplicationTests {
|
||||
assertThat(result.getBody()).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bareWords() throws Exception {
|
||||
ResponseEntity<String> result = rest
|
||||
.exchange(RequestEntity.get(new URI("/bareWords")).build(), String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(result.getBody()).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updates() throws Exception {
|
||||
ResponseEntity<String> result = rest.exchange(
|
||||
@@ -124,6 +132,16 @@ public class RestApplicationTests {
|
||||
assertThat(result.getBody()).isEqualTo("onetwo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bareUpdates() throws Exception {
|
||||
ResponseEntity<String> result = rest.exchange(
|
||||
RequestEntity.post(new URI("/bareUpdates")).body("one\ntwo"),
|
||||
String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED);
|
||||
assertThat(test.list).hasSize(2);
|
||||
assertThat(result.getBody()).isEqualTo("onetwo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void timeoutJson() throws Exception {
|
||||
assertThat(rest
|
||||
@@ -184,6 +202,12 @@ public class RestApplicationTests {
|
||||
.isEqualTo("[FOO][BAR]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bareUppercase() {
|
||||
assertThat(rest.postForObject("/bareUppercase", "foo\nbar", String.class))
|
||||
.isEqualTo("[FOO][BAR]");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void transform() {
|
||||
assertThat(rest.postForObject("/transform", "foo\nbar", String.class))
|
||||
@@ -270,6 +294,11 @@ public class RestApplicationTests {
|
||||
.map(value -> "[" + value.trim().toUpperCase() + "]");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<String, String> bareUppercase() {
|
||||
return value -> "[" + value.trim().toUpperCase() + "]";
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Integer>, Flux<String>> wrap() {
|
||||
return flux -> flux.log().map(value -> ".." + value + "..");
|
||||
@@ -294,11 +323,21 @@ public class RestApplicationTests {
|
||||
return () -> Flux.fromArray(new String[] { "foo", "bar" });
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Supplier<List<String>> bareWords() {
|
||||
return () -> Arrays.asList("foo", "bar");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<Flux<String>> updates() {
|
||||
return flux -> flux.subscribe(value -> list.add(value));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<String> bareUpdates() {
|
||||
return value -> list.add(value);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Supplier<Flux<String>> bang() {
|
||||
return () -> Flux.fromArray(new String[] { "foo", "bar" }).map(value -> {
|
||||
|
||||
Reference in New Issue
Block a user