public WsdlTestRequestDesktopPanel(WsdlTestRequestStep requestStep) {
    super(requestStep, requestStep.getTestRequest());

    SoapUI.getTestMonitor().addTestMonitorListener(testMonitorListener);
    setEnabled(!SoapUI.getTestMonitor().hasRunningTest(requestStep.getTestCase()));

    requestStep.getTestRequest().addAssertionsListener(assertionsListener);
  }
Example #2
0
  private void getAllMessages(ModelItem modelItem, List<AbstractWsdlModelItem<?>> list) {
    if (modelItem instanceof AbstractHttpRequestInterface<?>) {
      AbstractHttpRequest<?> wsdlRequest = (AbstractHttpRequest<?>) modelItem;
      if (wsdlRequest.getOperation().getInterface() == this) list.add(wsdlRequest);
    } else if (modelItem instanceof WsdlTestRequestStep) {
      WsdlTestRequestStep testRequestStep = (WsdlTestRequestStep) modelItem;
      WsdlTestRequest testRequest = testRequestStep.getTestRequest();
      if (testRequest != null
          && testRequest.getOperation() != null
          && testRequest.getOperation().getInterface() == this) list.add(testRequest);
    } else if (modelItem instanceof WsdlMockResponse) {
      WsdlMockResponse mockResponse = (WsdlMockResponse) modelItem;
      if (mockResponse.getMockOperation() != null
          && mockResponse.getMockOperation().getOperation() != null
          && mockResponse.getMockOperation().getOperation().getInterface() == this)
        list.add(mockResponse);
    }

    // Traverse the ModelItem hierarchy.
    for (ModelItem child : modelItem.getChildren()) {
      getAllMessages(child, list);
    }
  }
  public void perform(WsdlTestRequestStep target, Object param) {
    this.testStep = target;

    if (dialog == null) {
      dialog = ADialogBuilder.buildDialog(Form.class);
      dialog
          .getFormField(Form.INTERFACE)
          .addFormFieldListener(
              new XFormFieldListener() {

                public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                  WsdlProject project = testStep.getTestCase().getTestSuite().getProject();
                  dialog.setOptions(
                      Form.OPERATION,
                      ModelSupport.getNames(
                          project.getInterfaceByName(newValue).getOperationList()));
                  dialog.setValue(Form.OPERATION, testStep.getOperationName());
                }
              });

      dialog
          .getFormField(Form.RECREATE_REQUEST)
          .addFormFieldListener(
              new XFormFieldListener() {

                public void valueChanged(XFormField sourceField, String newValue, String oldValue) {
                  boolean enabled = Boolean.parseBoolean(newValue);

                  dialog.getFormField(Form.CREATE_OPTIONAL).setEnabled(enabled);
                  dialog.getFormField(Form.KEEP_EXISTING).setEnabled(enabled);
                }
              });

      dialog.getFormField(Form.CREATE_OPTIONAL).setEnabled(false);
      dialog.getFormField(Form.KEEP_EXISTING).setEnabled(false);
    }

    WsdlProject project = target.getTestCase().getTestSuite().getProject();
    dialog.setOptions(
        Form.INTERFACE,
        ModelSupport.getNames(
            project.getInterfaceList(),
            new ModelSupport.InterfaceTypeFilter(WsdlInterfaceFactory.WSDL_TYPE)));
    dialog.setValue(Form.INTERFACE, target.getInterfaceName());

    dialog.setOptions(
        Form.OPERATION,
        ModelSupport.getNames(
            project.getInterfaceByName(target.getInterfaceName()).getOperationList()));
    dialog.setValue(Form.OPERATION, target.getOperationName());
    dialog.setValue(Form.NAME, target.getName());

    if (dialog.show()) {
      String ifaceName = dialog.getValue(Form.INTERFACE);
      String operationName = dialog.getValue(Form.OPERATION);

      WsdlInterface iface = (WsdlInterface) project.getInterfaceByName(ifaceName);
      WsdlOperation operation = iface.getOperationByName(operationName);
      target.setOperation(operation);

      String name = dialog.getValue(Form.NAME).trim();
      if (name.length() > 0 && !target.getName().equals(name)) target.setName(name);

      if (dialog.getBooleanValue(Form.RECREATE_REQUEST)) {
        String req = operation.createRequest(dialog.getBooleanValue(Form.CREATE_OPTIONAL));
        if (req == null) {
          UISupport.showErrorMessage("Request creation failed");
          return;
        }

        WsdlTestRequest request = target.getTestRequest();
        if (dialog.getBooleanValue(Form.KEEP_EXISTING)) {
          req = XmlUtils.transferValues(request.getRequestContent(), req);
        }

        request.setRequestContent(req);
      }
    }
  }