use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRuleTest method testRuleSuppress.
@Test
public void testRuleSuppress() {
MyRule r = new MyRule();
RuleContext ctx = new RuleContext();
Map<Integer, String> m = new HashMap<>();
m.put(Integer.valueOf(5), "");
ctx.setReport(new Report());
ctx.getReport().suppress(m);
ctx.setSourceCodeFilename("filename");
DummyNode n = new DummyNode(1);
n.testingOnlySetBeginColumn(5);
n.testingOnlySetBeginLine(5);
RuleViolation rv = new ParametricRuleViolation(r, ctx, n, "specificdescription");
ctx.getReport().addRuleViolation(rv);
assertTrue(ctx.getReport().isEmpty());
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRendererTst method createNode.
protected static DummyNode createNode(int endColumn) {
DummyNode node = new DummyNode(1);
node.testingOnlySetBeginLine(1);
node.testingOnlySetBeginColumn(1);
node.testingOnlySetEndLine(1);
node.testingOnlySetEndColumn(endColumn);
return node;
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRendererTst method testRuleWithProperties.
@Test
public void testRuleWithProperties() throws Exception {
DummyNode node = createNode(1);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(getSourceCodeFilename());
Report report = new Report();
RuleWithProperties theRule = new RuleWithProperties();
theRule.setProperty(RuleWithProperties.STRING_PROPERTY_DESCRIPTOR, "the string value\nsecond line with \"quotes\"");
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
String rendered = ReportTest.render(getRenderer(), report);
assertEquals(filter(getExpectedWithProperties()), filter(rendered));
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AttributeAxisIteratorTest method testAttributeAxisIterator.
/**
* Test hasNext and next.
*/
@Test
public void testAttributeAxisIterator() {
DummyNode dummyNode = new DummyNode(1);
dummyNode.testingOnlySetBeginLine(1);
dummyNode.testingOnlySetBeginColumn(1);
AttributeAxisIterator it = new AttributeAxisIterator(dummyNode);
Map<String, Attribute> atts = new HashMap<>();
while (it.hasNext()) {
Attribute attribute = it.next();
atts.put(attribute.getName(), attribute);
}
Assert.assertEquals(7, atts.size());
Assert.assertTrue(atts.containsKey("BeginColumn"));
Assert.assertTrue(atts.containsKey("BeginLine"));
Assert.assertTrue(atts.containsKey("FindBoundary"));
Assert.assertTrue(atts.containsKey("Image"));
Assert.assertTrue(atts.containsKey("SingleLine"));
Assert.assertTrue(atts.containsKey("EndColumn"));
Assert.assertTrue(atts.containsKey("EndLine"));
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class DocumentNavigatorTest method getDocumentNode.
@Test
public void getDocumentNode() {
DocumentNavigator nav = new DocumentNavigator();
try {
nav.getDocumentNode(null);
fail();
} catch (RuntimeException e) {
assertNotNull(e);
}
Node root = new DummyRootNode(1);
Node n = new DummyNode(1);
root.jjtAddChild(n, 0);
n.jjtSetParent(root);
assertSame(root, nav.getDocumentNode(n));
}
Aggregations