From c6ad3d7a2a70edc4b32661a36b47df0aac903c01 Mon Sep 17 00:00:00 2001 From: prashantmurkute Date: Sat, 23 Jan 2021 13:22:53 +0530 Subject: [PATCH 1/5] Added support for csv file for csvSource --- .../zerocode/core/domain/Parameterized.java | 37 ++++++++++++++++++- .../ZeroCodeParameterizedProcessorImpl.java | 23 ++++++------ .../httpclient/JustHelloWorldSuite.java | 3 -- .../HelloWorldParameterizedCsvTest.java | 5 +++ ...d_test_parameterized_csv_source_files.json | 25 +++++++++++++ .../resources/parameterized_csv/params.csv | 2 + 6 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_files.json create mode 100644 http-testing/src/test/resources/parameterized_csv/params.csv diff --git a/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java b/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java index 14b119b4f..2e24b65a4 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java +++ b/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java @@ -1,7 +1,19 @@ package org.jsmart.zerocode.core.domain; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import org.apache.commons.lang.StringUtils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; public class Parameterized { private final List valueSource; @@ -9,9 +21,9 @@ public class Parameterized { public Parameterized( @JsonProperty("valueSource") List valueSource, - @JsonProperty("csvSource") List csvSource) { + @JsonProperty("csvSource") JsonNode csvSourceJsonNode) { this.valueSource = valueSource; - this.csvSource = csvSource; + this.csvSource = getCsvSourceFrom(csvSourceJsonNode); } public List getValueSource() { @@ -22,6 +34,27 @@ public List getCsvSource() { return csvSource; } + private List getCsvSourceFrom(JsonNode csvSourceJsonNode) { + try { + if (csvSourceJsonNode.isArray()) { + ObjectMapper mapper = new ObjectMapper(); + ObjectReader reader = mapper.readerFor(new TypeReference>() { + }); + return reader.readValue(csvSourceJsonNode); + + } else { + String csvSourceFilePath = csvSourceJsonNode.textValue(); + if (StringUtils.isNotBlank(csvSourceFilePath)) { + Path path = Paths.get(csvSourceFilePath); + return Files.lines(path).collect(Collectors.toList()); + } + } + } catch (IOException e) { + throw new RuntimeException("Error deserializing csvSource", e); + } + return Collections.emptyList(); + } + @Override public String toString() { return "Parameterized{" + diff --git a/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java b/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java index 466cf145f..79d5518c0 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java +++ b/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java @@ -4,17 +4,18 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import com.univocity.parsers.csv.CsvParser; +import org.apache.commons.lang.text.StrSubstitutor; +import org.jsmart.zerocode.core.domain.ScenarioSpec; +import org.slf4j.Logger; + import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.atomic.AtomicLong; -import org.apache.commons.lang.text.StrSubstitutor; -import org.jsmart.zerocode.core.domain.ScenarioSpec; -import org.slf4j.Logger; -import static org.jsmart.zerocode.core.di.provider.CsvParserProvider.LINE_SEPARATOR; import static org.jsmart.zerocode.core.constants.ZerocodeConstants.DSL_FORMAT; +import static org.jsmart.zerocode.core.di.provider.CsvParserProvider.LINE_SEPARATOR; import static org.slf4j.LoggerFactory.getLogger; /** @@ -25,17 +26,17 @@ *

* Parameters can be * "parameterized": [ - * 200, - * "Hello", - * true + * 200, + * "Hello", + * true * ] *

* -or- *

* "parameterizedCsv": [ - * "1, 2, 200", - * "11, 22, 400", - * "21, 31, 500" + * "1, 2, 200", + * "11, 22, 400", + * "21, 31, 500" * ] *

* In each the above cases, the step will execute 3 times. @@ -64,7 +65,7 @@ public ZeroCodeParameterizedProcessorImpl(ObjectMapper objectMapper, CsvParser c @Override public ScenarioSpec resolveParameterized(ScenarioSpec scenario, int iteration) { - if(scenario.getParameterized() == null){ + if (scenario.getParameterized() == null) { return scenario; diff --git a/http-testing/src/main/java/org/jsmart/zerocode/zerocodejavaexec/httpclient/JustHelloWorldSuite.java b/http-testing/src/main/java/org/jsmart/zerocode/zerocodejavaexec/httpclient/JustHelloWorldSuite.java index 413cf203d..97e3e7d75 100644 --- a/http-testing/src/main/java/org/jsmart/zerocode/zerocodejavaexec/httpclient/JustHelloWorldSuite.java +++ b/http-testing/src/main/java/org/jsmart/zerocode/zerocodejavaexec/httpclient/JustHelloWorldSuite.java @@ -1,11 +1,8 @@ package org.jsmart.zerocode.zerocodejavaexec.httpclient; -import org.jsmart.zerocode.core.domain.Scenario; import org.jsmart.zerocode.core.domain.TargetEnv; import org.jsmart.zerocode.core.domain.TestPackageRoot; import org.jsmart.zerocode.core.runner.ZeroCodePackageRunner; -import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner; -import org.junit.Test; import org.junit.runner.RunWith; @TargetEnv("hello_github_host.properties") diff --git a/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java b/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java index e169a8a24..649bd8118 100644 --- a/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java +++ b/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java @@ -15,4 +15,9 @@ public class HelloWorldParameterizedCsvTest { public void testGetByUserNames_csv() throws Exception { } + @Test + @Scenario("parameterized_csv/hello_world_test_parameterized_csv_source_files.json") + public void testGetByUserNames_csvSourceFiles() throws Exception { + } + } diff --git a/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_files.json b/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_files.json new file mode 100644 index 000000000..264f96f66 --- /dev/null +++ b/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_files.json @@ -0,0 +1,25 @@ +{ + "scenarioName": "Fetch and assert GitHub userIds by their userNames", + "steps": [ + { + "name": "get_user_details", + "url": "/users/${0}", + "method": "GET", + "request": { + }, + "assertions": { + "status": 200, + "body": { + "login" : "${0}", + "type" : "User", + "name" : "${1}", + "location" : "${2}", + "id" : "$EQ.${3}" + } + } + } + ], + "parameterized": { + "csvSource":"./src/test/resources/parameterized_csv/params.csv" + } +} diff --git a/http-testing/src/test/resources/parameterized_csv/params.csv b/http-testing/src/test/resources/parameterized_csv/params.csv new file mode 100644 index 000000000..faef91767 --- /dev/null +++ b/http-testing/src/test/resources/parameterized_csv/params.csv @@ -0,0 +1,2 @@ +octocat,The Octocat,San Francisco,583231 +siddhagalaxy,Sidd,UK,33847730 \ No newline at end of file From 5db65b47900d7885890089cd9cdc6eae45c67092 Mon Sep 17 00:00:00 2001 From: prashantmurkute Date: Sat, 23 Jan 2021 14:03:02 +0530 Subject: [PATCH 2/5] Added support to ignore header in CSV file --- .../zerocode/core/domain/Parameterized.java | 40 ++++++++++++++----- ...terized_csv_source_file_ignore_header.json | 26 ++++++++++++ .../parameterized_csv/params_with_header.csv | 3 ++ 3 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_file_ignore_header.json create mode 100644 http-testing/src/test/resources/parameterized_csv/params_with_header.csv diff --git a/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java b/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java index 2e24b65a4..2f85f4c5b 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java +++ b/core/src/main/java/org/jsmart/zerocode/core/domain/Parameterized.java @@ -13,16 +13,20 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; public class Parameterized { private final List valueSource; private final List csvSource; + private final Boolean ignoreHeader; public Parameterized( @JsonProperty("valueSource") List valueSource, - @JsonProperty("csvSource") JsonNode csvSourceJsonNode) { + @JsonProperty("csvSource") JsonNode csvSourceJsonNode, + @JsonProperty("ignoreHeader") Boolean ignoreHeader) { this.valueSource = valueSource; + this.ignoreHeader = Optional.ofNullable(ignoreHeader).orElse(false); this.csvSource = getCsvSourceFrom(csvSourceJsonNode); } @@ -37,21 +41,37 @@ public List getCsvSource() { private List getCsvSourceFrom(JsonNode csvSourceJsonNode) { try { if (csvSourceJsonNode.isArray()) { - ObjectMapper mapper = new ObjectMapper(); - ObjectReader reader = mapper.readerFor(new TypeReference>() { - }); - return reader.readValue(csvSourceJsonNode); + return readCsvSourceFromJson(csvSourceJsonNode); } else { - String csvSourceFilePath = csvSourceJsonNode.textValue(); - if (StringUtils.isNotBlank(csvSourceFilePath)) { - Path path = Paths.get(csvSourceFilePath); - return Files.lines(path).collect(Collectors.toList()); - } + return readCsvSourceFromExternalCsvFile(csvSourceJsonNode); } } catch (IOException e) { throw new RuntimeException("Error deserializing csvSource", e); } + } + + private List readCsvSourceFromJson(JsonNode csvSourceJsonNode) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + ObjectReader reader = mapper.readerFor(new TypeReference>() { + }); + return reader.readValue(csvSourceJsonNode); + } + + private List readCsvSourceFromExternalCsvFile(JsonNode csvSourceJsonNode) throws IOException { + String csvSourceFilePath = csvSourceJsonNode.textValue(); + if (StringUtils.isNotBlank(csvSourceFilePath)) { + Path path = Paths.get(csvSourceFilePath); + List csvSourceFileLines = Files.lines(path) + .filter(StringUtils::isNotBlank) + .collect(Collectors.toList()); + if (this.ignoreHeader) { + return csvSourceFileLines.stream() + .skip(1) + .collect(Collectors.toList()); + } + return csvSourceFileLines; + } return Collections.emptyList(); } diff --git a/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_file_ignore_header.json b/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_file_ignore_header.json new file mode 100644 index 000000000..48a7e741e --- /dev/null +++ b/http-testing/src/test/resources/parameterized_csv/hello_world_test_parameterized_csv_source_file_ignore_header.json @@ -0,0 +1,26 @@ +{ + "scenarioName": "Fetch and assert GitHub userIds by their userNames", + "steps": [ + { + "name": "get_user_details", + "url": "/users/${0}", + "method": "GET", + "request": { + }, + "assertions": { + "status": 200, + "body": { + "login" : "${0}", + "type" : "User", + "name" : "${1}", + "location" : "${2}", + "id" : "$EQ.${3}" + } + } + } + ], + "parameterized": { + "ignoreHeader": true, + "csvSource":"./src/test/resources/parameterized_csv/params_with_header.csv" + } +} diff --git a/http-testing/src/test/resources/parameterized_csv/params_with_header.csv b/http-testing/src/test/resources/parameterized_csv/params_with_header.csv new file mode 100644 index 000000000..3df16ea8d --- /dev/null +++ b/http-testing/src/test/resources/parameterized_csv/params_with_header.csv @@ -0,0 +1,3 @@ +user,name,city,userid +octocat,The Octocat,San Francisco,583231 +siddhagalaxy,Sidd,UK,33847730 \ No newline at end of file From 5f15cc8ec7eb385667184a7788a190770b2541aa Mon Sep 17 00:00:00 2001 From: prashantmurkute Date: Sat, 23 Jan 2021 14:28:24 +0530 Subject: [PATCH 3/5] Added Unit tests for Parameterized csv source from file --- .../core/domain/ParameterizedTest.java | 33 ++++++++++++++++++- ....1_parameterized_csv_source_from_file.json | 8 +++++ ...sv_source_from_file_containing_header.json | 9 +++++ .../engine_unit_test_jsons/params.csv | 2 ++ .../params_with_header.csv | 3 ++ 5 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.1_parameterized_csv_source_from_file.json create mode 100755 core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.2_parameterized_csv_source_from_file_containing_header.json create mode 100644 core/src/test/resources/unit_test_files/engine_unit_test_jsons/params.csv create mode 100644 core/src/test/resources/unit_test_files/engine_unit_test_jsons/params_with_header.csv diff --git a/core/src/test/java/org/jsmart/zerocode/core/domain/ParameterizedTest.java b/core/src/test/java/org/jsmart/zerocode/core/domain/ParameterizedTest.java index a2be5436d..09569bd21 100644 --- a/core/src/test/java/org/jsmart/zerocode/core/domain/ParameterizedTest.java +++ b/core/src/test/java/org/jsmart/zerocode/core/domain/ParameterizedTest.java @@ -10,7 +10,9 @@ import org.junit.Test; import org.junit.runner.RunWith; -import static org.hamcrest.CoreMatchers.hasItem; +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -58,4 +60,33 @@ public void testSerDe_csvSource() throws Exception { assertThat(parameterized.getCsvSource(), hasItem("11, 22, 400")); } + @Test + public void shouldReadCsvSourceFromCsvFile() throws IOException { + //given + String jsonDocumentAsString = + smartUtils.getJsonDocumentAsString("unit_test_files/engine_unit_test_jsons/08.1_parameterized_csv_source_from_file.json"); + + //when + Parameterized parameterized = mapper.readValue(jsonDocumentAsString, Parameterized.class); + + //then + assertThat(parameterized.getCsvSource(), hasItem("octocat,The Octocat,San Francisco,583231")); + assertThat(parameterized.getCsvSource(), hasItem("siddhagalaxy,Sidd,UK,33847730")); + } + + @Test + public void shouldReadCsvSourceFromCsvFileIgnoringHeader() throws IOException { + //given + String jsonDocumentAsString = + smartUtils.getJsonDocumentAsString("unit_test_files/engine_unit_test_jsons/08.2_parameterized_csv_source_from_file_containing_header.json"); + + //when + Parameterized parameterized = mapper.readValue(jsonDocumentAsString, Parameterized.class); + + //then + assertThat(parameterized.getCsvSource(), hasItem("octocat,The Octocat,San Francisco,583231")); + assertThat(parameterized.getCsvSource(), hasItem("siddhagalaxy,Sidd,UK,33847730")); + assertThat(parameterized.getCsvSource(), everyItem(not(is("user,name,city,userid"))));//assert header is ignored + } + } \ No newline at end of file diff --git a/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.1_parameterized_csv_source_from_file.json b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.1_parameterized_csv_source_from_file.json new file mode 100755 index 000000000..feedf0b89 --- /dev/null +++ b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.1_parameterized_csv_source_from_file.json @@ -0,0 +1,8 @@ +{ + "valueSource": [ + "hello", + 123, + true + ], + "csvSource": "./src/test/resources/unit_test_files/engine_unit_test_jsons/params.csv" +} diff --git a/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.2_parameterized_csv_source_from_file_containing_header.json b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.2_parameterized_csv_source_from_file_containing_header.json new file mode 100755 index 000000000..c7500a8c1 --- /dev/null +++ b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/08.2_parameterized_csv_source_from_file_containing_header.json @@ -0,0 +1,9 @@ +{ + "valueSource": [ + "hello", + 123, + true + ], + "ignoreHeader": true, + "csvSource": "./src/test/resources/unit_test_files/engine_unit_test_jsons/params_with_header.csv" +} diff --git a/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params.csv b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params.csv new file mode 100644 index 000000000..faef91767 --- /dev/null +++ b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params.csv @@ -0,0 +1,2 @@ +octocat,The Octocat,San Francisco,583231 +siddhagalaxy,Sidd,UK,33847730 \ No newline at end of file diff --git a/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params_with_header.csv b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params_with_header.csv new file mode 100644 index 000000000..3df16ea8d --- /dev/null +++ b/core/src/test/resources/unit_test_files/engine_unit_test_jsons/params_with_header.csv @@ -0,0 +1,3 @@ +user,name,city,userid +octocat,The Octocat,San Francisco,583231 +siddhagalaxy,Sidd,UK,33847730 \ No newline at end of file From 8b5e52f5b0dd365f8d004d644127813a0506079d Mon Sep 17 00:00:00 2001 From: prashantmurkute Date: Sat, 23 Jan 2021 14:28:56 +0530 Subject: [PATCH 4/5] Added Integration tests for Parameterized csv source from file --- .../HelloWorldParameterizedCsvTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java b/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java index 649bd8118..6baea481e 100644 --- a/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java +++ b/http-testing/src/test/java/org/jsmart/zerocode/testhelp/tests/helloworldparameterizedcsv/HelloWorldParameterizedCsvTest.java @@ -20,4 +20,9 @@ public void testGetByUserNames_csv() throws Exception { public void testGetByUserNames_csvSourceFiles() throws Exception { } + @Test + @Scenario("parameterized_csv/hello_world_test_parameterized_csv_source_file_ignore_header.json") + public void testGetByUserNames_csvSourceFiles_ignoringHeader() throws Exception { + } + } From 0fa5260e4cd3c702ba6d9941ab8c906e484e342c Mon Sep 17 00:00:00 2001 From: prashantmurkute Date: Sat, 23 Jan 2021 16:42:00 +0530 Subject: [PATCH 5/5] Fixed failing tests --- .../ZeroCodeParameterizedProcessorImpl.java | 3 ++- .../zerocode/core/utils/SmartUtilsTest.java | 24 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java b/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java index 79d5518c0..5d627111a 100644 --- a/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java +++ b/core/src/main/java/org/jsmart/zerocode/core/engine/preprocessor/ZeroCodeParameterizedProcessorImpl.java @@ -4,6 +4,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import com.univocity.parsers.csv.CsvParser; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.text.StrSubstitutor; import org.jsmart.zerocode.core.domain.ScenarioSpec; import org.slf4j.Logger; @@ -73,7 +74,7 @@ public ScenarioSpec resolveParameterized(ScenarioSpec scenario, int iteration) { return resolveParamsValues(scenario, iteration); - } else if (scenario.getParameterized().getCsvSource() != null) { + } else if (CollectionUtils.isNotEmpty(scenario.getParameterized().getCsvSource())) { return resolveParamsCsv(scenario, iteration); diff --git a/core/src/test/java/org/jsmart/zerocode/core/utils/SmartUtilsTest.java b/core/src/test/java/org/jsmart/zerocode/core/utils/SmartUtilsTest.java index 5e8374d0f..ad7ddb206 100644 --- a/core/src/test/java/org/jsmart/zerocode/core/utils/SmartUtilsTest.java +++ b/core/src/test/java/org/jsmart/zerocode/core/utils/SmartUtilsTest.java @@ -74,14 +74,14 @@ public void willGetJsonFileIntoA_JavaString() throws Exception { } @Test - public void willReadAllfileNamesFrom_TestResource() throws Exception { + public void willReadAllfileNamesFrom_TestResource() { List allTestCaseFiles = SmartUtils.getAllEndPointFiles("unit_test_files/engine_unit_test_jsons"); - assertThat(allTestCaseFiles.size(), is(18)); + assertThat(allTestCaseFiles.size(), is(20)); assertThat(allTestCaseFiles.get(0), is("unit_test_files/engine_unit_test_jsons/00_test_json_single_step_verifications.json")); } @Test - public void willReadAllfileNames_AND_return_FlowSpecList() throws Exception { + public void willReadAllfileNames_AND_return_FlowSpecList() { List allTestCaseFiles = smartUtils.getScenarioSpecListByPackage("unit_test_files/test_scenario_cases"); assertThat(allTestCaseFiles.size(), is(3)); @@ -91,19 +91,19 @@ public void willReadAllfileNames_AND_return_FlowSpecList() throws Exception { @Test(expected = RuntimeException.class) - public void willReadAllfiles_find_DuplicatesScenarioNamenames_old_style() throws Exception { + public void willReadAllfiles_find_DuplicatesScenarioNamenames_old_style() { smartUtils.checkDuplicateScenarios("unit_test_files/test_scenario_cases"); } @Test - public void willReadAllfiles_find_DuplicateScenarioNames() throws Exception { + public void willReadAllfiles_find_DuplicateScenarioNames() { expectedException.expect(RuntimeException.class); expectedException.expectMessage("Oops! Can not run with multiple Scenarios with same name."); smartUtils.checkDuplicateScenarios("unit_test_files/test_scenario_cases"); } @Test - public void willEvaluatePlaceHolder() throws Exception { + public void willEvaluatePlaceHolder() { String aString = "Hello_${WORLD}"; List placeHolders = getTestCaseTokens(aString); @@ -118,7 +118,7 @@ public void willEvaluatePlaceHolder() throws Exception { } @Test - public void testNullOrEmptyString_withPlaceHolders() throws Exception { + public void testNullOrEmptyString_withPlaceHolders() { String aString = ""; List placeHolders = getTestCaseTokens(aString); @@ -130,7 +130,7 @@ public void testNullOrEmptyString_withPlaceHolders() throws Exception { } @Test - public void testReplaceTokensOrPlaceHolders() throws Exception { + public void testReplaceTokensOrPlaceHolders() { String aString = "_${ENV_PROPERTY_NAME}"; Map paramMap = new HashMap<>(); @@ -142,7 +142,7 @@ public void testReplaceTokensOrPlaceHolders() throws Exception { } @Test - public void testEnvValue() throws Exception { + public void testEnvValue() { final String javaHomeValue = SmartUtils.getEnvPropertyValue("JAVA_HOME"); assertThat(javaHomeValue, notNullValue()); @@ -217,7 +217,7 @@ public void testScenarioFile_absolutePath() throws Exception { @Ignore("Tested in local laptop. Ignored for Ci build. Follow testSuiteFolder_absolutePath() like flow ") @Test - public void testSuiteFolder_symAbsolutePath() throws Exception { + public void testSuiteFolder_symAbsolutePath() { String absPath = "~/dev/ZEROCODE_REPOS/zerocode/core/src/test/resources/unit_test_files/cherry_pick_tests"; List allScenarios = SmartUtils.retrieveScenariosByAbsPath(absPath); assertThat(allScenarios.size(), is(2)); @@ -231,9 +231,7 @@ private static File createCascadeIfNotExisting(String fileName) { Path path = Paths.get(fileName); Files.createDirectories(path.getParent()); - File file = new File(fileName); - - return file; + return new File(fileName); } catch (IOException exx) { throw new RuntimeException("Create file '" + fileName + "' Exception" + exx); }