use of gherkin.ast.Step in project page-factory-2 by sbtqa.
the class StepReplacer method replaceWith.
List<Step> replaceWith(List<Step> replacementSteps) {
List<Map<String, String>> dataTable = FragmentDataTableUtils.getDataTable(step);
if (dataTable.isEmpty()) {
addSteps(replacementSteps);
return replacedSteps;
}
for (Map<String, String> dataTableRow : dataTable) {
for (Step replacementStep : replacementSteps) {
String text = FragmentDataTableUtils.applyToText(dataTableRow, replacementStep.getText());
DataTable argument = null;
if (replacementStep.getArgument() != null) {
argument = FragmentDataTableUtils.applyToArgument(dataTableRow, replacementStep);
}
addStep(step.getLocation(), replacementStep.getKeyword(), text, argument);
}
}
return replacedSteps;
}
use of gherkin.ast.Step in project page-factory-2 by sbtqa.
the class StepReplacer method addStep.
private void addStep(Location location, String keyword, String text, Node argument) {
Step replacedStep = new Step(location, keyword, text, argument);
replacedSteps.add(replacedStep);
}
use of gherkin.ast.Step in project cucable-plugin by trivago.
the class GherkinToCucableConverterTest method convertGherkinStepsToCucableStepsTest.
@Test
public void convertGherkinStepsToCucableStepsTest() {
List<Step> gherkinSteps = Arrays.asList(new Step(new Location(1, 1), "Given ", "this is a test step", null), new Step(new Location(2, 1), "Then ", "I get a test result", null));
List<com.trivago.vo.Step> steps = gherkinToCucableConverter.convertGherkinStepsToCucableSteps(gherkinSteps);
assertThat(steps.size(), is(gherkinSteps.size()));
com.trivago.vo.Step firstStep = steps.get(0);
assertThat(firstStep.getName(), is("Given this is a test step"));
com.trivago.vo.Step secondStep = steps.get(1);
assertThat(secondStep.getName(), is("Then I get a test result"));
}
use of gherkin.ast.Step in project cucable-plugin by trivago.
the class GherkinToCucableConverter method convertGherkinStepsToCucableSteps.
/**
* Converts a list of Gherkin steps to Cucable steps including data tables.
*
* @param gherkinSteps a {@link Step} list.
* @return a {@link com.trivago.rta.vo.Step} list.
*/
List<com.trivago.rta.vo.Step> convertGherkinStepsToCucableSteps(final List<Step> gherkinSteps) {
List<com.trivago.rta.vo.Step> steps = new ArrayList<>();
for (Step gherkinStep : gherkinSteps) {
com.trivago.rta.vo.Step step;
com.trivago.rta.vo.DataTable dataTable = null;
String docString = null;
Node argument = gherkinStep.getArgument();
if (argument instanceof DataTable) {
dataTable = convertGherkinDataTableToCucumberDataTable((DataTable) argument);
} else if (argument instanceof DocString) {
docString = ((DocString) argument).getContent();
}
String keywordAndName = gherkinStep.getKeyword().concat(gherkinStep.getText());
step = new com.trivago.rta.vo.Step(keywordAndName, dataTable, docString);
steps.add(step);
}
return steps;
}
use of gherkin.ast.Step in project cucable-plugin by trivago.
the class GherkinToCucableConverterTest method convertGherkinStepsToCucableStepsTest.
@Test
public void convertGherkinStepsToCucableStepsTest() {
List<Step> gherkinSteps = Arrays.asList(new Step(new Location(1, 1), "Given ", "this is a test step", null), new Step(new Location(2, 1), "Then ", "I get a test result", null));
List<com.trivago.rta.vo.Step> steps = gherkinToCucableConverter.convertGherkinStepsToCucableSteps(gherkinSteps);
assertThat(steps.size(), is(gherkinSteps.size()));
com.trivago.rta.vo.Step firstStep = steps.get(0);
assertThat(firstStep.getName(), is("Given this is a test step"));
com.trivago.rta.vo.Step secondStep = steps.get(1);
assertThat(secondStep.getName(), is("Then I get a test result"));
}
Aggregations