GH-794 Address regression with input type conversion of Maps

Resolves #794
This commit is contained in:
Oleg Zhurakousky
2022-01-26 12:48:51 +01:00
parent c6bc4f553f
commit 536d3d6e80
2 changed files with 15 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -530,6 +531,18 @@ public class BeanFactoryAwareFunctionRegistryTests {
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" })
@Test
public void testValueWrappedInMessageIfNecessary() {
@@ -934,7 +947,7 @@ public class BeanFactoryAwareFunctionRegistryTests {
@Bean
public Function<Map<String, Object>, Person> maptopojo() {
return map -> {
Person person = new Person((String) map.get("name"), Integer.parseInt((String) map.get("id")));
Person person = (Person) map.get("person");
return person;
};
}