use of org.apache.servicecomb.service.center.client.model.HeartbeatsRequest in project java-chassis by ServiceComb.
the class ServiceCenterClientTest method TestSendHeartBeats.
@Test
public void TestSendHeartBeats() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
HeartbeatsRequest heartbeatsRequest = new HeartbeatsRequest("001", "1001");
heartbeatsRequest.addInstances(new InstancesRequest("002", "1002"));
ObjectMapper mapper = new ObjectMapper();
Mockito.when(serviceCenterRawClient.putHttpRequest("/registry/microservices/111/instances/222/heartbeat", null, null)).thenReturn(httpResponse);
Mockito.when(serviceCenterRawClient.putHttpRequest("/registry/heartbeats", null, mapper.writeValueAsString(heartbeatsRequest))).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
serviceCenterClient.sendHeartBeats(heartbeatsRequest);
}
use of org.apache.servicecomb.service.center.client.model.HeartbeatsRequest in project incubator-servicecomb-java-chassis by apache.
the class ServiceCenterClientTest method TestSendHeartBeats.
@Test
public void TestSendHeartBeats() throws IOException {
ServiceCenterRawClient serviceCenterRawClient = Mockito.mock(ServiceCenterRawClient.class);
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setMessage("ok");
HeartbeatsRequest heartbeatsRequest = new HeartbeatsRequest("001", "1001");
heartbeatsRequest.addInstances(new InstancesRequest("002", "1002"));
ObjectMapper mapper = new ObjectMapper();
Mockito.when(serviceCenterRawClient.putHttpRequest("/registry/microservices/111/instances/222/heartbeat", null, null)).thenReturn(httpResponse);
Mockito.when(serviceCenterRawClient.putHttpRequest("/registry/heartbeats", null, mapper.writeValueAsString(heartbeatsRequest))).thenReturn(httpResponse);
ServiceCenterClient serviceCenterClient = new ServiceCenterClient(serviceCenterRawClient);
serviceCenterClient.sendHeartBeats(heartbeatsRequest);
}
Aggregations