ProcessInstanceListPresenter extends AbstractMultiGridPresenter<ProcessInstanceSummary, ProcessInstanceListPresenter.ProcessInstanceListView> { @Override public ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter) { if (columnFilter instanceof CoreFunctionFilter) { CoreFunctionFilter coreFunctionFilter = (CoreFunctionFilter) columnFilter; if (isStatusFilters(coreFunctionFilter)) { return new ActiveFilterItem<>(constants.State(), getStatusColumnFilterDescription(columnFilter), null, coreFunctionFilter.getParameters().stream().map(v -> v.toString()).collect(Collectors.toList()), v -> removeActiveFilter(columnFilter)); } if (isErrorsFilters(coreFunctionFilter)) { String labelValue = coreFunctionFilter.getLabelValue(); if (labelValue == null || labelValue.isEmpty()) { labelValue = columnFilter.toString(); } return new ActiveFilterItem<>(COLUMN_ERROR_COUNT, labelValue, null, coreFunctionFilter.getParameters().stream().map(v -> Boolean.valueOf(v.toString().equals("0")).toString()).collect(Collectors.toList()), v -> removeActiveFilter(columnFilter)); } } return super.getActiveFilterFromColumnFilter(columnFilter); }  @Inject void setProcessInstanceSelectedEvent(final Event<ProcessInstanceSelectionEvent> processInstanceSelectionEvent); @Override void createListBreadcrumb(); void setupDetailBreadcrumb(String detailLabel); void getDomainSpecifDataForProcessInstances(final Integer startRange,
                                                       final List<ProcessInstanceSummary> instancesFromDataSet,
                                                       final Boolean lastPage); void newInstanceCreated(@Observes final NewProcessInstanceEvent pi); void newInstanceCreated(@Observes final ProcessInstancesUpdateEvent pis); void abortProcessInstance(String containerId,
                                     long processInstanceId); void abortProcessInstances(Map<String, List<Long>> containerInstances); void bulkSignal(List<ProcessInstanceSummary> processInstances); void bulkAbort(List<ProcessInstanceSummary> processInstances); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); void signalProcessInstance(final ProcessInstanceSummary processInstance); @Override void selectSummaryItem(final ProcessInstanceSummary summary); void refreshDetailBreadcrumb(@Observes ProcessInstanceSelectionEvent event); void formClosed(@Observes BeforeClosePlaceEvent closed); @Inject void setFilterSettingsManager(final ProcessInstanceListFilterSettingsManager filterSettingsManager); @Inject void setProcessService(final Caller<ProcessService> processService); @Override void setupActiveSearchFilters(); @Override boolean existActiveSearchFilters(); @Override ActiveFilterItem getActiveFilterFromColumnFilter(ColumnFilter columnFilter); String getStatusColumnFilterDescription(ColumnFilter columnFilter); void openJobsView(final String pid); void openTaskView(final String pid); @Override void openErrorView(final String pid); Predicate<ProcessInstanceSummary> getSignalActionCondition(); Predicate<ProcessInstanceSummary> getAbortActionCondition(); Predicate<ProcessInstanceSummary> getViewJobsActionCondition(); Predicate<ProcessInstanceSummary> getViewTasksActionCondition(); @Override Predicate<ProcessInstanceSummary> getViewErrorsActionCondition();  }
@Test public void testActiveFilterLabelStatus() { ColumnFilter testColumFilter = equalsTo(COLUMN_STATUS, Arrays.asList(String.valueOf(ProcessInstance.STATE_ACTIVE), String.valueOf(ProcessInstance.STATE_COMPLETED))); ActiveFilterItem activeFilterItem = presenter.getActiveFilterFromColumnFilter(testColumFilter); assertEquals(Constants.INSTANCE.State(), activeFilterItem.getKey()); assertEquals(Constants.INSTANCE.State() + ": " + Constants.INSTANCE.Active() + ", " + Constants.INSTANCE.Completed(), activeFilterItem.getLabelValue()); assertNotEquals(testColumFilter.toString(), activeFilterItem.getLabelValue()); }
@Test public void testActiveFilterLabelOther() { ColumnFilter testColumFilter = equalsTo(COLUMN_PROCESS_ID, "evaluation"); ActiveFilterItem activeFilterItem = presenter.getActiveFilterFromColumnFilter(testColumFilter); assertEquals(COLUMN_PROCESS_ID, activeFilterItem.getKey()); assertEquals(testColumFilter.toString(), activeFilterItem.getLabelValue()); testColumFilter = equalsTo(COLUMN_PROCESS_INSTANCE_ID, 1); activeFilterItem = presenter.getActiveFilterFromColumnFilter(testColumFilter); assertEquals(COLUMN_PROCESS_INSTANCE_ID, activeFilterItem.getKey()); assertEquals(testColumFilter.toString(), activeFilterItem.getLabelValue()); }
@Test public void testGetActiveFilterFromColumnFilter() { ColumnFilter testStateColumFilter = equalsTo(COLUMN_STATUS, "Active"); ActiveFilterItem activeStateFilterItem = presenter.getActiveFilterFromColumnFilter(testStateColumFilter); assertEquals("State", activeStateFilterItem.getKey()); assertEquals("Active", ((List<String>) activeStateFilterItem.getValue()).get(0)); ColumnFilter testWithErrorsColumFilter = greaterThan(COLUMN_ERROR_COUNT, "0"); ActiveFilterItem activeWithErrorsFilterItem = presenter.getActiveFilterFromColumnFilter(testWithErrorsColumFilter); assertEquals(COLUMN_ERROR_COUNT, activeWithErrorsFilterItem.getKey()); assertEquals("true", ((List<String>) activeWithErrorsFilterItem.getValue()).get(0)); ColumnFilter testWithoutErrorsColumFilter = lowerOrEqualsTo(COLUMN_ERROR_COUNT, "1"); ActiveFilterItem activeWithoutErrorsFilterItem = presenter.getActiveFilterFromColumnFilter(testWithoutErrorsColumFilter); assertEquals(COLUMN_ERROR_COUNT, activeWithoutErrorsFilterItem.getKey()); assertEquals("false", ((List<String>) activeWithoutErrorsFilterItem.getValue()).get(0)); }