@@ -55,10 +55,17 @@ public class ContextFunctionCatalogAutoConfigurationKotlinTests {
|
||||
@Test
|
||||
public void typeDiscoveryTests() {
|
||||
create(new Class[] { KotlinLambdasConfiguration.class,
|
||||
SimpleConfiguration.class });
|
||||
SimpleConfiguration.class,
|
||||
KotlinComponentFunction.class});
|
||||
|
||||
FunctionCatalog functionCatalog = this.context.getBean(FunctionCatalog.class);
|
||||
|
||||
FunctionInvocationWrapper kotlinComponentFunction = functionCatalog.lookup("kotlinComponentFunction");
|
||||
assertThat(kotlinComponentFunction.isFunction()).isTrue();
|
||||
assertThat(kotlinComponentFunction.getInputType().getTypeName()).isEqualTo("java.lang.String");
|
||||
assertThat(kotlinComponentFunction.getOutputType().getTypeName()).isEqualTo("java.lang.String");
|
||||
assertThat(kotlinComponentFunction.apply("bob")).isEqualTo("BOB");
|
||||
|
||||
FunctionInvocationWrapper kotlinFunction = functionCatalog.lookup("kotlinFunction");
|
||||
assertThat(kotlinFunction.isFunction()).isTrue();
|
||||
assertThat(kotlinFunction.getInputType()).isEqualTo(String.class);
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.springframework.cloud.function.kotlin
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import java.util.function.Function
|
||||
|
||||
@Component
|
||||
class KotlinComponentFunction : Function<String, String> {
|
||||
|
||||
override fun apply(t: String): String {
|
||||
return t.uppercase();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user