Search in sources :

Example 1 with SpringmvcAddWrapperV1

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

the class TestSpringmvcV1V1 method addBody_addWrapper.

@Test
public void addBody_addWrapper() {
    SwaggerEnvironment environment = new SwaggerEnvironment();
    Swagger swagger = SwaggerGenerator.generate(SpringmvcAddWrapperV1.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 : SpringmvcAddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV1) 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)

Example 2 with SpringmvcAddWrapperV1

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

the class TestSpringmvc method addWrapper.

@Test
public void addWrapper() {
    SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddWrapperV1(), null);
    ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
    Map<String, Object> arguments = new HashMap<>();
    arguments.put("x", 1);
    arguments.put("y", 2);
    SwaggerInvocation invocation = new SwaggerInvocation();
    Map<String, Object> result = mapper.swaggerArgumentToInvocationArguments(invocation, arguments);
    Assert.assertEquals(1, result.size());
    AddWrapperV1 paramV1 = (AddWrapperV1) result.get("wrapper");
    Assert.assertEquals(1, paramV1.getX());
    Assert.assertEquals(2, paramV1.y);
}
Also used : SwaggerInvocation(org.apache.servicecomb.swagger.invocation.SwaggerInvocation) SpringmvcAddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV1) AddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1) SpringmvcAddWrapperV1(org.apache.servicecomb.swagger.invocation.schemas.SpringmvcAddWrapperV1) SwaggerProducer(org.apache.servicecomb.swagger.engine.SwaggerProducer) HashMap(java.util.HashMap) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) Test(org.junit.Test)

Aggregations

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