Search in sources :

Example 1 with HeartbeatsRequest

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);
}
Also used : HeartbeatsRequest(org.apache.servicecomb.service.center.client.model.HeartbeatsRequest) HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) InstancesRequest(org.apache.servicecomb.service.center.client.model.InstancesRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 2 with 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);
}
Also used : HeartbeatsRequest(org.apache.servicecomb.service.center.client.model.HeartbeatsRequest) HttpResponse(org.apache.servicecomb.http.client.common.HttpResponse) InstancesRequest(org.apache.servicecomb.service.center.client.model.InstancesRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 HttpResponse (org.apache.servicecomb.http.client.common.HttpResponse)2 HeartbeatsRequest (org.apache.servicecomb.service.center.client.model.HeartbeatsRequest)2 InstancesRequest (org.apache.servicecomb.service.center.client.model.InstancesRequest)2 Test (org.junit.Test)2