use of net.sourceforge.pmd.lang.rule.MockRule in project pmd by pmd.
the class RuleSetTest method testAddRuleSetByReferenceSingleRule.
@Test
public void testAddRuleSetByReferenceSingleRule() {
RuleSet set2 = createRuleSetBuilder("ruleset2").withFileName("foo").addRule(new MockRule("name", "desc", "msg", "rulesetname")).addRule(new MockRule("name2", "desc", "msg", "rulesetname")).build();
RuleSet set1 = createRuleSetBuilder("ruleset1").addRuleSetByReference(set2, false).build();
assertEquals("wrong rule size", 2, set1.getRules().size());
for (Rule rule : set1.getRules()) {
assertTrue("not a rule reference", rule instanceof RuleReference);
RuleReference ruleReference = (RuleReference) rule;
assertEquals("wrong ruleset file name", "foo", ruleReference.getRuleSetReference().getRuleSetFileName());
assertFalse("should not be all rule reference", ruleReference.getRuleSetReference().isAllRules());
}
}
use of net.sourceforge.pmd.lang.rule.MockRule in project pmd by pmd.
the class RuleSetTest method testAddRuleSetByReferenceBad.
@Test(expected = RuntimeException.class)
public void testAddRuleSetByReferenceBad() {
RuleSet set1 = createRuleSetBuilder("ruleset1").addRule(new MockRule("name", "desc", "msg", "rulesetname")).build();
createRuleSetBuilder("ruleset2").addRule(new MockRule("name2", "desc", "msg", "rulesetname")).addRuleSetByReference(set1, false).build();
}
use of net.sourceforge.pmd.lang.rule.MockRule in project pmd by pmd.
the class RuleSetTest method testAddRuleSet.
@Test
public void testAddRuleSet() {
RuleSet set1 = createRuleSetBuilder("ruleset1").addRule(new MockRule("name", "desc", "msg", "rulesetname")).build();
RuleSet set2 = createRuleSetBuilder("ruleset2").addRule(new MockRule("name2", "desc", "msg", "rulesetname")).addRuleSet(set1).build();
assertEquals("ruleset size wrong", 2, set2.size());
}
use of net.sourceforge.pmd.lang.rule.MockRule in project pmd by pmd.
the class RuleSetTest method testGetRuleByName.
@Test
public void testGetRuleByName() {
MockRule mock = new MockRule("name", "desc", "msg", "rulesetname");
RuleSet rs = new RuleSetFactory().createSingleRuleRuleSet(mock);
assertEquals("unable to fetch rule by name", mock, rs.getRuleByName("name"));
}
use of net.sourceforge.pmd.lang.rule.MockRule in project pmd by pmd.
the class RuleSetTest method testNoDFA.
@Test
public void testNoDFA() {
MockRule mock = new MockRule("name", "desc", "msg", "rulesetname");
mock.setLanguage(LanguageRegistry.getLanguage(DummyLanguageModule.NAME));
RuleSet rs = new RuleSetFactory().createSingleRuleRuleSet(mock);
assertFalse(rs.usesDFA(LanguageRegistry.getLanguage(DummyLanguageModule.NAME)));
}
Aggregations