M2RepoEditorPresenter implements RefreshMenuBuilder.SupportsRefresh { @WorkbenchMenu public void getMenus(final Consumer<Menus> menusConsumer) { menusConsumer.accept(MenuFactory.newTopLevelMenu(constants.Upload()) .respondsWith(() -> uploadFormPresenter.showView()) .endMenu() .newTopLevelCustomMenu(new RefreshMenuBuilder(this)) .endMenu() .build()); } @Inject  M2RepoEditorPresenter(final Event<M2RepoRefreshEvent> refreshEvents,
                                 final UploadFormPresenter uploadFormPresenter,
                                 final MavenRepositoryPagedJarTable view); @WorkbenchPartView MavenRepositoryPagedJarTable getWidget(); @WorkbenchPartTitle String getTitle(); void refreshEvent(@Observes final M2RepoRefreshEvent event); void searchEvent(@Observes final M2RepoSearchEvent event); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @Override void onRefresh();  }
@Test public void testUpload() { presenter.getMenus(menus -> { final MenuItemCommand upload = (MenuItemCommand) menus.getItems().get(0); upload.getCommand().execute(); verify(uploadFormPresenter).showView(); }); }
@Test public void testRefresh() { when(menuRefreshButton.addClickHandler(any(ClickHandler.class))).thenAnswer(new Answer() { public Object answer(InvocationOnMock aInvocation) throws Throwable { clickHandler = (ClickHandler) aInvocation.getArguments()[0]; return null; } }); presenter.getMenus(menus -> { final MenuCustom refresh = (MenuCustom) menus.getItems().get(1); refresh.build(); clickHandler.onClick(new ClickEvent() { }); verify(refreshEvents).fire(any(M2RepoRefreshEvent.class)); }); }