public boolean canAddAssertion(WsdlMessageAssertion assertion, Assertable assertable) {
    if (assertion.isAllowMultiple()) {
      return true;
    }

    for (int c = 0; c < assertable.getAssertionCount(); c++) {
      if (assertion.getClass().equals(assertable.getAssertionAt(c).getClass())) {
        return false;
      }
    }

    return true;
  }
Beispiel #2
0
  public WsdlMessageAssertion importAssertion(
      WsdlMessageAssertion source, boolean overwrite, boolean createCopy, String newName) {
    TestAssertionConfig conf = assertableConfig.addNewAssertion();
    conf.set(source.getConfig());
    conf.setName(newName);
    if (createCopy && conf.isSetId()) conf.unsetId();

    if (!source.isAllowMultiple()) {
      List<WsdlMessageAssertion> existing = getAssertionsOfType(source.getClass());
      if (!existing.isEmpty() && !overwrite) return null;

      while (!existing.isEmpty()) {
        removeAssertion(existing.remove(0));
      }
    }

    WsdlMessageAssertion result = addWsdlAssertion(conf);
    fireAssertionAdded(result);
    return result;
  }