Search in sources :

Example 6 with AddWrapperV1

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

the class TestPojoV1V2 method addBody_addBody.

@Test
public void addBody_addBody() {
    SwaggerEnvironment environment = new SwaggerEnvironment();
    Swagger swagger = SwaggerGenerator.generate(PojoAddBodyV2.class);
    SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddBodyV1.class, swagger);
    ArgumentsMapper mapper = swaggerConsumer.findOperation("add").getArgumentsMapper();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("addBody", new AddWrapperV1(1, 2));
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> result = mapper.invocationArgumentToSwaggerArguments(invocation, arguments);
    Assert.assertSame(arguments.get("addBody"), result.get("addBody"));
}
Also used : AddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1) SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Swagger(io.swagger.models.Swagger) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) ArgumentsMapper(org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper) Test(org.junit.Test)

Example 7 with AddWrapperV1

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

the class TestJaxrsV1V2 method addBody_addBody.

@Test
public void addBody_addBody() {
    SwaggerEnvironment environment = new SwaggerEnvironment();
    Swagger swagger = SwaggerGenerator.generate(JaxrsAddBodyV2.class);
    SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddBodyV1.class, swagger);
    ArgumentsMapper mapper = swaggerConsumer.findOperation("add").getArgumentsMapper();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("addBody", new AddWrapperV1(1, 2));
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> result = mapper.invocationArgumentToSwaggerArguments(invocation, arguments);
    Assert.assertSame(result.get("addBody"), arguments.get("addBody"));
}
Also used : AddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1) SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Swagger(io.swagger.models.Swagger) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) ArgumentsMapper(org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper) Test(org.junit.Test)

Example 8 with AddWrapperV1

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

the class TestJaxrsV1V2 method addBody_addBeanParam.

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

Example 9 with AddWrapperV1

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

the class TestJaxrsV1V1 method should_mapper_consumer_wrapped_body_to_swagger_multi_args.

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

Example 10 with AddWrapperV1

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

the class TestSpringmvcV1V2 method addBody_add.

@Test
public void addBody_add() {
    SwaggerEnvironment environment = new SwaggerEnvironment();
    Swagger swagger = SwaggerGenerator.generate(SpringmvcAddV2.class);
    SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddBodyV1.class, swagger);
    ArgumentsMapper mapper = swaggerConsumer.findOperation("add").getArgumentsMapper();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("addBody", new AddWrapperV1(1, 2));
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> result = mapper.invocationArgumentToSwaggerArguments(invocation, arguments);
    Assert.assertEquals(2, result.size());
    Assert.assertEquals(1, (int) result.get("x"));
    Assert.assertEquals(2, (int) result.get("y"));
    Assert.assertEquals(null, result.get("x-z"));
}
Also used : AddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1) SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) 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

HashMap (java.util.HashMap)19 SwaggerEnvironment (org.apache.servicecomb.swagger.engine.SwaggerEnvironment)19 SwaggerInvocation (org.apache.servicecomb.swagger.invocation.SwaggerInvocation)19 AddWrapperV1 (org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1)19 Test (org.junit.Test)19 Swagger (io.swagger.models.Swagger)16 SwaggerConsumer (org.apache.servicecomb.swagger.engine.SwaggerConsumer)16 ArgumentsMapper (org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapper)16 LinkedHashMap (java.util.LinkedHashMap)8 SpringmvcAddWrapperV1 (org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV1)5 SwaggerProducer (org.apache.servicecomb.swagger.engine.SwaggerProducer)3 JaxrsAddBodyV1 (org.apache.servicecomb.swagger.invocation.schemas.JaxrsAddBodyV1)1 SpringmvcAddBodyV1 (org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddBodyV1)1