Esempio n. 1
0
  public WsdlMessageAssertion moveAssertion(int ix, int offset) {
    // int ix = assertions.indexOf( assertion );
    WsdlMessageAssertion assertion = getAssertionAt(ix);
    if (ix == -1) {
      throw new RuntimeException("assertion [" + assertion.getName() + "] not available ");
    }
    // if first selected can't move up and if last selected can't move down
    if ((ix == 0 && offset == -1) || (ix == assertions.size() - 1 && offset == 1)) {
      return assertion;
    }
    TestAssertionConfig conf = assertion.getConfig();
    XmlObject newXmlObject = conf.copy();

    TestAssertionConfig newConf = TestAssertionConfig.Factory.newInstance();
    newConf.set(newXmlObject);
    WsdlMessageAssertion newAssertion =
        TestAssertionRegistry.getInstance().buildAssertion(newConf, assertable);

    assertion.removePropertyChangeListener(this);
    assertions.remove(ix);

    assertion.release();

    assertableConfig.removeAssertion(ix);

    newAssertion.addPropertyChangeListener(this);
    assertions.add(ix + offset, newAssertion);

    assertableConfig.insertAssertion(newConf, ix + offset);
    fireAssertionMoved(newAssertion, ix, offset);
    return newAssertion;
  }
Esempio n. 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;
  }