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 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; }
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 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())); } }
/** * Sets the feature file location based on the given file. The full file path is trimmed to only include the * featuresDirectory. E.g. /myproject/src/test/resources/features/feature1.feature will be saved as * features/feature1.feature * * @param file The feature file */ private void setFeatureFileLocation(final File file, final Location location) { featureFileLocation = normalizePathSeparator(file).concat(":" + location.getLine()); }
/** * Sets the feature file location based on the given file. The full file path is trimmed to only include the * featuresDirectory. E.g. /myproject/src/test/resources/features/feature1.feature will be saved as * features/feature1.feature * * @param file The feature file */ private void setFeatureFileLocation(final File file, final Location location) { featureFileLocation = normalizePathSeparator(file).concat(":" + location.getLine()); }
private void addRow(Map<Integer, Map<String, String>> exampleRows, List<String> headers, TableRow currentTableRow) { Map<String, String> row = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { List<String> cells = currentTableRow.getCells().stream().map(TableCell::getValue).collect(Collectors.toList()); row.put(headers.get(j), cells.get(j)); } exampleRows().put(currentTableRow.getLocation().getLine(), row); }
private boolean tableRowIsNotExcludedByLinesFilter(TableRow tableRow) { if (lineFilters.isEmpty()) { return true; } if (!lineFilters.containsKey(currentFeaturePath())) { return false; } else { return lineFilters.get(currentFeaturePath()).contains((long) tableRow.getLocation().getLine()); } }
private boolean examplesAreNotExcludedByLinesFilter(Examples examples) { if (lineFilters.isEmpty()) { return true; } if (!lineFilters.containsKey(currentFeaturePath())) { return false; } else { return examples.getTableBody().stream().anyMatch( row -> lineFilters.get(currentFeaturePath()).contains((long) row.getLocation().getLine())); } }
private void processScenarioDefinition( final Map<Integer, AstNode> nodeMap, final ScenarioDefinition child, final AstNode currentParent ) { final AstNode childNode = new AstNode(child, currentParent); nodeMap.put(child.getLocation().getLine(), childNode); child.getSteps().forEach( step -> nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)) ); if (child instanceof ScenarioOutline) { processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode); } }
private void processScenarioDefinition( final Map<Integer, AstNode> nodeMap, final ScenarioDefinition child, final AstNode currentParent ) { final AstNode childNode = new AstNode(child, currentParent); nodeMap.put(child.getLocation().getLine(), childNode); child.getSteps().forEach( step -> nodeMap.put(step.getLocation().getLine(), new AstNode(step, childNode)) ); if (child instanceof ScenarioOutline) { processScenarioOutlineExamples(nodeMap, (ScenarioOutline) child, childNode); } }
private List<Parameter> getExamplesAsParameters(final ScenarioOutline scenarioOutline) { final Examples examples = scenarioOutline.getExamples().get(0); final TableRow row = examples.getTableBody().stream() .filter(example -> example.getLocation().getLine() == currentTestCase.getLine()) .findFirst().get(); return IntStream.range(0, examples.getTableHeader().getCells().size()).mapToObj(index -> { final String name = examples.getTableHeader().getCells().get(index).getValue(); final String value = row.getCells().get(index).getValue(); return new Parameter().setName(name).setValue(value); }).collect(Collectors.toList()); }
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 static Location getLocation(Token receivedToken) { return receivedToken.location.getColumn() > 1 ? receivedToken.location : new Location(receivedToken.location.getLine(), receivedToken.line.indent() + 1); } }
public String formatToken(Token token) { if (token.isEOF()) return "EOF"; return String.format("(%s:%s)%s:%s/%s/%s", toString(token.location.getLine()), toString(token.location.getColumn()), toString(token.matchedType), toString(token.matchedKeyword), toString(token.matchedText), toString(token.mathcedItems == null ? "" : StringUtils.join(SPAN_TO_STRING, ",", token.mathcedItems)) ); }
private PickleLocation pickleStepLocation(Step step) { return new PickleLocation( step.getLocation().getLine(), step.getLocation().getColumn() + (step.getKeyword() != null ? SymbolCounter.countSymbols(step.getKeyword()) : 0) ); }