use of org.apache.servicecomb.service.center.client.model.MicroservicesResponse in project java-chassis by ServiceComb.
the class ServiceCenterClientTest method TestGetServiceList.
@Test
public void TestGetServiceList() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
MicroservicesResponse microservicesResponse = new MicroservicesResponse();
List<Microservice> microserviceList = new ArrayList<Microservice>();
microserviceList.add(new Microservice("Test1"));
microserviceList.add(new Microservice("Test2"));
microserviceList.add(new Microservice("Test3"));
microservicesResponse.setServices(microserviceList);
ObjectMapper mapper = new ObjectMapper();
httpResponse.setContent(mapper.writeValueAsString(microservicesResponse));
Mockito.when(serviceCenterRawClient.getHttpRequest(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
MicroservicesResponse actualMicroservicesResponse = serviceCenterClient.getMicroserviceList();
Assert.assertNotNull(actualMicroservicesResponse);
Assert.assertEquals(3, actualMicroservicesResponse.getServices().size());
Assert.assertEquals("Test1", actualMicroservicesResponse.getServices().get(0).getServiceName());
}
Aggregations