You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2019/05/14 07:02:34 UTC

[servicecomb-java-chassis] 03/03: [SCB-1269][WIP][WEAK] update UT

This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch weak-contract-type
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit 6516edbad7f1f0caec96ca5ca6eb201fa0ceeeba
Author: wujimin <wu...@huawei.com>
AuthorDate: Thu Apr 25 11:23:27 2019 +0800

    [SCB-1269][WIP][WEAK] update UT
---
 .../JaxRSProducerArgumentsMapperFactoryTest.java   | 229 ---------------------
 .../producer/ProducerBeanParamMapperTest.java      | 146 -------------
 .../ProducerSpringMVCQueryObjectMapperTest.java    | 183 ----------------
 .../invocation/arguments/producer/TestJaxrs.java   |  76 +++++++
 .../invocation/arguments/producer/TestPojo.java    |  83 ++++++++
 .../arguments/producer/TestSpringmvc.java          |  75 +++++++
 6 files changed, 234 insertions(+), 558 deletions(-)

diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/JaxRSProducerArgumentsMapperFactoryTest.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/JaxRSProducerArgumentsMapperFactoryTest.java
deleted file mode 100644
index 7519203..0000000
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/JaxRSProducerArgumentsMapperFactoryTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.swagger.invocation.arguments.producer;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.http.Part;
-import javax.ws.rs.BeanParam;
-import javax.ws.rs.CookieParam;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
-
-import org.apache.servicecomb.swagger.generator.jaxrs.JaxrsSwaggerGeneratorContext;
-import org.apache.servicecomb.swagger.generator.pojo.PojoSwaggerGeneratorContext;
-import org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapperConfig;
-import org.apache.servicecomb.swagger.invocation.arguments.ProviderParameter;
-import org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapperFactory.ParamWrapper;
-import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Test;
-
-import io.swagger.models.parameters.CookieParameter;
-import io.swagger.models.parameters.FormParameter;
-import io.swagger.models.parameters.HeaderParameter;
-import io.swagger.models.parameters.Parameter;
-import io.swagger.models.parameters.PathParameter;
-import io.swagger.models.parameters.QueryParameter;
-import mockit.Deencapsulation;
-
-public class JaxRSProducerArgumentsMapperFactoryTest {
-
-  private final JaxRSProducerArgumentsMapperFactory producerArgumentsMapperFactory = new JaxRSProducerArgumentsMapperFactory();
-
-  @Test
-  public void canProcess() {
-    ArgumentsMapperConfig argumentsMapperConfig = new ArgumentsMapperConfig();
-
-    argumentsMapperConfig.setSwaggerGeneratorContext(new JaxrsSwaggerGeneratorContext());
-    Assert.assertTrue(producerArgumentsMapperFactory.canProcess(argumentsMapperConfig));
-
-    argumentsMapperConfig.setSwaggerGeneratorContext(new PojoSwaggerGeneratorContext());
-    Assert.assertFalse(producerArgumentsMapperFactory.canProcess(argumentsMapperConfig));
-  }
-
-  @Test
-  public void findAggregatedParamNames() throws NoSuchMethodException {
-    Map<String, ProviderParameter> providerParamMap = new HashMap<>();
-    providerParamMap.put("qqq", new ProviderParameter(1, String.class, "qqq"));
-    Method aggregatedTestParamMethod = AggregatedParamProvider.class
-        .getMethod("aggregatedParamTest", AggregatedTestParam.class);
-    Annotation beanParamAnnotation = aggregatedTestParamMethod.getParameterAnnotations()[0][0];
-    providerParamMap.put("aggregatedTestParam",
-        new ProviderParameter(0, AggregatedTestParam.class, "aggregatedTestParam")
-            .setAnnotations(new Annotation[] {beanParamAnnotation}));
-
-    Map<String, ParamWrapper<Parameter>> swaggerParamMap = new HashMap<>();
-    Parameter swaggerParam = new PathParameter().name("pathSwaggerParam");
-    swaggerParamMap.put("pathSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(0));
-    swaggerParam = new HeaderParameter().name("headerSwaggerParam");
-    swaggerParamMap.put("headerSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(1));
-    swaggerParam = new CookieParameter().name("intSwaggerVal");
-    swaggerParamMap.put("intSwaggerVal", new ParamWrapper<>(swaggerParam).setIndex(2));
-    swaggerParam = new FormParameter().name("longSwaggerVal");
-    swaggerParamMap.put("longSwaggerVal", new ParamWrapper<>(swaggerParam).setIndex(3));
-    swaggerParam = new QueryParameter().name("querySwaggerParam");
-    swaggerParamMap.put("querySwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(4));
-    swaggerParam = new FormParameter().name("uploadSwaggerParam");
-    swaggerParamMap.put("uploadSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(5));
-    swaggerParam = new QueryParameter().name("qqq");
-    swaggerParamMap.put("qqq", new ParamWrapper<>(swaggerParam).setIndex(6));
-
-    Set<String> aggregatedParamNames = producerArgumentsMapperFactory
-        .findAggregatedParamNames(providerParamMap, swaggerParamMap);
-    Assert.assertThat(aggregatedParamNames, Matchers.contains("aggregatedTestParam"));
-  }
-
-  @Test
-  public void generateAggregatedParamMapper() throws NoSuchMethodException {
-    Map<String, ProviderParameter> providerParamMap = new HashMap<>();
-    providerParamMap.put("qqq", new ProviderParameter(1, String.class, "qqq"));
-    Method aggregatedTestParamMethod = AggregatedParamProvider.class
-        .getMethod("aggregatedParamTest", AggregatedTestParam.class);
-    Annotation beanParamAnnotation = aggregatedTestParamMethod.getParameterAnnotations()[0][0];
-    providerParamMap.put("aggregatedTestParam",
-        new ProviderParameter(0, AggregatedTestParam.class, "aggregatedTestParam")
-            .setAnnotations(new Annotation[] {beanParamAnnotation}));
-
-    Map<String, ParamWrapper<Parameter>> swaggerParamMap = new HashMap<>();
-    Parameter swaggerParam = new PathParameter().name("pathSwaggerParam");
-    swaggerParamMap.put("pathSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(0));
-    swaggerParam = new HeaderParameter().name("headerSwaggerParam");
-    swaggerParamMap.put("headerSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(1));
-    swaggerParam = new CookieParameter().name("intSwaggerVal");
-    swaggerParamMap.put("intSwaggerVal", new ParamWrapper<>(swaggerParam).setIndex(2));
-    swaggerParam = new FormParameter().name("longSwaggerVal");
-    swaggerParamMap.put("longSwaggerVal", new ParamWrapper<>(swaggerParam).setIndex(3));
-    swaggerParam = new QueryParameter().name("querySwaggerParam");
-    swaggerParamMap.put("querySwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(4));
-    swaggerParam = new FormParameter().name("uploadSwaggerParam");
-    swaggerParamMap.put("uploadSwaggerParam", new ParamWrapper<>(swaggerParam).setIndex(5));
-    swaggerParam = new QueryParameter().name("qqq");
-    swaggerParamMap.put("qqq", new ParamWrapper<>(swaggerParam).setIndex(6));
-
-    Set<String> aggregatedParamNames = new HashSet<>();
-    aggregatedParamNames.add("aggregatedTestParam");
-    ArgumentsMapperConfig argumentsMapperConfig = new ArgumentsMapperConfig();
-    producerArgumentsMapperFactory.generateAggregatedParamMapper(
-        argumentsMapperConfig, providerParamMap, swaggerParamMap, aggregatedParamNames);
-
-    Assert.assertEquals(1, argumentsMapperConfig.getArgumentMapperList().size());
-    Assert.assertEquals(ProducerBeanParamMapper.class, argumentsMapperConfig.getArgumentMapperList().get(0).getClass());
-    ProducerBeanParamMapper producerBeanParamMapper =
-        (ProducerBeanParamMapper) argumentsMapperConfig.getArgumentMapperList().get(0);
-    Assert.assertEquals(Integer.valueOf(0), Deencapsulation.getField(producerBeanParamMapper, "producerIdx"));
-    Map<String, Integer> swaggerParamIndexMap =
-        Deencapsulation.getField(producerBeanParamMapper, "swaggerParamIndexMap");
-    Assert.assertEquals(Integer.valueOf(0), swaggerParamIndexMap.get("pathParam"));
-    Assert.assertEquals(Integer.valueOf(1), swaggerParamIndexMap.get("headerParam"));
-    Assert.assertEquals(Integer.valueOf(2), swaggerParamIndexMap.get("intVal"));
-    Assert.assertEquals(Integer.valueOf(3), swaggerParamIndexMap.get("longVal"));
-    Assert.assertEquals(Integer.valueOf(4), swaggerParamIndexMap.get("q"));
-    Assert.assertEquals(Integer.valueOf(5), swaggerParamIndexMap.get("uploaded"));
-  }
-
-  static class AggregatedParamProvider {
-    public String aggregatedParamTest(@BeanParam AggregatedTestParam aggregatedTestParam) {
-      return null;
-    }
-  }
-
-  static class AggregatedTestParam {
-    @PathParam("pathSwaggerParam")
-    private String pathParam;
-
-    private String queryParam;
-
-    @DefaultValue("defaultHeader")
-    @HeaderParam(value = "headerSwaggerParam")
-    private String headerParam;
-
-    @CookieParam("intSwaggerVal")
-    private int intVal;
-
-    @FormParam("longSwaggerVal")
-    private long longVal;
-
-    private Part uploaded;
-
-    public String getPathParam() {
-      return pathParam;
-    }
-
-    public AggregatedTestParam setPathParam(String pathParam) {
-      this.pathParam = pathParam;
-      return this;
-    }
-
-    public String getQ() {
-      return queryParam;
-    }
-
-    @DefaultValue("defaultQuery")
-    @QueryParam(value = "querySwaggerParam")
-    public AggregatedTestParam setQ(String queryParam) {
-      this.queryParam = queryParam;
-      return this;
-    }
-
-    public String getHeaderParam() {
-      return headerParam;
-    }
-
-    public AggregatedTestParam setHeaderParam(String headerParam) {
-      this.headerParam = headerParam;
-      return this;
-    }
-
-    public int getIntVal() {
-      return intVal;
-    }
-
-    public AggregatedTestParam setIntVal(int intVal) {
-      this.intVal = intVal;
-      return this;
-    }
-
-    public long getLongVal() {
-      return longVal;
-    }
-
-    public AggregatedTestParam setLongVal(long longVal) {
-      this.longVal = longVal;
-      return this;
-    }
-
-    public Part getUploaded() {
-      return uploaded;
-    }
-
-    @FormParam("uploadSwaggerParam")
-    public AggregatedTestParam setUploaded(Part uploaded) {
-      this.uploaded = uploaded;
-      return this;
-    }
-  }
-}
\ No newline at end of file
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerBeanParamMapperTest.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerBeanParamMapperTest.java
deleted file mode 100644
index 81c8d35..0000000
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerBeanParamMapperTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.swagger.invocation.arguments.producer;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Objects;
-
-import javax.servlet.http.Part;
-
-import org.apache.servicecomb.foundation.common.part.AbstractPart;
-import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
-import org.apache.servicecomb.swagger.invocation.arguments.ArgumentMapper;
-import org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerSpringMVCQueryObjectMapperTest.RecursiveParam;
-import org.apache.servicecomb.swagger.invocation.arguments.producer.ProducerSpringMVCQueryObjectMapperTest.TestParam;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ProducerBeanParamMapperTest {
-
-  @Test
-  public void mapArgument() {
-    final HashMap<String, Integer> producerNameToSwaggerIndexMap = new HashMap<>();
-    producerNameToSwaggerIndexMap.put("name", 2);
-    producerNameToSwaggerIndexMap.put("age", 0);
-    ArgumentMapper argumentMapper = new ProducerBeanParamMapper(producerNameToSwaggerIndexMap, 0, TestParam.class);
-    SwaggerInvocation swaggerInvocation = new SwaggerInvocation();
-    swaggerInvocation.setSwaggerArguments(new Object[] {22, "abc", "nameTest"});
-
-    final Object[] producerArguments = new Object[1];
-    argumentMapper.mapArgument(swaggerInvocation, producerArguments);
-    Assert.assertEquals(producerArguments[0], new TestParam().setName("nameTest").setAge(22));
-  }
-
-  @Test
-  public void mapArgumentOnRecursiveParam() {
-    final HashMap<String, Integer> producerNameToSwaggerIndexMap = new HashMap<>();
-    producerNameToSwaggerIndexMap.put("num", 0);
-    producerNameToSwaggerIndexMap.put("str", 1);
-    producerNameToSwaggerIndexMap.put("date", 2);
-    ArgumentMapper argumentMapper = new ProducerBeanParamMapper(producerNameToSwaggerIndexMap, 1,
-        RecursiveParam.class);
-    SwaggerInvocation swaggerInvocation = new SwaggerInvocation();
-    final Date testDate = new Date();
-    swaggerInvocation.setSwaggerArguments(new Object[] {2, "str0_0", testDate});
-
-    final Object[] producerArguments = new Object[2];
-    argumentMapper.mapArgument(swaggerInvocation, producerArguments);
-    Assert.assertNull(producerArguments[0]);
-    Assert.assertEquals(producerArguments[1], new RecursiveParam().setNum(2).setStr("str0_0").setDate(testDate));
-  }
-
-  @Test
-  public void mapArgumentWithPart() {
-    final HashMap<String, Integer> producerNameToSwaggerIndexMap = new HashMap<>();
-    producerNameToSwaggerIndexMap.put("up", 0);
-    producerNameToSwaggerIndexMap.put("str", 2);
-    producerNameToSwaggerIndexMap.put("longValue", 3);
-    ArgumentMapper argumentMapper = new ProducerBeanParamMapper(producerNameToSwaggerIndexMap, 0,
-        TestParamWithPart.class);
-    SwaggerInvocation swaggerInvocation = new SwaggerInvocation();
-    final AbstractPart uploadedFile = new AbstractPart();
-    swaggerInvocation.setSwaggerArguments(new Object[] {uploadedFile, 123L, "testString", 12L});
-
-    final Object[] producerArguments = new Object[2];
-    argumentMapper.mapArgument(swaggerInvocation, producerArguments);
-    Assert.assertEquals(producerArguments[0], new TestParamWithPart("testString", 12L, uploadedFile));
-    Assert.assertSame(((TestParamWithPart) producerArguments[0]).getUp(), uploadedFile);
-    Assert.assertNull(producerArguments[1]);
-  }
-
-  static class TestParamWithPart {
-    private String str;
-
-    private long longValue;
-
-    private Part uploaded;
-
-    public TestParamWithPart() {
-    }
-
-    public TestParamWithPart(String str, long longValue, Part uploaded) {
-      this.str = str;
-      this.longValue = longValue;
-      this.uploaded = uploaded;
-    }
-
-    public String getStr() {
-      return str;
-    }
-
-    public void setStr(String str) {
-      this.str = str;
-    }
-
-    public long getLongValue() {
-      return longValue;
-    }
-
-    public void setLongValue(long longValue) {
-      this.longValue = longValue;
-    }
-
-    public Part getUp() {
-      return uploaded;
-    }
-
-    public void setUp(Part uploaded) {
-      this.uploaded = uploaded;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-        return false;
-      }
-      TestParamWithPart that = (TestParamWithPart) o;
-      return longValue == that.longValue &&
-          Objects.equals(str, that.str) &&
-          Objects.equals(uploaded, that.uploaded);
-    }
-
-    @Override
-    public int hashCode() {
-      return Objects.hash(str, longValue, uploaded);
-    }
-  }
-}
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerSpringMVCQueryObjectMapperTest.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerSpringMVCQueryObjectMapperTest.java
deleted file mode 100644
index fea80f2..0000000
--- a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/ProducerSpringMVCQueryObjectMapperTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.servicecomb.swagger.invocation.arguments.producer;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Objects;
-
-import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
-import org.apache.servicecomb.swagger.invocation.arguments.ArgumentMapper;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ProducerSpringMVCQueryObjectMapperTest {
-
-  @Test
-  public void mapArgument() {
-    final HashMap<String, Integer> swaggerParamIndexMap = new HashMap<>();
-    swaggerParamIndexMap.put("name", 0);
-    swaggerParamIndexMap.put("age", 1);
-    ArgumentMapper argumentMapper = new ProducerSpringMVCQueryObjectMapper(swaggerParamIndexMap, 0, TestParam.class);
-    SwaggerInvocation swaggerInvocation = new SwaggerInvocation();
-    swaggerInvocation.setSwaggerArguments(new Object[] {"nameTest", 22});
-
-    final Object[] producerArguments = new Object[1];
-    argumentMapper.mapArgument(swaggerInvocation, producerArguments);
-    Assert.assertEquals(producerArguments[0], new TestParam().setName("nameTest").setAge(22));
-  }
-
-  @Test
-  public void mapArgumentOnRecursiveParam() {
-    final HashMap<String, Integer> swaggerParamIndexMap = new HashMap<>();
-    swaggerParamIndexMap.put("num", 0);
-    swaggerParamIndexMap.put("str", 1);
-    swaggerParamIndexMap.put("date", 2);
-    ArgumentMapper argumentMapper = new ProducerSpringMVCQueryObjectMapper(swaggerParamIndexMap, 1,
-        RecursiveParam.class);
-    SwaggerInvocation swaggerInvocation = new SwaggerInvocation();
-    final Date testDate = new Date();
-    swaggerInvocation.setSwaggerArguments(new Object[] {2, "str0_0", testDate});
-
-    final Object[] producerArguments = new Object[2];
-    argumentMapper.mapArgument(swaggerInvocation, producerArguments);
-    Assert.assertNull(producerArguments[0]);
-    Assert.assertEquals(producerArguments[1], new RecursiveParam().setNum(2).setStr("str0_0").setDate(testDate));
-  }
-
-  static class TestParam {
-    private String name;
-
-    private int age;
-
-    public String getName() {
-      return name;
-    }
-
-    public TestParam setName(String name) {
-      this.name = name;
-      return this;
-    }
-
-    public int getAge() {
-      return age;
-    }
-
-    public TestParam setAge(int age) {
-      this.age = age;
-      return this;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-        return false;
-      }
-      TestParam testParam = (TestParam) o;
-      return age == testParam.age &&
-          Objects.equals(name, testParam.name);
-    }
-
-    @Override
-    public int hashCode() {
-      return Objects.hash(name, age);
-    }
-  }
-
-  static class RecursiveParam {
-
-    private int num;
-
-    private String str;
-
-    private Date date;
-
-    private RecursiveParam recursiveParam;
-
-    public int getNum() {
-      return num;
-    }
-
-    public RecursiveParam setNum(int num) {
-      this.num = num;
-      return this;
-    }
-
-    public String getStr() {
-      return str;
-    }
-
-    public RecursiveParam setStr(String str) {
-      this.str = str;
-      return this;
-    }
-
-    public Date getDate() {
-      return date;
-    }
-
-    public RecursiveParam setDate(Date date) {
-      this.date = date;
-      return this;
-    }
-
-    public RecursiveParam getRecursiveParam() {
-      return recursiveParam;
-    }
-
-    public RecursiveParam setRecursiveParam(
-        RecursiveParam recursiveParam) {
-      this.recursiveParam = recursiveParam;
-      return this;
-    }
-
-    @Override
-    public String toString() {
-      final StringBuilder sb = new StringBuilder("RecursiveParam{");
-      sb.append("num=").append(num);
-      sb.append(", str='").append(str).append('\'');
-      sb.append(", date=").append(date);
-      sb.append(", recursiveParam=").append(recursiveParam);
-      sb.append('}');
-      return sb.toString();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-        return false;
-      }
-      RecursiveParam that = (RecursiveParam) o;
-      return num == that.num &&
-          Objects.equals(str, that.str) &&
-          Objects.equals(date, that.date) &&
-          Objects.equals(recursiveParam, that.recursiveParam);
-    }
-
-    @Override
-    public int hashCode() {
-      return Objects.hash(num, str, date, recursiveParam);
-    }
-  }
-}
\ No newline at end of file
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestJaxrs.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestJaxrs.java
new file mode 100644
index 0000000..0559101
--- /dev/null
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestJaxrs.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.swagger.invocation.arguments.producer;
+
+import org.apache.servicecomb.swagger.engine.SwaggerEnvironment;
+import org.apache.servicecomb.swagger.engine.SwaggerProducer;
+import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
+import org.apache.servicecomb.swagger.invocation.schemas.JaxrsAddBeanParamV1;
+import org.apache.servicecomb.swagger.invocation.schemas.JaxrsAddBodyV1;
+import org.apache.servicecomb.swagger.invocation.schemas.JaxrsAddV1;
+import org.apache.servicecomb.swagger.invocation.schemas.models.AddBeanParamV1;
+import org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestJaxrs {
+  @Test
+  public void add() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new JaxrsAddV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {1, 2});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(2, arguments.length);
+    Assert.assertEquals(1, arguments[0]);
+    Assert.assertEquals(2, arguments[1]);
+  }
+
+  @Test
+  public void addBeanParam() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new JaxrsAddBeanParamV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {1, 2});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(1, arguments.length);
+    AddBeanParamV1 paramV1 = (AddBeanParamV1) arguments[0];
+    Assert.assertEquals(1, paramV1.getX());
+    Assert.assertEquals(2, paramV1.y);
+  }
+
+  @Test
+  public void addBody() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new JaxrsAddBodyV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    AddWrapperV1 addBody = new AddWrapperV1();
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {addBody});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(1, arguments.length);
+    Assert.assertSame(addBody, arguments[0]);
+  }
+}
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestPojo.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestPojo.java
new file mode 100644
index 0000000..6ec4af5
--- /dev/null
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestPojo.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.swagger.invocation.arguments.producer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.servicecomb.swagger.engine.SwaggerEnvironment;
+import org.apache.servicecomb.swagger.engine.SwaggerProducer;
+import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
+import org.apache.servicecomb.swagger.invocation.schemas.PojoAddBodyV1;
+import org.apache.servicecomb.swagger.invocation.schemas.PojoAddV1;
+import org.apache.servicecomb.swagger.invocation.schemas.PojoAddWithContextV1;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestPojo {
+  static Map<String, Object> addBody = new HashMap<>();
+
+  static {
+    addBody.put("x", 1);
+    addBody.put("y", 2);
+  }
+
+  @Test
+  public void add() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new PojoAddV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {addBody});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(2, arguments.length);
+    Assert.assertEquals(1, arguments[0]);
+    Assert.assertEquals(2, arguments[1]);
+  }
+
+  @Test
+  public void addBody() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new PojoAddBodyV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {addBody});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(1, arguments.length);
+    Assert.assertSame(addBody, arguments[0]);
+  }
+
+  @Test
+  public void addWithContext_add() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new PojoAddWithContextV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {addBody});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(3, arguments.length);
+    Assert.assertSame(invocation, arguments[0]);
+    Assert.assertEquals(1, arguments[1]);
+    Assert.assertEquals(2, arguments[2]);
+  }
+}
diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestSpringmvc.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestSpringmvc.java
new file mode 100644
index 0000000..3991da8
--- /dev/null
+++ b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/arguments/producer/TestSpringmvc.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.swagger.invocation.arguments.producer;
+
+import org.apache.servicecomb.swagger.engine.SwaggerEnvironment;
+import org.apache.servicecomb.swagger.engine.SwaggerProducer;
+import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
+import org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddBodyV1;
+import org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddV1;
+import org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV1;
+import org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestSpringmvc {
+  @Test
+  public void add() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {1, 2});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(2, arguments.length);
+    Assert.assertEquals(1, arguments[0]);
+    Assert.assertEquals(2, arguments[1]);
+  }
+
+  @Test
+  public void addWrapper() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddWrapperV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {1, 2});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(1, arguments.length);
+    AddWrapperV1 paramV1 = (AddWrapperV1) arguments[0];
+    Assert.assertEquals(1, paramV1.getX());
+    Assert.assertEquals(2, paramV1.y);
+  }
+
+  @Test
+  public void addBody() {
+    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddBodyV1(), null);
+    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
+
+    AddWrapperV1 addBody = new AddWrapperV1();
+    SwaggerInvocation invocation = new SwaggerInvocation();
+    invocation.setSwaggerArguments(new Object[] {addBody});
+
+    Object[] arguments = mapper.toProducerArgs(invocation);
+
+    Assert.assertEquals(1, arguments.length);
+    Assert.assertSame(addBody, arguments[0]);
+  }
+}