GH-640 Fix NPE with non-Message json conversion
Resolves #640 Added test
This commit is contained in:
@@ -86,6 +86,21 @@ public class SimpleFunctionRegistryTests {
|
||||
this.conversionService = new DefaultConversionService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSCF640() {
|
||||
Echo function = new Echo();
|
||||
FunctionRegistration<Echo> registration = new FunctionRegistration<>(
|
||||
function, "echo").type(FunctionType.of(Echo.class));
|
||||
SimpleFunctionRegistry catalog = new SimpleFunctionRegistry(this.conversionService, this.messageConverter,
|
||||
new JacksonMapper(new ObjectMapper()));
|
||||
catalog.register(registration);
|
||||
|
||||
FunctionInvocationWrapper lookedUpFunction = catalog.lookup("echo");
|
||||
Object result = lookedUpFunction.apply("{\"HELLO\":\"WORLD\"}");
|
||||
assertThat(result).isNotInstanceOf(Message.class);
|
||||
assertThat(result).isEqualTo("{\"HELLO\":\"WORLD\"}");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSCF588() {
|
||||
@@ -468,6 +483,15 @@ public class SimpleFunctionRegistryTests {
|
||||
|
||||
}
|
||||
|
||||
private static class Echo implements Function<Object, Object> {
|
||||
|
||||
@Override
|
||||
public Object apply(Object t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class UpperCaseMessage
|
||||
implements Function<Message<String>, Message<String>> {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user