Example #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;
  }
Example #2
0
  @Override
  protected boolean handleOk() {
    setVisible(false);

    int selectedRow = assertionsTable.getSelectedRow();
    String selection =
        ((AssertionListEntry) assertionsListTableModel.getValueAt(selectedRow, 0)).getName();
    if (selection == null) {
      return false;
    }

    if (!TestAssertionRegistry.getInstance().canAddMultipleAssertions(selection, assertable)) {
      UISupport.showErrorMessage("This assertion can only be added once");
      return false;
    }

    TestAssertion assertion = assertable.addAssertion(selection);
    if (assertion == null) {
      UISupport.showErrorMessage("Failed to add assertion");
      return false;
    }

    recentAssertionHandler.add(selection);

    if (assertion.isConfigurable()) {
      assertion.configure();
      return true;
    }

    return true;
  }
Example #3
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      boldFont = getFont().deriveFont(Font.BOLD);

      AssertionListEntry entry = (AssertionListEntry) value;
      String type = TestAssertionRegistry.getInstance().getAssertionTypeForName(entry.getName());
      boolean canAssert = false;
      boolean disable = true;
      JLabel label;
      JTextArea descText;
      JLabel disabledInfo;
      if (type != null && assertable != null && assertable.getModelItem() != null) {
        canAssert =
            isAssertionApplicable(type, assertable.getModelItem(), getSelectedPropertyName());
        disable = !categoriesListTable.isEnabled() || !canAssert;
      }
      String str = entry.getName();
      label = new JLabel(str);
      label.setFont(boldFont);
      descText = new JTextArea(((AssertionListEntry) value).getDescription());
      descText.setSize(new Dimension(80, 20));
      descText.setLineWrap(true);
      descText.setWrapStyleWord(true);
      disabledInfo = new JLabel("Not applicable with selected Source and Property");
      descText.setFont(disabledInfo.getFont());
      if (disable) {
        label.setForeground(Color.LIGHT_GRAY);
        descText.setForeground(Color.LIGHT_GRAY);
        disabledInfo.setForeground(Color.LIGHT_GRAY);
      }
      SimpleForm form = new SimpleForm();
      form.addComponent(label);
      if (!isHideDescriptionSelected()) {
        form.addComponent(descText);
        //				if( disable )
        //				{
        //					form.addComponent( disabledInfo );
        //				}
        getAssertionsTable().setRowHeight(70);
      } else {
        if (disable) {
          form.addComponent(disabledInfo);
        }
        getAssertionsTable().setRowHeight(40);
      }
      if (isSelected) {
        descText.setBackground(Color.LIGHT_GRAY);
        form.getPanel().setBackground(Color.LIGHT_GRAY);
      } else {
        descText.setBackground(Color.WHITE);
        form.getPanel().setBackground(Color.WHITE);
      }
      return form.getPanel();
    }
Example #4
0
 protected boolean isAssertionApplicable(
     String assertionType, ModelItem modelItem, String property) {
   try {
     // property is only used for adding assertions with selecting source and property,
     // therefore here can be empty string, but gets its meaning in Override of this method
     return TestAssertionRegistry.getInstance().canAssert(assertionType, assertable);
   } catch (Throwable t) {
     SoapUI.logError(t);
     return false;
   }
 }
Example #5
0
  public void refresh() {
    int mod = 0;

    List<TestAssertionConfig> assertionList = assertableConfig.getAssertionList();

    for (int i = 0; i < assertionList.size(); i++) {
      TestAssertionConfig config = assertionList.get(i);
      if (TestAssertionRegistry.getInstance().canBuildAssertion(config)) {
        assertions.get(i - mod).updateConfig(config);
      } else mod++;
    }
  }
Example #6
0
  public WsdlMessageAssertion addWsdlAssertion(String assertionLabel) {
    try {
      TestAssertionConfig assertionConfig = assertableConfig.addNewAssertion();
      assertionConfig.setType(
          TestAssertionRegistry.getInstance().getAssertionTypeForName(assertionLabel));

      String name = assertionLabel;
      while (getAssertionByName(name.trim()) != null) {
        name =
            UISupport.prompt(
                "Specify unique name of Assertion",
                "Rename Assertion",
                assertionLabel
                    + " "
                    + (getAssertionsOfType(
                            TestAssertionRegistry.getInstance()
                                .getAssertionClassType(assertionConfig))
                        .size()));
        if (name == null) {
          return null;
        }
      }
      WsdlMessageAssertion assertion = addWsdlAssertion(assertionConfig);
      if (assertion == null) return null;

      assertionConfig.setName(name);
      assertion.updateConfig(assertionConfig);

      if (assertion != null) {
        fireAssertionAdded(assertion);
      }

      return assertion;
    } catch (Exception e) {
      SoapUI.logError(e);
      return null;
    }
  }
Example #7
0
  public WsdlMessageAssertion addWsdlAssertion(TestAssertionConfig config) {
    try {
      WsdlMessageAssertion assertion =
          TestAssertionRegistry.getInstance().buildAssertion(config, assertable);
      if (assertion == null) {
        return null;
      } else {
        assertions.add(assertion);
        assertion.addPropertyChangeListener(this);

        return assertion;
      }
    } catch (Exception e) {
      SoapUI.logError(e);
      return null;
    }
  }
Example #8
0
 protected boolean isAssertionApplicable(String assertionType) {
   return TestAssertionRegistry.getInstance().canAssert(assertionType, assertable);
 }