use of com.alibaba.nacos.api.naming.remote.response.QueryServiceResponse in project nacos by alibaba.
the class NamingGrpcClientProxyTest method testQueryInstancesOfService.
@Test
public void testQueryInstancesOfService() throws Exception {
QueryServiceResponse res = new QueryServiceResponse();
ServiceInfo info = new ServiceInfo(GROUP_NAME + "@@" + SERVICE_NAME + "@@" + CLUSTERS);
res.setServiceInfo(info);
when(this.rpcClient.request(any())).thenReturn(res);
ServiceInfo actual = client.queryInstancesOfService(SERVICE_NAME, GROUP_NAME, CLUSTERS, 0, false);
Assert.assertEquals(info, actual);
}
use of com.alibaba.nacos.api.naming.remote.response.QueryServiceResponse in project nacos by alibaba.
the class NamingGrpcClientProxy method queryInstancesOfService.
@Override
public ServiceInfo queryInstancesOfService(String serviceName, String groupName, String clusters, int udpPort, boolean healthyOnly) throws NacosException {
ServiceQueryRequest request = new ServiceQueryRequest(namespaceId, serviceName, groupName);
request.setCluster(clusters);
request.setHealthyOnly(healthyOnly);
request.setUdpPort(udpPort);
QueryServiceResponse response = requestToServer(request, QueryServiceResponse.class);
return response.getServiceInfo();
}
use of com.alibaba.nacos.api.naming.remote.response.QueryServiceResponse in project nacos by alibaba.
the class ServiceQueryRequestHandlerTest method testHandle.
@Test
public void testHandle() throws NacosException {
Instance instance = new Instance();
instance.setIp("1.1.1.1");
List<Instance> instances = Arrays.asList(instance);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setGroupName("A");
serviceInfo.setGroupName("B");
serviceInfo.setName("C");
serviceInfo.setHosts(instances);
Mockito.when(serviceStorage.getData(Mockito.any())).thenReturn(serviceInfo);
ServiceMetadata serviceMetadata = new ServiceMetadata();
Mockito.when(metadataManager.getServiceMetadata(Mockito.any())).thenReturn(Optional.of(serviceMetadata));
ServiceQueryRequest serviceQueryRequest = new ServiceQueryRequest();
serviceQueryRequest.setNamespace("A");
serviceQueryRequest.setGroupName("B");
serviceQueryRequest.setServiceName("C");
serviceQueryRequest.setHealthyOnly(false);
QueryServiceResponse queryServiceResponse = serviceQueryRequestHandler.handle(serviceQueryRequest, new RequestMeta());
Assert.assertEquals(queryServiceResponse.getServiceInfo().getName(), "C");
}
Aggregations