AdminAppsCategoriesPresenterImpl implements AdminCategoriesView.Presenter,
                                                         AppCategoriesView.AppCategoryHierarchyProvider { @Override public void onRenameCategorySelected(final RenameCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategory(); view.mask(appearance.renameAppCategoryLoadingMask()); adminAppService.renameAppCategory(selectedAppCategory, event.getNewCategoryName(), new AsyncCallback<AppCategory>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.renameCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(AppCategory result) { view.unmask(); selectedAppCategory.setName(result.getName()); treeStore.update(selectedAppCategory); } }); } @Inject  AdminAppsCategoriesPresenterImpl(final AppCategoriesViewFactory viewFactory,
                                     final TreeStore<AppCategory> treeStore); @Override List<String> getGroupHierarchy(AppCategory appCategory); @Override AppCategoriesView getView(); @Override void go(final HasId selectedAppCategory); @Override void onAddCategorySelected(final AddCategorySelected event); @Override void onAppSearchResultLoad(AppSearchResultLoadEvent event); @Override void onCategorizeAppSelected(final CategorizeAppSelected event); @Override void onDeleteCategorySelected(final DeleteCategorySelected event); @Override void onMoveCategorySelected(MoveCategorySelected event); @Override void onRemove(StoreRemoveEvent<App> event); @Override void onRenameCategorySelected(final RenameCategorySelected event);  }
@Test public void verifyServiceCalled_onRenameCategorySelected() { RenameCategorySelected eventMock = mock(RenameCategorySelected.class); AppCategory appCategoryMock = mock(AppCategory.class); String newNameMock = "new category name"; when(eventMock.getAppCategory()).thenReturn(appCategoryMock); when(eventMock.getNewCategoryName()).thenReturn(newNameMock); uut.onRenameCategorySelected(eventMock); verify(viewMock).mask(anyString()); verify(adminAppServiceMock).renameAppCategory(eq(appCategoryMock), eq(newNameMock), appCatCallbackCaptor.capture()); AppCategory resultMock = mock(AppCategory.class); when(resultMock.getName()).thenReturn(newNameMock); appCatCallbackCaptor.getValue().onSuccess(resultMock); verify(viewMock).unmask(); verify(appCategoryMock).setName(eq(newNameMock)); verify(treeStoreMock).update(eq(appCategoryMock)); verifyNoMoreInteractions(viewMock, adminAppServiceMock); verifyZeroInteractions(appServiceMock); }