GH-243, GH-257 Added reactive consumer wrapper
- Added wrapper for an already reactive consumer to ensure that consumers can be consistently represented as Function<Flux, Mono> - Fixed the big that deal with inconsistent result in web environments due to inconsistent representation of the Consumers - Polished tests Resolves #243 Resolves #257
This commit is contained in:
@@ -124,14 +124,23 @@ public class HttpPostIntegrationTests {
|
||||
assertThat(result.getBody()).isEqualTo(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFoosFlux() throws Exception {
|
||||
ResponseEntity<String> result = this.rest.exchange(RequestEntity
|
||||
.post(new URI("/addFoosFlux")).contentType(MediaType.APPLICATION_JSON)
|
||||
.body("[{\"value\":\"foo\"},{\"value\":\"bar\"}]"), String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED);
|
||||
assertThat(this.test.list).hasSize(2);
|
||||
assertThat(result.getBody()).isEqualTo(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bareUpdates() throws Exception {
|
||||
ResponseEntity<String> result = this.rest.exchange(RequestEntity
|
||||
.post(new URI("/bareUpdates")).contentType(MediaType.APPLICATION_JSON)
|
||||
.body("[\"one\",\"two\"]"), String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED);
|
||||
assertThat(this.test.list).hasSize(2);
|
||||
assertThat(result.getBody()).isEqualTo("[]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,12 +408,6 @@ public class HttpPostIntegrationTests {
|
||||
};
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public Function<byte[],?> byteArrayInputFunction() {
|
||||
//// return value -> new Foo(value.getValue().trim().toUpperCase());
|
||||
// throw new UnsupportedOperationException("boom?");
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Integer>, Flux<String>> wrap() {
|
||||
return flux -> flux.log().map(value -> ".." + value + "..");
|
||||
@@ -437,13 +440,22 @@ public class HttpPostIntegrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<Flux<Foo>> addFoos() {
|
||||
public Consumer<Flux<Foo>> addFoosFlux() {
|
||||
return flux -> flux.subscribe(value -> this.list.add(value.getValue()));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<Foo> addFoos() {
|
||||
return value -> {
|
||||
this.list.add(value.getValue());
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Consumer<String> bareUpdates() {
|
||||
return value -> this.list.add(value);
|
||||
return value -> {
|
||||
this.list.add(value);
|
||||
};
|
||||
}
|
||||
|
||||
@Bean("not/a")
|
||||
|
||||
@@ -128,9 +128,8 @@ public class HttpPostIntegrationTests {
|
||||
ResponseEntity<String> result = this.rest.exchange(RequestEntity
|
||||
.post(new URI("/bareUpdates")).contentType(MediaType.APPLICATION_JSON)
|
||||
.body("[\"one\",\"two\"]"), String.class);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.ACCEPTED);
|
||||
assertThat(this.test.list).hasSize(2);
|
||||
assertThat(result.getBody()).isEqualTo("[]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user