ProcessInstanceListBasicFiltersPresenter extends BasicFiltersPresenter { @Override protected void onActiveFilterAdded(ActiveFilterItem activeFilterItem) { if (activeFilterItem.getKey().equals(constants.State()) && activeFilterItem.getValue() instanceof List) { final List<String> values = (List<String>) activeFilterItem.getValue(); values.forEach(v -> view.checkSelectFilter(constants.State(), v)); } if (activeFilterItem.getKey().equals(COLUMN_ERROR_COUNT) && activeFilterItem.getValue() instanceof List) { final List<String> values = (List<String>) activeFilterItem.getValue(); values.forEach(v -> view.checkSelectFilter(constants.Errors(), v)); } }  @Override String getDataSetId(); @Override void loadFilters();  }
@Test public void onActiveFilterAddedTest() { ActiveFilterItem activeFilterItemMock = mock(ActiveFilterItem.class); when(activeFilterItemMock.getKey()).thenReturn(Constants.INSTANCE.Name()); presenter.onActiveFilterAdded(activeFilterItemMock); verify(getView(), never()).checkSelectFilter(anyString(), anyString()); verify(activeFilterItemMock, never()).getValue(); when(activeFilterItemMock.getKey()).thenReturn(Constants.INSTANCE.State()); when(activeFilterItemMock.getValue()).thenReturn(Arrays.asList(String.valueOf(ProcessInstance.STATE_ACTIVE), String.valueOf(ProcessInstance.STATE_COMPLETED))); presenter.onActiveFilterAdded(activeFilterItemMock); verify(getView()).checkSelectFilter(Constants.INSTANCE.State(), String.valueOf(ProcessInstance.STATE_ACTIVE)); verify(getView()).checkSelectFilter(Constants.INSTANCE.State(), String.valueOf(ProcessInstance.STATE_COMPLETED)); }
@Test public void testOnActiveFilterAdded() { ActiveFilterItem testActiveFilterItem = new ActiveFilterItem(Constants.INSTANCE.State(), "test label", null, Arrays.asList("Active"), null); presenter.onActiveFilterAdded(testActiveFilterItem); verify(getView()).checkSelectFilter(Constants.INSTANCE.State(), "Active"); ActiveFilterItem activeWithErrorsFilterItem = new ActiveFilterItem("errorCount", "test label", null, Arrays.asList("0"), null); presenter.onActiveFilterAdded(activeWithErrorsFilterItem); verify(getView()).checkSelectFilter(Constants.INSTANCE.Errors(), "0"); ActiveFilterItem activeWithoutErrorsFilterItem = new ActiveFilterItem("errorCount", "test label", null, Arrays.asList("1"), null); presenter.onActiveFilterAdded(activeWithoutErrorsFilterItem); verify(getView()).checkSelectFilter(Constants.INSTANCE.Errors(), "1"); }