private StepNode processScenarioDefinition(Map<Integer, StepNode> stepMap, StepNode initialPreviousNode, ScenarioDefinition child) { StepNode previousNode = initialPreviousNode; for (Step step : child.getSteps()) { StepNode stepNode = new StepNode(step, previousNode); stepMap.put(step.getLocation().getLine(), stepNode); previousNode = stepNode; } return previousNode; }
@Override public Token read() { try { String line = reader.readLine(); Location location = new Location(++lineNumber, 0); return line == null ? new Token(null, location) : new Token(new GherkinLine(line), location); } catch (IOException e) { throw new RuntimeException(e); } } }
protected void setTokenMatched(Token token, TokenType matchedType, String text, String keyword, Integer indent, List<GherkinLineSpan> items) { token.matchedType = matchedType; token.matchedKeyword = keyword; token.matchedText = text; token.mathcedItems = items; token.matchedGherkinDialect = getCurrentDialect(); token.matchedIndent = indent != null ? indent : (token.line == null ? 0 : token.line.indent()); token.location = new Location(token.location.getLine(), token.matchedIndent + 1); }
private Location findLocationByIndex(Pickle pickle, int locationIndex) { return new Location(pickle.getLocations().get(locationIndex).getLine(), pickle.getLocations().get(locationIndex).getColumn()); }
private void processScenarioDefinition(Map<Integer, AstNode> nodeMap, ScenarioDefinition child, AstNode currentParent) { AstNode childNode = new AstNode(child, currentParent); nodeMap.put(child.getLocation().getLine(), childNode); for (Step step : child.getSteps()) { nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)); } if (child instanceof ScenarioOutline) { processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode); } }
private Location findLocationByIndex(Pickle pickle, int locationIndex) { return new Location(pickle.getLocations().get(locationIndex).getLine(), pickle.getLocations().get(locationIndex).getColumn()); }
private Map<String, Object> createBackground(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testCase.getLine()); if (astNode != null) { Background background = TestSourcesModel.getBackgroundForTestCase(astNode); Map<String, Object> testCaseMap = new HashMap<String, Object>(); testCaseMap.put("name", background.getName()); testCaseMap.put("line", background.getLocation().getLine()); testCaseMap.put("type", "background"); testCaseMap.put("keyword", background.getKeyword()); testCaseMap.put("description", background.getDescription() != null ? background.getDescription() : ""); testCaseMap.put("steps", new ArrayList<Map<String, Object>>()); return testCaseMap; } return null; }
private Map<String, Object> createFeatureMap(TestCase testCase) { Map<String, Object> featureMap = new HashMap<String, Object>(); featureMap.put("uri", testCase.getUri()); featureMap.put("elements", new ArrayList<Map<String, Object>>()); Feature feature = testSources.getFeature(testCase.getUri()); if (feature != null) { featureMap.put("keyword", feature.getKeyword()); featureMap.put("name", feature.getName()); featureMap.put("description", feature.getDescription() != null ? feature.getDescription() : ""); featureMap.put("line", feature.getLocation().getLine()); featureMap.put("id", TestSourcesModel.convertToId(feature.getName())); featureMap.put("tags", feature.getTags()); } return featureMap; }
private Map<String, String> parametersMap(TableRow header, TableRow row) { List<TableCell> headerCells = header.getCells(); List<TableCell> rowCells = row.getCells(); if (headerCells.size() == rowCells.size()) { Map<String, String> parameters = new LinkedHashMap<>(); for (int i = 0; i < headerCells.size(); i++) { TableCell headerCell = headerCells.get(i); TableCell rowCell = rowCells.get(i); parameters.put(headerCell.getValue(), rowCell.getValue()); } return parameters; } else { throw new InvalidExampleException(header.getLocation().getLine(), header.getLocation().getColumn()); } }
private void processScenarioOutlineExamples(Map<Integer, AstNode> nodeMap, ScenarioOutline scenarioOutline, AstNode childNode) { for (Examples examples : scenarioOutline.getExamples()) { AstNode examplesNode = new AstNode(examples, childNode); TableRow headerRow = examples.getTableHeader(); AstNode headerNode = new AstNode(headerRow, examplesNode); nodeMap.put(headerRow.getLocation().getLine(), headerNode); for (int i = 0; i < examples.getTableBody().size(); ++i) { TableRow examplesRow = examples.getTableBody().get(i); Node rowNode = new ExamplesRowWrapperNode(examplesRow, i); AstNode expandedScenarioNode = new AstNode(rowNode, examplesNode); nodeMap.put(examplesRow.getLocation().getLine(), expandedScenarioNode); } } }
private void printBackground(TestCase testCase) { TestSourcesModel.AstNode astNode = testSources.getAstNode(currentFeatureFile, testCase.getLine()); if (astNode != null) { Background background = TestSourcesModel.getBackgroundForTestCase(astNode); String backgroundText = getScenarioDefinitionText(background); boolean useBackgroundSteps = true; calculateLocationIndentation(SCENARIO_INDENT + backgroundText, testCase.getTestSteps(), useBackgroundSteps); String locationPadding = createPaddingToLocation(SCENARIO_INDENT, backgroundText); out.println(); out.println(SCENARIO_INDENT + backgroundText + locationPadding + getLocationText(currentFeatureFile, background.getLocation().getLine())); printDescription(background.getDescription()); } }
private void printScenarioOutline(ScenarioOutline scenarioOutline) { out.println(); printTags(scenarioOutline.getTags(), SCENARIO_INDENT); out.println(SCENARIO_INDENT + getScenarioDefinitionText(scenarioOutline) + " " + getLocationText(currentFeatureFile, scenarioOutline.getLocation().getLine())); printDescription(scenarioOutline.getDescription()); for (Step step : scenarioOutline.getSteps()) { out.println(STEP_INDENT + formats.get("skipped").text(step.getKeyword() + step.getText())); } }