Search in sources :

Example 1 with UrlRuleSource

use of com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource in project jqa-core-framework by buschmais.

the class CompoundRuleSetReaderTest method testReadUrlSource.

@Test
public void testReadUrlSource() throws Exception {
    RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance();
    URL url = getClass().getResource("/test-concepts.xml");
    RuleSetReader reader = new XmlRuleSetReader(RuleConfiguration.builder().build());
    reader.read(singletonList(new UrlRuleSource(url)), 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 : XmlRuleSetReader(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleSetReader) CompoundRuleSetReader(com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader) RuleSetReader(com.buschmais.jqassistant.core.rule.api.reader.RuleSetReader) XmlRuleSetReader(com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleSetReader) UrlRuleSource(com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource) URL(java.net.URL) Test(org.junit.Test)

Example 2 with UrlRuleSource

use of com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource in project jqa-core-framework by buschmais.

the class RuleSetTestHelper method readRuleSet.

public static RuleSet readRuleSet(String resource, RuleConfiguration ruleConfiguration) throws RuleException {
    RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance();
    CompoundRuleSetReader reader = new CompoundRuleSetReader(ruleConfiguration);
    URL url = RuleSetTestHelper.class.getResource(resource);
    assertThat("Cannot read resource URL:" + resource, url, notNullValue());
    RuleSource ruleSource = new UrlRuleSource(url);
    reader.read(Collections.singletonList(ruleSource), ruleSetBuilder);
    return ruleSetBuilder.getRuleSet();
}
Also used : RuleSource(com.buschmais.jqassistant.core.rule.api.source.RuleSource) UrlRuleSource(com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource) UrlRuleSource(com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource) CompoundRuleSetReader(com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader) URL(java.net.URL)

Aggregations

UrlRuleSource (com.buschmais.jqassistant.core.rule.api.source.UrlRuleSource)2 CompoundRuleSetReader (com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader)2 URL (java.net.URL)2 RuleSetReader (com.buschmais.jqassistant.core.rule.api.reader.RuleSetReader)1 RuleSource (com.buschmais.jqassistant.core.rule.api.source.RuleSource)1 XmlRuleSetReader (com.buschmais.jqassistant.core.rule.impl.reader.XmlRuleSetReader)1 Test (org.junit.Test)1