Search in sources :

Example 6 with ProtoSchema

use of org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema 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);
}
Also used : Expectations(mockit.Expectations) ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SwaggerProducer(org.apache.servicecomb.swagger.engine.SwaggerProducer) Swagger(io.swagger.models.Swagger) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Before(org.junit.Before)

Aggregations

ProtoSchema (org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema)6 SpringmvcSwaggerGenerator (org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator)6 Test (org.junit.Test)5 Swagger (io.swagger.models.Swagger)1 Expectations (mockit.Expectations)1 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)1 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)1 SwaggerEnvironment (org.apache.servicecomb.swagger.engine.SwaggerEnvironment)1 SwaggerProducer (org.apache.servicecomb.swagger.engine.SwaggerProducer)1 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)1 Before (org.junit.Before)1