Search in sources :

Example 1 with SpringmvcAddWrapperV2

use of org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV2 in project java-chassis by ServiceComb.

the class TestSpringmvcV2V2 method addBody_addWrapper.

@Test
public void addBody_addWrapper() {
    SwaggerEnvironment environment = new SwaggerEnvironment();
    Swagger swagger = SwaggerGenerator.generate(SpringmvcAddWrapperV2.class);
    SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddBodyV2.class, swagger);
    ArgumentsMapper mapper = swaggerConsumer.findOperation("add").getArgumentsMapper();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("addBody", new AddWrapperV2(1, 2, 3));
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> result = mapper.invocationArgumentToSwaggerArguments(invocation, arguments);
    Assert.assertEquals(3, result.size());
    Assert.assertEquals(1, (int) result.get("x"));
    Assert.assertEquals(2, (int) result.get("y"));
    Assert.assertEquals(3, (int) result.get("x-z"));
}
Also used : SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) SpringmvcAddWrapperV2(org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV2) AddWrapperV2(org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV2) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) HashMap(java.util.HashMap) Swagger(io.swagger.models.Swagger) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) ArgumentsMapper(org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper) Test(org.junit.Test)

Aggregations

Swagger (io.swagger.models.Swagger)1 HashMap (java.util.HashMap)1 SwaggerConsumer (org.apache.servicecomb.swagger.engine.SwaggerConsumer)1 SwaggerEnvironment (org.apache.servicecomb.swagger.engine.SwaggerEnvironment)1 SwaggerInvocation (org.apache.servicecomb.swagger.invocation.SwaggerInvocation)1 ArgumentsMapper (org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper)1 SpringmvcAddWrapperV2 (org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV2)1 AddWrapperV2 (org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV2)1 Test (org.junit.Test)1