This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4ba9e8544f04299d1557bc44d4e50d207adca2af Author: Andrea Cosentino <[email protected]> AuthorDate: Thu Apr 9 15:58:14 2020 +0200 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ecs fixed CS --- .../component/aws2/ecs/ECS2ProducerSpringTest.java | 22 ++++++++++++++++++++- .../camel/component/aws2/ecs/ECS2ProducerTest.java | 23 +++++++++++++++++++++- .../aws2/ecs/ECSComponentSpringTest-context.xml | 5 +++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java index 286f9d7..b5d7858 100644 --- a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java +++ b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerSpringTest.java @@ -26,6 +26,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import software.amazon.awssdk.services.ecs.model.CreateClusterResponse; import software.amazon.awssdk.services.ecs.model.DeleteClusterResponse; import software.amazon.awssdk.services.ecs.model.DescribeClustersResponse; +import software.amazon.awssdk.services.ecs.model.ListClustersRequest; import software.amazon.awssdk.services.ecs.model.ListClustersResponse; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -36,7 +37,7 @@ public class ECS2ProducerSpringTest extends CamelSpringTestSupport { private MockEndpoint mock; @Test - public void kmsListClustersTest() throws Exception { + public void ecsListClustersTest() throws Exception { mock.expectedMessageCount(1); Exchange exchange = template.request("direct:listClusters", new Processor() { @@ -52,6 +53,25 @@ public class ECS2ProducerSpringTest extends CamelSpringTestSupport { assertEquals(1, resultGet.clusterArns().size()); assertEquals("Test", resultGet.clusterArns().get(0)); } + + @Test + public void ecsListClustersPojoTest() throws Exception { + + mock.expectedMessageCount(1); + Exchange exchange = template.request("direct:listClustersPojo", new Processor() { + @Override + public void process(Exchange exchange) throws Exception { + exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters); + exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build()); + } + }); + + assertMockEndpointsSatisfied(); + + ListClustersResponse resultGet = (ListClustersResponse)exchange.getIn().getBody(); + assertEquals(1, resultGet.clusterArns().size()); + assertEquals("Test", resultGet.clusterArns().get(0)); + } @Test public void ecsCreateClusterTest() throws Exception { diff --git a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java index b687e28..142ecab 100644 --- a/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java +++ b/components/camel-aws2-ecs/src/test/java/org/apache/camel/component/aws2/ecs/ECS2ProducerTest.java @@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test; import software.amazon.awssdk.services.ecs.model.CreateClusterResponse; import software.amazon.awssdk.services.ecs.model.DeleteClusterResponse; import software.amazon.awssdk.services.ecs.model.DescribeClustersResponse; +import software.amazon.awssdk.services.ecs.model.ListClustersRequest; import software.amazon.awssdk.services.ecs.model.ListClustersResponse; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -40,7 +41,7 @@ public class ECS2ProducerTest extends CamelTestSupport { private MockEndpoint mock; @Test - public void kmsListClustersTest() throws Exception { + public void ecsListClustersTest() throws Exception { mock.expectedMessageCount(1); Exchange exchange = template.request("direct:listClusters", new Processor() { @@ -56,6 +57,25 @@ public class ECS2ProducerTest extends CamelTestSupport { assertEquals(1, resultGet.clusterArns().size()); assertEquals("Test", resultGet.clusterArns().get(0)); } + + @Test + public void ecsListClustersPojoTest() throws Exception { + + mock.expectedMessageCount(1); + Exchange exchange = template.request("direct:listClustersPojo", new Processor() { + @Override + public void process(Exchange exchange) throws Exception { + exchange.getIn().setHeader(ECS2Constants.OPERATION, ECS2Operations.listClusters); + exchange.getIn().setBody(ListClustersRequest.builder().maxResults(10).build()); + } + }); + + assertMockEndpointsSatisfied(); + + ListClustersResponse resultGet = (ListClustersResponse)exchange.getIn().getBody(); + assertEquals(1, resultGet.clusterArns().size()); + assertEquals("Test", resultGet.clusterArns().get(0)); + } @Test public void ecsCreateClusterTest() throws Exception { @@ -117,6 +137,7 @@ public class ECS2ProducerTest extends CamelTestSupport { @Override public void configure() throws Exception { from("direct:listClusters").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters").to("mock:result"); + from("direct:listClustersPojo").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters&pojoRequest=true").to("mock:result"); from("direct:createCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=createCluster").to("mock:result"); from("direct:deleteCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=deleteCluster").to("mock:result"); from("direct:describeCluster").to("aws2-ecs://test?ecsClient=#amazonEcsClient&operation=describeCluster").to("mock:result"); diff --git a/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml b/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml index fe4ab20..8b3c72e 100644 --- a/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml +++ b/components/camel-aws2-ecs/src/test/resources/org/apache/camel/component/aws2/ecs/ECSComponentSpringTest-context.xml @@ -30,6 +30,11 @@ <to uri="mock:result"/> </route> <route> + <from uri="direct:listClustersPojo"/> + <to uri="aws2-ecs://test?ecsClient=#amazonEcsClient&operation=listClusters&pojoRequest=true"/> + <to uri="mock:result"/> + </route> + <route> <from uri="direct:createCluster"/> <to uri="aws2-ecs://test?ecsClient=#amazonEcsClient&operation=createCluster"/> <to uri="mock:result"/>
