Search in sources :

Example 1 with NotifySubscriberResponse

use of com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse in project nacos by alibaba.

the class NamingPushRequestHandlerTest method testRequestReply.

@Test
public void testRequestReply() {
    // given
    ServiceInfoHolder holder = mock(ServiceInfoHolder.class);
    NamingPushRequestHandler handler = new NamingPushRequestHandler(holder);
    ServiceInfo info = new ServiceInfo("name", "cluster1");
    Request req = NotifySubscriberRequest.buildNotifySubscriberRequest(info);
    // when
    Response response = handler.requestReply(req);
    // then
    Assert.assertTrue(response instanceof NotifySubscriberResponse);
    verify(holder, times(1)).processServiceInfo(info);
}
Also used : ServiceInfo(com.alibaba.nacos.api.naming.pojo.ServiceInfo) Response(com.alibaba.nacos.api.remote.response.Response) NotifySubscriberResponse(com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse) ServiceInfoHolder(com.alibaba.nacos.client.naming.cache.ServiceInfoHolder) NotifySubscriberResponse(com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse) NotifySubscriberRequest(com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest) Request(com.alibaba.nacos.api.remote.request.Request) Test(org.junit.Test)

Example 2 with NotifySubscriberResponse

use of com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse in project nacos by alibaba.

the class NamingPushRequestHandler method requestReply.

@Override
public Response requestReply(Request request) {
    if (request instanceof NotifySubscriberRequest) {
        NotifySubscriberRequest notifyResponse = (NotifySubscriberRequest) request;
        serviceInfoHolder.processServiceInfo(notifyResponse.getServiceInfo());
        return new NotifySubscriberResponse();
    }
    return null;
}
Also used : NotifySubscriberRequest(com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest) NotifySubscriberResponse(com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse)

Aggregations

NotifySubscriberRequest (com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest)2 NotifySubscriberResponse (com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse)2 ServiceInfo (com.alibaba.nacos.api.naming.pojo.ServiceInfo)1 Request (com.alibaba.nacos.api.remote.request.Request)1 Response (com.alibaba.nacos.api.remote.response.Response)1 ServiceInfoHolder (com.alibaba.nacos.client.naming.cache.ServiceInfoHolder)1 Test (org.junit.Test)1