Search in sources :

Example 16 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class PojoConsumerMetaRefresher method refreshMeta.

protected PojoConsumerMeta refreshMeta() {
    MicroserviceReferenceConfig microserviceReferenceConfig = scbEngine.createMicroserviceReferenceConfig(microserviceName);
    MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
    SchemaMeta schemaMeta = findSchemaMeta(microserviceMeta);
    if (schemaMeta == null) {
        throw new IllegalStateException(String.format("Schema not exist, microserviceName=%s, schemaId=%s, consumer interface=%s; " + "new producer not running or not deployed.", microserviceName, schemaId, consumerIntf.getName()));
    }
    SwaggerConsumer swaggerConsumer = scbEngine.getSwaggerEnvironment().createConsumer(consumerIntf, schemaMeta.getSwagger());
    return new PojoConsumerMeta(microserviceReferenceConfig, swaggerConsumer, schemaMeta);
}
Also used : MicroserviceReferenceConfig(org.apache.servicecomb.core.provider.consumer.MicroserviceReferenceConfig) SwaggerConsumer(org.apache.servicecomb.swagger.engine.SwaggerConsumer) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) PojoConsumerMeta(org.apache.servicecomb.provider.pojo.definition.PojoConsumerMeta)

Example 17 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class ITSCBRestTemplate method init.

public ITSCBRestTemplate init() {
    String producerName = ITJUnitUtils.getProducerName();
    MicroserviceReferenceConfig microserviceReferenceConfig = SCBEngine.getInstance().createMicroserviceReferenceConfig(producerName);
    MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
    SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
    basePath = schemaMeta.getSwagger().getBasePath();
    urlPrefix = String.format("cse://%s%s", producerName, basePath);
    instance = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceManager(RegistrationManager.INSTANCE.getMicroservice().getAppId()).getOrCreateMicroserviceVersions(producerName).getPulledInstances().get(0);
    setUriTemplateHandler(new ITUriTemplateHandler(urlPrefix));
    setRequestFactory(new ITClientHttpRequestFactory());
    return this;
}
Also used : MicroserviceReferenceConfig(org.apache.servicecomb.core.provider.consumer.MicroserviceReferenceConfig) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta)

Example 18 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestIgnoreMethod method ignoreMethodSpringmvc_apiOperation.

@Test
public void ignoreMethodSpringmvc_apiOperation() {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta("ignoreMethodSpringmvc");
    Assert.assertNull(schemaMeta.findOperation("hideByApiOperation"));
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) Test(org.junit.Test)

Example 19 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestIgnoreMethod method ignoreMethodJaxrs_apiOperation.

@Test
public void ignoreMethodJaxrs_apiOperation() {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta("ignoreMethodJaxrs");
    Assert.assertNull(schemaMeta.findOperation("hideByApiOperation"));
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) Test(org.junit.Test)

Example 20 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestApiParam method check.

protected void check(String schemaId, String opName, String paramType) {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta(schemaId);
    OperationMeta operationMeta = schemaMeta.findOperation(opName);
    parameter = operationMeta.getSwaggerOperation().getParameters().get(0);
    Assert.assertEquals("desc of " + opName + " param", parameter.getDescription());
    Assert.assertEquals(paramType, parameter.getIn());
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta)

Aggregations

SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)58 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)28 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)25 Test (org.junit.Test)24 Invocation (org.apache.servicecomb.core.Invocation)13 Swagger (io.swagger.models.Swagger)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 Executor (java.util.concurrent.Executor)5 InvocationRuntimeType (org.apache.servicecomb.core.definition.InvocationRuntimeType)5 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)5 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)5 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)5 MockUp (mockit.MockUp)4 NonSwaggerInvocation (org.apache.servicecomb.core.NonSwaggerInvocation)4 Transport (org.apache.servicecomb.core.Transport)4 TransportManager (org.apache.servicecomb.core.transport.TransportManager)4 InstanceCacheManager (org.apache.servicecomb.registry.cache.InstanceCacheManager)4 DiscoveryTreeNode (org.apache.servicecomb.registry.discovery.DiscoveryTreeNode)4 ServiceRegistry (org.apache.servicecomb.serviceregistry.ServiceRegistry)4