ProcessInstanceListBasicFiltersPresenter extends BasicFiltersPresenter { @Override public void loadFilters() { view.addNumericFilter(constants.Id(), constants.FilterByProcessInstanceId(), f -> addSearchFilter(f, equalsTo(COLUMN_PROCESS_INSTANCE_ID, f.getValue())) ); view.addTextFilter(constants.Initiator(), constants.FilterByInitiator(), f -> addSearchFilter(f, likeTo(COLUMN_IDENTITY, f.getValue(), false)) ); view.addTextFilter(constants.Correlation_Key(), constants.FilterByCorrelationKey(), f -> addSearchFilter(f, likeTo(COLUMN_CORRELATION_KEY, f.getValue(), false)) ); view.addTextFilter(constants.Process_Instance_Description(), constants.FilterByDescription(), f -> addSearchFilter(f, likeTo(COLUMN_PROCESS_INSTANCE_DESCRIPTION, f.getValue(), false)) ); final Map<String, String> errorOptions = new HashMap<>(); errorOptions.put(String.valueOf(true), constants.WithErrors()); errorOptions.put(String.valueOf(false), constants.WithoutErrors()); final Function<String, ColumnFilter> errorFilterGenerator = (String hasErrors) -> (Boolean.valueOf(hasErrors) ? greaterThan(COLUMN_ERROR_COUNT, 0) : lowerOrEqualsTo(COLUMN_ERROR_COUNT, 1)); view.addMultiSelectFilter(constants.Errors(), errorOptions, f -> { if (f.getValue().isEmpty() || f.getValue().size() == 2) { removeSearchFilter(f, notNull(COLUMN_ERROR_COUNT)); } else { addSearchFilter(f, errorFilterGenerator.apply(f.getValue().get(0))); } } ); view.addMultiSelectFilter(constants.State(), ProcessInstanceStatusUtils.getStatesStrMapping(), f -> { final List<Integer> values = f.getValue().stream().map(s -> Integer.valueOf(s)).collect(Collectors.toList()); final ColumnFilter columnFilter = in(COLUMN_STATUS, values); addSearchFilterList(f, columnFilter); }); addProcessNameFilter(); addProcessIdFilter(); addDeploymentIdFilter(); addParentProcessIdFilter(); addSLAComplianceFilter(); view.addDateRangeFilter(constants.Start_Date(), constants.Start_Date_Placeholder(), true, f -> addSearchFilter(f, between(COLUMN_START, f.getValue().getStartDate(), f.getValue().getEndDate())) ); view.addDateRangeFilter(constants.Last_Modification_Date(), constants.Last_Modification_Date_Placeholder(), true, f -> addSearchFilter(f, between(COLUMN_LAST_MODIFICATION_DATE, f.getValue().getStartDate(), f.getValue().getEndDate())) ); }  @Override String getDataSetId(); @Override void loadFilters();  }
@Override @Test public void testLoadFilters() { presenter.loadFilters(); final InOrder inOrder = inOrder(getView()); inOrder.verify(getView()).addNumericFilter(eq(Constants.INSTANCE.Id()), any(), any()); inOrder.verify(getView()).addTextFilter(eq(Constants.INSTANCE.Initiator()), any(), any()); inOrder.verify(getView()).addTextFilter(eq(Constants.INSTANCE.Correlation_Key()), any(), any()); inOrder.verify(getView()).addTextFilter(eq(Constants.INSTANCE.Process_Instance_Description()), any(), any()); inOrder.verify(getView()).addMultiSelectFilter(eq(Constants.INSTANCE.Errors()), any(), any()); inOrder.verify(getView()).addMultiSelectFilter(eq(Constants.INSTANCE.State()), any(), any()); inOrder.verify(getView()).addDataSetSelectFilter(eq(Constants.INSTANCE.Name()), any(), any(), any(), any()); inOrder.verify(getView()).addDataSetSelectFilter(eq(Constants.INSTANCE.Process_Definition_Id()), any(), any(), any(), any()); inOrder.verify(getView()).addDataSetSelectFilter(eq(Constants.INSTANCE.DeploymentId()), any(), any(), any(), any()); inOrder.verify(getView()).addDataSetSelectFilter(eq(Constants.INSTANCE.Parent_Process_Instance_Id()), any(), any(), any(), any()); inOrder.verify(getView()).addSelectFilter(eq(Constants.INSTANCE.SlaCompliance()), any(), any()); inOrder.verify(getView()).addDateRangeFilter(eq(Constants.INSTANCE.Start_Date()), any(), any(), any()); inOrder.verify(getView()).addDateRangeFilter(eq(Constants.INSTANCE.Last_Modification_Date()), any(), any(), any()); }