GH-640 Fix NPE with non-Message json conversion

Resolves #640

Added test
This commit is contained in:
Oleg Zhurakousky
2021-02-05 16:03:45 +01:00
parent 315ed4612d
commit c4dfffe0ba
2 changed files with 27 additions and 3 deletions

View File

@@ -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>> {