Search in sources :

Example 1 with ListItem

use of org.asciidoctor.ast.ListItem in project drools by kiegroup.

the class ADocFEELExamplesTest method processBlock.

private void processBlock(StructuralNode block) {
    List<StructuralNode> blocks = block.getBlocks();
    for (int i = 0; i < blocks.size(); i++) {
        final StructuralNode currentBlock = blocks.get(i);
        if (currentBlock instanceof StructuralNode) {
            if (currentBlock instanceof DescriptionList) {
                DescriptionList descriptionList = (DescriptionList) currentBlock;
                for (DescriptionListEntry dle : descriptionList.getItems()) {
                    ListItem description = dle.getDescription();
                    processBlock(description);
                }
            } else if ("listing".equals(currentBlock.getContext())) {
                Block b = (Block) currentBlock;
                List<String> lines = b.getLines();
                LOG.trace("{}", lines);
                LOG.trace("{}", b.getAttributes());
                if (b.getAttribute("language", "unknown").equals("FEEL")) {
                    for (String line : lines) {
                        LOG.info("checking DOC {}", line);
                        Object FEELResult = feel.evaluate(line);
                        Assert.assertThat(line, FEELResult, Matchers.is(true));
                    }
                } else {
                    LOG.trace("This block is not FEEL true predicate snippets: {}", b);
                }
            } else {
                processBlock(currentBlock);
            }
        }
    }
}
Also used : StructuralNode(org.asciidoctor.ast.StructuralNode) DescriptionListEntry(org.asciidoctor.ast.DescriptionListEntry) DescriptionList(org.asciidoctor.ast.DescriptionList) Block(org.asciidoctor.ast.Block) DescriptionList(org.asciidoctor.ast.DescriptionList) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.asciidoctor.ast.ListItem)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Block (org.asciidoctor.ast.Block)1 DescriptionList (org.asciidoctor.ast.DescriptionList)1 DescriptionListEntry (org.asciidoctor.ast.DescriptionListEntry)1 ListItem (org.asciidoctor.ast.ListItem)1 StructuralNode (org.asciidoctor.ast.StructuralNode)1