@Test public void exposes_transforms_in_generated_expression() { GeneratedExpression generatedExpression = generator.generateExpressions("I have 2 cukes and 1.5 euro").get(0); assertEquals(Integer.class, generatedExpression.getParameterTypes().get(0).getType()); assertEquals(Double.class, generatedExpression.getParameterTypes().get(1).getType()); }
public List<GeneratedExpression> generateExpressions(String text) { List<List<ParameterType<?>>> parameterTypeCombinations = new ArrayList<>(); List<ParameterTypeMatcher> parameterTypeMatchers = createParameterTypeMatchers(text); StringBuilder expressionTemplate = new StringBuilder(); int pos = 0; while (true) { List<ParameterTypeMatcher> matchingParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher parameterTypeMatcher : parameterTypeMatchers) { if (parameterTypeMatcher.advanceToAndFind(pos)) { matchingParameterTypeMatchers.add(parameterTypeMatcher); } } if (!matchingParameterTypeMatchers.isEmpty()) { Collections.sort(matchingParameterTypeMatchers); ParameterTypeMatcher bestParameterTypeMatcher = matchingParameterTypeMatchers.get(0); List<ParameterTypeMatcher> bestParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher m : matchingParameterTypeMatchers) { if (m.compareTo(bestParameterTypeMatcher) == 0) { bestParameterTypeMatchers.add(m); } } Set<ParameterType<?>> set = new HashSet<>(); for (ParameterTypeMatcher parameterTypeMatcher : bestParameterTypeMatchers) { ParameterType<?> parameterType = parameterTypeMatcher.getParameterType(); set.add(parameterType); } SortedSet<ParameterType<?>> parameterTypes = new TreeSet<>(set); parameterTypeCombinations.add(new ArrayList<>(parameterTypes)); expressionTemplate .append(escape(text.substring(pos, bestParameterTypeMatcher.start()))) .append("{%s}"); pos = bestParameterTypeMatcher.start() + bestParameterTypeMatcher.group().length(); } else { break; } if (pos >= text.length()) { break; } } expressionTemplate.append(escape(text.substring(pos))); return new CombinatorialGeneratedExpressionFactory(expressionTemplate.toString(), parameterTypeCombinations).generateExpressions(); }
CucumberExpressionGenerator { public List<GeneratedExpression> generateExpressions(String text) { List<List<ParameterType<?>>> parameterTypeCombinations = new ArrayList<>(); List<ParameterTypeMatcher> parameterTypeMatchers = createParameterTypeMatchers(text); StringBuilder expressionTemplate = new StringBuilder(); int pos = 0; while (true) { List<ParameterTypeMatcher> matchingParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher parameterTypeMatcher : parameterTypeMatchers) { if (parameterTypeMatcher.advanceToAndFind(pos)) { matchingParameterTypeMatchers.add(parameterTypeMatcher); } } if (!matchingParameterTypeMatchers.isEmpty()) { Collections.sort(matchingParameterTypeMatchers); ParameterTypeMatcher bestParameterTypeMatcher = matchingParameterTypeMatchers.get(0); List<ParameterTypeMatcher> bestParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher m : matchingParameterTypeMatchers) { if (m.compareTo(bestParameterTypeMatcher) == 0) { bestParameterTypeMatchers.add(m); } } Set<ParameterType<?>> set = new HashSet<>(); for (ParameterTypeMatcher parameterTypeMatcher : bestParameterTypeMatchers) { ParameterType<?> parameterType = parameterTypeMatcher.getParameterType(); set.add(parameterType); } SortedSet<ParameterType<?>> parameterTypes = new TreeSet<>(set); parameterTypeCombinations.add(new ArrayList<>(parameterTypes)); expressionTemplate .append(escape(text.substring(pos, bestParameterTypeMatcher.start()))) .append("{%s}"); pos = bestParameterTypeMatcher.start() + bestParameterTypeMatcher.group().length(); } else { break; } if (pos >= text.length()) { break; } } expressionTemplate.append(escape(text.substring(pos))); return new CombinatorialGeneratedExpressionFactory(expressionTemplate.toString(), parameterTypeCombinations).generateExpressions(); } }
CucumberExpressionGenerator { public List<GeneratedExpression> generateExpressions(String text) { List<List<ParameterType<?>>> parameterTypeCombinations = new ArrayList<>(); List<ParameterTypeMatcher> parameterTypeMatchers = createParameterTypeMatchers(text); StringBuilder expressionTemplate = new StringBuilder(); int pos = 0; while (true) { List<ParameterTypeMatcher> matchingParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher parameterTypeMatcher : parameterTypeMatchers) { if (parameterTypeMatcher.advanceToAndFind(pos)) { matchingParameterTypeMatchers.add(parameterTypeMatcher); } } if (!matchingParameterTypeMatchers.isEmpty()) { Collections.sort(matchingParameterTypeMatchers); ParameterTypeMatcher bestParameterTypeMatcher = matchingParameterTypeMatchers.get(0); List<ParameterTypeMatcher> bestParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher m : matchingParameterTypeMatchers) { if (m.compareTo(bestParameterTypeMatcher) == 0) { bestParameterTypeMatchers.add(m); } } Set<ParameterType<?>> set = new HashSet<>(); for (ParameterTypeMatcher parameterTypeMatcher : bestParameterTypeMatchers) { ParameterType<?> parameterType = parameterTypeMatcher.getParameterType(); set.add(parameterType); } SortedSet<ParameterType<?>> parameterTypes = new TreeSet<>(set); parameterTypeCombinations.add(new ArrayList<>(parameterTypes)); expressionTemplate .append(escape(text.substring(pos, bestParameterTypeMatcher.start()))) .append("{%s}"); pos = bestParameterTypeMatcher.start() + bestParameterTypeMatcher.group().length(); } else { break; } if (pos >= text.length()) { break; } } expressionTemplate.append(escape(text.substring(pos))); return new CombinatorialGeneratedExpressionFactory(expressionTemplate.toString(), parameterTypeCombinations).generateExpressions(); } CucumberExpressionGenerator(ParameterTypeRegistry parameterTypeRegistry); }
CucumberExpressionGenerator { public List<GeneratedExpression> generateExpressions(String text) { List<List<ParameterType<?>>> parameterTypeCombinations = new ArrayList<>(); List<ParameterTypeMatcher> parameterTypeMatchers = createParameterTypeMatchers(text); StringBuilder expressionTemplate = new StringBuilder(); int pos = 0; while (true) { List<ParameterTypeMatcher> matchingParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher parameterTypeMatcher : parameterTypeMatchers) { if (parameterTypeMatcher.advanceToAndFind(pos)) { matchingParameterTypeMatchers.add(parameterTypeMatcher); } } if (!matchingParameterTypeMatchers.isEmpty()) { Collections.sort(matchingParameterTypeMatchers); ParameterTypeMatcher bestParameterTypeMatcher = matchingParameterTypeMatchers.get(0); List<ParameterTypeMatcher> bestParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher m : matchingParameterTypeMatchers) { if (m.compareTo(bestParameterTypeMatcher) == 0) { bestParameterTypeMatchers.add(m); } } Set<ParameterType<?>> set = new HashSet<>(); for (ParameterTypeMatcher parameterTypeMatcher : bestParameterTypeMatchers) { ParameterType<?> parameterType = parameterTypeMatcher.getParameterType(); set.add(parameterType); } SortedSet<ParameterType<?>> parameterTypes = new TreeSet<>(set); parameterTypeCombinations.add(new ArrayList<>(parameterTypes)); expressionTemplate .append(escape(text.substring(pos, bestParameterTypeMatcher.start()))) .append("{%s}"); pos = bestParameterTypeMatcher.start() + bestParameterTypeMatcher.group().length(); } else { break; } if (pos >= text.length()) { break; } } expressionTemplate.append(escape(text.substring(pos))); return new CombinatorialGeneratedExpressionFactory(expressionTemplate.toString(), parameterTypeCombinations).generateExpressions(); } CucumberExpressionGenerator(ParameterTypeRegistry parameterTypeRegistry); List<GeneratedExpression> generateExpressions(String text); @Deprecated GeneratedExpression generateExpression(String text); }
CucumberExpressionGenerator { public List<GeneratedExpression> generateExpressions(String text) { List<List<ParameterType<?>>> parameterTypeCombinations = new ArrayList<>(); List<ParameterTypeMatcher> parameterTypeMatchers = createParameterTypeMatchers(text); StringBuilder expressionTemplate = new StringBuilder(); int pos = 0; while (true) { List<ParameterTypeMatcher> matchingParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher parameterTypeMatcher : parameterTypeMatchers) { if (parameterTypeMatcher.advanceToAndFind(pos)) { matchingParameterTypeMatchers.add(parameterTypeMatcher); } } if (!matchingParameterTypeMatchers.isEmpty()) { Collections.sort(matchingParameterTypeMatchers); ParameterTypeMatcher bestParameterTypeMatcher = matchingParameterTypeMatchers.get(0); List<ParameterTypeMatcher> bestParameterTypeMatchers = new ArrayList<>(); for (ParameterTypeMatcher m : matchingParameterTypeMatchers) { if (m.compareTo(bestParameterTypeMatcher) == 0) { bestParameterTypeMatchers.add(m); } } Set<ParameterType<?>> set = new HashSet<>(); for (ParameterTypeMatcher parameterTypeMatcher : bestParameterTypeMatchers) { ParameterType<?> parameterType = parameterTypeMatcher.getParameterType(); set.add(parameterType); } SortedSet<ParameterType<?>> parameterTypes = new TreeSet<>(set); parameterTypeCombinations.add(new ArrayList<>(parameterTypes)); expressionTemplate .append(escape(text.substring(pos, bestParameterTypeMatcher.start()))) .append("{%s}"); pos = bestParameterTypeMatcher.start() + bestParameterTypeMatcher.group().length(); } else { break; } if (pos >= text.length()) { break; } } expressionTemplate.append(escape(text.substring(pos))); return new CombinatorialGeneratedExpressionFactory(expressionTemplate.toString(), parameterTypeCombinations).generateExpressions(); } CucumberExpressionGenerator(ParameterTypeRegistry parameterTypeRegistry); List<GeneratedExpression> generateExpressions(String text); @Deprecated GeneratedExpression generateExpression(String text);  }