use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class RuleViolationComparatorTest method createJavaRuleViolation.
private RuleViolation createJavaRuleViolation(Rule rule, String fileName, int beginLine, String description, int beginColumn, int endLine, int endColumn) {
RuleContext ruleContext = new RuleContext();
ruleContext.setSourceCodeFilename(fileName);
DummyNode simpleNode = new DummyNode(1);
simpleNode.testingOnlySetBeginLine(beginLine);
simpleNode.testingOnlySetBeginColumn(beginColumn);
simpleNode.testingOnlySetEndLine(endLine);
simpleNode.testingOnlySetEndColumn(endColumn);
RuleViolation ruleViolation = new ParametricRuleViolation<Node>(rule, ruleContext, simpleNode, description);
return ruleViolation;
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AttributeAxisIteratorTest method testRemove.
@Test(expected = UnsupportedOperationException.class)
public void testRemove() {
DummyNode n = new DummyNode(0);
n.testingOnlySetBeginColumn(1);
n.testingOnlySetBeginLine(1);
AttributeAxisIterator iter = new AttributeAxisIterator(n);
iter.remove();
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class RuleViolationTest method testComparatorWithDifferentFilenames.
@Test
public void testComparatorWithDifferentFilenames() {
Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
RuleViolationComparator comp = RuleViolationComparator.INSTANCE;
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("filename1");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(10);
s.testingOnlySetBeginColumn(1);
RuleViolation r1 = new ParametricRuleViolation<Node>(rule, ctx, s, "description");
ctx.setSourceCodeFilename("filename2");
DummyNode s1 = new DummyNode(1);
s1.testingOnlySetBeginLine(10);
s1.testingOnlySetBeginColumn(1);
RuleViolation r2 = new ParametricRuleViolation<Node>(rule, ctx, s1, "description");
assertEquals(-1, comp.compare(r1, r2));
assertEquals(1, comp.compare(r2, r1));
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class RuleViolationTest method testConstructor1.
@Test
public void testConstructor1() {
Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("filename");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(2);
s.testingOnlySetBeginColumn(1);
RuleViolation r = new ParametricRuleViolation<Node>(rule, ctx, s, rule.getMessage());
assertEquals("object mismatch", rule, r.getRule());
assertEquals("line number is wrong", 2, r.getBeginLine());
assertEquals("filename is wrong", "filename", r.getFilename());
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class RuleViolationTest method testComparatorWithSameFileDifferentLines.
@Test
public void testComparatorWithSameFileDifferentLines() {
Rule rule = new MockRule("name", "desc", "msg", "rulesetname");
RuleViolationComparator comp = RuleViolationComparator.INSTANCE;
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("filename");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(10);
s.testingOnlySetBeginColumn(1);
DummyNode s1 = new DummyNode(1);
s1.testingOnlySetBeginLine(20);
s1.testingOnlySetBeginColumn(1);
RuleViolation r1 = new ParametricRuleViolation<Node>(rule, ctx, s, "description");
RuleViolation r2 = new ParametricRuleViolation<Node>(rule, ctx, s1, "description");
assertTrue(comp.compare(r1, r2) < 0);
assertTrue(comp.compare(r2, r1) > 0);
}
Aggregations