GH-1615 Removed conversion hint passing

Removed conversion hint passing from FunctionInvoker
Added missing test

Resolves #1615
This commit is contained in:
Oleg Zhurakousky
2019-02-14 22:04:13 +01:00
parent 4522e654f3
commit 7e0f42ed34
2 changed files with 48 additions and 2 deletions

View File

@@ -169,8 +169,7 @@ class FunctionInvoker<I, O> implements Function<Flux<Message<I>>, Flux<Message<O
}
else {
returnMessage = (Message<O>) (value instanceof Message ? value
: this.messageConverter.toMessage(value, originalMessage.getHeaders(),
this.outputClass));
: this.messageConverter.toMessage(value, originalMessage.getHeaders()));
if (returnMessage == null
&& value.getClass().isAssignableFrom(this.outputClass)) {
returnMessage = wrapOutputToMessage(value, originalMessage);

View File

@@ -49,6 +49,7 @@ import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Oleg Zhurakousky
* @author Tolga Kavukcu
@@ -58,6 +59,30 @@ public class FunctionInvokerTests {
private static String testWithFluxedConsumerValue;
@Test
public void testSimpleEchoConfiguration() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
TestChannelBinderConfiguration.getCompleteConfiguration(
SimpleEchoConfiguration.class))
.web(WebApplicationType.NONE)
.run("--spring.jmx.enabled=false",
"--spring.cloud.stream.function.definition=func")) {
InputDestination inputDestination = context.getBean(InputDestination.class);
OutputDestination outputDestination = context
.getBean(OutputDestination.class);
Message<byte[]> inputMessage = MessageBuilder
.withPayload("{\"name\":\"bob\"}".getBytes()).build();
inputDestination.send(inputMessage);
Message<byte[]> outputMessage = outputDestination.receive();
System.out.println("Received: " + new String(outputMessage.getPayload()));
assertThat(outputMessage.getPayload()).isEqualTo("{\"name\":\"bob\"}".getBytes());
}
}
@Test
public void testFunctionHonorsOutboundBindingContentType() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(
@@ -304,6 +329,28 @@ public class FunctionInvokerTests {
}
}
@EnableAutoConfiguration
@EnableBinding(Processor.class)
public static class SimpleEchoConfiguration {
@Bean
public Function<Person, Person> func() {
return x -> x;
}
public static class Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
@EnableAutoConfiguration
@EnableBinding(Processor.class)
public static class ConverterDoesNotProduceCTConfiguration {