Search in sources :

Example 1 with XmlRuleParserPlugin

use of com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin 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"));
}
Also used : RuleParserPlugin(com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin) XmlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin) XmlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin) UrlRuleSource(com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 2 with XmlRuleParserPlugin

use of com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin 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;
}
Also used : RuleParserPlugin(com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin) YamlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.YamlRuleParserPlugin) AsciidocRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.AsciidocRuleParserPlugin) XmlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin) YamlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.YamlRuleParserPlugin) XmlRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin) AsciidocRuleParserPlugin(com.buschmais.jqassistant.core.rule.impl.reader.AsciidocRuleParserPlugin)

Aggregations

RuleParserPlugin (com.buschmais.jqassistant.core.rule.api.reader.RuleParserPlugin)2 XmlRuleParserPlugin (com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleParserPlugin)2 UrlRuleSource (com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource)1 AsciidocRuleParserPlugin (com.buschmais.jqassistant.core.rule.impl.reader.AsciidocRuleParserPlugin)1 YamlRuleParserPlugin (com.buschmais.jqassistant.core.rule.impl.reader.YamlRuleParserPlugin)1 URL (java.net.URL)1 Test (org.junit.jupiter.api.Test)1