@Test public void documents_match_arguments() { ParameterTypeRegistry parameterTypeRegistry = new ParameterTypeRegistry(Locale.ENGLISH); String expr = "I have {int} cuke(s)"; Expression expression = new CucumberExpression(expr, parameterTypeRegistry); List<Argument<?>> args = expression.match("I have 7 cukes"); assertEquals(7, args.get(0).getValue()); }
@Override public List<Argument<?>> match(String text, Type... typeHints) { final Group group = treeRegexp.match(text); if (group == null) { return null; } List<ParameterType<?>> parameterTypes = new ArrayList<>(this.parameterTypes); for (int i = 0; i < parameterTypes.size(); i++) { ParameterType<?> parameterType = parameterTypes.get(i); Type type = i < typeHints.length ? typeHints[i] : String.class; if (parameterType.isAnonymous()) { ParameterByTypeTransformer defaultTransformer = parameterTypeRegistry.getDefaultParameterTransformer(); parameterTypes.set(i, parameterType.deAnonymize(type, arg -> defaultTransformer.transform(arg, type))); } } return Argument.build(group, treeRegexp, parameterTypes); }
CucumberExpression implements Expression { @Override public List<Argument<?>> match(String text, Type... typeHints) { final Group group = treeRegexp.match(text); if (group == null) { return null; } List<ParameterType<?>> parameterTypes = new ArrayList<>(this.parameterTypes); for (int i = 0; i < parameterTypes.size(); i++) { ParameterType<?> parameterType = parameterTypes.get(i); Type type = i < typeHints.length ? typeHints[i] : String.class; if (parameterType.isAnonymous()) { ParameterByTypeTransformer defaultTransformer = parameterTypeRegistry.getDefaultParameterTransformer(); parameterTypes.set(i, parameterType.deAnonymize(type, arg -> defaultTransformer.transform(arg, type))); } } return Argument.build(group, treeRegexp, parameterTypes); } }
CucumberExpression implements Expression { @Override public List<Argument<?>> match(String text, Type... typeHints) { final Group group = treeRegexp.match(text); if (group == null) { return null; } List<ParameterType<?>> parameterTypes = new ArrayList<>(this.parameterTypes); for (int i = 0; i < parameterTypes.size(); i++) { ParameterType<?> parameterType = parameterTypes.get(i); Type type = i < typeHints.length ? typeHints[i] : String.class; if (parameterType.isAnonymous()) { ParameterByTypeTransformer defaultTransformer = parameterTypeRegistry.getDefaultParameterTransformer(); parameterTypes.set(i, parameterType.deAnonymize(type, arg -> defaultTransformer.transform(arg, type))); } } return Argument.build(group, treeRegexp, parameterTypes); } CucumberExpression(String expression, ParameterTypeRegistry parameterTypeRegistry); }
CucumberExpression implements Expression { @Override public List<Argument<?>> match(String text, Type... typeHints) { final Group group = treeRegexp.match(text); if (group == null) { return null; } List<ParameterType<?>> parameterTypes = new ArrayList<>(this.parameterTypes); for (int i = 0; i < parameterTypes.size(); i++) { ParameterType<?> parameterType = parameterTypes.get(i); Type type = i < typeHints.length ? typeHints[i] : String.class; if (parameterType.isAnonymous()) { ParameterByTypeTransformer defaultTransformer = parameterTypeRegistry.getDefaultParameterTransformer(); parameterTypes.set(i, parameterType.deAnonymize(type, arg -> defaultTransformer.transform(arg, type))); } } return Argument.build(group, treeRegexp, parameterTypes); } CucumberExpression(String expression, ParameterTypeRegistry parameterTypeRegistry); @Override List<Argument<?>> match(String text, Type... typeHints); @Override String getSource(); @Override Pattern getRegexp(); }
CucumberExpression implements Expression { @Override public List<Argument<?>> match(String text, Type... typeHints) { final Group group = treeRegexp.match(text); if (group == null) { return null; } List<ParameterType<?>> parameterTypes = new ArrayList<>(this.parameterTypes); for (int i = 0; i < parameterTypes.size(); i++) { ParameterType<?> parameterType = parameterTypes.get(i); Type type = i < typeHints.length ? typeHints[i] : String.class; if (parameterType.isAnonymous()) { ParameterByTypeTransformer defaultTransformer = parameterTypeRegistry.getDefaultParameterTransformer(); parameterTypes.set(i, parameterType.deAnonymize(type, arg -> defaultTransformer.transform(arg, type))); } } return Argument.build(group, treeRegexp, parameterTypes); } CucumberExpression(String expression, ParameterTypeRegistry parameterTypeRegistry); @Override List<Argument<?>> match(String text, Type... typeHints); @Override String getSource(); @Override Pattern getRegexp();  }