use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.
the class ConsumerSchemaFactory method findMicroservice.
protected Microservice findMicroservice(MicroserviceMeta microserviceMeta, String microserviceVersionRule) {
String appId = microserviceMeta.getAppId();
String microserviceName = microserviceMeta.getName();
ServiceRegistryClient client = RegistryClientFactory.getRegistryClient();
String microserviceId = client.getMicroserviceId(appId, microserviceMeta.getShortName(), microserviceVersionRule);
if (StringUtils.isEmpty(microserviceId)) {
LOGGER.error("can not get microservice id, {}:{}:{}", appId, microserviceName, microserviceVersionRule);
return null;
}
Microservice microservice = client.getMicroservice(microserviceId);
if (microservice == null) {
LOGGER.error("can not get microservice, {}:{}:{}", appId, microserviceName, microserviceVersionRule);
return null;
}
LOGGER.info("Found schema ids from service center, {}:{}:{}:{}", appId, microserviceName, microserviceVersionRule, microservice.getSchemas());
return microservice;
}
use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestTransport method setupClass.
@BeforeClass
public static void setupClass() throws Exception {
Microservice microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("testname");
new MockUp<RegistryUtils>() {
@Mock
private Microservice createMicroserviceFromDefinition() {
return microservice;
}
};
}
use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestSimpleLoadBalanceHandler method testHandler.
@Test
public void testHandler() {
boolean status = false;
mock();
Assert.assertNotNull(simpleLoadBalanceHandler);
try {
final Microservice microService = new Microservice();
new MockUp<RegistryUtils>() {
@Mock
private Microservice createMicroserviceFromDefinition() {
return microService;
}
};
Mockito.when(invocation.getMicroserviceName()).thenReturn(microserviceMetaManager.getName());
Mockito.when(invocation.getMicroserviceVersionRule()).thenReturn("MicroserviceVersionRule");
Mockito.when(invocation.getConfigTransportName()).thenReturn("TransportName");
simpleLoadBalanceHandler.handle(invocation, asyncResp);
} catch (Exception e) {
status = true;
}
Assert.assertTrue(status);
}
use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestCseServerList method mockTestCases.
private void mockTestCases() {
final Microservice microService = new Microservice();
microService.setAppId("appId");
new MockUp<RegistryUtils>() {
@Mock
public Microservice getMicroservice() {
return microService;
}
@Mock
private Microservice createMicroserviceFromDefinition() {
return microService;
}
};
new MockUp<InstanceCacheManager>() {
@Mock
public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
return null;
}
};
}
use of io.servicecomb.serviceregistry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestServerListCache method mockTestCases.
private void mockTestCases() {
final Microservice microService = new Microservice();
microService.setAppId("appId");
new MockUp<RegistryUtils>() {
@Mock
public Microservice getMicroservice() {
return microService;
}
@Mock
private Microservice createMicroserviceFromDefinition() {
return microService;
}
};
new MockUp<InstanceCacheManager>() {
@Mock
public InstanceCache getOrCreate(String appId, String microserviceName, String microserviceVersionRule) {
return null;
}
};
transport = Mockito.mock(Transport.class);
}
Aggregations