@Test public void verifyServiceCalled_onDeleteCategorySelected() { DeleteCategorySelected eventMock = mock(DeleteCategorySelected.class); AppCategory categoryMock = mock(AppCategory.class); when(eventMock.getAppCategories()).thenReturn(Lists.newArrayList(categoryMock)); uut.onDeleteCategorySelected(eventMock); verify(viewMock).mask(anyString()); verify(adminAppServiceMock).deleteAppCategory(eq(categoryMock), voidCallbackCaptor.capture()); voidCallbackCaptor.getValue().onSuccess(null); verify(viewMock).unmask(); verify(treeStoreMock).remove(eq(categoryMock)); verifyNoMoreInteractions(adminAppServiceMock, viewMock); verifyZeroInteractions(appServiceMock); }
@Override public void onDeleteCategorySelected(final DeleteCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategories().iterator().next(); if (selectedAppCategory.getAppCount() > 0) { announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteCategoryPermissionError())); return; } view.mask(appearance.deleteAppCategoryLoadingMask()); adminAppService.deleteAppCategory(selectedAppCategory, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteAppCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(Void result) { view.unmask(); treeStore.remove(selectedAppCategory); } }); }
AdminAppsCategoriesPresenterImpl implements AdminCategoriesView.Presenter,
                                                         AppCategoriesView.AppCategoryHierarchyProvider { @Override public void onDeleteCategorySelected(final DeleteCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategories().iterator().next(); if (selectedAppCategory.getAppCount() > 0) { announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteCategoryPermissionError())); return; } view.mask(appearance.deleteAppCategoryLoadingMask()); adminAppService.deleteAppCategory(selectedAppCategory, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteAppCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(Void result) { view.unmask(); treeStore.remove(selectedAppCategory); } }); } }
AdminAppsCategoriesPresenterImpl implements AdminCategoriesView.Presenter,
                                                         AppCategoriesView.AppCategoryHierarchyProvider { @Override public void onDeleteCategorySelected(final DeleteCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategories().iterator().next(); if (selectedAppCategory.getAppCount() > 0) { announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteCategoryPermissionError())); return; } view.mask(appearance.deleteAppCategoryLoadingMask()); adminAppService.deleteAppCategory(selectedAppCategory, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteAppCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(Void result) { view.unmask(); treeStore.remove(selectedAppCategory); } }); } @Inject  AdminAppsCategoriesPresenterImpl(final AppCategoriesViewFactory viewFactory,
                                     final TreeStore<AppCategory> treeStore); }
AdminAppsCategoriesPresenterImpl implements AdminCategoriesView.Presenter,
                                                         AppCategoriesView.AppCategoryHierarchyProvider { @Override public void onDeleteCategorySelected(final DeleteCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategories().iterator().next(); if (selectedAppCategory.getAppCount() > 0) { announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteCategoryPermissionError())); return; } view.mask(appearance.deleteAppCategoryLoadingMask()); adminAppService.deleteAppCategory(selectedAppCategory, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteAppCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(Void result) { view.unmask(); treeStore.remove(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); }
AdminAppsCategoriesPresenterImpl implements AdminCategoriesView.Presenter,
                                                         AppCategoriesView.AppCategoryHierarchyProvider { @Override public void onDeleteCategorySelected(final DeleteCategorySelected event) { final AppCategory selectedAppCategory = event.getAppCategories().iterator().next(); if (selectedAppCategory.getAppCount() > 0) { announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteCategoryPermissionError())); return; } view.mask(appearance.deleteAppCategoryLoadingMask()); adminAppService.deleteAppCategory(selectedAppCategory, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { view.unmask(); announcer.schedule(new ErrorAnnouncementConfig(appearance.deleteAppCategoryError(selectedAppCategory.getName()))); } @Override public void onSuccess(Void result) { view.unmask(); treeStore.remove(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);  }