use of com.alibaba.nacos.api.selector.AbstractSelector in project nacos by alibaba.
the class NacosNamingMaintainServiceTest method testUpdateService3.
@Test
public void testUpdateService3() throws NacosException {
// given
Service service = new Service();
AbstractSelector selector = new NoneSelector();
// when
nacosNamingMaintainService.updateService(service, selector);
// then
verify(serverProxy, times(1)).updateService(service, selector);
}
use of com.alibaba.nacos.api.selector.AbstractSelector in project nacos by alibaba.
the class NacosNamingServiceTest method testGetServicesOfServer3.
@Test
public void testGetServicesOfServer3() throws NacosException {
// given
int pageNo = 1;
int pageSize = 10;
AbstractSelector selector = new AbstractSelector("aaa") {
@Override
public String getType() {
return super.getType();
}
};
// when
client.getServicesOfServer(pageNo, pageSize, selector);
// then
verify(proxy, times(1)).getServiceList(pageNo, pageSize, Constants.DEFAULT_GROUP, selector);
}
use of com.alibaba.nacos.api.selector.AbstractSelector in project nacos by alibaba.
the class NamingGrpcClientProxyTest method testGetServiceList.
@Test
public void testGetServiceList() throws Exception {
ServiceListResponse res = new ServiceListResponse();
List<String> services = Arrays.asList("service1", "service2");
res.setServiceNames(services);
res.setCount(5);
when(this.rpcClient.request(any())).thenReturn(res);
AbstractSelector selector = new NoneSelector();
ListView<String> serviceList = client.getServiceList(1, 10, GROUP_NAME, selector);
Assert.assertEquals(5, serviceList.getCount());
Assert.assertEquals(services, serviceList.getData());
}
use of com.alibaba.nacos.api.selector.AbstractSelector in project nacos by alibaba.
the class NamingGrpcClientProxyTest method testCreateService.
@Test
public void testCreateService() throws Exception {
// TODO thrown.expect(UnsupportedOperationException.class);
Service service = new Service();
AbstractSelector selector = new NoneSelector();
client.createService(service, selector);
}
use of com.alibaba.nacos.api.selector.AbstractSelector in project nacos by alibaba.
the class NamingClientProxyDelegateTest method testGetServiceList.
@Test
public void testGetServiceList() throws NacosException, NoSuchFieldException, IllegalAccessException {
String ns = "ns1";
ServiceInfoHolder holder = Mockito.mock(ServiceInfoHolder.class);
Properties props = new Properties();
props.setProperty("serverAddr", "localhost");
InstancesChangeNotifier notifier = new InstancesChangeNotifier();
NamingClientProxyDelegate delegate = new NamingClientProxyDelegate(ns, holder, props, notifier);
NamingGrpcClientProxy mockGrpcClient = Mockito.mock(NamingGrpcClientProxy.class);
Field grpcClientProxyField = NamingClientProxyDelegate.class.getDeclaredField("grpcClientProxy");
grpcClientProxyField.setAccessible(true);
grpcClientProxyField.set(delegate, mockGrpcClient);
AbstractSelector selector = new ExpressionSelector();
int pageNo = 1;
int pageSize = 10;
String groupName = "group2";
delegate.getServiceList(pageNo, pageSize, groupName, selector);
verify(mockGrpcClient, times(1)).getServiceList(pageNo, pageSize, groupName, selector);
}
Aggregations