Ejemplo n.º 1
0
  /**
   * @param assertable
   * @param categoryAssertionsMap
   * @return assertion categories mapped with assertions in exact category if @param assertable is
   *     not null only assertions for specific @param assertable will be included if @param
   *     assertable is null all assertions are included
   */
  public LinkedHashMap<String, SortedSet<AssertionListEntry>> addCategoriesAssertionsMap(
      Assertable assertable,
      LinkedHashMap<String, SortedSet<AssertionListEntry>> categoryAssertionsMap) {
    for (String category : AssertionCategoryMapping.getAssertionCategories()) {
      SortedSet<AssertionListEntry> assertionCategorySet = new TreeSet<AssertionListEntry>();
      categoryAssertionsMap.put(category, assertionCategorySet);
    }

    for (TestAssertionFactory assertion : availableAssertions.values()) {
      SortedSet<AssertionListEntry> set;
      if (assertable == null || assertion.canAssert(assertable)) {
        set = categoryAssertionsMap.get(assertion.getCategory());
        if (set != null) {
          AssertionListEntry assertionListEntry = assertion.getAssertionListEntry();
          //					if( assertable == null && disableNonApplicable )
          set.add(assertionListEntry);
          categoryAssertionsMap.put(assertion.getCategory(), set);
        }
      }
    }
    for (String category : AssertionCategoryMapping.getAssertionCategories()) {
      if (categoryAssertionsMap.get(category).isEmpty()) {
        categoryAssertionsMap.remove(category);
      }
    }

    return categoryAssertionsMap;
  }
Ejemplo n.º 2
0
  /** adds all assertions into map, to be disabled later when non applicable */
  public LinkedHashMap<String, SortedSet<AssertionListEntry>> addAllCategoriesMap(
      LinkedHashMap<String, SortedSet<AssertionListEntry>> categoryAssertionsMap) {
    for (String category : AssertionCategoryMapping.getAssertionCategories()) {
      SortedSet<AssertionListEntry> assertionCategorySet = new TreeSet<AssertionListEntry>();
      categoryAssertionsMap.put(category, assertionCategorySet);
    }

    for (TestAssertionFactory assertion : availableAssertions.values()) {
      SortedSet<AssertionListEntry> set;
      set = categoryAssertionsMap.get(assertion.getCategory());
      if (set != null) {
        AssertionListEntry assertionListEntry = assertion.getAssertionListEntry();
        set.add(assertionListEntry);
        categoryAssertionsMap.put(assertion.getCategory(), set);
      }
    }
    for (String category : AssertionCategoryMapping.getAssertionCategories()) {
      if (categoryAssertionsMap.get(category).isEmpty()) {
        categoryAssertionsMap.remove(category);
      }
    }

    return categoryAssertionsMap;
  }