private List<PickleStepDefinitionMatch> stepDefinitionMatches(String featurePath, PickleStep step) { List<PickleStepDefinitionMatch> result = new ArrayList<PickleStepDefinitionMatch>(); for (StepDefinition stepDefinition : stepDefinitionsByPattern.values()) { List<Argument> arguments = stepDefinition.matchedArguments(step); if (arguments != null) { result.add(new PickleStepDefinitionMatch(arguments, stepDefinition, featurePath, step)); } } return result; }
PickleStepDefinitionMatch stepDefinitionMatch(String featurePath, PickleStep step) { String stepText = step.getText(); StepDefinition stepDefinition = stepDefinitionsByStepText.get(stepText); if (stepDefinition != null) { // Step definition arguments consists of parameters included in the step text and // gherkin step arguments (doc string and data table) which are not included in // the step text. As such the step definition arguments can not be cached and // must be recreated each time. List<Argument> arguments = stepDefinition.matchedArguments(step); return new PickleStepDefinitionMatch(arguments, stepDefinition, featurePath, step); } List<PickleStepDefinitionMatch> matches = stepDefinitionMatches(featurePath, step); if (matches.isEmpty()) { return null; } if (matches.size() > 1) { throw new AmbiguousStepDefinitionsException(step, matches); } PickleStepDefinitionMatch match = matches.get(0); stepDefinitionsByStepText.put(stepText, match.getStepDefinition()); return match; }
public StepMatchDTO matchedArguments(UUID uuid, long id, StepDTO stepProxy) throws Throwable { SimpleGlue glue = glues.get(uuid); StepDefinition stepDefinition = glue.stepDefinition(id); List<Argument> matchedArguments = stepDefinition.matchedArguments(stepProxy.toStep()); return new StepMatchDTO(matchedArguments); }