ProviderGroup { public ProviderGroup addAll(Collection<ProviderInfo> providerInfos) { if (CommonUtils.isEmpty(providerInfos)) { return this; } ConcurrentHashSet<ProviderInfo> tmp = new ConcurrentHashSet<ProviderInfo>(this.providerInfos); tmp.addAll(providerInfos); this.providerInfos = new ArrayList<ProviderInfo>(tmp); return this; } ProviderGroup();  ProviderGroup(String name);  ProviderGroup(String name, List<ProviderInfo> providerInfos);  ProviderGroup(List<ProviderInfo> providerInfos); String getName(); List<ProviderInfo> getProviderInfos(); void setProviderInfos(List<ProviderInfo> providerInfos); boolean isEmpty(); int size(); ProviderGroup add(ProviderInfo providerInfo); ProviderGroup addAll(Collection<ProviderInfo> providerInfos); ProviderGroup remove(ProviderInfo providerInfo); ProviderGroup removeAll(List<ProviderInfo> providerInfos); @Override String toString();  }
@Test public void addAll() throws Exception { ProviderGroup pg = new ProviderGroup("xxx", null); Assert.assertTrue(pg.size() == 0); pg.addAll(null); Assert.assertTrue(pg.size() == 0); pg.addAll(new ArrayList<ProviderInfo>()); Assert.assertTrue(pg.size() == 0); pg.addAll(Arrays.asList(ProviderHelper.toProviderInfo("127.0.0.1:12200"), ProviderHelper.toProviderInfo("127.0.0.1:12201"))); Assert.assertTrue(pg.size() == 2); pg.addAll(Collections.singleton(ProviderHelper.toProviderInfo("127.0.0.1:12202"))); Assert.assertTrue(pg.size() == 3); pg.addAll(Arrays.asList(ProviderHelper.toProviderInfo("127.0.0.1:12201"), ProviderHelper.toProviderInfo("127.0.0.1:12203"))); Assert.assertTrue(pg.size() == 4); pg.addAll(Arrays.asList(ProviderHelper.toProviderInfo("127.0.0.1:12201"), ProviderHelper.toProviderInfo("127.0.0.1:12202"))); Assert.assertTrue(pg.size() == 4); }