RefreshSelectorMenuBuilder implements MenuFactory.CustomMenuBuilder { protected AnchorListItem createTimeSelector(int time, String name, int configuredSeconds, final AnchorListItem refreshDisableButton) { final AnchorListItem oneMinuteRadioButton = GWT.create(AnchorListItem.class); oneMinuteRadioButton.setText(name); oneMinuteRadioButton.setIconFixedWidth(true); final int selectedRefreshTime = time; if (configuredSeconds == selectedRefreshTime) { oneMinuteRadioButton.setIcon(IconType.CHECK); } oneMinuteRadioButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { oneMinuteRadioButton.setIcon(IconType.CHECK); supportsRefreshInterval.onUpdateRefreshInterval(true, selectedRefreshTime); refreshDisableButton.setActive(false); refreshDisableButton.setEnabled(true); refreshDisableButton.setText(constants.Disable_autorefresh()); } }); return oneMinuteRadioButton; } RefreshSelectorMenuBuilder(final SupportsRefreshInterval supportsRefreshInterval); @Override void push(MenuFactory.CustomMenuBuilder element); @Override MenuItem build(); void loadOptions(int configuredSeconds);  }
@Test public void testUpdateRefreshInterval() { int time = 1; refreshSelectorMenuBuilder.createTimeSelector(time, "", time, mock(AnchorListItem.class)); clickHandler.onClick(new ClickEvent() { }); verify(supportsRefreshInterval).onUpdateRefreshInterval(true, time); verify(oneMinuteRadioButton, times(2)).setIcon(IconType.CHECK); }
@Test public void testSelectedRefreshInterval() { int time = 1; int selectedTime = 2; refreshSelectorMenuBuilder.createTimeSelector(time, "", selectedTime, mock(AnchorListItem.class)); verify(oneMinuteRadioButton, never()).setIcon(any(IconType.class)); }