Search in sources :

Example 1 with RuleSetReader

use of com.buschmais.jqassistant.core.rule.api.reader.RuleSetReader 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 RuleSetReader

use of com.buschmais.jqassistant.core.rule.api.reader.RuleSetReader in project jqa-core-framework by buschmais.

the class CompoundRuleSetReaderTest method testReadCompoundSources.

@Test
public void testReadCompoundSources() throws Exception {
    File adocFile = ClasspathResource.getFile("/junit-without-assert.adoc");
    File xmlFile = ClasspathResource.getFile("/test-concepts.xml");
    RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance();
    RuleSetReader reader = new CompoundRuleSetReader(RuleConfiguration.builder().build());
    reader.read(asList(new FileRuleSource(adocFile), new FileRuleSource(xmlFile)), ruleSetBuilder);
    RuleSet ruleSet = ruleSetBuilder.getRuleSet();
    assertThat(ruleSet.getConceptBucket().size(), equalTo(3));
    assertThat(ruleSet.getConstraintBucket().size(), equalTo(2));
    assertThat(ruleSet.getConceptBucket().getIds(), containsInAnyOrder("junit4:TestClassOrMethod", "junit4:AssertMethod", "java:Throwable"));
    assertThat(ruleSet.getConstraintBucket().getIds(), containsInAnyOrder("junit4:TestMethodWithoutAssertion", "example:ConstructorOfDateMustNotBeUsed"));
    assertThat(ruleSet.getGroupsBucket().size(), equalTo(1));
    Group group = ruleSet.getGroupsBucket().getById("default");
    assertThat(group.getId(), equalTo("default"));
    assertThat(group.getConcepts(), aMapWithSize(1));
    assertThat(group.getConcepts(), hasKey("java:Throwable"));
    assertThat(group.getConstraints().size(), equalTo(1));
    assertThat(group.getConstraints(), hasKey("example:ConstructorOfDateMustNotBeUsed"));
}
Also used : FileRuleSource(com.buschmais.jqassistant.core.rule.api.source.FileRuleSource) 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) File(java.io.File) CompoundRuleSetReader(com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader) Test(org.junit.Test)

Aggregations

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