Search in sources :

Example 46 with SchemaMeta

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

the class TestIgnoreStaticMethod method ignoreStaticMethod_pojo.

@Test
public void ignoreStaticMethod_pojo() {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta("ignoreStaticMethodPojoSchema");
    OperationMeta add = schemaMeta.findOperation("add");
    Assert.assertNotNull(add);
    OperationMeta sub = schemaMeta.findOperation("staticSub");
    Assert.assertNull(sub);
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) Test(org.junit.Test)

Example 47 with SchemaMeta

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

the class TestIgnoreStaticMethod method ignoreStaticMethod_Springmvc.

@Test
public void ignoreStaticMethod_Springmvc() {
    SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta("ignoreStaticMethodSpringmvcSchema");
    OperationMeta add = schemaMeta.findOperation("add");
    Assert.assertNotNull(add);
    OperationMeta sub = schemaMeta.findOperation("staticSub");
    Assert.assertNull(sub);
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) Test(org.junit.Test)

Example 48 with SchemaMeta

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

the class TestIgnoreMethod method ignoreMethodPojo_apiOperation.

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

Example 49 with SchemaMeta

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

the class GateRestTemplate method getUrlPrefix.

private String getUrlPrefix(String gateName, String producerName, String schemaId) {
    MicroserviceVersionRule microserviceVersionRule = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceVersionRule(RegistrationManager.INSTANCE.getMicroservice().getAppId(), gateName, DefinitionConst.VERSION_RULE_ALL);
    MicroserviceInstance microserviceInstance = microserviceVersionRule.getInstances().values().stream().findFirst().get();
    URIEndpointObject edgeAddress = new URIEndpointObject(microserviceInstance.getEndpoints().get(0));
    String urlSchema = "http";
    if (edgeAddress.isSslEnabled()) {
        urlSchema = "https";
    }
    MicroserviceReferenceConfig microserviceReferenceConfig = SCBEngine.getInstance().createMicroserviceReferenceConfig(producerName);
    MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
    SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
    return String.format("%s://%s:%d/rest/%s%s", urlSchema, edgeAddress.getHostOrIp(), edgeAddress.getPort(), producerName, schemaMeta.getSwagger().getBasePath());
}
Also used : MicroserviceVersionRule(org.apache.servicecomb.registry.consumer.MicroserviceVersionRule) MicroserviceReferenceConfig(org.apache.servicecomb.core.provider.consumer.MicroserviceReferenceConfig) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) URIEndpointObject(org.apache.servicecomb.foundation.common.net.URIEndpointObject)

Example 50 with SchemaMeta

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

the class ITSCBAsyncRestTemplate method ensureProviderBasePath.

private void ensureProviderBasePath(String producerName) {
    MicroserviceManager microserviceManager = DiscoveryManager.INSTANCE.getAppManager().getOrCreateMicroserviceManager(RegistrationManager.INSTANCE.getMicroservice().getAppId());
    MicroserviceVersions producerMicroserviceVersions = microserviceManager.getOrCreateMicroserviceVersions(producerName);
    Optional<MicroserviceVersion> latestMicroserviceVersion = producerMicroserviceVersions.getVersions().values().stream().max(Comparator.comparing(MicroserviceVersion::getVersion));
    latestMicroserviceVersion.ifPresent(microserviceVersion -> {
        MicroserviceMeta microserviceMeta = microserviceVersion.getVendorExtensions().get(CORE_MICROSERVICE_META);
        SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
        basePath = schemaMeta.getSwagger().getBasePath();
    });
    latestMicroserviceVersion.orElseThrow(() -> new IllegalStateException("cannot find producer: " + producerName));
}
Also used : MicroserviceVersion(org.apache.servicecomb.registry.consumer.MicroserviceVersion) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) MicroserviceManager(org.apache.servicecomb.registry.consumer.MicroserviceManager) MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions)

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