use of org.apache.servicecomb.service.center.client.model.Microservice in project incubator-servicecomb-java-chassis by apache.
the class ServiceCenterClientTest method TestRegistryService.
@Test
public void TestRegistryService() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
httpResponse.setContent("{\"serviceId\": \"111111\"}");
Microservice microservice = new Microservice();
microservice.setServiceName("Test");
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
Mockito.when(serviceCenterRawClient.postHttpRequest("/registry/microservices", null, objectMapper.writeValueAsString(microservice))).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
RegisteredMicroserviceResponse actualResponse = serviceCenterClient.registerMicroservice(microservice);
Assert.assertNotNull(actualResponse);
Assert.assertEquals("111111", actualResponse.getServiceId());
}
use of org.apache.servicecomb.service.center.client.model.Microservice in project incubator-servicecomb-java-chassis by apache.
the class ServiceCenterClientTest method TestQueryServiceId.
@Test
public void TestQueryServiceId() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
httpResponse.setContent("{\"serviceId\": \"111111\"}");
Mockito.when(serviceCenterRawClient.getHttpRequest(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
Microservice microservice = new Microservice("Test111");
RegisteredMicroserviceResponse actualServiceId = serviceCenterClient.queryServiceId(microservice);
Assert.assertNotNull(actualServiceId);
Assert.assertEquals("111111", actualServiceId.getServiceId());
}
Aggregations