use of org.apache.servicecomb.service.center.client.model.MicroserviceInstancesResponse in project java-chassis by ServiceComb.
the class ServiceCenterClientTest method TestGetServiceCenterInstances.
@Test
public void TestGetServiceCenterInstances() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
String responseString = "{\n" + " \"instances\": [\n" + " {\n" + " \"instanceId\": \"111111\",\n" + " \"serviceId\": \"222222\",\n" + " \"version\": \"1.0\",\n" + " \"hostName\": \"Test\",\n" + " \"endpoints\": [\n" + " \"string\"\n" + " ],\n" + " \"status\": \"UP\",\n" + " \"properties\": {\n" + " \"additionalProp1\": \"string\",\n" + " \"additionalProp2\": \"string\",\n" + " \"additionalProp3\": \"string\"\n" + " },\n" + " \"healthCheck\": {\n" + " \"mode\": \"push\",\n" + " \"port\": \"0\",\n" + " \"interval\": \"0\",\n" + " \"times\": \"0\"\n" + " },\n" + " \"dataCenterInfo\": {\n" + " \"name\": \"string\",\n" + " \"region\": \"string\",\n" + " \"availableZone\": \"string\"\n" + " },\n" + " \"timestamp\": \"333333\",\n" + " \"modTimestamp\": \"4444444\"\n" + " }\n" + " ]\n" + "}";
httpResponse.setContent(responseString);
Mockito.when(serviceCenterRawClient.getHttpRequest("/registry/health", null, null)).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
MicroserviceInstancesResponse serviceCenterInstances = serviceCenterClient.getServiceCenterInstances();
Assert.assertNotNull(serviceCenterInstances);
Assert.assertEquals(1, serviceCenterInstances.getInstances().size());
Assert.assertEquals("111111", serviceCenterInstances.getInstances().get(0).getInstanceId());
Assert.assertEquals("222222", serviceCenterInstances.getInstances().get(0).getServiceId());
}
use of org.apache.servicecomb.service.center.client.model.MicroserviceInstancesResponse in project java-chassis by ServiceComb.
the class ServiceCenterClientTest method TestGetServiceInstanceList.
@Test
public void TestGetServiceInstanceList() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
String responseString = "{\n" + " \"instances\": [\n" + " {\n" + " \"instanceId\": \"111111\",\n" + " \"serviceId\": \"222222\",\n" + " \"version\": \"1.0\",\n" + " \"hostName\": \"Test\",\n" + " \"endpoints\": [\n" + " \"string\"\n" + " ],\n" + " \"status\": \"UP\",\n" + " \"timestamp\": \"333333\",\n" + " \"modTimestamp\": \"4444444\"\n" + " }\n" + " ]\n" + "}";
httpResponse.setContent(responseString);
Mockito.when(serviceCenterRawClient.getHttpRequest("/registry/microservices/222222/instances", null, null)).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
MicroserviceInstancesResponse serviceCenterInstances = serviceCenterClient.getMicroserviceInstanceList("222222");
Assert.assertNotNull(serviceCenterInstances);
Assert.assertEquals(1, serviceCenterInstances.getInstances().size());
Assert.assertEquals("111111", serviceCenterInstances.getInstances().get(0).getInstanceId());
Assert.assertEquals("222222", serviceCenterInstances.getInstances().get(0).getServiceId());
}
Aggregations