Ensure a function is inspectable as itself and its wrapper

Since a function is wrapper in a FluxWrapper (and possibly also
an Isolated), the link is lost between the bean and the type
metadata without this change.
This commit is contained in:
Dave Syer
2018-03-01 09:10:14 +00:00
parent 955e99bfe3
commit dc008cc24d
4 changed files with 100 additions and 12 deletions

View File

@@ -331,6 +331,20 @@ public class ContextFunctionCatalogAutoConfigurationTests {
}
}
@Test
public void simpleFunction() {
create(SimpleConfiguration.class);
Object bean = context.getBean("function");
assertThat(bean).isInstanceOf(Function.class);
Function<Flux<String>, Flux<String>> function = catalog.lookup(Function.class,
"function");
assertThat(function.apply(Flux.just("foo")).blockFirst()).isEqualTo("FOO");
assertThat(bean).isNotSameAs(function);
assertThat(inspector.getRegistration(bean)).isNotNull();
assertThat(inspector.getRegistration(bean).getType())
.isEqualTo(inspector.getRegistration(function).getType());
}
@Test
public void simpleSupplier() {
create(SimpleConfiguration.class);