public void init(final TimeInstant ti, final Command onChangeCommand) { this.timeInstant = ti != null ? ti : new TimeInstant(); this.onChangeCommand = onChangeCommand; this.timeAmountEditor.init(timeInstant.getTimeAmount(), new Command() { public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } }); initTimeModeSelector(); initIntervalTypeSelector(); }
public void init(final TimeInstant ti, final Command onChangeCommand) { this.timeInstant = ti != null ? ti : new TimeInstant(); this.onChangeCommand = onChangeCommand; this.timeAmountEditor.init(timeInstant.getTimeAmount(), new Command() { public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } }); initTimeModeSelector(); initIntervalTypeSelector(); }
@Test public void testNullInitialization() { TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(null, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); // "0year" set by default verify(timeAmountView).setSelectedTypeIndex(7); verify(timeAmountView).setQuantity(0); }
@Test public void testNullInitialization() { TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(null, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); // "0year" set by default verify(timeAmountView).setSelectedTypeIndex(7); verify(timeAmountView).setQuantity(0); }
@Test public void testViewInitialization() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(timeAmount, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeAmountView).setSelectedTypeIndex(3); verify(timeAmountView).setQuantity(10); }
@Test public void testViewInitialization() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor editor = new TimeAmountEditor(timeAmountView); editor.init(timeAmount, changeCommand); verify(timeAmountView).clearIntervalTypeSelector(); verify(timeAmountView, times(TimeAmountEditor.INTERVAL_TYPES.size())).addIntervalTypeItem(any(DateIntervalType.class)); verify(timeAmountView).setSelectedTypeIndex(3); verify(timeAmountView).setQuantity(10); }
@Test public void testDecreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.decreaseQuantity(); verify(timeAmountView).setQuantity(9); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 9); }
@Test public void testIncreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.increaseQuantity(); verify(timeAmountView).setQuantity(11); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 11); } }
@Test public void testIncreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.increaseQuantity(); verify(timeAmountView).setQuantity(11); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 11); } }
@Test public void testDecreaseQuantity() { TimeAmount timeAmount = new TimeAmount(10, DateIntervalType.DAY); TimeAmountEditor timeAmountEditor = new TimeAmountEditor(timeAmountView); timeAmountEditor.init(timeAmount, changeCommand); timeAmountEditor.decreaseQuantity(); verify(timeAmountView).setQuantity(9); verify(changeCommand).execute(); assertEquals(timeAmount.getQuantity(), 9); }