use of org.apache.servicecomb.service.center.client.model.RegisteredMicroserviceInstanceResponse in project java-chassis by ServiceComb.
the class ServiceCenterClientTest method TestRegisterServiceInstance.
@Test
public void TestRegisterServiceInstance() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
httpResponse.setContent("{\"instanceId\": \"111111\"}");
MicroserviceInstance instance = new MicroserviceInstance();
instance.setInstanceId("111111");
instance.setServiceId("222222");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
Mockito.when(serviceCenterRawClient.postHttpRequest("/registry/microservices/222222/instances", null, mapper.writeValueAsString(instance))).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
RegisteredMicroserviceInstanceResponse actualResponse = serviceCenterClient.registerMicroserviceInstance(instance);
Assert.assertNotNull(actualResponse);
Assert.assertEquals("111111", actualResponse.getInstanceId());
}
Aggregations