Skip to content

Commit

Permalink
Adding another PMD test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Mar 7, 2018
1 parent 83dc267 commit c36c7bd
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/test/java/se/bjurr/violations/lib/PMDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@ public void testThatViolationsCanBeParsed() {
.isEqualTo(WARN);
}

@Test
public void testThatViolationsCanBeParsedCsvDelta() {
final String rootFolder = getRootFolder();

final List<Violation> actual =
violationsApi() //
.withPattern(".*/pmd/csv-delta\\.xml$") //
.inFolder(rootFolder) //
.findAll(PMD) //
.violations();

assertThat(actual) //
.hasSize(5);

final Violation violationZero = actual.get(0);
assertThat(violationZero.getFile()) //
.isEqualTo("src/CustomTableClass.java");
assertThat(violationZero.getMessage()) //
.startsWith("Description") //
.doesNotContain("CDATA");
assertThat(violationZero.getStartLine()) //
.isEqualTo(1);
assertThat(violationZero.getEndLine()) //
.isEqualTo(1);
assertThat(violationZero.getRule().get()) //
.isEqualTo("RULE1");
assertThat(violationZero.getSeverity()) //
.isEqualTo(WARN);
}

@Test
public void testThatViolationsCanBeParsedIfNoRuleset() {
final String rootFolder = getRootFolder();
Expand Down
23 changes: 23 additions & 0 deletions src/test/resources/pmd/csv-delta.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<pmd xmlns="http://pmd.sourceforge.net/report/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/report/2.0.0 http://pmd.sourceforge.net/report_2_0_0.xsd"
version="6.1.0" timestamp="2018-03-07T08:21:41.695">
<file name="src/CustomTableClass.java">
<violation beginline="1" endline="1" begincolumn="14" endcolumn="29" rule="RULE1" ruleset="Security" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_security.html#RULE1" priority="3">
Description 1
</violation>
<violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE2" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE2" priority="3">
Description 2
</violation>
<violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE3" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE3" priority="3">
Description 3
</violation>
<violation beginline="1" endline="242" begincolumn="14" endcolumn="11" rule="RULE4" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE4" priority="3">
Description 4
</violation>
<violation beginline="39" endline="39" begincolumn="17" endcolumn="18" rule="RULE5" ruleset="Design" externalInfoUrl="https://pmd.github.io/pmd-6.1.0/pmd_rules_java_design.html#RULE5" priority="3">
Description 5
</violation>
</file>
</pmd>

0 comments on commit c36c7bd

Please sign in to comment.