Package com.eviware.soapui.impl.wsdl

Examples of com.eviware.soapui.impl.wsdl.WsdlProject


    {
      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


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

      WsdlProject project = ( WsdlProject )mockService.getProject();
      WsdlMockService clonedService = null;

      // within same project?
      boolean cloneDescription = dialog.getBooleanValue( Form.CLONE_DESCRIPTION );
      String description = mockService.getDescription();
      if( !cloneDescription )
      {
        description = dialog.getValue( Form.DESCRIPTION );
      }
      if( targetProjectName.equals( mockService.getProject().getName() ) )
      {
        clonedService = cloneMockServiceWithinProject( mockService, name, project, description );
      }
      else
      {
        clonedService = cloneToAnotherProject( mockService, targetProjectName, name, description );
      }

      if( clonedService != null )
      {
        UISupport.select( clonedService );
      }

      if( dialog.getBooleanValue( Form.MOVE ) )
      {
        project.removeMockService( mockService );
      }
    }
  }
View Full Code Here

  public WsdlMockService cloneToAnotherProject( WsdlMockService mockService, String targetProjectName, String name,
      String description )
  {
    WorkspaceImpl workspace = mockService.getProject().getWorkspace();
    WsdlProject targetProject = ( WsdlProject )workspace.getProjectByName( targetProjectName );
    if( targetProject == null )
    {
      targetProjectName = UISupport.prompt( "Enter name for new Project", "Clone MockService", "" );
      if( targetProjectName == null )
        return null;

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

      if( targetProject == null )
        return null;
    }

    Set<WsdlInterface> requiredInterfaces = getRequiredInterfaces( mockService, targetProject );

    if( requiredInterfaces.size() > 0 )
    {
      String msg = "Target project [" + targetProjectName + "] is missing required interfaces;\r\n\r\n";
      for( WsdlInterface 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 MockService" ) )
        return null;

      for( WsdlInterface iface : requiredInterfaces )
      {
        targetProject.importInterface( iface, false, true );
      }
    }

    mockService = targetProject.importMockService( mockService, name, true, description );
    UISupport.select( mockService );
    return mockService;
  }
View Full Code Here

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

        public void valueChanged( XFormField sourceField, String newValue, String oldValue )
        {
          WsdlProject project = testStep.getMockService().getProject();
          dialog.setOptions( Form.OPERATION,
              ModelSupport.getNames( project.getInterfaceByName( newValue ).getOperationList() ) );
          WsdlOperation operation = testStep.getOperation();
          dialog.setValue( Form.OPERATION, operation == null ? "" : operation.getName() );
        }
      } );

      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 );
    }

    WsdlOperation operation = testStep.getOperation();
    WsdlProject project = testStep.getMockService().getProject();
    String[] interfaceNames = ModelSupport.getNames( project.getInterfaceList(),
        new ModelSupport.InterfaceTypeFilter( WsdlInterfaceFactory.WSDL_TYPE ) );
    dialog.setOptions( Form.INTERFACE, interfaceNames );
    dialog.setValue( Form.INTERFACE, operation == null ? interfaceNames[0] : operation.getInterface().getName() );

    dialog.setOptions( Form.OPERATION,
        ModelSupport.getNames( project.getInterfaceByName( dialog.getValue( Form.INTERFACE ) ).getOperationList() ) );
    dialog.setValue( Form.OPERATION, operation == null ? null : operation.getName() );
    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 );
      operation = iface.getOperationByName( operationName );
      target.setOperation( operation );

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

    dialog.setOptions( GenerateForm.RESOURCES, paths.toStringArray() );
    XFormOptionsField operationsFormField = ( XFormOptionsField )dialog.getFormField( GenerateForm.RESOURCES );
    operationsFormField.setSelectedOptions( paths.toStringArray() );

    WsdlProject project = service.getProject();
    String[] testSuites = ModelSupport.getNames( new String[] { "<create>" }, project.getTestSuiteList() );
    dialog.setOptions( GenerateForm.TESTSUITE, testSuites );

    if( dialog.show() )
    {
      List<String> resources = Arrays.asList( StringUtils.toStringArray( operationsFormField.getSelectedOptions() ) );
      if( resources.size() == 0 )
      {
        UISupport.showErrorMessage( "No Resources selected.." );
        return null;
      }

      String testSuiteName = dialog.getValue( GenerateForm.TESTSUITE );

      if( testSuiteName.equals( "<create>" ) )
        testSuiteName = UISupport.prompt( "Enter name of TestSuite to create", "Generate TestSuite",
            service.getName() + " TestSuite" );

      if( testSuiteName != null && testSuiteName.trim().length() > 0 )
      {
        WsdlTestSuite testSuite = project.getTestSuiteByName( testSuiteName );

        if( testSuite == null )
        {
          testSuite = project.addNewTestSuite( testSuiteName );
          testSuite.setDescription( "TestSuite generated for REST Service [" + service.getName() + "]" );
        }

        int style = dialog.getValueIndex( GenerateForm.STYLE );
        boolean generateLoadTest = dialog.getBooleanValue( GenerateForm.GENERATE_LOADTEST );
View Full Code Here

    super( "Add to TestCase", "Adds this REST Request to a TestCase" );
  }

  public void perform( RestRequest request, Object param )
  {
    WsdlProject project = request.getOperation().getInterface().getProject();

    WsdlTestCase testCase = getTargetTestCase( project );
    if( testCase != null )
      addRequest( testCase, request, -1 );
  }
View Full Code Here

      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 ) )
View Full Code Here

    super( "Move TestSuite Down", "Moves this TestSuite down" );
  }

  public void perform( WsdlTestSuite testSuite, Object param )
  {
    WsdlProject project = testSuite.getProject();
    int ix = project.getIndexOfTestSuite( testSuite );
    if( ix == -1 || ix >= project.getTestSuiteCount() - 1 )
      return;

    project.moveTestSuite( ix, 1 );
    UISupport.select( testSuite );
  }
View Full Code Here

    WsdlMockService mockService = null;
    WsdlMockOperation mockOperation = ( WsdlMockOperation )param;
    if( mockOperation != null )
      mockService = mockOperation.getMockService();

    WsdlProject project = request.getOperation().getInterface().getProject();

    while( mockService == null )
    {
      if( project.getMockServiceCount() > 0 )
      {
        String[] mockServices = ModelSupport.getNames( project.getMockServiceList(),
            new String[] { CREATE_MOCKSUITE_OPTION } );

        // prompt
        String option = UISupport.prompt( "Select MockService for MockOperation", title, mockServices );
        if( option == null )
          return;

        mockService = project.getMockServiceByName( option );
      }

      // create new mocksuite?
      if( mockService == null )
      {
        String mockServiceName = UISupport.prompt( "Enter name of new MockService", title, "MockService "
            + ( project.getMockServiceCount() + 1 ) );
        if( mockServiceName == null || mockServiceName.trim().length() == 0 )
          return;

        mockService = project.addNewMockService( mockServiceName );
      }

      mockOperation = mockService.getMockOperation( request.getOperation() );
      if( mockOperation != null )
      {
View Full Code Here

      putValue( Action.SHORT_DESCRIPTION, "Synchronizes this testcase with loadUI" );
    }

    public void actionPerformed( ActionEvent e )
    {
      WsdlProject project = testCase.getTestSuite().getProject();
//      try
//      {
//        if( StringUtils.hasContent( project.getPath() ) || project.getWorkspace() == null )
//          project.save();
//        else
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.wsdl.WsdlProject

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.