Package com.eviware.soapui.impl.rest

Examples of com.eviware.soapui.impl.rest.RestRequest


  @SuppressWarnings( "deprecation" )
  private static void convert( RestResource resource, OldRestRequestConfig oldConfig, RestMethod method )
  {

    RestRequest request = method.addNewRequest( oldConfig.getName() );

    XmlBeansRestParamsTestPropertyHolder params = new XmlBeansRestParamsTestPropertyHolder( null,
        oldConfig.getParameters() );
    RestParamsPropertyHolder parentParams = method.getOverlayParams();

    for( TestProperty prop : params.values() )
    {
      if( !parentParams.containsKey( prop.getName() ) )
      {
        method.getParams().addParameter( ( RestParamProperty )prop );
      }
      request.setPropertyValue( prop.getName(), prop.getValue() );
    }
    params.release();

    boolean exists;
    for( RestResourceRepresentationConfig rep : oldConfig.getRepresentationList() )
    {
      exists = false;
      for( RestRepresentation existing : method.getRepresentations(
          RestRepresentation.Type.valueOf( rep.getType().toString() ), rep.getMediaType() ) )
      {
        if( existing.getElement() == null && rep.getElement() == null
            || existing.getElement().equals( rep.getElement() ) )
        {
          exists = true;
          break;
        }
      }
      if( !exists )
      {
        RestRepresentation repr = method.addNewRepresentation( RestRepresentation.Type.valueOf( rep.getType()
            .toString() ) );
        repr.setConfig( ( RestResourceRepresentationConfig )rep.copy() );
      }
    }

    RestRequestConfig newConfig = request.getConfig();

    newConfig.setRequest( oldConfig.getRequest() );

    for( AttachmentConfig ac : oldConfig.getAttachmentList() )
      try
      {
        if( ac.isSetData() )
        {
          File temp = File.createTempFile( "pattern", ".suffix" );
          temp.deleteOnExit();
          FileOutputStream out = new FileOutputStream( temp );
          out.write( ac.getData() );
          request.attachFile( temp, true );
        }
        else
        {
          request.attachFile( new File( ac.getUrl() ), false );
        }
      }
      catch( IOException e )
      {
        e.printStackTrace();
      }
    newConfig.setAttachmentArray( oldConfig.getAttachmentArray() );

    if( oldConfig.isSetFullPath() )
      newConfig.setFullPath( oldConfig.getFullPath() );
    if( oldConfig.isSetMediaType() )
      newConfig.setMediaType( oldConfig.getMediaType() );
    if( oldConfig.isSetPostQueryString() )
      newConfig.setPostQueryString( oldConfig.getPostQueryString() );
    if( oldConfig.isSetAccept() )
      newConfig.setAccept( oldConfig.getAccept() );
    if( oldConfig.isSetDescription() )
      newConfig.setDescription( oldConfig.getDescription() );
    if( oldConfig.isSetId() )
      newConfig.setId( oldConfig.getId() );
    if( oldConfig.isSetSettings() )
      newConfig.setSettings( ( SettingsConfig )oldConfig.getSettings().copy() );
    if( oldConfig.isSetSslKeystore() )
      newConfig.setSslKeystore( oldConfig.getSslKeystore() );
    if( oldConfig.isSetTimestamp() )
      newConfig.setTimestamp( oldConfig.getTimestamp() );
    if( oldConfig.isSetWadlId() )
      newConfig.setWadlId( oldConfig.getWadlId() );

    request.updateConfig( newConfig );

  }
View Full Code Here


    }
  }

  protected void createRequest( RestMethod method )
  {
    RestRequest request = method.addNewRequest( "Request " + ( method.getRequestCount() + 1 ) );
    UISupport.showDesktopPanel( request );
  }
View Full Code Here

    assertEquals( 1, resource.getPropertyCount() );
    assertEquals( "appid", resource.getPropertyAt( 0 ).getName() );
    assertNotNull( resource.getProperty( "appid" ) );
    assertEquals( 1, resource.getRequestCount() );

    RestRequest request = resource.getRequestAt( 0 );
    assertEquals( RestRequestInterface.RequestMethod.GET, request.getMethod() );
    assertEquals( 9, request.getPropertyCount() );
  }
View Full Code Here

    String name = UISupport
        .prompt( "Specify name of cloned Request", "Clone Request", "Copy of " + request.getName() );
    if( name == null )
      return;

    RestRequest newRequest = request.getRestMethod().cloneRequest( request, name );

    UISupport.selectAndShow( newRequest );
  }
View Full Code Here

      if( resource.getRequestCount() > 0 )
      {
        for( int x = 0; x < resource.getRequestCount(); x++ )
        {
          RestRequest request = resource.getRequestAt( x );
          testCase.addTestStep( RestRequestStepFactory.createConfig( request, request.getName() ) );
        }
      }

      if( createLoadTest )
      {
View Full Code Here

  protected void createRequest( RestMethod method )
  {
    // RestRequest request = resource.addNewRequest( dialog.getValue(
    // Form.RESOURCENAME ) );
    RestRequest request = method.addNewRequest( "Request " + ( method.getRequestCount() + 1 ) );
    UISupport.showDesktopPanel( request );
  }
View Full Code Here

      dialog.setValue( Form.RESOURCENAME, "" );
    }

    if( dialog.show() )
    {
      RestRequest request = method.addNewRequest( dialog.getValue( Form.RESOURCENAME ) );

      UISupport.select( request );

      if( dialog.getBooleanValue( Form.OPENSREQUEST ) )
      {
View Full Code Here

        if (StringUtils.isNullOrEmpty(URI)) {
            return;
        }

        RestResource restResource = createResource(ModelCreationStrategy.CREATE_NEW_MODEL, project, URI);
        RestRequest restRequest = addNewRequest(addNewMethod(ModelCreationStrategy.CREATE_NEW_MODEL, restResource, RestRequestInterface.HttpMethod.GET));
        copyParameters(extractParams(URI), restResource.getParams());
        UISupport.select(restRequest);
        UISupport.showDesktopPanel(restRequest);

    }
View Full Code Here

*
*/
public class RestRequestStepFactoryTest {
    @Test
    public void copiesRESTRequestBody() throws Exception {
        RestRequest restRequest = ModelItemFactory.makeRestRequest();
        restRequest.setMethod(RestRequestInterface.HttpMethod.POST);
        String requestBody = "Some meaningful data";
        restRequest.setRequestContent(requestBody);

        TestStepConfig testStepConfig = RestRequestStepFactory.createConfig(restRequest, "Rest Request");
        RestRequestStepConfig config = (RestRequestStepConfig) testStepConfig.getConfig();

        assertThat(config.getRestRequest().getRequest().getStringValue(), is(requestBody));
View Full Code Here

        assertThat(mockServiceX.getMockOperationAt(1).getName(), is("a"));
    }

    private void addRestMockResponseToProject() throws SoapUIException {
        RestMockService restMockService = project.addNewRestMockService(restMockServiceName);
        RestRequest restRequest = ModelItemFactory.makeRestRequest();
        restRequest.setMethod(GET);
        restRequest.setName("REST Mock Action");
        restRequest.setPath("Resource/path/subpath");
        RestMockAction restMockAction = restMockService.addNewMockAction(restRequest);
        RestMockResponse mockResponse = restMockAction.addNewMockResponse("Response 1");
        mockResponse.setResponseContent(restMockResponseContent);
        mockResponse.setName(restMockResponseName);
    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.rest.RestRequest

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.