GH-208 polishing ec68f64 commit
Ensured that the composed Supplier is of type Mono<Void> Fix tests
This commit is contained in:
@@ -71,6 +71,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -333,10 +334,10 @@ public class ContextFunctionCatalogAutoConfiguration {
|
||||
if (b instanceof FluxConsumer) {
|
||||
if (supplier instanceof FluxSupplier) {
|
||||
FluxConsumer<Object> fConsumer = ((FluxConsumer<Object>)b);
|
||||
return (Supplier<Flux<Void>>) () -> supplier.get().compose(v -> fConsumer.apply(supplier.get()));
|
||||
return (Supplier<Mono<Void>>) () -> Mono.from(supplier.get().compose(v -> fConsumer.apply(supplier.get())));
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException("The provided supplier is terminal (i.e., already composed with Consumer) "
|
||||
throw new IllegalStateException("The provided supplier is finite (i.e., already composed with Consumer) "
|
||||
+ "therefore it can not be composed with another consumer");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@ public class BeanFactoryFunctionCatalogTests {
|
||||
processor.register(new FunctionRegistration<>(s, "supplier"));
|
||||
Consumer<String> c = x -> ref.set(x.toUpperCase());
|
||||
processor.register(new FunctionRegistration<>(c, "consumer"));
|
||||
Supplier<Flux<Void>> f = processor.lookup("supplier|consumer");
|
||||
f.get().blockFirst();
|
||||
Supplier<Mono<Void>> f = processor.lookup("supplier|consumer");
|
||||
((Mono<Void>)f.get()).block();
|
||||
assertThat(ref.get()).isEqualTo("HELLO");
|
||||
}
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ public class ContextFunctionPostProcessorTests {
|
||||
public void supplierAndConsumer() {
|
||||
processor.register(new FunctionRegistration<Supplier<String>>(() -> "foo", "supplier"));
|
||||
processor.register(new FunctionRegistration<Consumer<String>>(System.out::println, "consumer"));
|
||||
Supplier<Flux<Void>> supplier = (Supplier<Flux<Void>>) processor.lookupSupplier("supplier|consumer");
|
||||
assertNull(supplier.get().blockFirst());
|
||||
Supplier<Mono<Void>> supplier = (Supplier<Mono<Void>>) processor.lookupSupplier("supplier|consumer");
|
||||
assertNull(supplier.get().block());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user