ToggleSwitchEditor implements IsWidget, LeafAttributeEditor<Boolean> { void onValueChanged(final Boolean value) { if (this.value != null && this.value.equals(value)) return; view.clearError(); Boolean before = this.value; this.value = value; valueChangeEvent.fire(new org.dashbuilder.common.client.event.ValueChangeEvent<Boolean>(this, before, this.value)); } @Inject  ToggleSwitchEditor(final View view,
                              final Event<org.dashbuilder.common.client.event.ValueChangeEvent<Boolean>> valueChangeEvent); @PostConstruct void init(); void setEnabled(final boolean isEnabled); @Override void showErrors(List<EditorError> errors); @Override Widget asWidget(); @Override void setValue(Boolean value); @Override Boolean getValue(); public View view; }
@Test public void testOnValueChanged() throws Exception { final Boolean newValue = true; presenter.onValueChanged(newValue); assertEquals(newValue, presenter.getValue()); verify(view, times(1)).clearError(); verify(view, times(0)).setValue(newValue); verify(view, times(0)).showError(any(SafeHtml.class)); verify(view, times(0)).init(presenter); verify( valueChangeEvent, times( 1 ) ).fire(any(ValueChangeEvent.class)); }