### Question:
AbstractRegistry implements Registry { protected void notify(List<URL> urls) { if (urls == null || urls.isEmpty()) { return; } for (Map.Entry<URL, Set<NotifyListener>> entry : getSubscribed().entrySet()) { URL url = entry.getKey(); if (!UrlUtils.isMatch(url, urls.get(0))) { continue; } Set<NotifyListener> listeners = entry.getValue(); if (listeners != null) { for (NotifyListener listener : listeners) { try { notify(url, listener, filterEmpty(url, urls)); } catch (Throwable t) { logger.error("Failed to notify registry event, urls: " + urls + ", cause: " + t.getMessage(), t); } } } } } AbstractRegistry(URL url); @Override URL getUrl(); Set<URL> getRegistered(); Map<URL, Set<NotifyListener>> getSubscribed(); Map<URL, Map<String, List<URL>>> getNotified(); File getCacheFile(); Properties getCacheProperties(); AtomicLong getLastCacheChanged(); void doSaveProperties(long version); List<URL> getCacheUrls(URL url); @Override List<URL> lookup(URL url); @Override void register(URL url); @Override void unregister(URL url); @Override void subscribe(URL url, NotifyListener listener); @Override void unsubscribe(URL url, NotifyListener listener); @Override void destroy(); @Override String toString();  }### Answer:
@Test public void testNotify() throws Exception { final AtomicReference<Boolean> notified = new AtomicReference<Boolean>(false); NotifyListener listner1 = urls -> notified.set(Boolean.TRUE); URL url1 = new URL("dubbo", "192.168.0.1", 2200, parametersConsumer); abstractRegistry.subscribe(url1, listner1); NotifyListener listner2 = urls -> notified.set(Boolean.TRUE); URL url2 = new URL("dubbo", "192.168.0.2", 2201, parametersConsumer); abstractRegistry.subscribe(url2, listner2); NotifyListener listner3 = urls -> notified.set(Boolean.TRUE); URL url3 = new URL("dubbo", "192.168.0.3", 2202, parametersConsumer); abstractRegistry.subscribe(url3, listner3); List<URL> urls = new ArrayList<>(); urls.add(url1); urls.add(url2); urls.add(url3); abstractRegistry.notify(url1, listner1, urls); Map<URL, Map<String, List<URL>>> map = abstractRegistry.getNotified(); MatcherAssert.assertThat(true, Matchers.equalTo(map.containsKey(url1))); MatcherAssert.assertThat(false, Matchers.equalTo(map.containsKey(url2))); MatcherAssert.assertThat(false, Matchers.equalTo(map.containsKey(url3))); }
@Test public void testNotifyArgs() throws Exception { try { abstractRegistry.notify(null, null, null); Assertions.fail(); } catch (Exception e) { Assertions.assertTrue(e instanceof IllegalArgumentException); } try { abstractRegistry.notify(testUrl, null, null); Assertions.fail(); } catch (Exception e) { Assertions.assertTrue(e instanceof IllegalArgumentException); } try { abstractRegistry.notify(null, listener, null); Assertions.fail(); } catch (Exception e) { Assertions.assertTrue(e instanceof IllegalArgumentException); } Assertions.assertFalse(notifySuccess); abstractRegistry.notify(testUrl, listener, null); Assertions.assertFalse(notifySuccess); List<URL> urls = new ArrayList<>(); urls.add(testUrl); Assertions.assertFalse(notifySuccess); abstractRegistry.notify(testUrl, listener, urls); Assertions.assertTrue(notifySuccess); }