/** * Checks if all categories are accepted. * * @param categories the categories to be accepted. * @return <code>true</code> if all categories are accepted, * <code>false</code> if at least one category is rejected. */ private boolean acceptsAllOf(final List<String> categories) { if (categories.isEmpty()) { return excludeCategories != ALL; // NOPMD } for (final String category : categories) { if (!acceptCategory(category)) { return false; } } return true; }
if (excludeCategories == ALL) // NOPMD return acceptIncludes(type); return acceptIncludes(type);
/** * Checks if the scenario is accepted. * * @param scenario the scenario to check. * @return true when accepted false otherwise. */ public boolean acceptScenario(final ScenarioTestDoc scenario) { return acceptsAllOf(scenario.getCategories()); }
private ReportConfig createReportConfig() throws MavenReportException { final InformationFilter.Builder builder = new InformationFilter.Builder(); builder.setShowIndexOfIndices(showIndexOfIndices); builder.setShowNumbering(showNumbering); builder.setShowCategories(showCategories); builder.setShowTestCase(showTestCase); builder.setShowTestStatus(showTestStatus); final InformationFilter filter = builder.build(); final SelectionFilter selectionFilter = new SelectionFilter(includeCategories, excludeCategories); final Comparator<UnitTestDoc> comparator = createComparator(); final ReportConfig config = new ReportConfig(selectionFilter, filter, junitManager, imageHelper, reports, comparator); return config; }
/** * Default constructor. * * @param includeCategories the category names of test scenarios that should * be included. * @param excludeCategories the category names of test scenarios that should * be excluded. */ public SelectionFilter(final List<String> includeCategories, final List<String> excludeCategories) { this.includeCategories = provideCategories(includeCategories); this.excludeCategories = provideCategories(excludeCategories); }
/** * Filters scenarios by their categories according the the given report * configuration. * * @param scenarios the scenarios to filter. * @return the filtered scenarios. */ public List<ScenarioTestDoc> filterScenarios( final List<ScenarioTestDoc> scenarios) { return config.getSelectionFilter().filterScenarios(scenarios); }
/** * Filters the given categories according the the given report configuration. * * @param categories the categories to be filtered. * @return a copy of the given <code>categories</code> containing only those * categories that are accepted. */ public List<String> filter(final List<String> categories) { return config.getSelectionFilter().filterCategories(categories); }
private ReportConfig createReportConfig() throws MavenReportException { final InformationFilter.Builder builder = new InformationFilter.Builder(); builder.setShowIndexOfIndices(showIndexOfIndices); builder.setShowNumbering(showNumbering); builder.setShowCategories(showCategories); builder.setShowTestCase(showTestCase); builder.setShowTestStatus(showTestStatus); final InformationFilter filter = builder.build(); final SelectionFilter selectionFilter = new SelectionFilter(includeCategories, excludeCategories); final Comparator<UnitTestDoc> comparator = createComparator(); final ReportConfig config = new ReportConfig(selectionFilter, filter, junitManager, imageHelper, reports, comparator); return config; }
/** * Filters scenarios by their categories. * * @param scenarios the scenarios to filter. * @return the filtered scenarios. */ public List<ScenarioTestDoc> filterScenarios( final List<ScenarioTestDoc> scenarios) { final List<ScenarioTestDoc> filtered = new ArrayList<ScenarioTestDoc>(scenarios.size()); for (final ScenarioTestDoc scenario : scenarios) { final List<String> categories = scenario.getCategories(); if (acceptsAllOf(categories)) { filtered.add(scenario); } } return filtered; }
/** * Filters the list of categories to retain only those that are accepted by * {@link #acceptCategory(String)}. * * @param categories the category list to filter. * @return a copy of the given <code>categories</code> containing only those * categories that are accepted. */ public List<String> filterCategories(final List<String> categories) { if (categories == null) { return null; } if (excludeCategories != ALL && excludeCategories.isEmpty()) // NOPMD { return new ArrayList<String>(categories); } final List<String> copy = new ArrayList<String>(categories.size()); for (final String category : categories) { if (acceptCategory(category)) { copy.add(category); } } return copy; }