use of io.cucumber.plugin.event.Argument in project cucumber-jvm by cucumber.
the class JsonFormatter method createMatchMap.
private Map<String, Object> createMatchMap(TestStep step, Result result) {
Map<String, Object> matchMap = new HashMap<>();
if (step instanceof PickleStepTestStep) {
PickleStepTestStep testStep = (PickleStepTestStep) step;
if (!testStep.getDefinitionArgument().isEmpty()) {
List<Map<String, Object>> argumentList = new ArrayList<>();
for (Argument argument : testStep.getDefinitionArgument()) {
Map<String, Object> argumentMap = new HashMap<>();
if (argument.getValue() != null) {
argumentMap.put("val", argument.getValue());
argumentMap.put("offset", argument.getStart());
}
argumentList.add(argumentMap);
}
matchMap.put("arguments", argumentList);
}
}
if (!result.getStatus().is(Status.UNDEFINED)) {
matchMap.put("location", step.getCodeLocation());
}
return matchMap;
}
use of io.cucumber.plugin.event.Argument in project syndesis-qe by syndesisio.
the class PrettyFormatter method formatStepText.
String formatStepText(String keyword, String stepText, Format textFormat, Format argFormat, List<Argument> arguments) {
int beginIndex = 0;
StringBuilder result = new StringBuilder(textFormat.text(keyword));
for (Argument argument : arguments) {
// can be null if the argument is missing.
if (argument.getValue() != null) {
int argumentOffset = argument.getStart();
// ignore it when formatting
if (argumentOffset < beginIndex) {
continue;
}
String text = stepText.substring(beginIndex, argumentOffset);
result.append(textFormat.text(text));
}
if (argument.getValue() != null) {
String text = stepText.substring(argument.getStart(), argument.getEnd());
result.append(argFormat.text(text));
// set beginIndex to end of argument
beginIndex = argument.getEnd();
}
}
if (beginIndex != stepText.length()) {
String text = stepText.substring(beginIndex);
result.append(textFormat.text(text));
}
return result.toString();
}
use of io.cucumber.plugin.event.Argument in project cucumber-jvm by cucumber.
the class PrettyFormatter method formatStepText.
String formatStepText(String keyword, String stepText, Format textFormat, Format argFormat, List<Argument> arguments) {
int beginIndex = 0;
StringBuilder result = new StringBuilder(textFormat.text(keyword));
for (Argument argument : arguments) {
// can be null if the argument is missing.
if (argument.getValue() != null) {
int argumentOffset = argument.getStart();
// ignore it when formatting
if (argumentOffset < beginIndex) {
continue;
}
String text = stepText.substring(beginIndex, argumentOffset);
result.append(textFormat.text(text));
}
// @And("(it )?has something")
if (argument.getValue() != null) {
String text = stepText.substring(argument.getStart(), argument.getEnd());
result.append(argFormat.text(text));
// set beginIndex to end of argument
beginIndex = argument.getEnd();
}
}
if (beginIndex != stepText.length()) {
String text = stepText.substring(beginIndex);
result.append(textFormat.text(text));
}
return result.toString();
}
use of io.cucumber.plugin.event.Argument in project cucumber-jvm by cucumber.
the class DefinitionArgument method createArguments.
static List<Argument> createArguments(List<io.cucumber.core.stepexpression.Argument> match) {
List<Argument> args = new ArrayList<>();
for (io.cucumber.core.stepexpression.Argument argument : match) {
if (argument instanceof ExpressionArgument) {
ExpressionArgument expressionArgument = (ExpressionArgument) argument;
args.add(new DefinitionArgument(expressionArgument));
}
}
return args;
}
Aggregations