@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)); verify(timeAmountView).setSelectedTypeIndex(7); verify(timeAmountView).setQuantity(0); }
public void init(final TimeAmount ta, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeAmount = ta != null ? ta : new TimeAmount(); view.setQuantity(timeAmount.getQuantity()); view.clearIntervalTypeSelector(); for (int i=0; i< INTERVAL_TYPES.size(); i++) { DateIntervalType type = INTERVAL_TYPES.get(i); view.addIntervalTypeItem(type); if (timeAmount != null && timeAmount.getType().equals(type)) { view.setSelectedTypeIndex(i); } } }
TimeAmountEditor implements IsWidget { public void init(final TimeAmount ta, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeAmount = ta != null ? ta : new TimeAmount(); view.setQuantity(timeAmount.getQuantity()); view.clearIntervalTypeSelector(); for (int i=0; i< INTERVAL_TYPES.size(); i++) { DateIntervalType type = INTERVAL_TYPES.get(i); view.addIntervalTypeItem(type); if (timeAmount != null && timeAmount.getType().equals(type)) { view.setSelectedTypeIndex(i); } } } }
TimeAmountEditor implements IsWidget { public void init(final TimeAmount ta, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeAmount = ta != null ? ta : new TimeAmount(); view.setQuantity(timeAmount.getQuantity()); view.clearIntervalTypeSelector(); for (int i=0; i< INTERVAL_TYPES.size(); i++) { DateIntervalType type = INTERVAL_TYPES.get(i); view.addIntervalTypeItem(type); if (timeAmount != null && timeAmount.getType().equals(type)) { view.setSelectedTypeIndex(i); } } } @Inject  TimeAmountEditor(View view); }
TimeAmountEditor implements IsWidget { public void init(final TimeAmount ta, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeAmount = ta != null ? ta : new TimeAmount(); view.setQuantity(timeAmount.getQuantity()); view.clearIntervalTypeSelector(); for (int i=0; i< INTERVAL_TYPES.size(); i++) { DateIntervalType type = INTERVAL_TYPES.get(i); view.addIntervalTypeItem(type); if (timeAmount != null && timeAmount.getType().equals(type)) { view.setSelectedTypeIndex(i); } } } @Inject  TimeAmountEditor(View view); @Override Widget asWidget(); TimeAmount getTimeAmount(); void init(final TimeAmount ta, Command onChangeCommand); long getQuantity(); void decreaseQuantity(); void increaseQuantity(); void changeQuantity(String value); void changeIntervalType(); }
TimeAmountEditor implements IsWidget { public void init(final TimeAmount ta, Command onChangeCommand) { this.onChangeCommand = onChangeCommand; this.timeAmount = ta != null ? ta : new TimeAmount(); view.setQuantity(timeAmount.getQuantity()); view.clearIntervalTypeSelector(); for (int i=0; i< INTERVAL_TYPES.size(); i++) { DateIntervalType type = INTERVAL_TYPES.get(i); view.addIntervalTypeItem(type); if (timeAmount != null && timeAmount.getType().equals(type)) { view.setSelectedTypeIndex(i); } } } @Inject  TimeAmountEditor(View view); @Override Widget asWidget(); TimeAmount getTimeAmount(); void init(final TimeAmount ta, Command onChangeCommand); long getQuantity(); void decreaseQuantity(); void increaseQuantity(); void changeQuantity(String value); void changeIntervalType(); static List<DateIntervalType> INTERVAL_TYPES; }