@Test public void testSwitchToNow() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); reset(timeInstantView); when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.NOW.getIndex()); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.NOW); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(changeCommand).execute(); }
@Test public void testSwitchToNow() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); reset(timeInstantView); when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.NOW.getIndex()); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.NOW); verify(timeInstantView).disableIntervalTypeSelector(); verify(timeInstantView, never()).enableIntervalTypeSelector(); verify(changeCommand).execute(); }
@Test public void testSwitchFromNow() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); reset(timeInstantView); when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.END.getIndex()); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.END); verify(timeInstantView).enableIntervalTypeSelector(); verify(changeCommand).execute(); } }
@Test public void testSwitchFromNow() { TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); reset(timeInstantView); when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.END.getIndex()); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.END); verify(timeInstantView).enableIntervalTypeSelector(); verify(changeCommand).execute(); } }
@Test public void testChangeTimeMode() { when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.BEGIN.getIndex()); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.BEGIN); verify(changeCommand).execute(); }
void changeTimeMode() { int selectedIdx = view.getTimeModeSelectedIndex(); TimeInstant.TimeMode mode = TimeInstant.TimeMode.getByIndex(selectedIdx); timeInstant.setTimeMode(mode); TimeAmount timeAmount = timeInstant.getTimeAmount(); if (timeAmount != null) { timeAmount.setQuantity(0); } onChangeCommand.execute(); initIntervalTypeSelector(); }
void changeTimeMode() { int selectedIdx = view.getTimeModeSelectedIndex(); TimeInstant.TimeMode mode = TimeInstant.TimeMode.getByIndex(selectedIdx); timeInstant.setTimeMode(mode); TimeAmount timeAmount = timeInstant.getTimeAmount(); if (timeAmount != null) { timeAmount.setQuantity(0); } onChangeCommand.execute(); initIntervalTypeSelector(); }
@Test public void testChangeTimeMode() { when(timeInstantView.getTimeModeSelectedIndex()).thenReturn(TimeInstant.TimeMode.BEGIN.getIndex()); TimeInstantEditor timeInstantEditor = new TimeInstantEditor(timeInstantView, timeAmountEditor); timeInstantEditor.init(null, changeCommand); timeInstantEditor.changeTimeMode(); TimeInstant timeInstant = timeInstantEditor.getTimeInstant(); assertEquals(timeInstant.getTimeMode(), TimeInstant.TimeMode.BEGIN); verify(changeCommand).execute(); }