Search in sources :

Example 1 with ReferenceConfig

use of org.apache.servicecomb.core.provider.consumer.ReferenceConfig in project incubator-servicecomb-java-chassis by apache.

the class CseClientHttpRequest method createRequestMeta.

private RequestMeta createRequestMeta(String httpMetod, URI uri) {
    String microserviceName = uri.getAuthority();
    ReferenceConfig referenceConfig = ReferenceConfigUtils.getForInvoke(microserviceName);
    MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
    ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
    if (servicePathManager == null) {
        throw new Error(String.format("no schema defined for %s:%s", microserviceMeta.getAppId(), microserviceMeta.getName()));
    }
    OperationLocator locator = servicePathManager.consumerLocateOperation(path, httpMetod);
    RestOperationMeta swaggerRestOperation = locator.getOperation();
    Map<String, String> pathParams = locator.getPathVarMap();
    return new RequestMeta(referenceConfig, swaggerRestOperation, pathParams);
}
Also used : OperationLocator(org.apache.servicecomb.common.rest.locator.OperationLocator) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta) ReferenceConfig(org.apache.servicecomb.core.provider.consumer.ReferenceConfig) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) ServicePathManager(org.apache.servicecomb.common.rest.locator.ServicePathManager)

Example 2 with ReferenceConfig

use of org.apache.servicecomb.core.provider.consumer.ReferenceConfig in project incubator-servicecomb-java-chassis by apache.

the class TestRequestMeta method testGetReferenceConfig.

@Test
public void testGetReferenceConfig() {
    ReferenceConfig value = requestmeta.getReferenceConfig();
    Assert.assertNotNull(value);
}
Also used : ReferenceConfig(org.apache.servicecomb.core.provider.consumer.ReferenceConfig) Test(org.junit.Test)

Example 3 with ReferenceConfig

use of org.apache.servicecomb.core.provider.consumer.ReferenceConfig in project incubator-servicecomb-java-chassis by apache.

the class EdgeInvocation method createInvocation.

@Override
protected void createInvocation() {
    ReferenceConfig referenceConfig = new ReferenceConfig();
    referenceConfig.setMicroserviceMeta(latestMicroserviceVersionMeta.getMicroserviceMeta());
    referenceConfig.setMicroserviceVersionRule(microserviceVersionRule.getVersionRule().getVersionRule());
    referenceConfig.setTransport(Const.ANY_TRANSPORT);
    this.invocation = InvocationFactory.forConsumer(referenceConfig, restOperationMeta.getOperationMeta(), null);
    this.invocation.setResponseExecutor(new ReactiveResponseExecutor());
}
Also used : ReferenceConfig(org.apache.servicecomb.core.provider.consumer.ReferenceConfig) ReactiveResponseExecutor(org.apache.servicecomb.core.provider.consumer.ReactiveResponseExecutor)

Example 4 with ReferenceConfig

use of org.apache.servicecomb.core.provider.consumer.ReferenceConfig in project incubator-servicecomb-java-chassis by apache.

the class MockUtil method mockConsumerProviderManager.

public void mockConsumerProviderManager() {
    ConsumerProviderManager consumerProviderManager = new MockUp<ConsumerProviderManager>() {

        @Mock
        public ReferenceConfig getReferenceConfig(String microserviceName) {
            return new ReferenceConfig(CseContext.getInstance().getConsumerSchemaFactory(), "test", "test", "test");
        }
    }.getMockInstance();
    CseContext.getInstance().setConsumerProviderManager(consumerProviderManager);
}
Also used : ConsumerProviderManager(org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager) ReferenceConfig(org.apache.servicecomb.core.provider.consumer.ReferenceConfig) Mock(mockit.Mock)

Aggregations

ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)4 Mock (mockit.Mock)1 RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)1 OperationLocator (org.apache.servicecomb.common.rest.locator.OperationLocator)1 ServicePathManager (org.apache.servicecomb.common.rest.locator.ServicePathManager)1 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)1 ConsumerProviderManager (org.apache.servicecomb.core.provider.consumer.ConsumerProviderManager)1 ReactiveResponseExecutor (org.apache.servicecomb.core.provider.consumer.ReactiveResponseExecutor)1 Test (org.junit.Test)1