use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestSpringmvcV2V2 method addBody_addBody.
@Test
public void addBody_addBody() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(SpringmvcAddBodyV2.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(result.get("addBody"), arguments.get("addBody"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestSpringmvcV2V2 method add_add.
@Test
public void add_add() {
SwaggerEnvironment environment = new SwaggerEnvironment();
Swagger swagger = SwaggerGenerator.generate(SpringmvcAddV2.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("z", 3);
SwaggerInvocation invocation = new SwaggerInvocation();
Map<String, Object> result = mapper.invocationArgumentToSwaggerArguments(invocation, arguments);
Assert.assertEquals(3, result.size());
Assert.assertEquals(1, (int) result.get("x"));
Assert.assertEquals(2, (int) result.get("y"));
Assert.assertEquals(3, (int) result.get("x-z"));
}
use of org.apache.servicecomb.swagger.engine.SwaggerEnvironment in project java-chassis by ServiceComb.
the class TestSchemaMetaCodecRestTemplate method setUp.
@Before
public void setUp() {
ProtobufManager.clear();
new Expectations() {
{
providerMicroserviceMeta.getMicroserviceName();
result = "test";
providerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
result = null;
consumerMicroserviceMeta.getMicroserviceName();
result = "test";
consumerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
result = null;
}
};
SpringmvcSwaggerGenerator swaggerGenerator = new SpringmvcSwaggerGenerator(ProtoSchema.class);
Swagger swagger = swaggerGenerator.generate();
SwaggerEnvironment swaggerEnvironment = new SwaggerEnvironment();
providerSchemaMeta = new SchemaMeta(providerMicroserviceMeta, "ProtoSchema", swagger);
SwaggerProducer swaggerProducer = swaggerEnvironment.createProducer(new ProtoSchema(), swagger);
for (SwaggerProducerOperation producerOperation : swaggerProducer.getAllOperations()) {
OperationMeta operationMeta = providerSchemaMeta.ensureFindOperation(producerOperation.getOperationId());
operationMeta.setSwaggerProducerOperation(producerOperation);
}
consumerSchemaMeta = new SchemaMeta(consumerMicroserviceMeta, "ProtoSchema", swagger);
}
Aggregations