use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestSpringmvc method addBody.
@Test
public void addBody() {
SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddBodyV1(), 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.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestSpringmvc method add.
@Test
public void add() {
SwaggerProducer swaggerProducer = new SwaggerEnvironment().createProducer(new SpringmvcAddV1(), 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(2, result.size());
Assert.assertEquals(1, (int) result.get("x"));
Assert.assertEquals(2, (int) result.get("y"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestJaxrsV2V1 method addBody_add.
@Test
public void addBody_add() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(JaxrsAddV1.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(2, result.size());
Assert.assertEquals(1, (int) result.get("x"));
Assert.assertEquals(2, (int) result.get("y"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestJaxrsV2V1 method add_addBeanParam.
@Test
public void add_addBeanParam() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(JaxrsAddBeanParamV1.class);
SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddV2.class, swagger);
ArgumentsMapper mapper = swaggerConsumer.findOperation("add").getArgumentsMapper();
Map<String, Object> arguments = new HashMap<>();
arguments.put("x", 1);
arguments.put("y", 2);
arguments.put("x-z", 3);
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"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestJaxrsV2V1 method addBody_addBeanParam.
@Test
public void addBody_addBeanParam() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(JaxrsAddBeanParamV1.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(2, result.size());
Assert.assertEquals(1, (int) result.get("x"));
Assert.assertEquals(2, (int) result.get("y"));
}
Aggregations