SavedFiltersPresenter implements RestoreDefaultFiltersMenuBuilder.SupportsRestoreDefaultFilters { protected void removeSavedFilter(final SavedFilter savedFilter) { filterSettingsManager.removeSavedFilterFromPreferences(savedFilter.getKey(), () -> { view.removeSavedFilter(savedFilter); if (savedFilter.isDefaultFilter()) { view.setFirstFilterAsDefault(); } }); }  @WorkbenchPartView IsElement getView(); @WorkbenchPartTitle String getTitle(); @PostConstruct void init(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); void setFilterSettingsManager(final FilterSettingsManager filterSettingsManager); void onSaveFilter(@Observes final SavedFilterAddedEvent event); void onRemoveSavedFilter(@Observes final SavedFilterRemoveEvent event); @Override void onRestoreDefaultFilters(); void onSaveDefaultActiveFilter(@Observes final SavedFilterAsDefaultActiveEvent event);  }
@Test public void testRemoveSavedFilters() { final SavedFilter filter = new SavedFilter("key", "name"); doAnswer(invocation -> { Command callback = (Command) invocation.getArguments()[1]; callback.execute(); return null; }).when(filterSettingsManager).removeSavedFilterFromPreferences(anyString(), any()); presenter.removeSavedFilter(filter); verify(view).removeSavedFilter(filter); verify(filterSettingsManager).removeSavedFilterFromPreferences(eq(filter.getKey()), any()); verify(view, never()).setFirstFilterAsDefault(); }
@Test public void testRemoveDefaultSavedFilters() { final SavedFilter filter = new SavedFilter("key", "name"); filter.setDefaultFilter(true); doAnswer(invocation -> { Command callback = (Command) invocation.getArguments()[1]; callback.execute(); return null; }).when(filterSettingsManager).removeSavedFilterFromPreferences(anyString(), any()); presenter.removeSavedFilter(filter); verify(view).removeSavedFilter(filter); verify(filterSettingsManager).removeSavedFilterFromPreferences(eq(filter.getKey()), any()); verify(view).setFirstFilterAsDefault(); }