Polished adapter initializers consolidation effort
- Added ability to retrieve input type from FunctionRegistration (if available) in AbstractSpringFunctionAdapterInitializer
- Removed azure/AzureSpringFunctionInitializer and aws/SpringFunctionInitializer
- Added additional tests in AWS and Azure modules
- See 0189c578ef for additional info
This commit is contained in:
@@ -34,6 +34,9 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class SpringBootApiGatewayRequestHandlerTests {
|
||||
|
||||
private SpringBootApiGatewayRequestHandler handler;
|
||||
@@ -41,8 +44,6 @@ public class SpringBootApiGatewayRequestHandlerTests {
|
||||
@Test
|
||||
public void functionBean() {
|
||||
this.handler = new SpringBootApiGatewayRequestHandler(FunctionConfig.class);
|
||||
this.handler.initialize();
|
||||
|
||||
APIGatewayProxyRequestEvent request = new APIGatewayProxyRequestEvent();
|
||||
request.setBody("{\"value\":\"foo\"}");
|
||||
|
||||
@@ -58,8 +59,6 @@ public class SpringBootApiGatewayRequestHandlerTests {
|
||||
public void functionMessageBean() {
|
||||
this.handler = new SpringBootApiGatewayRequestHandler(
|
||||
FunctionMessageConfig.class);
|
||||
this.handler.initialize();
|
||||
|
||||
APIGatewayProxyRequestEvent request = new APIGatewayProxyRequestEvent();
|
||||
request.setBody("{\"value\":\"foo\"}");
|
||||
|
||||
|
||||
@@ -111,7 +111,6 @@ public class SpringBootKinesisEventHandlerTests {
|
||||
@Test
|
||||
public void functionBeanHandlesKinesisEvent() throws Exception {
|
||||
this.handler = new SpringBootKinesisEventHandler<>(FunctionConfig.class);
|
||||
this.handler.initialize();
|
||||
|
||||
KinesisEvent event = asKinesisEvent(singletonList(new Foo("foo")));
|
||||
|
||||
@@ -123,7 +122,6 @@ public class SpringBootKinesisEventHandlerTests {
|
||||
@Test
|
||||
public void functionBeanHandlesAggregatedKinesisEvent() throws Exception {
|
||||
this.handler = new SpringBootKinesisEventHandler<>(FunctionConfig.class);
|
||||
this.handler.initialize();
|
||||
|
||||
List<Foo> events = asList(new Foo("foo"), new Foo("bar"), new Foo("baz"));
|
||||
KinesisEvent aggregatedEvent = asAggregatedKinesisEvent(events);
|
||||
@@ -137,7 +135,6 @@ public class SpringBootKinesisEventHandlerTests {
|
||||
@Test
|
||||
public void functionMessageBean() throws Exception {
|
||||
this.handler = new SpringBootKinesisEventHandler<>(FunctionMessageConfig.class);
|
||||
this.handler.initialize();
|
||||
|
||||
KinesisEvent event = asKinesisEvent(asList(new Foo("foo"), new Foo("bar")));
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public class SpringBootRequestHandlerTests {
|
||||
@Test
|
||||
public void functionBean() throws Exception {
|
||||
this.handler = new SpringBootRequestHandler<Foo, Bar>(FunctionConfig.class);
|
||||
this.handler.initialize();
|
||||
Object output = this.handler.handleRequest(new Foo("foo"), null);
|
||||
assertThat(output).isInstanceOf(Bar.class);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||
import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration;
|
||||
@@ -58,6 +59,46 @@ public class SpringBootStreamHandlerTests {
|
||||
assertThat(output.toString()).isEqualTo("{\"value\":\"FOO\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void functionNonFluxBeanNoCatalog() throws Exception {
|
||||
this.handler = new SpringBootStreamHandler(NoCatalogNonFluxFunctionConfig.class);
|
||||
this.handler.initialize(null);
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
this.handler.handleRequest(
|
||||
new ByteArrayInputStream("{\"value\":\"foo\"}".getBytes()), output, null);
|
||||
assertThat(output.toString()).isEqualTo("{\"value\":\"FOO\"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void functionFluxBeanNoCatalog() throws Exception {
|
||||
this.handler = new SpringBootStreamHandler(NoCatalogFluxFunctionConfig.class);
|
||||
this.handler.initialize(null);
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
this.handler.handleRequest(
|
||||
new ByteArrayInputStream("{\"value\":\"foo\"}".getBytes()), output, null);
|
||||
assertThat(output.toString()).isEqualTo("{\"value\":\"FOO\"}");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class NoCatalogNonFluxFunctionConfig {
|
||||
|
||||
@Bean
|
||||
public Function<Foo, Bar> function() {
|
||||
return foo -> new Bar(foo.getValue().toUpperCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class NoCatalogFluxFunctionConfig {
|
||||
|
||||
@Bean
|
||||
public Function<Flux<Foo>, Flux<Bar>> function() {
|
||||
return flux -> flux.map(foo -> new Bar(foo.getValue().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Import({ ContextFunctionCatalogAutoConfiguration.class,
|
||||
JacksonAutoConfiguration.class })
|
||||
|
||||
Reference in New Issue
Block a user