use of io.cucumber.cucumberexpressions.Expression in project cucumber-jvm by cucumber.
the class JavaParameterTypeDefinitionTest method arguments_must_match_captured_groups.
@Test
void arguments_must_match_captured_groups() throws NoSuchMethodException {
Method method = JavaParameterTypeDefinitionTest.class.getMethod("convert_two_capture_group_to_string", String.class, String.class);
JavaParameterTypeDefinition definition = new JavaParameterTypeDefinition("", ".*", method, false, false, false, lookup);
registry.defineParameterType(definition.parameterType());
Expression cucumberExpression = new ExpressionFactory(registry).createExpression("{convert_two_capture_group_to_string}");
List<Argument<?>> test = cucumberExpression.match("test");
assertThrows(CucumberExpressionException.class, () -> test.get(0).getValue());
}
use of io.cucumber.cucumberexpressions.Expression in project cucumber-jvm by cucumber.
the class StepExpressionFactory method createExpression.
private StepExpression createExpression(String expressionString, Supplier<Type> tableOrDocStringType, boolean transpose) {
requireNonNull(expressionString, "expressionString can not be null");
requireNonNull(tableOrDocStringType, "tableOrDocStringType can not be null");
final Expression expression = crateExpression(expressionString);
RawTableTransformer<?> tableTransform = (List<List<String>> raw) -> {
DataTable dataTable = DataTable.create(raw, StepExpressionFactory.this.tableConverter);
Type targetType = tableOrDocStringType.get();
return dataTable.convert(Object.class.equals(targetType) ? DataTable.class : targetType, transpose);
};
DocStringTransformer<?> docStringTransform = (text, contentType) -> {
DocString docString = DocString.create(text, contentType, docStringConverter);
Type targetType = tableOrDocStringType.get();
return docString.convert(Object.class.equals(targetType) ? DocString.class : targetType);
};
return new StepExpression(expression, docStringTransform, tableTransform);
}
Aggregations