GH-699 Fixed a bug where Kotlin Lambda was incorrectly converted to a consumer function

Fixed consumer type

Fixed tests

Added javadoc @author tag

Resolves #699
Resolves #700
This commit is contained in:
Tsypov Dmitriy
2021-05-19 20:37:31 +07:00
committed by Oleg Zhurakousky
parent 238ac301df
commit 0db0a2f555
2 changed files with 41 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.cloud.function.kotlin;
import java.lang.reflect.ParameterizedType;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -67,10 +68,9 @@ public class ContextFunctionCatalogAutoConfigurationKotlinTests {
function = this.context.getBean("kotlinConsumer");
functionType = (ParameterizedType) FunctionTypeUtils.discoverFunctionType(function, "kotlinConsumer", this.context);
assertThat(functionType.getRawType().getTypeName()).isEqualTo(Function.class.getName());
assertThat(functionType.getActualTypeArguments().length).isEqualTo(2);
assertThat(functionType.getRawType().getTypeName()).isEqualTo(Consumer.class.getName());
assertThat(functionType.getActualTypeArguments().length).isEqualTo(1);
assertThat(functionType.getActualTypeArguments()[0].getTypeName()).isEqualTo(String.class.getName());
assertThat(functionType.getActualTypeArguments()[1].getTypeName()).isEqualTo("kotlin.Unit");
function = this.context.getBean("kotlinSupplier");
functionType = (ParameterizedType) FunctionTypeUtils.discoverFunctionType(function, "kotlinSupplier", this.context);