use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class StatisticalRuleTest method testSingleDatapoint.
// Test Single Datapoint
@Test
public void testSingleDatapoint() {
StatisticalRule rule = new MockStatisticalRule();
DataPoint point = new DataPoint();
point.setScore(POINTS + 1.0);
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(POINTS + 1);
s.testingOnlySetBeginColumn(1);
point.setNode(s);
point.setMessage("SingleDataPoint");
rule.setProperty(MINIMUM_DESCRIPTOR, (double) POINTS);
rule.addDataPoint(point);
Report report = makeReport(rule);
assertEquals("Expecting only one result", 1, report.size());
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class CodeClimateRendererTest method testXPathRule.
@Test
public void testXPathRule() throws Exception {
DummyNode node = createNode(1);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(getSourceCodeFilename());
Report report = new Report();
XPathRule theRule = new XPathRule();
theRule.setProperty(XPathRule.XPATH_DESCRIPTOR, "//dummyNode");
// Setup as FooRule
theRule.setDescription("desc");
theRule.setName("Foo");
report.addRuleViolation(new ParametricRuleViolation<Node>(theRule, ctx, node, "blah"));
String rendered = ReportTest.render(getRenderer(), report);
// Output should be the exact same as for non xpath rules
assertEquals(filter(getExpected()), filter(rendered));
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class AbstractRendererTst method newRuleViolation.
private RuleViolation newRuleViolation(int endColumn) {
DummyNode node = createNode(endColumn);
RuleContext ctx = new RuleContext();
ctx.setSourceCodeFilename(getSourceCodeFilename());
return new ParametricRuleViolation<Node>(new FooRule(), ctx, node, "blah");
}
use of net.sourceforge.pmd.lang.ast.DummyNode in project pmd by pmd.
the class StatisticalRuleTest method setUp.
@Before
public void setUp() {
ruleUnderTest = new MockStatisticalRule();
if (testName.endsWith("0")) {
for (int i = 0; i < POINTS; i++) {
points[i] = new DataPoint();
points[i].setScore(1.0 * i);
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(i);
s.testingOnlySetBeginColumn(1);
points[i].setNode(s);
points[i].setMessage("DataPoint[" + Integer.toString(i) + "]");
ruleUnderTest.addDataPoint(points[i]);
}
} else if (testName.endsWith("1")) {
for (int i = POINTS - 1; i >= 0; i--) {
points[i] = new DataPoint();
points[i].setScore(1.0 * i);
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(i);
s.testingOnlySetBeginColumn(1);
points[i].setNode(s);
points[i].setMessage("DataPoint[" + Integer.toString(i) + "]");
ruleUnderTest.addDataPoint(points[i]);
}
} else {
List<DataPoint> lPoints = new ArrayList<>();
for (int i = 0; i < POINTS; i++) {
points[i] = new DataPoint();
points[i].setScore(1.0 * i);
DummyNode s = new DummyNode(1);
s.testingOnlySetBeginLine(i);
s.testingOnlySetBeginColumn(1);
s.testingOnlySetBeginColumn(1);
points[i].setNode(s);
points[i].setMessage("DataPoint[" + Integer.toString(i) + "]");
lPoints.add(points[i]);
}
Collections.shuffle(lPoints);
for (int i = 0; i < POINTS; i++) {
ruleUnderTest.addDataPoint(lPoints.get(i));
}
}
}
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) {
DummyNode s = new DummyNode(2);
DummyNode parent = new DummyNode(1);
parent.testingOnlySetBeginLine(line);
parent.testingOnlySetBeginColumn(column);
s.jjtSetParent(parent);
s.testingOnlySetBeginLine(10);
s.testingOnlySetBeginColumn(5);
return s;
}
Aggregations