Search in sources :

Example 1 with ReferenceConfig

use of io.servicecomb.core.provider.consumer.ReferenceConfig in project java-chassis by ServiceComb.

the class MockUtil method mockConsumerProviderManager.

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

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

Example 2 with ReferenceConfig

use of io.servicecomb.core.provider.consumer.ReferenceConfig in project java-chassis by ServiceComb.

the class TestRequestMeta method testGetReferenceConfig.

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

Example 3 with ReferenceConfig

use of io.servicecomb.core.provider.consumer.ReferenceConfig in project java-chassis by ServiceComb.

the class CseClientHttpRequest method createRequestMeta.

private RequestMeta createRequestMeta(String httpMetod, URI uri) {
    String microserviceName = uri.getAuthority();
    ReferenceConfig referenceConfig = CseContext.getInstance().getConsumerProviderManager().getReferenceConfig(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.locateOperation(uri.getPath(), httpMetod);
    RestOperationMeta swaggerRestOperation = locator.getOperation();
    Map<String, String> pathParams = locator.getPathVarMap();
    return new RequestMeta(referenceConfig, swaggerRestOperation, pathParams);
}
Also used : OperationLocator(io.servicecomb.common.rest.locator.OperationLocator) RestOperationMeta(io.servicecomb.common.rest.definition.RestOperationMeta) ReferenceConfig(io.servicecomb.core.provider.consumer.ReferenceConfig) MicroserviceMeta(io.servicecomb.core.definition.MicroserviceMeta) ServicePathManager(io.servicecomb.common.rest.locator.ServicePathManager)

Aggregations

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