diff --git a/modules/core/pom.xml b/modules/core/pom.xml index 315d6e2..a02a86e 100644 --- a/modules/core/pom.xml +++ b/modules/core/pom.xml @@ -9,7 +9,6 @@ testserver-cucumber-core - 1.0.1-SNAPSHOT jar @@ -45,8 +44,8 @@ com.smartbear.readyapi - ready-api-testserver-client - 1.2.2-SNAPSHOT + readyapi4j-testserver-client + 2.0.0-SNAPSHOT diff --git a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeBuilder.java b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeBuilder.java index c75aa64..b46f910 100644 --- a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeBuilder.java +++ b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeBuilder.java @@ -1,10 +1,10 @@ package com.smartbear.readyapi.testserver.cucumber; import com.google.common.collect.Lists; -import com.smartbear.readyapi.client.execution.Execution; import com.smartbear.readyapi.client.model.ProjectResultReport; import com.smartbear.readyapi.client.model.TestCase; import com.smartbear.readyapi.client.model.TestStep; +import com.smartbear.readyapi4j.execution.Execution; import cucumber.api.Scenario; import cucumber.api.java.After; import cucumber.runtime.java.guice.ScenarioScoped; @@ -49,9 +49,9 @@ public void run(Scenario scenario) { testCase.setTestSteps(testSteps); Execution execution = executor.runTestCase(testCase, scenario); - if( assertResult && !executor.isAsync() ) { + if (assertResult && !executor.isAsync()) { assertEquals(Arrays.toString(execution.getErrorMessages().toArray()), - ProjectResultReport.StatusEnum.FINISHED, execution.getCurrentStatus()); + ProjectResultReport.StatusEnum.FINISHED, execution.getCurrentStatus()); } } diff --git a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeExecutor.java b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeExecutor.java index a654870..a325305 100644 --- a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeExecutor.java +++ b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/CucumberRecipeExecutor.java @@ -1,11 +1,11 @@ package com.smartbear.readyapi.testserver.cucumber; -import com.smartbear.readyapi.client.ExecutionListener; -import com.smartbear.readyapi.client.TestRecipe; -import com.smartbear.readyapi.client.execution.Execution; -import com.smartbear.readyapi.client.execution.RecipeExecutor; -import com.smartbear.readyapi.client.execution.TestServerClient; import com.smartbear.readyapi.client.model.TestCase; +import com.smartbear.readyapi4j.ExecutionListener; +import com.smartbear.readyapi4j.TestRecipe; +import com.smartbear.readyapi4j.execution.Execution; +import com.smartbear.readyapi4j.execution.RecipeExecutor; +import com.smartbear.readyapi4j.testserver.execution.TestServerClient; import cucumber.api.Scenario; import io.swagger.util.Json; import org.apache.commons.lang3.StringUtils; @@ -40,15 +40,15 @@ public class CucumberRecipeExecutor { public CucumberRecipeExecutor() throws MalformedURLException { Map env = System.getenv(); URL url = new URL(env.getOrDefault(TESTSERVER_ENDPOINT, - System.getProperty(TESTSERVER_ENDPOINT, DEFAULT_TESTSERVER_ENDPOINT))); + System.getProperty(TESTSERVER_ENDPOINT, DEFAULT_TESTSERVER_ENDPOINT))); - TestServerClient testServerClient = TestServerClient.fromUrl( url.toString() ); + TestServerClient testServerClient = TestServerClient.fromUrl(url.toString()); String user = env.getOrDefault(TESTSERVER_USER, - System.getProperty(TESTSERVER_USER, DEFAULT_TESTSERVER_USER)); + System.getProperty(TESTSERVER_USER, DEFAULT_TESTSERVER_USER)); String password = env.getOrDefault(TESTSERVER_PASSWORD, - System.getProperty(TESTSERVER_PASSWORD, DEFAULT_TESTSERVER_PASSWORD)); + System.getProperty(TESTSERVER_PASSWORD, DEFAULT_TESTSERVER_PASSWORD)); testServerClient.setCredentials(user, password); executor = testServerClient.createRecipeExecutor(); @@ -58,7 +58,7 @@ public CucumberRecipeExecutor() throws MalformedURLException { * Executes the specified TestCase and returns the Execution. If a scenario * is specified and the testserver.cucumber.logfolder system property is set, * the generated recipe will be written to the specified folder. - * + *

* It is possible to temporarily "bypass" recipe execution by specifying * a testserver.cucumber.silent property - in which case testcases will not be * submitted to the server, but still logged to the above folder. @@ -66,7 +66,7 @@ public CucumberRecipeExecutor() throws MalformedURLException { * @param testCase the TestCase to execute * @param scenario the Cucumber scenario used to generate the specified Recipe * @return the TestServer Execution for the executed TestCase - * @throws com.smartbear.readyapi.client.execution.ApiException if recipe execution failes + * @throws com.smartbear.readyapi4j.testserver.execution.ApiException if recipe execution failes */ public Execution runTestCase(TestCase testCase, Scenario scenario) { @@ -77,12 +77,12 @@ public Execution runTestCase(TestCase testCase, Scenario scenario) { LOG.debug(testRecipe.toString()); } - String logFolder = System.getProperty( "testserver.cucumber.logfolder", null ); - if( scenario != null && logFolder != null ){ + String logFolder = System.getProperty("testserver.cucumber.logfolder", null); + if (scenario != null && logFolder != null) { logScenarioToFile(testRecipe, scenario, logFolder); } - return async ? executor.submitRecipe( testRecipe ) : executor.executeRecipe(testRecipe); + return async ? executor.submitRecipe(testRecipe) : executor.executeRecipe(testRecipe); } /** @@ -90,14 +90,14 @@ public Execution runTestCase(TestCase testCase, Scenario scenario) { * specified scenario * * @param testRecipe the test recipe to log - * @param scenario the associated Cucumber scenario - * @param logFolder the root folder for generated folders and files + * @param scenario the associated Cucumber scenario + * @param logFolder the root folder for generated folders and files */ protected void logScenarioToFile(TestRecipe testRecipe, Scenario scenario, String logFolder) { try { - File folder = new File( logFolder ); - if( !folder.exists() || !folder.isDirectory()){ + File folder = new File(logFolder); + if (!folder.exists() || !folder.isDirectory()) { folder.mkdirs(); } @@ -105,7 +105,7 @@ protected void logScenarioToFile(TestRecipe testRecipe, Scenario scenario, Strin File scenarioFolder = folder; int fileIndex = 0; - if( pathSegments.length > 1 ) { + if (pathSegments.length > 1) { scenarioFolder = new File(folder, pathSegments[0]); if (scenarioFolder.exists() || !scenarioFolder.isDirectory()) { scenarioFolder.mkdirs(); @@ -115,25 +115,25 @@ protected void logScenarioToFile(TestRecipe testRecipe, Scenario scenario, Strin } String filename = pathSegments[fileIndex]; - for( int c = fileIndex+1; c < pathSegments.length; c++ ){ + for (int c = fileIndex + 1; c < pathSegments.length; c++) { String segment = pathSegments[c].trim(); - if( !StringUtils.isBlank( segment )){ + if (!StringUtils.isBlank(segment)) { filename += "_" + segment; } } filename += ".json"; - File scenarioFile = new File( scenarioFolder, filename ); - FileWriter writer = new FileWriter( scenarioFile ); + File scenarioFile = new File(scenarioFolder, filename); + FileWriter writer = new FileWriter(scenarioFile); LOG.info("Writing recipe to " + folder.getName() + File.separatorChar + scenarioFolder.getName() + - File.separatorChar + scenarioFile.getName()); + File.separatorChar + scenarioFile.getName()); - writer.write( Json.pretty(testRecipe) ); + writer.write(Json.pretty(testRecipe)); writer.close(); } catch (Exception e) { - LOG.error("Failed to write recipe to logFolder [" + logFolder + "]", e ); + LOG.error("Failed to write recipe to logFolder [" + logFolder + "]", e); } } diff --git a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/builders/TestSteps.java b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/builders/TestSteps.java index a88a230..8ad3e99 100644 --- a/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/builders/TestSteps.java +++ b/modules/core/src/main/java/com/smartbear/readyapi/testserver/cucumber/builders/TestSteps.java @@ -2,7 +2,7 @@ import com.smartbear.readyapi.client.model.RestTestRequestStep; import com.smartbear.readyapi.client.model.SoapRequestTestStep; -import com.smartbear.readyapi.client.teststeps.TestStepTypes; +import com.smartbear.readyapi4j.teststeps.TestStepTypes; /** * Utility class with static method for building various types of TestSteps @@ -10,7 +10,7 @@ public class TestSteps { - public static RestTestRequestStep restRequest( String method, String endpoint ){ + public static RestTestRequestStep restRequest(String method, String endpoint) { RestTestRequestStep testStep = new RestTestRequestStep(); testStep.setURI(endpoint); testStep.setMethod(method); @@ -18,12 +18,12 @@ public static RestTestRequestStep restRequest( String method, String endpoint ){ return testStep; } - public static SoapRequestTestStep soapRequest( String wsdl, String operation, String binding ){ + public static SoapRequestTestStep soapRequest(String wsdl, String operation, String binding) { SoapRequestTestStep testStep = new SoapRequestTestStep(); - testStep.setWsdl( wsdl ); - testStep.setBinding( binding ); - testStep.setOperation( operation ); - testStep.setType( TestStepTypes.SOAP_REQUEST.getName()); + testStep.setWsdl(wsdl); + testStep.setBinding(binding); + testStep.setOperation(operation); + testStep.setType(TestStepTypes.SOAP_REQUEST.getName()); return testStep; } } diff --git a/modules/runner/pom.xml b/modules/runner/pom.xml index 905d273..88d155c 100644 --- a/modules/runner/pom.xml +++ b/modules/runner/pom.xml @@ -9,19 +9,18 @@ testserver-cucumber-runner - 1.0.1-SNAPSHOT jar com.smartbear.readyapi.testserver.cucumber testserver-cucumber-core - 1.0.1-SNAPSHOT + ${project.version} com.smartbear.readyapi.testserver.cucumber testserver-cucumber-stepdefs - 1.0.1-SNAPSHOT + ${project.version} diff --git a/modules/samples/src/test/resources/cucumber/swaggerhub.feature b/modules/samples/src/test/resources/cucumber/swaggerhub.feature index 0d9556d..c9b8425 100644 --- a/modules/samples/src/test/resources/cucumber/swaggerhub.feature +++ b/modules/samples/src/test/resources/cucumber/swaggerhub.feature @@ -28,9 +28,9 @@ Feature: SwaggerHub REST API And the response type is json And the response body contains """ - "description":"" + "title":"" """ Examples: - | owner | api | version | description | - | swagger-hub | registry-api | 1.0.10 | The registry API for SwaggerHub | - | fehguy | sonos-api | 1.0.0 | A REST API for the Sonos platform | \ No newline at end of file + | owner | api | version | title | + | swagger-hub | registry-api | 1.0.10 | SwaggerHub Registry API | + | smartbear | ready-api-testserver | 1.2.1 | Ready! API TestServer API | \ No newline at end of file diff --git a/modules/stepdefs/pom.xml b/modules/stepdefs/pom.xml index 1c7cd33..8153566 100644 --- a/modules/stepdefs/pom.xml +++ b/modules/stepdefs/pom.xml @@ -11,14 +11,13 @@ <description>the actual Cucumber API StepDefs</description> <artifactId>testserver-cucumber-stepdefs</artifactId> - <version>1.0.1-SNAPSHOT</version> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.smartbear.readyapi.testserver.cucumber</groupId> <artifactId>testserver-cucumber-core</artifactId> - <version>1.0.1-SNAPSHOT</version> + <version>${project.version}</version> </dependency> </dependencies>