@UiHandler(value = "typeList") public void onFilterSelected(ChangeEvent changeEvent) { presenter.changeIntervalType(); } }
public void onClick(ClickEvent event) { presenter.decreaseQuantity(); } }, ClickEvent.getType());
public void onClick(ClickEvent event) { presenter.increaseQuantity(); } }, ClickEvent.getType());
public void decreaseQuantity() { long q = getQuantity()-1; changeQuantity(q); view.setQuantity(q); }
@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 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); }
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 changeQuantity(String value) { if (StringUtils.isBlank(value)) { changeQuantity(0); } else { changeQuantity(Long.parseLong(value)); } }
public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } });
@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@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 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); }
public void decreaseQuantity() { long q = getQuantity()-1; changeQuantity(q); view.setQuantity(q); }
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 changeQuantity(String value) { if (StringUtils.isBlank(value)) { changeQuantity(0); } else { changeQuantity(Long.parseLong(value)); } }
public void execute() { timeInstant.setTimeAmount(timeAmountEditor.getTimeAmount()); onChangeCommand.execute(); } });
@Before public void init() { fromAmountEditor = new TimeAmountEditor(timeAmountView); toAmountEditor = new TimeAmountEditor(timeAmountView); fromInstantEditor = new TimeInstantEditor(timeInstantView, fromAmountEditor); toInstantEditor = new TimeInstantEditor(timeInstantView, toAmountEditor); timeFrameEditor = new TimeFrameEditor(timeFrameView, beanManager); SyncBeanDef tieBeanDef = mock(SyncBeanDef.class); when(beanManager.lookupBean(TimeInstantEditor.class)).thenReturn(tieBeanDef); when(tieBeanDef.newInstance()).thenReturn(fromInstantEditor, toInstantEditor); }
@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); }