@Test public void parses_rules() { Parser<GherkinDocument.Builder> parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); String data = "" + "Feature: Some rules\n" + "\n" + " Background:\n" + " Given fb\n" + "\n" + " Rule: A\n" + " The rule A description\n" + "\n" + " Background:\n" + " Given ab\n" + "\n" + " Example: Example A\n" + " Given a\n" + "\n" + " Rule: B\n" + " The rule B description\n" + "\n" + " Example: Example B\n" + " Given b"; GherkinDocument doc = parser.parse(data).build(); List<FeatureChild> children = doc.getFeature().getChildrenList(); assertEquals(3, children.size()); IdGenerator idGenerator = new IdGenerator.Incrementing(); PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List<Pickle> pickles = pickleCompiler.compile(doc, "hello.feature"); assertEquals(2, pickles.size()); assertEquals(3, pickles.get(0).getStepsList().size()); assertEquals(2, pickles.get(1).getStepsList().size()); }
@Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); @Override void reset(); @Override void build(Token token); @Override void startRule(RuleType ruleType); @Override void endRule(RuleType ruleType); @Override GherkinDocument.Builder getResult(); }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); @Override void reset(); @Override void build(Token token); @Override void startRule(RuleType ruleType); @Override void endRule(RuleType ruleType); @Override GherkinDocument.Builder getResult();  }