Skip to content

Commit

Permalink
GH-1225 Add additional Kotlin test to verify the regression
Browse files Browse the repository at this point in the history
Resolves #1225
  • Loading branch information
olegz committed Jan 8, 2025
1 parent 5b4c557 commit 26b4a59
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.ResolvableType;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -57,7 +59,8 @@ public void typeDiscoveryTests() {
create(new Class[] { KotlinLambdasConfiguration.class,
SimpleConfiguration.class,
KotlinComponentFunction.class,
ComponentUppercase.class});
ComponentUppercase.class,
ComponentWithUnitReturn.class});

FunctionCatalog functionCatalog = this.context.getBean(FunctionCatalog.class);

Expand All @@ -72,6 +75,10 @@ public void typeDiscoveryTests() {
assertThat(kotlinFunction.getInputType()).isEqualTo(String.class);
assertThat(kotlinFunction.getOutputType()).isEqualTo(String.class);

FunctionInvocationWrapper componentWithUnitReturn = functionCatalog.lookup("componentWithUnitReturn");
assertThat(componentWithUnitReturn.isConsumer()).isTrue();
assertThat(componentWithUnitReturn.getInputType()).isEqualTo(ResolvableType.forClassWithGenerics(Message.class, String.class).getType());

FunctionInvocationWrapper kotlinConsumer = functionCatalog.lookup("kotlinConsumer");
assertThat(kotlinConsumer.isConsumer()).isTrue();
assertThat(kotlinConsumer.getInputType()).isEqualTo(String.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.springframework.cloud.function.kotlin

import org.springframework.messaging.Message
import org.springframework.stereotype.Component

@Component
class ComponentWithUnitReturn() : (Message<String>) -> Unit {
override fun invoke(message: Message<String>) {
println(message.payload)
}
}

0 comments on commit 26b4a59

Please sign in to comment.