Ensure a concrete type with parametrric subtype is detected

If user defines their own @Beans from conrete types that implement
Function<...> then their type signature is detectable from the
class.
This commit is contained in:
Dave Syer
2017-11-20 15:34:06 +00:00
parent 7bf7b8b9c0
commit 8459fb4e30
2 changed files with 26 additions and 1 deletions

View File

@@ -211,6 +211,17 @@ public class ContextFunctionCatalogAutoConfigurationTests {
.isAssignableFrom(Integer.class);
}
@Test
public void nonParametericTypeFunction() {
create(NonParametricTypeSingletonConfiguration.class);
assertThat(context.getBean("function")).isInstanceOf(Function.class);
assertThat(catalog.lookupFunction("function")).isInstanceOf(Function.class);
assertThat(inspector.getInputType(catalog.lookupFunction("function")))
.isAssignableFrom(Integer.class);
assertThat(inspector.getInputWrapper(catalog.lookupFunction("function")))
.isAssignableFrom(Integer.class);
}
@Test
public void componentScanBeanFunction() {
create(ComponentScanBeanConfiguration.class);
@@ -487,6 +498,15 @@ public class ContextFunctionCatalogAutoConfigurationTests {
}
}
@EnableAutoConfiguration
@Configuration
protected static class NonParametricTypeSingletonConfiguration {
@Bean
public SingletonFunction function() {
return new SingletonFunction();
}
}
protected static class SingletonFunction implements Function<Integer, String> {
@Override