예제 #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;
  }
예제 #2
0
 public boolean canAssert(String type, Assertable assertable) {
   TestAssertionFactory factory = availableAssertions.get(type);
   if (factory != null) {
     return factory.canAssert(assertable);
   } else {
     return false;
   }
 }
예제 #3
0
 public boolean canAssert(String type, TestModelItem modelItem, String property) {
   TestAssertionFactory factory = availableAssertions.get(type);
   if (factory != null) {
     return factory.canAssert(modelItem, property);
   } else {
     return false;
   }
 }
예제 #4
0
 public AssertionListEntry getAssertionListEntry(String type) {
   TestAssertionFactory factory = availableAssertions.get(type);
   if (factory != null) {
     return factory.getAssertionListEntry();
   } else {
     return null;
   }
 }
예제 #5
0
  public String[] getAvailableAssertionNames(Assertable assertable) {
    List<String> result = new ArrayList<String>();

    for (TestAssertionFactory assertion : availableAssertions.values()) {
      if (assertion.canAssert(assertable)) {
        result.add(assertion.getAssertionLabel());
      }
    }

    return result.toArray(new String[result.size()]);
  }
예제 #6
0
  public Class<? extends WsdlMessageAssertion> getAssertionClassType(String assertionType) {
    try {
      TestAssertionFactory factory = availableAssertions.get(assertionType);
      if (factory == null) {
        log.error("Missing assertion for type [" + assertionType + "]");
      } else {
        return factory.getAssertionClassType();
      }
    } catch (Exception e) {
      SoapUI.logError(e);
    }

    return null;
  }
예제 #7
0
  public WsdlMessageAssertion buildAssertion(TestAssertionConfig config, Assertable assertable) {
    try {
      String type = config.getType();
      TestAssertionFactory factory = availableAssertions.get(type);
      if (factory == null) {
        log.error("Missing assertion for type [" + type + "]");
      } else {
        return (WsdlMessageAssertion) factory.buildAssertion(config, assertable);
      }
    } catch (Exception e) {
      SoapUI.logError(e);
    }

    return null;
  }
예제 #8
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;
  }
예제 #9
0
 public void removeFactory(TestAssertionFactory factory) {
   availableAssertions.remove(factory.getAssertionId());
   assertionLabels.remove(factory.getAssertionLabel());
 }
예제 #10
0
 public void addAssertion(TestAssertionFactory factory) {
   availableAssertions.put(factory.getAssertionId(), factory);
   assertionLabels.put(factory.getAssertionLabel(), factory.getAssertionId());
 }