GlobalConfigurationObservable extends Observable { @Override public synchronized void addObserver(Observer o) { if (o instanceof GlobalConfigurationObserver) { super.addObserver(o); } }  @Override synchronized void addObserver(Observer o); void notifyThemeChanged(final String oldTheme, final String newTheme); void notifyProxyHostChanged(final boolean forHttps, final String oldHost, final String newHost); void notifyProxyPortChanged(final boolean forHttps, final Integer oldPort, final Integer newPort);  }
@Test @DisplayName("doesn't add a null observer") void dontAddNullObserver() { final GlobalConfigurationObservable observable = new GlobalConfigurationObservable(); observable.addObserver(null); assertEquals(0, observable.countObservers()); }
@Test @DisplayName("doesn't add non GlobalConfigurationObserver instances") void dontAcceptNonGlobalConfigurationObservers() { final GlobalConfigurationObservable observable = new GlobalConfigurationObservable(); observable.addObserver((o, arg) -> { }); assertEquals(0, observable.countObservers()); }
@Test @DisplayName("accepts GlobalConfigurationObserver instances") void addGlobalConfigurationObservers() { final GlobalConfigurationObservable observable = new GlobalConfigurationObservable(); observable.addObserver(new GlobalConfigurationObserver() { @Override public void updateTheme(String oldTheme, String newTheme) { } @Override public void updateHttpProxyHost(boolean forHttps, String oldHost, String newHost) { } @Override public void updateHttpProxyPort(boolean forHttps, Integer oldPort, Integer newPort) { } }); assertEquals(1, observable.countObservers()); }