Search in sources :

Example 11 with XPathRule

use of net.sourceforge.pmd.lang.rule.XPathRule in project pmd by pmd.

the class PLSQLXPathRuleTest method testXPathRule2.

/**
 * See https://sourceforge.net/p/pmd/bugs/1166/
 */
@Test
public void testXPathRule2() {
    XPathRule rule = createRule("2.0");
    rule.apply(Arrays.asList(node), ctx);
    Assert.assertEquals(2, ctx.getReport().treeSize());
}
Also used : XPathRule(net.sourceforge.pmd.lang.rule.XPathRule) Test(org.junit.Test)

Example 12 with XPathRule

use of net.sourceforge.pmd.lang.rule.XPathRule in project pmd by pmd.

the class PLSQLXPathRuleTest method testXPathRule1.

/**
 * See https://sourceforge.net/p/pmd/bugs/1166/
 */
@Test
public void testXPathRule1() {
    XPathRule rule = createRule("1.0");
    rule.apply(Arrays.asList(node), ctx);
    Assert.assertEquals(2, ctx.getReport().treeSize());
}
Also used : XPathRule(net.sourceforge.pmd.lang.rule.XPathRule) Test(org.junit.Test)

Example 13 with XPathRule

use of net.sourceforge.pmd.lang.rule.XPathRule in project pmd by pmd.

the class PLSQLXPathRuleTest method createRule.

private XPathRule createRule(String version) {
    XPathRule rule = new XPathRule("//PrimaryExpression");
    rule.setLanguage(LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME));
    rule.setVersion(version);
    rule.setMessage("Test Violation");
    return rule;
}
Also used : XPathRule(net.sourceforge.pmd.lang.rule.XPathRule)

Aggregations

XPathRule (net.sourceforge.pmd.lang.rule.XPathRule)13 Test (org.junit.Test)6 RuleContext (net.sourceforge.pmd.RuleContext)4 RuleSet (net.sourceforge.pmd.RuleSet)4 ArrayList (java.util.ArrayList)3 Rule (net.sourceforge.pmd.Rule)3 RuleSets (net.sourceforge.pmd.RuleSets)3 Node (net.sourceforge.pmd.lang.ast.Node)3 Report (net.sourceforge.pmd.Report)2 RuleSetFactory (net.sourceforge.pmd.RuleSetFactory)2 StringReader (java.io.StringReader)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 PMD (net.sourceforge.pmd.PMD)1 ReportTest (net.sourceforge.pmd.ReportTest)1