From ec3f324ff747944a23c6ba9ed29a8ce1ed3e72dc Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 30 Nov 2021 22:09:27 +0100 Subject: [PATCH] GH-768 Modified test to try to force the issue --- .../BeanFactoryAwareFunctionRegistryTests.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistryTests.java b/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistryTests.java index d4234d89b..47318beb8 100644 --- a/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistryTests.java +++ b/spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/catalog/BeanFactoryAwareFunctionRegistryTests.java @@ -647,8 +647,10 @@ public class BeanFactoryAwareFunctionRegistryTests { FunctionCatalog catalog = this.configureCatalog(SCF_GH_768ConfigurationAsFunction.class); Function function = catalog.lookup("echo"); - String result = (String) function.apply("{\"ricky\":{\"name\":\"ricky\"}}"); - assertThat(result).isEqualTo("{ricky=Person: ricky/0}"); + JsonMapper mapper = this.context.getBean(JsonMapper.class); + String date = mapper.toString(new Date()); + String result = (String) function.apply("{\"date\":" + date + "}"); + assertThat(result).startsWith("{date="); } @SuppressWarnings({ "rawtypes", "unchecked" }) @@ -1131,12 +1133,12 @@ public class BeanFactoryAwareFunctionRegistryTests { @EnableAutoConfiguration public static class SCF_GH_768ConfigurationAsFunction { @Bean - public Function, String> echoToString() { - return persons -> { - for (Entry entry : persons.entrySet()) { - assertThat(entry.getValue().getName()).isNotEmpty(); // would fail if value would not be converted to Person + public Function, String> echoToString() { + return data -> { + for (Entry dataEntry : data.entrySet()) { + assertThat(dataEntry.getValue()).isInstanceOf(Date.class); // would fail if value would not be converted to Person } - return persons.toString(); + return data.toString(); }; } }