AdminAppsGridPresenterImpl implements AdminAppsGridView.Presenter,
                                                   AppInfoSelectedEvent.AppInfoSelectedEventHandler,
                                                   SaveAppSelected.SaveAppSelectedHandler { @Override public void onAppCategorySelectionChanged(AppCategorySelectionChangedEvent event) { if (event.getAppCategorySelection().isEmpty()) { return; } Preconditions.checkArgument(event.getAppCategorySelection().size() == 1); view.mask(appearance.getAppsLoadingMask()); final AppCategory appCategory = event.getAppCategorySelection().iterator().next(); appService.getApps(appCategory, new AsyncCallback<List<App>>() { @Override public void onFailure(Throwable caught) { ErrorHandler.post(caught); view.unmask(); } @Override public void onSuccess(final List<App> apps) { listStore.clear(); listStore.addAll(apps); view.unmask(); } }); } @Inject  AdminAppsGridPresenterImpl(final AdminAppsGridViewFactory viewFactory,
                               final ListStore<App> listStore); @Override HandlerRegistration addStoreRemoveHandler(StoreRemoveEvent.StoreRemoveHandler<App> handler); @Override void fireEvent(GwtEvent<?> event); @Override AdminAppsGridView getView(); @Override App getAppFromElement(Element eventTarget); @Override List<App> getSelectedApps(); @Override void onAppCategorySelectionChanged(AppCategorySelectionChangedEvent event); @Override void onAppInfoSelected(final AppInfoSelectedEvent event); @Override void onAppSearchResultLoad(AppSearchResultLoadEvent event); @Override void onDeleteAppsSelected(final DeleteAppsSelected event); @Override void onRestoreAppSelected(final RestoreAppSelected event); @Override void onSaveAppSelected(SaveAppSelected event); void updateBetaStatus(final App app);  }
@Test public void verifyAppServiceCalled_onAppCategorySelectionChanged() { AppCategorySelectionChangedEvent eventMock = mock(AppCategorySelectionChangedEvent.class); final AppCategory appCategoryMock = mock(AppCategory.class); when(appCategoryMock.getId()).thenReturn("mock category id"); List<AppCategory> selection = Lists.newArrayList(appCategoryMock); when(eventMock.getAppCategorySelection()).thenReturn(selection); when(appearanceMock.getAppsLoadingMask()).thenReturn("loading mask"); uut.onAppCategorySelectionChanged(eventMock); verify(viewMock).mask(anyString()); verify(appearanceMock).getAppsLoadingMask(); verify(appServiceMock).getApps(eq(appCategoryMock), appListCallbackCaptor.capture()); List<App> resultList = Lists.newArrayList(mock(App.class)); appListCallbackCaptor.getValue().onSuccess(resultList); verify(listStoreMock).clear(); verify(listStoreMock).addAll(eq(resultList)); verify(viewMock).unmask(); verifyNoMoreInteractions(appServiceMock, appearanceMock, listStoreMock); }