Package com.eviware.soapui.model.project

Examples of com.eviware.soapui.model.project.Project


    this.context = context;
  }

  public final String getProjectPath()
  {
    Project project = ModelSupport.getModelItemProject( context.getModelItem() );

    String path = project.getPath();
    int ix = path.lastIndexOf( File.separatorChar );
    return ix == -1 ? "" : path.substring( 0, ix );
  }
View Full Code Here


public class ProjectDirProvider implements ValueProvider
{
  public String getValue( PropertyExpansionContext context )
  {
    Project project = ModelSupport.getModelItemProject( context.getModelItem() );
    if( project != null )
    {
      return getProjectFolder( project );
    }
View Full Code Here

      {
        workspace = ( Workspace )modelItem;
      }
      else
      {
        Project project = ModelSupport.getModelItemProject( modelItem );
        if( project != null )
          workspace = project.getWorkspace();
      }
    }

    return workspace == null ? null : PathUtils.getAbsoluteFolder( workspace.getPath() );
  }
View Full Code Here

    ModelItem modelItem = context.getModelItem();

    TestStep testStep = null;
    TestCase testCase = null;
    TestSuite testSuite = null;
    Project project = null;
    WsdlMockService mockService = null;
    WsdlMockResponse mockResponse = null;
    SecurityTest securityTest = null;

    if( modelItem instanceof WsdlTestStep )
View Full Code Here

            dialog.setOptions( Form.TESTSUITE, new String[] { CREATE_NEW_OPTION } );
            dialog.setOptions( Form.TESTCASE, new String[] { CREATE_NEW_OPTION } );
          }
          else
          {
            Project project = SoapUI.getWorkspace().getProjectByName( newValue );
            String[] names = ModelSupport.getNames( project.getTestSuiteList(),
                new String[] { CREATE_NEW_OPTION } );
            dialog.setOptions( Form.TESTSUITE, names );
            dialog.setValue( Form.TESTSUITE, names[0] );

            if( names.length > 1 )
            {
              TestSuite testSuite = project.getTestSuiteByName( names[0] );
              dialog.setOptions( Form.TESTCASE,
                  ModelSupport.getNames( testSuite.getTestCaseList(), new String[] { CREATE_NEW_OPTION } ) );
            }
            else
            {
              dialog.setOptions( Form.TESTCASE, new String[] { CREATE_NEW_OPTION } );
            }
          }
        }
      } );

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

        public void valueChanged( XFormField sourceField, String newValue, String oldValue )
        {
          if( newValue.equals( CREATE_NEW_OPTION ) )
          {
            dialog.setOptions( Form.TESTCASE, new String[] { CREATE_NEW_OPTION } );
          }
          else
          {
            String projectName = dialog.getValue( Form.PROJECT );
            Project project = SoapUI.getWorkspace().getProjectByName( projectName );
            TestSuite testSuite = project.getTestSuiteByName( newValue );
            dialog.setOptions( Form.TESTCASE, testSuite == null ? new String[] { CREATE_NEW_OPTION }
                : ModelSupport.getNames( testSuite.getTestCaseList(), new String[] { CREATE_NEW_OPTION } ) );
          }
        }
      } );

    }

    dialog.setBooleanValue( Form.MOVE, false );
    dialog.setValue( Form.NAME, "Copy of " + testStep.getName() );
    WorkspaceImpl workspace = testStep.getTestCase().getTestSuite().getProject().getWorkspace();
    dialog.setOptions( Form.PROJECT,
        ModelSupport.getNames( workspace.getOpenProjectList(), new String[] { CREATE_NEW_OPTION } ) );

    dialog.setValue( Form.PROJECT, testStep.getTestCase().getTestSuite().getProject().getName() );

    dialog.setOptions( Form.TESTSUITE, ModelSupport.getNames( testStep.getTestCase().getTestSuite().getProject()
        .getTestSuiteList(), new String[] { CREATE_NEW_OPTION } ) );
    dialog.setValue( Form.TESTSUITE, testStep.getTestCase().getTestSuite().getName() );

    dialog.setOptions( Form.TESTCASE, ModelSupport.getNames( testStep.getTestCase().getTestSuite().getTestCaseList(),
        new String[] { CREATE_NEW_OPTION } ) );
    dialog.setValue( Form.TESTCASE, testStep.getTestCase().getName() );

    if( dialog.show() )
    {
      String targetProjectName = dialog.getValue( Form.PROJECT );
      String targetTestSuiteName = dialog.getValue( Form.TESTSUITE );
      String targetTestCaseName = dialog.getValue( Form.TESTCASE );
      String name = dialog.getValue( Form.NAME );

      WsdlProject project = testStep.getTestCase().getTestSuite().getProject();
      WsdlTestSuite targetTestSuite = null;
      WsdlTestCase targetTestCase = null;
      Set<Interface> requiredInterfaces = new HashSet<Interface>();

      // to another project project?
      if( !targetProjectName.equals( project.getName() ) )
      {
        // get required interfaces
        requiredInterfaces.addAll( testStep.getRequiredInterfaces() );

        project = ( WsdlProject )workspace.getProjectByName( targetProjectName );
        if( project == null )
        {
          targetProjectName = UISupport.prompt( "Enter name for new Project", "Clone TestStep", "" );
          if( targetProjectName == null )
            return;

          try
          {
            project = workspace.createProject( targetProjectName, null );
          }
          catch( SoapUIException e )
          {
            UISupport.showErrorMessage( e );
          }

          if( project == null )
            return;
        }

        if( requiredInterfaces.size() > 0 && project.getInterfaceCount() > 0 )
        {
          Map<String, Interface> bindings = new HashMap<String, Interface>();
          for( Interface iface : requiredInterfaces )
          {
            bindings.put( iface.getTechnicalId(), iface );
          }

          for( Interface iface : project.getInterfaceList() )
          {
            bindings.remove( iface.getTechnicalId() );
          }

          requiredInterfaces.retainAll( bindings.values() );
        }

        if( requiredInterfaces.size() > 0 )
        {
          String msg = "Target project [" + targetProjectName + "] is missing required Interfaces;\r\n\r\n";
          for( Interface iface : requiredInterfaces )
          {
            msg += iface.getName() + " [" + iface.getTechnicalId() + "]\r\n";
          }
          msg += "\r\nThese will be cloned to the targetProject as well";

          if( !UISupport.confirm( msg, "Clone TestStep" ) )
            return;

          for( Interface iface : requiredInterfaces )
          {
            project.importInterface( ( AbstractInterface<?> )iface, true, true );
          }
        }
      }

      targetTestSuite = project.getTestSuiteByName( targetTestSuiteName );
      if( targetTestSuite == null )
      {
        targetTestSuiteName = UISupport.prompt( "Specify name for new TestSuite", "Clone TestStep", "Copy of "
            + testStep.getTestCase().getTestSuite().getName() );
        if( targetTestSuiteName == null )
          return;

        targetTestSuite = project.addNewTestSuite( targetTestSuiteName );
      }

      targetTestCase = targetTestSuite.getTestCaseByName( targetTestCaseName );
      if( targetTestCase == null )
      {
View Full Code Here

  @SuppressWarnings( "unchecked" )
  public TestStepConfig createNewTestStep( WsdlTestCase testCase, String name )
  {
    // build list of available interfaces / restResources
    Project project = testCase.getTestSuite().getProject();
    List<String> options = new ArrayList<String>();
    TupleList<RestMethod, RestRequest> restMethods = new TupleList<RestMethod, RestRequest>();

    for( int c = 0; c < project.getInterfaceCount(); c++ )
    {
      Interface iface = project.getInterfaceAt( c );
      if( iface instanceof RestService )
      {
        List<RestResource> resources = ( ( RestService )iface ).getAllResources();

        for( RestResource resource : resources )
View Full Code Here

        {
          if( newValue.equals( CREATE_NEW_OPTION ) )
            dialog.setOptions( Form.TESTSUITE, new String[] { CREATE_NEW_OPTION } );
          else
          {
            Project project = SoapUI.getWorkspace().getProjectByName( newValue );
            dialog.setOptions( Form.TESTSUITE,
                ModelSupport.getNames( project.getTestSuiteList(), new String[] { CREATE_NEW_OPTION } ) );
          }
        }
      } );
      dialog.getFormField( Form.CLONE_DESCRIPTION ).addFormFieldListener( new XFormFieldListener()
      {

        public void valueChanged( XFormField sourceField, String newValue, String oldValue )
        {
          if( dialog.getBooleanValue( Form.CLONE_DESCRIPTION ) )
          {
            dialog.getFormField( Form.DESCRIPTION ).setEnabled( false );
          }
          else
          {
            dialog.getFormField( Form.DESCRIPTION ).setEnabled( true );
          }

        }
      } );
    }

    dialog.setBooleanValue( Form.MOVE, false );
    dialog.setBooleanValue( Form.CLONE_DESCRIPTION, true );
    dialog.getFormField( Form.DESCRIPTION ).setEnabled( false );
    dialog.setValue( Form.DESCRIPTION, testCase.getDescription() );
    dialog.setValue( Form.NAME, "Copy of " + testCase.getName() );
    WorkspaceImpl workspace = testCase.getTestSuite().getProject().getWorkspace();
    dialog.setOptions( Form.PROJECT,
        ModelSupport.getNames( workspace.getOpenProjectList(), new String[] { CREATE_NEW_OPTION } ) );

    dialog.setValue( Form.PROJECT, testCase.getTestSuite().getProject().getName() );

    dialog.setOptions( Form.TESTSUITE, ModelSupport.getNames(
        testCase.getTestSuite().getProject().getTestSuiteList(), new String[] { CREATE_NEW_OPTION } ) );

    dialog.setValue( Form.TESTSUITE, testCase.getTestSuite().getName() );

    boolean hasLoadTests = testCase.getLoadTestCount() > 0;
    dialog.setBooleanValue( Form.CLONE_LOADTESTS, hasLoadTests );
    dialog.getFormField( Form.CLONE_LOADTESTS ).setEnabled( hasLoadTests );

    boolean hasSecurityTests = testCase.getSecurityTestCount() > 0;
    dialog.setBooleanValue( Form.CLONE_SECURITYTESTS, hasSecurityTests );
    dialog.getFormField( Form.CLONE_SECURITYTESTS ).setEnabled( hasSecurityTests );

    if( dialog.show() )
    {
      String targetProjectName = dialog.getValue( Form.PROJECT );
      String targetTestSuiteName = dialog.getValue( Form.TESTSUITE );
      String name = dialog.getValue( Form.NAME );

      WsdlProject project = testCase.getTestSuite().getProject();
      WsdlTestSuite targetTestSuite = null;
      Set<Interface> requiredInterfaces = new HashSet<Interface>();

      // to another project project?
      if( !targetProjectName.equals( project.getName() ) )
      {
        // get required interfaces
        for( int y = 0; y < testCase.getTestStepCount(); y++ )
        {
          WsdlTestStep testStep = testCase.getTestStepAt( y );
          requiredInterfaces.addAll( testStep.getRequiredInterfaces() );
        }

        project = ( WsdlProject )workspace.getProjectByName( targetProjectName );
        if( project == null )
        {
          targetProjectName = UISupport.prompt( "Enter name for new Project", "Clone TestCase", "" );
          if( targetProjectName == null )
            return;

          try
          {
            project = workspace.createProject( targetProjectName, null );
          }
          catch( SoapUIException e )
          {
            UISupport.showErrorMessage( e );
          }

          if( project == null )
            return;
        }

        if( requiredInterfaces.size() > 0 && project.getInterfaceCount() > 0 )
        {
          Map<String, Interface> bindings = new HashMap<String, Interface>();
          for( Interface iface : requiredInterfaces )
          {
            bindings.put( iface.getTechnicalId(), iface );
          }

          for( Interface iface : project.getInterfaceList() )
          {
            bindings.remove( iface.getTechnicalId() );
          }

          requiredInterfaces.retainAll( bindings.values() );
        }

        if( requiredInterfaces.size() > 0 )
        {
          String msg = "Target project [" + targetProjectName + "] is missing required Interfaces;\r\n\r\n";
          for( Interface iface : requiredInterfaces )
          {
            msg += iface.getName() + " [" + iface.getTechnicalId() + "]\r\n";
          }
          msg += "\r\nShould these will be cloned to the targetProject as well?";

          Boolean result = UISupport.confirmOrCancel( msg, "Clone TestCase" );
          if( result == null )
            return;

          if( result )
          {
            for( Interface iface : requiredInterfaces )
            {
              project.importInterface( ( AbstractInterface<?> )iface, true, true );
            }
          }
        }
      }

      targetTestSuite = project.getTestSuiteByName( targetTestSuiteName );
      if( targetTestSuite == null )
      {
        targetTestSuiteName = UISupport.prompt( "Specify name for new TestSuite", "Clone TestCase", "Copy of "
            + testCase.getTestSuite().getName() );
        if( targetTestSuiteName == null )
          return;

        targetTestSuite = project.addNewTestSuite( targetTestSuiteName );
      }

      boolean move = dialog.getBooleanValue( Form.MOVE );
      WsdlTestCase newTestCase = targetTestSuite.importTestCase( testCase, name, -1,
          dialog.getBooleanValue( Form.CLONE_LOADTESTS ), dialog.getBooleanValue( Form.CLONE_SECURITYTESTS ),
View Full Code Here

        UISupport.showErrorMessage( "No Parameters selected.." );
      }
      return items;
    }

    Project project = securityScan.getTestStep().getTestCase().getTestSuite().getProject();
    TestSuite targetTestSuite = project.getTestSuiteByName( targetTestSuiteName );
    TestCase targetTestCase = targetTestSuite.getTestCaseByName( targetTestCaseName );
    SecurityTest targetSecurityTest = targetTestCase.getSecurityTestByName( targetSecurityTestName );
    TestStep targetTestStep = targetTestCase.getTestStepByName( targetSecurityTestStepName );

    boolean overwrite = dialog.getBooleanValue( CloneParameterDialog.OVERWRITE );
View Full Code Here

    okAction.setDialog( dialog );
    cancelAction.setDialog( dialog );
    applyAction.setDialog( dialog );

    final TestCase testCase = securityScan.getTestStep().getTestCase();
    final Project project = testCase.getTestSuite().getProject();

    dialog.getFormField( CloneParameterDialog.TARGET_TESTSUITE ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        TestSuite testSuite = project.getTestSuiteByName( newValue );
        String[] testCaseNames = ModelSupport.getNames( testSuite.getTestCaseList() );
        dialog.setOptions( CloneParameterDialog.TARGET_TESTCASE, testCaseNames );

        if( testCaseNames.length > 0 )
        {
          dialog.setValue( CloneParameterDialog.TARGET_TESTCASE, testCaseNames[0] );
          TestCase testCase = testSuite.getTestCaseByName( testCaseNames[0] );

          String[] testStepNames = new String[0];
          String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
          if( securityTestNames.length > 0 )
          {
            testStepNames = getSecurableTestStepsNames( testCase );
          }
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );

          if( securityTestNames.length > 0 )
          {
            dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
            if( testStepNames.length > 0 )
            {
              dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
            }
            else
            {
              dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
            }

            String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
            SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
            String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
            TestStep testStep = testCase.getTestStepByName( testStepName );
            String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
                testStep.getId(), AbstractSecurityScanWithProperties.class ) );
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
          }
          else
          {
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
            dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
            dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
          }
        }
        else
        {
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
        }
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_TESTCASE ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        TestCase testCase = testSuite.getTestCaseByName( newValue );

        String[] testStepNames = new String[0];
        String[] securityTestNames = ModelSupport.getNames( testCase.getSecurityTestList() );
        dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames );
        if( securityTestNames.length > 0 )
        {
          testStepNames = getSecurableTestStepsNames( testCase );
        }
        dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, testStepNames );

        if( securityTestNames.length > 0 )
        {
          dialog.setValue( CloneParameterDialog.TARGET_SECURITYTEST, securityTestNames[0] );
          if( testStepNames.length > 0 )
          {
            dialog.setValue( CloneParameterDialog.TARGET_TESTSTEP, testStepNames[0] );
          }
          else
          {
            dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
          }

          String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
          SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
          String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
          TestStep testStep = testCase.getTestStepByName( testStepName );
          String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
              testStep.getId(), AbstractSecurityScanWithProperties.class ) );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
        }
        else
        {
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYTEST, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_TESTSTEP, new String[0] );
          dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, new String[0] );
        }
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_TESTSTEP ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
        TestCase testCase = testSuite.getTestCaseByName( testCaseName );
        String securityTestName = dialog.getValue( CloneParameterDialog.TARGET_SECURITYTEST );
        SecurityTest securityTest = testCase.getSecurityTestByName( securityTestName );
        TestStep testStep = testCase.getTestStepByName( newValue );

        String[] securityScanNames = ModelSupport.getNames( securityTest.getTestStepSecurityScanByType(
            testStep.getId(), AbstractSecurityScanWithProperties.class ) );
        dialog.setOptions( CloneParameterDialog.TARGET_SECURITYSCAN, securityScanNames );
      }
    } );
    dialog.getFormField( CloneParameterDialog.TARGET_SECURITYTEST ).addFormFieldListener( new XFormFieldListener()
    {
      public void valueChanged( XFormField sourceField, String newValue, String oldValue )
      {
        String testSuiteName = dialog.getValue( CloneParameterDialog.TARGET_TESTSUITE );
        TestSuite testSuite = project.getTestSuiteByName( testSuiteName );
        String testCaseName = dialog.getValue( CloneParameterDialog.TARGET_TESTCASE );
        TestCase testCase = testSuite.getTestCaseByName( testCaseName );
        SecurityTest securityTest = testCase.getSecurityTestByName( newValue );
        String testStepName = dialog.getValue( CloneParameterDialog.TARGET_TESTSTEP );
        TestStep testStep = testCase.getTestStepByName( testStepName );
View Full Code Here

  }

  public TestStepConfig createNewTestStep( WsdlTestCase testCase, String name )
  {
    // build list of available interfaces / operations
    Project project = testCase.getTestSuite().getProject();
    List<String> options = new ArrayList<String>();
    List<Operation> operations = new ArrayList<Operation>();

    for( int c = 0; c < project.getInterfaceCount(); c++ )
    {
      Interface iface = project.getInterfaceAt( c );
      for( int i = 0; i < iface.getOperationCount(); i++ )
      {
        options.add( iface.getName() + " -> " + iface.getOperationAt( i ).getName() );
        operations.add( iface.getOperationAt( i ) );
      }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.model.project.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.