Search in sources :

Example 16 with OperationMeta

use of io.servicecomb.core.definition.OperationMeta in project java-chassis by ServiceComb.

the class TestLocator method createRestOperatonMeta.

protected RestOperationMeta createRestOperatonMeta(String httpMethod, String path) {
    OperationMeta om = new OperationMeta();
    om.setHttpMethod(httpMethod);
    RestOperationMeta rom = new RestOperationMeta();
    rom.setOperationMeta(om);
    rom.setAbsolutePath(path);
    return rom;
}
Also used : RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta) OperationMeta(io.servicecomb.core.definition.OperationMeta) RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta)

Example 17 with OperationMeta

use of io.servicecomb.core.definition.OperationMeta in project java-chassis by ServiceComb.

the class ConsumerSchemaFactory method mapSameIntfParameters.

protected void mapSameIntfParameters(ConsumerSchemaContext context) {
    for (OperationMeta operationMeta : context.getSchemaMeta().getOperations()) {
        List<ArgumentMapper> consumerArgMapperList = new ArrayList<>();
        int swaggerParameterCount = operationMeta.getSwaggerOperation().getParameters().size();
        for (int idx = 0; idx < swaggerParameterCount; idx++) {
            ConsumerArgumentSame argMapper = new ConsumerArgumentSame(idx, idx);
            consumerArgMapperList.add(argMapper);
        }
        ConsumerArgumentsMapper argsMapper = new ConsumerArgumentsMapper(consumerArgMapperList, swaggerParameterCount);
        createOperation(context, operationMeta, argsMapper);
    }
}
Also used : ConsumerArgumentsMapper(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentsMapper) ArrayList(java.util.ArrayList) ConsumerArgumentSame(io.servicecomb.swagger.invocation.arguments.consumer.ConsumerArgumentSame) ConsumerOperationMeta(io.servicecomb.core.provider.consumer.ConsumerOperationMeta) OperationMeta(io.servicecomb.core.definition.OperationMeta) ArgumentMapper(io.servicecomb.swagger.invocation.arguments.ArgumentMapper)

Example 18 with OperationMeta

use of io.servicecomb.core.definition.OperationMeta in project java-chassis by ServiceComb.

the class ProducerSchemaFactory method connectToProvider.

@Override
protected void connectToProvider(ProducerSchemaContext context) {
    if (context.getGenerator() == null) {
        generateSwagger(context);
    }
    // 建立契约与producer之间的参数映射关系
    Class<?> swaggerIntf = ClassUtils.getJavaInterface(context.getSchemaMeta().getSwagger());
    for (OperationMeta operationMeta : context.getSchemaMeta().getOperations()) {
        OperationGenerator operationGenerator = context.getGenerator().getOperationGeneratorMap().get(operationMeta.getOperationId());
        Method swaggerMethod = ReflectUtils.findMethod(swaggerIntf, operationMeta.getOperationId());
        List<Parameter> swaggerParameters = operationMeta.getSwaggerOperation().getParameters();
        Method producerMethod = operationGenerator.getProviderMethod();
        List<Parameter> producerParameters = operationGenerator.getProviderParameters();
        ProducerArgumentsMapper argsMapper = producerArgsMapperFactory.createArgumentsMapper(context.getSchemaMeta().getSwagger(), swaggerMethod, swaggerParameters, producerMethod, producerParameters);
        createOperation(context, operationMeta, argsMapper);
    }
}
Also used : ProducerArgumentsMapper(io.servicecomb.swagger.invocation.arguments.producer.ProducerArgumentsMapper) Parameter(io.swagger.models.parameters.Parameter) OperationMeta(io.servicecomb.core.definition.OperationMeta) Method(java.lang.reflect.Method) OperationGenerator(io.servicecomb.swagger.generator.core.OperationGenerator)

Example 19 with OperationMeta

use of io.servicecomb.core.definition.OperationMeta in project java-chassis by ServiceComb.

the class InvocationFactory method forConsumer.

public static Invocation forConsumer(ReferenceConfig referenceConfig, SchemaMeta schemaMeta, String operationName, Object[] swaggerArguments) {
    OperationMeta operationMeta = schemaMeta.ensureFindOperation(operationName);
    Invocation invocation = new Invocation(referenceConfig, operationMeta, swaggerArguments);
    invocation.addContext(Const.SRC_MICROSERVICE, microserviceName);
    return invocation;
}
Also used : Invocation(io.servicecomb.core.Invocation) OperationMeta(io.servicecomb.core.definition.OperationMeta)

Example 20 with OperationMeta

use of io.servicecomb.core.definition.OperationMeta in project java-chassis by ServiceComb.

the class MockUtil method mockAbstactRestServer.

public void mockAbstactRestServer() {
    new MockUp<AbstractRestServer<HttpServletResponse>>() {

        @Mock
        protected RestOperationMeta findRestOperation(RestServerRequestInternal restRequest) {
            RestOperationMeta restOperationMeta = Mockito.mock(RestOperationMeta.class);
            OperationMeta operationMeta = Mockito.mock(OperationMeta.class);
            Executor executor = Mockito.mock(Executor.class);
            operationMeta.setExecutor(executor);
            return restOperationMeta;
        }
    };
}
Also used : Executor(java.util.concurrent.Executor) RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta) RestServerRequestInternal(io.servicecomb.common.rest.codec.RestServerRequestInternal) HttpServletResponse(javax.servlet.http.HttpServletResponse) MockUp(mockit.MockUp) OperationMeta(io.servicecomb.core.definition.OperationMeta) RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta)

Aggregations

OperationMeta (io.servicecomb.core.definition.OperationMeta)36 Test (org.junit.Test)18 Invocation (io.servicecomb.core.Invocation)15 RestOperationMeta (io.servicecomb.common.rest.definition.RestOperationMeta)12 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)8 SchemaMeta (io.servicecomb.core.definition.SchemaMeta)8 MockUp (mockit.MockUp)7 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)6 AsyncResponse (io.servicecomb.core.AsyncResponse)6 Endpoint (io.servicecomb.core.Endpoint)6 Response (io.servicecomb.core.Response)5 InvocationException (io.servicecomb.core.exception.InvocationException)5 HttpClientResponse (io.vertx.core.http.HttpClientResponse)5 URLPathBuilder (io.servicecomb.common.rest.definition.path.URLPathBuilder)4 MicroserviceMeta (io.servicecomb.core.definition.MicroserviceMeta)4 HttpClientWithContext (io.servicecomb.foundation.vertx.client.http.HttpClientWithContext)4 Buffer (io.vertx.core.buffer.Buffer)4 ConsumerOperationMeta (io.servicecomb.core.provider.consumer.ConsumerOperationMeta)3 IpPort (io.servicecomb.foundation.common.net.IpPort)3 HttpClientRequest (io.vertx.core.http.HttpClientRequest)3