use of com.buschmais.jqassistant.core.rule.api.source.RuleSource in project jqa-core-framework by buschmais.
the class XmlRuleSetReader method read.
@Override
public void read(List<? extends RuleSource> sources, RuleSetBuilder ruleSetBuilder) throws RuleException {
for (RuleSource ruleSource : sources) {
if (ruleSource.isType(RuleSource.Type.XML)) {
List<JqassistantRules> rules = readXmlSource(ruleSource);
convert(rules, ruleSource, ruleSetBuilder);
}
}
}
use of com.buschmais.jqassistant.core.rule.api.source.RuleSource in project jqa-core-framework by buschmais.
the class RuleSetBuilderTest method duplicateRules.
@Test
public void duplicateRules() throws RuleException {
RuleSource ruleSource = new FileRuleSource(new File("test.xml"));
// Concepts
Concept concept1 = Concept.Builder.newConcept().id("test").ruleSource(ruleSource).get();
Concept concept2 = Concept.Builder.newConcept().id("test").ruleSource(ruleSource).get();
RuleSetBuilder builder = RuleSetBuilder.newInstance();
builder.addConcept(concept1);
try {
builder.addConcept(concept2);
Assert.fail("Expecting an exception");
} catch (RuleException e) {
}
// Constraints
Constraint constraint1 = Constraint.Builder.newConstraint().id("test").ruleSource(ruleSource).get();
Constraint constraint2 = Constraint.Builder.newConstraint().id("test").ruleSource(ruleSource).get();
builder.addConstraint(constraint1);
try {
builder.addConstraint(constraint2);
Assert.fail("Expecting an exception");
} catch (RuleException e) {
}
// Groups
Group group1 = Group.Builder.newGroup().id("test").ruleSource(ruleSource).get();
Group group2 = Group.Builder.newGroup().id("test").ruleSource(ruleSource).get();
builder.addGroup(group1);
try {
builder.addGroup(group2);
Assert.fail("Expecting an exception");
} catch (RuleException e) {
}
}
use of com.buschmais.jqassistant.core.rule.api.source.RuleSource in project jqa-core-framework by buschmais.
the class RulePluginRepositoryImpl method getRuleSources.
private List<RuleSource> getRuleSources(List<JqassistantPlugin> plugins) {
List<RuleSource> sources = new ArrayList<>();
for (JqassistantPlugin plugin : plugins) {
RulesType rulesType = plugin.getRules();
if (rulesType != null) {
for (String resource : rulesType.getResource()) {
String resourceName = RULE_RESOURCE_PATH + resource;
sources.add(new ClasspathRuleSource(classLoader, resourceName));
}
}
}
return sources;
}
use of com.buschmais.jqassistant.core.rule.api.source.RuleSource 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