use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project incubator-servicecomb-java-chassis by apache.
the class BootstrapNormal method boot.
public SwaggerEnvironment boot() {
SwaggerEnvironment env = new SwaggerEnvironment();
ConverterMgr converterMgr = new ConverterMgr();
ProducerArgumentsMapperFactory producerArgumentsFactory = new ProducerArgumentsMapperFactory();
producerArgumentsFactory.setFactoryList(Arrays.asList(new ProducerInvocationContextMapperFactory()));
producerArgumentsFactory.setConverterMgr(converterMgr);
env.setProducerArgumentsFactory(producerArgumentsFactory);
ConsumerArgumentsMapperFactory consumerArgumentsFactory = new ConsumerArgumentsMapperFactory();
consumerArgumentsFactory.setFactoryList(Arrays.asList(new ConsumerInvocationContextMapperFactory()));
consumerArgumentsFactory.setConverterMgr(converterMgr);
env.setConsumerArgumentsFactory(consumerArgumentsFactory);
env.setConverterMgr(converterMgr);
return env;
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestPojoV2V1 method addBody_addBody.
@Test
public void addBody_addBody() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(PojoAddBodyV1.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.assertSame(arguments.get("addBody"), result.get("addBody"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestPojoV2V1 method add_addBody.
@Test
public void add_addBody() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(PojoAddBodyV1.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(1, result.size());
result = (Map<String, Object>) result.get("addBody");
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 TestSpringmvcV1V1 method add_add.
@Test
public void add_add() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(SpringmvcAddV1.class);
SwaggerConsumer swaggerConsumer = environment.createConsumer(ConsumerAddV1.class, swagger);
ArgumentsMapper mapper = swaggerConsumer.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.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 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"));
}
Aggregations