use of com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin in project jqa-core-framework by buschmais.
the class RuleParser method parse.
private void parse(RuleSource source, RuleSetBuilder ruleSetBuilder) throws RuleException {
for (RuleParserPlugin ruleParserPlugin : ruleParserPlugins) {
if (ruleParserPlugin.accepts(source)) {
logger.debug("Parsing rule source with id '{}' using '{}'.", source.getId(), ruleParserPlugin);
ruleParserPlugin.parse(source, ruleSetBuilder);
return;
}
}
logger.debug("Rule source with id '{}' has not been accepted by any rule parser.", source.getId());
}
use of com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin in project jqa-core-framework by buschmais.
the class XmlRuleParserPluginTest method testReadUrlSource.
@Test
void testReadUrlSource() throws Exception {
RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance();
URL url = getClass().getResource("/test-concepts.xml");
RuleParserPlugin reader = new XmlRuleParserPlugin();
reader.initialize();
reader.configure(RuleConfiguration.builder().build());
UrlRuleSource ruleSource = new UrlRuleSource(url);
assertThat(reader.accepts(ruleSource), equalTo(true));
reader.parse(ruleSource, ruleSetBuilder);
RuleSet ruleSet = ruleSetBuilder.getRuleSet();
assertThat(ruleSet.getConceptBucket().size(), equalTo(1));
assertThat(ruleSet.getConstraintBucket().size(), equalTo(1));
assertThat(ruleSet.getConceptBucket().getIds(), contains("java:Throwable"));
assertThat(ruleSet.getConstraintBucket().getIds(), contains("example:ConstructorOfDateMustNotBeUsed"));
assertThat(ruleSet.getGroupsBucket().size(), equalTo(1));
Group group = ruleSet.getGroupsBucket().getById("default");
assertThat(group.getId(), equalTo("default"));
}
use of com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin in project jqa-core-framework by buschmais.
the class RulePluginRepositoryImpl method initialize.
@Override
public void initialize() {
for (JqassistantPlugin plugin : plugins) {
IdClassListType ruleParsers = plugin.getRuleParser();
if (ruleParsers != null) {
for (IdClassType pluginType : ruleParsers.getClazz()) {
RuleParserPlugin ruleParserPlugin = createInstance(pluginType.getValue());
try {
ruleParserPlugin.initialize();
} catch (RuleException e) {
throw new PluginRepositoryException("Cannot initialize plugin " + ruleParserPlugin, e);
}
ruleParserPlugins.add(ruleParserPlugin);
}
}
}
}
use of com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin in project jqa-core-framework by buschmais.
the class RuleSetTestHelper method getDefaultRuleParserPlugins.
public static List<RuleParserPlugin> getDefaultRuleParserPlugins(RuleConfiguration ruleConfiguration) throws RuleException {
List<RuleParserPlugin> ruleParserPlugins = asList(new AsciidocRuleParserPlugin(), new XmlRuleParserPlugin(), new YamlRuleParserPlugin());
for (RuleParserPlugin ruleParserPlugin : ruleParserPlugins) {
ruleParserPlugin.initialize();
ruleParserPlugin.configure(ruleConfiguration);
}
return ruleParserPlugins;
}
Aggregations