use of org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1 in project java-chassis by ServiceComb.
the class TestSpringmvcV1V2 method addBody_addWrapper.
@Test
public void addBody_addWrapper() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(SpringmvcAddWrapperV2.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"));
}
use of org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1 in project java-chassis by ServiceComb.
the class TestSpringmvcV1V2 method addBody_addBody.
@Test
public void addBody_addBody() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(SpringmvcAddBodyV2.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"));
}
use of org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1 in project java-chassis by ServiceComb.
the class TestJaxrs method addBody.
@Test
public void addBody() {
SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new JaxrsAddBodyV1(), null);
ProducerArgumentsMapper mapper = swaggerProducer.findOperation("add").getArgumentsMapper();
AddWrapperV1 addBody = new AddWrapperV1();
Map<String, Object> arguments = new HashMap<>();
arguments.put("addBody", addBody);
SwaggerInvocation invocation = new SwaggerInvocation();
Map<String, Object> result = mapper.swaggerArgumentToInvocationArguments(invocation, arguments);
Assert.assertEquals(1, result.size());
Assert.assertSame(addBody, result.get("addBody"));
}
use of org.apache.servicecomb.swagger.invocation.schemas.models.AddWrapperV1 in project java-chassis by ServiceComb.
the class TestJaxrsV1V1 method should_mapper_consumer_body_to_swagger_body.
@Test
public void should_mapper_consumer_body_to_swagger_body() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(JaxrsAddBodyV1.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"));
}
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_gen_by_BeanParam.
@Test
public void should_mapper_consumer_wrapped_body_to_swagger_multi_args_gen_by_BeanParam() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(JaxrsAddBeanParamV1.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"));
}
Aggregations