DataSetDefColumnsFilterEditor implements IsWidget,
                                                      org.dashbuilder.dataset.client.editor.DataSetDefColumnsFilterEditor { void onFilterChangedEvent(@Observes FilterChangedEvent filterChangedEvent) { checkNotNull("filterChangedEvent", filterChangedEvent); if (filterChangedEvent.getContext().equals(dataSetFilterEditor)) { final DataSetFilter old = filterChangedEvent.getOldFilter(); final DataSetFilter f = filterChangedEvent.getFilter(); updateColumnsRestrictedByFilter(old, f); } } @Inject  DataSetDefColumnsFilterEditor(final DataSetDefColumnsEditor columnsEditor,
                                         final DataSetDefFilterEditor dataSetFilterEditor,
                                         final View view); @PostConstruct void init(); @Override Widget asWidget(); void setMaxHeight(final String maxHeight); @Override org.dashbuilder.dataset.client.editor.DataSetDefColumnsEditor columnListEditor(); @Override org.dashbuilder.dataset.client.editor.DataSetDefFilterEditor dataSetFilter(); @Override void setAcceptableValues(final List<DataColumnDef> acceptableValues); @Override void flush(); @Override void onPropertyChange(final String... paths); @Override void setValue(final DataSetDef value); @Override void setDelegate(final EditorDelegate<DataSetDef> delegate); public View view; }
@Test public void testOnFilterChangedEvent() throws Exception { DataSetFilter oldFilter = mock(DataSetFilter.class); List<ColumnFilter> oldCreateColumnFilters = createColumnFilters("col1", "col2", "col3"); when(oldFilter.getColumnFilterList()).thenReturn(oldCreateColumnFilters); DataSetFilter newFilter = mock(DataSetFilter.class); List<ColumnFilter> createColumnFilters = createColumnFilters("col2"); when(newFilter.getColumnFilterList()).thenReturn(createColumnFilters); when(dataSetDef.getDataSetFilter()).thenReturn(newFilter); FilterChangedEvent filterChangedEvent = mock(FilterChangedEvent.class); when(filterChangedEvent.getContext()).thenReturn(dataSetFilterEditor); when(filterChangedEvent.getOldFilter()).thenReturn(oldFilter); when(filterChangedEvent.getFilter()).thenReturn(newFilter); tested.onFilterChangedEvent(filterChangedEvent); verify(columnsEditor, times(1)).onValueRestricted("col2"); verify(columnsEditor, times(1)).onValueUnRestricted("col1"); verify(columnsEditor, times(1)).onValueUnRestricted("col3"); verify(columnsEditor, times(0)).setAcceptableValues(any(List.class)); verify(view, times(0)).init(tested); verify(view, times(0)).initWidgets(any(IsWidget.class), any(DataSetDefFilterEditor.View.class)); verify(view, times(0)).setMaxHeight(anyString()); }