private ScenarioToken createScenarioFromOutline(String scenarioName, ScenarioToken outlineScenario, List<String> placeholders, List<String> values,List<String> currentFeaturesTags, List<String> currentScenariosTags, List<StepMacro> stepMacros) { ScenarioToken scenario = new ScenarioToken(); List<String> outlineVariableTags = findChorusTagsFromOutlineVariables(placeholders, values); //append the first paramter to the scenario name if there is one String firstParam = " " + (!values.isEmpty() ? values.get(0) : ""); scenarioName += firstParam.trim().length() > 0 ? firstParam : ""; scenario.setName(scenarioName); //then the outline scenario steps for (StepToken step : outlineScenario.getSteps()) { String action = step.getAction(); for (int i = 0; i < placeholders.size(); i++) { String placeholder = placeholders.get(i); String value = values.get(i); value = RegexpUtils.escapeRegexReplacement(value); action = action.replaceAll("<" + placeholder + ">", value); } addStepToScenario(scenario, createStepToken(step.getType(), action), stepMacros); } //add the filter tags scenario.addTags(currentFeaturesTags); scenario.addTags(currentScenariosTags); scenario.addTags(outlineVariableTags); return scenario; }
private void addChildSteps(StepToken parentToken, Matcher macroMatcher, List<StepMacro> macros, int depth) { for (StepToken s : steps) { String action = s.getAction(); String type = s.getType(); action = replaceVariablesInMacroStep(macroMatcher, action); action = replaceGroupsInMacroStep(macroMatcher, action); //having replaced any capture groups, create the child step StepToken childToken = StepToken.createStep(type, action); //match the new child step against the list of StepMacros recursively boolean alreadyMatched = false; for ( StepMacro stepMacro : macros) { alreadyMatched = stepMacro.doProcessStep(childToken, macros, depth + 1, alreadyMatched); } parentToken.addChildStep(childToken); } }
@Override public StepTokenBean marshal(StepToken v) throws Exception { StepTokenBean toRet = new StepTokenBean(); toRet.setTokenId(v.getTokenId()); toRet.setType(v.getType()); toRet.setAction(v.getAction()); toRet.setEndState(v.getEndState()); toRet.setMessage(v.getMessage()); //we don't want to add an error details attribute unless there's a real value if ( ! "".equals(v.getErrorDetails().trim())) { toRet.setErrorDetails(v.getErrorDetails()); } if (v.getException()!=null){ toRet.setException(v.getException()); toRet.setStackTrace(v.getStackTrace()); } toRet.setTimeTaken(v.getTimeTaken()); toRet.setTimeTakenSeconds(FormattingUtils.getTimeTakenAsSecondsString(v.getTimeTaken())); toRet.setChildSteps(v.getChildSteps()); return toRet; }