History { public void attachChangeListener(Setting setting) { ChangeListener changeEvent = (observable, oldValue, newValue) -> { if (isListenerActive() && oldValue != newValue) { LOGGER.trace("Change detected, old: " + oldValue + " new: " + newValue); addChange(new Change(setting, oldValue, newValue)); } }; ChangeListener listChangeEvent = (observable, oldValue, newValue) -> { if (isListenerActive()) { LOGGER.trace("List Change detected: " + oldValue); addChange(new Change(setting, (ObservableList) oldValue, (ObservableList) newValue)); } }; if (setting.valueProperty() instanceof SimpleListProperty) { setting.valueProperty().addListener(listChangeEvent); } else { setting.valueProperty().addListener(changeEvent); } } History(); void attachChangeListener(Setting setting); void doWithoutListeners(Setting setting, Runnable action); boolean undo(); void undoAll(); boolean redo(); void redoAll(); void clear(boolean undoAll); boolean isUndoAvailable(); BooleanProperty undoAvailableProperty(); boolean isRedoAvailable(); BooleanProperty redoAvailableProperty(); ObservableList<Change> getChanges(); ReadOnlyObjectProperty<Change> currentChangeProperty(); boolean isListenerActive(); ReadOnlyBooleanProperty listenerActiveProperty(); void setListenerActive(boolean listenerActive);  }
@Test public void attachChangeListener() throws Exception { setupMockProperty(); verify(mockProperty, never()).addListener(any(ChangeListener.class)); history.attachChangeListener(mockSetting); verify(mockProperty).addListener(any(ChangeListener.class)); }