use of org.asciidoctor.ast.StructuralNode 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);
}
}
}
}
use of org.asciidoctor.ast.StructuralNode in project jqa-core-framework by buschmais.
the class ExecutablesTest method plantuml.
@Test
void plantuml() throws Exception {
RuleSet ruleSet = RuleSetTestHelper.readRuleSet("/executables.adoc", RuleConfiguration.DEFAULT);
Concept concept = verifyConceptExecutable(ruleSet, "test:PlantUML", SourceExecutable.class, StructuralNode.class, "plantuml");
StructuralNode abstractBlock = (StructuralNode) concept.getExecutable().getSource();
String imagesDirectoryAttribute = (String) abstractBlock.getDocument().getAttributes().get(AsciidoctorFactory.ATTRIBUTE_IMAGES_OUT_DIR);
assertThat(imagesDirectoryAttribute, notNullValue());
File imagesOutDir = new File(imagesDirectoryAttribute);
assertThat(imagesOutDir.exists(), equalTo(true));
String fileName = (String) abstractBlock.getAttributes().get("target");
assertThat(fileName, notNullValue());
File diagramFile = new File(imagesOutDir, fileName);
assertThat("Expected file " + diagramFile + " does not exist.", diagramFile.exists(), equalTo(true));
String diagramMetadata = new MetadataTag(diagramFile, "plantuml").getData();
assertThat(diagramMetadata, containsString("@startuml"));
assertThat(diagramMetadata, containsString("@enduml"));
}
use of org.asciidoctor.ast.StructuralNode in project jqa-core-framework by buschmais.
the class DocumentParser method parse.
private void parse(Collection<?> blocks, Map<String, StructuralNode> conceptBlocks, Map<String, StructuralNode> constraintBlocks, Map<String, StructuralNode> groupBlocks) {
if (blocks != null) {
for (Object element : blocks) {
if (element instanceof StructuralNode && !(element instanceof DescriptionListEntry)) {
StructuralNode block = (StructuralNode) element;
String role = block.getRole();
if (role != null) {
String id = (String) block.getAttribute(ID);
if (ROLE_CONCEPT.equalsIgnoreCase(role)) {
conceptBlocks.put(id, block);
} else if (ROLE_CONSTRAINT.equalsIgnoreCase(role)) {
constraintBlocks.put(id, block);
} else if (ROLE_GROUP.equalsIgnoreCase(role)) {
groupBlocks.put(id, block);
}
}
parse(block.getBlocks(), conceptBlocks, constraintBlocks, groupBlocks);
} else if (element instanceof Collection<?>) {
parse((Collection<?>) element);
}
}
}
}
Aggregations