AbstractMultiGridPresenter extends AbstractScreenListPresenter<T> { protected void addActiveFilters(final FilterSettings filter) { view.removeAllActiveFilters(); setFilterSettings(filter, table -> { if (filter.getDataSetLookup().getFirstFilterOp() != null) { List<ColumnFilter> filters = filter.getDataSetLookup().getFirstFilterOp().getColumnFilterList(); filters.forEach(column -> { final ActiveFilterItem activeFilter = getActiveFilterFromColumnFilter(column); view.addActiveFilter(activeFilter); }); } addDataDisplay(table); }); }  @Inject void setErrorHandlerBuilder(final ManagedInstance<ErrorHandlerBuilder> errorHandlerBuilder); @Inject void setAuthorizationManager(final AuthorizationManager authorizationManager); @Inject void setDataSetQueryHelper(final DataSetQueryHelper dataSetQueryHelper); @Inject void setClearAllActiveFiltersEvent(Event<ClearAllActiveFiltersEvent> clearAllActiveFiltersEvent); void setFilterSettingsManager(final FilterSettingsManager filterSettingsManager); DataSetQueryHelper getDataSetQueryHelper(); @WorkbenchPartView UberView<T> getView(); @Inject void setView(V view); abstract void setupActiveSearchFilters(); abstract boolean existActiveSearchFilters(); @PostConstruct void init(); @Override @OnOpen void onOpen(); Predicate<String> getFilterEventPredicate(); void onBasicFilterAddEvent(@Observes final BasicFilterAddEvent event); void onBasicFilterRemoveEvent(@Observes final BasicFilterRemoveEvent event); ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter); @Override void getData(final Range visibleRange); void saveSearchFilterSettings(final String filterName,
                                         final Consumer<String> callback); boolean isUserAuthorizedForPerspective(final String perspectiveId); void openErrorView(final String parameterId); Predicate<T> getViewErrorsActionCondition();  }
@Test public void addActiveFiltersTest() { String defaultFilterKey = "defaultFilterKey"; DataSetLookup dataSetLookupMock = mock(DataSetLookup.class); DataSetFilter dataSetFilterMock = mock(DataSetFilter.class); final ColumnFilter columnFilter = mock(ColumnFilter.class); final ColumnFilter columnFilter2 = mock(ColumnFilter.class); AsyncDataProvider dataProviderMock = mock(AsyncDataProvider.class); ListTable listTableMock = mock(ListTable.class); when(presenter.existActiveSearchFilters()).thenReturn(false); when(filterSettingsMock.getKey()).thenReturn(defaultFilterKey); when(filterSettingsMock.getDataSetLookup()).thenReturn(dataSetLookupMock); when(dataSetLookupMock.getFirstFilterOp()).thenReturn(dataSetFilterMock); when(dataSetFilterMock.getColumnFilterList()).thenReturn(Arrays.asList(columnFilter, columnFilter2)); presenter.setDataProvider(dataProviderMock); presenter.addActiveFilters(filterSettingsMock); verify(view).removeAllActiveFilters(); verify(dataSetQueryHelper).setCurrentTableSettings(filterSettingsMock); ArgumentCaptor<Consumer> listTableConsumerCaptor = ArgumentCaptor.forClass(Consumer.class); verify(view).loadListTable(eq(defaultFilterKey), listTableConsumerCaptor.capture()); listTableConsumerCaptor.getValue().accept(listTableMock); verify(presenter).getActiveFilterFromColumnFilter(columnFilter); verify(presenter).getActiveFilterFromColumnFilter(columnFilter2); verify(view, times(2)).addActiveFilter(any(ActiveFilterItem.class)); verify(presenter).addDataDisplay(listTableMock); }