GH-794 Address regression with input type conversion of Maps
Resolves #794
This commit is contained in:
@@ -1067,7 +1067,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
convertedInput = this.convertNonMessageInputIfNecessary(type, input, JsonMapper.isJsonString(input) || input instanceof Map);
|
convertedInput = this.convertNonMessageInputIfNecessary(type, input, JsonMapper.isJsonString(input));
|
||||||
if (convertedInput != null && logger.isDebugEnabled()) {
|
if (convertedInput != null && logger.isDebugEnabled()) {
|
||||||
logger.debug("Converted input: " + input + " to: " + convertedInput);
|
logger.debug("Converted input: " + input + " to: " + convertedInput);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -526,6 +527,18 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
registry.register(e);
|
registry.register(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
|
@Test
|
||||||
|
public void testNoConversionOnInputMapIfInputIsMap() {
|
||||||
|
FunctionCatalog catalog = this.configureCatalog();
|
||||||
|
Function f = catalog.lookup("maptopojo");
|
||||||
|
Person p = new Person("John", 123);
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("person", p);
|
||||||
|
map.put("foo", "foo");
|
||||||
|
assertThat(f.apply(map)).isInstanceOf(Person.class);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Test
|
@Test
|
||||||
public void testValueWrappedInMessageIfNecessary() {
|
public void testValueWrappedInMessageIfNecessary() {
|
||||||
@@ -930,7 +943,7 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
@Bean
|
@Bean
|
||||||
public Function<Map<String, Object>, Person> maptopojo() {
|
public Function<Map<String, Object>, Person> maptopojo() {
|
||||||
return map -> {
|
return map -> {
|
||||||
Person person = new Person((String) map.get("name"), Integer.parseInt((String) map.get("id")));
|
Person person = (Person) map.get("person");
|
||||||
return person;
|
return person;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user