/** * To simulate a uncheck of the component * * @param <T> type of the component * @param component testatoo component * @return the unchecked component */ public static <T extends CheckBox> T unCheck(T component) { component.unCheck(); return component; }
@Test public void can_check_and_modifiy_checkbox_state() { CheckBox checkBox = new CheckBox(evaluator, id); when(evaluator.isChecked(checkBox)).thenReturn(false, true, false); assertThat(checkBox.isChecked(), is(false)); checkBox.check(); assertThat(checkBox.isChecked(), is(true)); checkBox.unCheck(); assertThat(checkBox.isChecked(), is(false)); verify(evaluator, times(3)).isChecked(checkBox); verify(evaluator, times(1)).check(checkBox); verify(evaluator, times(1)).unCheck(checkBox); }