use of com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader 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"));
}
use of com.buschmais.jqassistant.core.rule.impl.reader.CompoundRuleSetReader 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();
}
Aggregations