Ask a Question

Problem with saving/creating REST TestRequests as project (in Java)

streamerd
Occasional Contributor

Problem with saving/creating REST TestRequests as project (in Java)

Hi,

 

Recently I've successfully developed a method that uses wsdl endpoint and saves the SOAPUI project file.

 

Our purpose is to create these project documents for the endpoints with custom request contents,then run regularly on some remote machine that have SOAPUI installed.

 

However, for the REST part, I've done many things but could not make it work to add test step(s) to the test case.

 

I am not sure if followed the right practice, yet I can see that there is a testStep under the testRequestList.

 

 

My code is as follows (also attaching one of the failure projects):

 

---

 

TestCaseConfig testCaseConfig = restConfiguration.getTestCaseConfig();
WsdlProject wsdlProject = new WsdlProject();
wsdlProject.setName("restProject");

RestServiceBuilder serviceBuilder = new RestServiceBuilder();
serviceBuilder.createRestService(wsdlProject, url);
WsdlTestSuite wsdlTestSuite = wsdlProject.addNewTestSuite("Suite");
WsdlTestCase wsdlTestCase = new WsdlTestCase(wsdlTestSuite, testCaseConfig, false);
wsdlTestSuite.addNewTestCase("Case");
RestService restService = (RestService) wsdlProject.getInterfaceList().get(0);
RestResource restResource = restService.getOperationAt(0);
RestRequest requestx = restResource.getRequestAt( 0 );
TestStepConfig testStepConfigx = RestRequestStepFactory.createConfig(requestx, "Step");
wsdlTestCase.addTestStep(testStepConfigx);
wsdlTestCase.insertTestStep(testStepConfigx, -1);
wsdlProject.saveIn(projectFile); 

 

0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: