GH-662 Fix support for reactive functions in AWS

This commit also includes other minor fixes around CustomRuntime which was getting in the way of this specific issue
 Added lookup for _HANDLER env variable
 Added few tests (will need more)
 Added support for Iterable for reactive functions

Resolves #662
This commit is contained in:
Oleg Zhurakousky
2021-04-08 15:56:46 +02:00
parent cf58cdc700
commit fc42819357
7 changed files with 134 additions and 45 deletions

View File

@@ -20,6 +20,7 @@ package org.springframework.cloud.function.context.catalog;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -593,6 +594,24 @@ public class BeanFactoryAwareFunctionRegistryTests {
assertThat(resultList).isEmpty();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testArrayPayloadOnFluxFunction() throws Exception {
FunctionCatalog catalog = this.configureCatalog(SampleFunctionConfiguration.class);
FunctionInvocationWrapper lmFunction = catalog.lookup("uppercaseFlux", "application/json");
lmFunction.setSkipOutputConversion(true);
List<String> list = new ArrayList<>();
list.add("Ricky");
list.add("Julien");
list.add("Bubbles");
Publisher p = (Publisher) lmFunction.apply(MessageBuilder.withPayload(list).setHeader(MessageHeaders.CONTENT_TYPE, "application/json").build());
List<Object> result = new ArrayList<>();
for (Object value : Flux.from(p).toIterable()) {
result.add(value);
}
assertThat(result.size()).isEqualTo(3);
}
@EnableAutoConfiguration