use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceInstanceRegisterTask method setup.
@Before
public void setup() {
eventBus = new EventBus();
taskList = new ArrayList<>();
eventBus.register(new Object() {
@Subscribe
public void onEvent(MicroserviceInstanceRegisterTask task) {
taskList.add(task);
}
});
microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("ms");
microservice.setServiceId("serviceId");
microservice.setInstance(new MicroserviceInstance());
HealthCheck healthCheck = new HealthCheck();
healthCheck.setMode(HealthCheckMode.HEARTBEAT);
microservice.getInstance().setHealthCheck(healthCheck);
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceRegisterTask method setup.
@Before
public void setup() {
eventBus = new EventBus();
taskList = new ArrayList<>();
eventBus.register(new Object() {
@Subscribe
public void onEvent(MicroserviceRegisterTask task) {
taskList.add(task);
}
});
microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("ms");
microservice.setInstance(new MicroserviceInstance());
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceRegisterTask method testAlreadyRegisteredSchemaIdSetNotMatch.
@Test
public void testAlreadyRegisteredSchemaIdSetNotMatch(@Mocked ServiceRegistryClient srClient) {
Microservice otherMicroservice = new Microservice();
otherMicroservice.setAppId(microservice.getAppId());
otherMicroservice.setServiceName("ms1");
otherMicroservice.addSchema("s1", "");
new Expectations() {
{
srClient.getMicroserviceId(anyString, anyString, anyString);
result = "serviceId";
srClient.getMicroservice(anyString);
result = otherMicroservice;
}
};
MicroserviceRegisterTask registerTask = new MicroserviceRegisterTask(eventBus, srClient, microservice);
registerTask.run();
Assert.assertEquals(true, registerTask.isRegistered());
Assert.assertEquals(false, registerTask.isSchemaIdSetMatch());
Assert.assertEquals("serviceId", microservice.getServiceId());
Assert.assertEquals("serviceId", microservice.getInstance().getServiceId());
Assert.assertEquals(1, taskList.size());
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class LocalServiceRegistryClientImplTest method registerSchema_normal.
@Test
public void registerSchema_normal() {
Microservice v1 = mockRegisterMicroservice(appId, microserviceName, "1.0.0");
Assert.assertTrue(registryClient.registerSchema(v1.getServiceId(), "sid", "content"));
}
use of org.apache.servicecomb.serviceregistry.api.registry.Microservice in project incubator-servicecomb-java-chassis by apache.
the class CseDiscoveryClient method getServices.
@Override
public List<String> getServices() {
ServiceRegistryClient client = RegistryUtils.getServiceRegistryClient();
List<Microservice> services = client.getAllMicroservices();
List<String> serviceIDList = new ArrayList<>();
if (null != services && !services.isEmpty()) {
for (Microservice service : services) {
serviceIDList.add(service.getServiceName());
}
}
return serviceIDList;
}
Aggregations