use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class ReportTest method getNode.
private static Node getNode(int line, int column, boolean nextLine) {
DummyNode s = (DummyNode) getNode(line, column);
if (nextLine) {
s.testingOnlySetBeginLine(line + 1);
s.testingOnlySetBeginColumn(column + 4);
}
return s;
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class RuleSetTest method makeCompilationUnits.
private List<Node> makeCompilationUnits() {
List<Node> nodes = new ArrayList<>();
DummyNode node = new DummyNode(1);
node.testingOnlySetBeginLine(1);
node.testingOnlySetBeginColumn(1);
node.setImage("Foo");
nodes.add(node);
return nodes;
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRuleTest method testRuleWithVariableInMessage.
@Test
public void testRuleWithVariableInMessage() {
MyRule r = new MyRule();
r.definePropertyDescriptor(IntegerProperty.named("testInt").desc("description").range(0, 100).defaultValue(10).uiOrder(0).build());
r.setMessage("Message ${packageName} ${className} ${methodName} ${variableName} ${testInt} ${noSuchProperty}");
RuleContext ctx = new RuleContext();
ctx.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
ctx.setReport(new Report());
ctx.setSourceCodeFilename("filename");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginColumn(5);
s.testingOnlySetBeginLine(5);
s.setImage("TestImage");
r.addViolation(ctx, s);
RuleViolation rv = ctx.getReport().getViolationTree().iterator().next();
assertEquals("Message foo 10 ${noSuchProperty}", rv.getDescription());
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRuleTest method testCreateRV.
@Test
public void testCreateRV() {
MyRule r = new MyRule();
r.setRuleSetName("foo");
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("filename");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginColumn(5);
s.testingOnlySetBeginLine(5);
RuleViolation rv = new ParametricRuleViolation(r, ctx, s, r.getMessage());
assertEquals("Line number mismatch!", 5, rv.getBeginLine());
assertEquals("Filename mismatch!", "filename", rv.getFilename());
assertEquals("Rule object mismatch!", r, rv.getRule());
assertEquals("Rule msg mismatch!", "my rule msg", rv.getDescription());
assertEquals("RuleSet name mismatch!", "foo", rv.getRule().getRuleSetName());
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRuleTest method testCreateRV2.
@Test
public void testCreateRV2() {
MyRule r = new MyRule();
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename("filename");
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginColumn(5);
s.testingOnlySetBeginLine(5);
RuleViolation rv = new ParametricRuleViolation(r, ctx, s, "specificdescription");
assertEquals("Line number mismatch!", 5, rv.getBeginLine());
assertEquals("Filename mismatch!", "filename", rv.getFilename());
assertEquals("Rule object mismatch!", r, rv.getRule());
assertEquals("Rule description mismatch!", "specificdescription", rv.getDescription());
}
Aggregations