Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Mar 4, 2024
1 parent 5079d1d commit 18593cc
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation 'uk.co.jemos.podam:podam:8.0.1.RELEASE'
testImplementation 'com.approvaltests:approvaltests:22.3.3'
testImplementation 'com.approvaltests:approvaltests:22.4.0'
testImplementation 'com.networknt:json-schema-validator:1.3.3'
}
61 changes: 61 additions & 0 deletions src/test/java/se/bjurr/violations/lib/FindbugsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,65 @@ public void testThatViolationsCanBeParsedFromSpotbugs2() {
assertThat(violation0.getFile()) //
.isEqualTo("se/bjurr/violations/lib/reports/ReportsFinder.java");
}

@Test
public void testThatViolationsCanBeParsedFromSpotbugsReport() {
final String rootFolder = getRootFolder();
final Set<Violation> actual =
violationsApi() //
.withPattern(".*/findbugs/spotbugs-report\\.xml$") //
.inFolder(rootFolder) //
.findAll(FINDBUGS) //
.violations();

assertThat(actual) //
.hasSize(3);
final Violation violation0 = new ArrayList<>(actual).get(0);
assertThat(violation0.getFile()) //
.isEqualTo("removed/CurrentSupplierContactResolverImpl.java");
assertThat(violation0.getMessage()) //
.isEqualTo("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS");
assertThat(violation0.getStartLine()) //
.isEqualTo(92);
assertThat(violation0.getEndLine()) //
.isEqualTo(92);
assertThat(violation0.getRule()) //
.isEqualTo("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS");
assertThat(violation0.getSeverity()) //
.isEqualTo(INFO);
assertThat(violation0.getSource()) //
.isEqualTo("removed.CurrentSupplierContactResolverImpl");

final Violation violation1 = new ArrayList<>(actual).get(1);
assertThat(violation1.getFile()) //
.isEqualTo("removed/FacadeReadOnlyHandler.java");
assertThat(violation1.getMessage()) //
.isEqualTo("WEM_WEAK_EXCEPTION_MESSAGING");
assertThat(violation1.getStartLine()) //
.isEqualTo(255);
assertThat(violation1.getEndLine()) //
.isEqualTo(255);
assertThat(violation1.getRule()) //
.isEqualTo("WEM_WEAK_EXCEPTION_MESSAGING");
assertThat(violation1.getSeverity()) //
.isEqualTo(INFO);
assertThat(violation1.getSource()) //
.isEqualTo("removed.FacadeReadOnlyHandler");

final Violation violation2 = new ArrayList<>(actual).get(2);
assertThat(violation2.getFile()) //
.isEqualTo("removed/FacadeReadOnlyHandler.java");
assertThat(violation2.getMessage()) //
.isEqualTo("BL_BURYING_LOGIC");
assertThat(violation2.getStartLine()) //
.isEqualTo(169);
assertThat(violation2.getEndLine()) //
.isEqualTo(175);
assertThat(violation2.getRule()) //
.isEqualTo("BL_BURYING_LOGIC");
assertThat(violation2.getSeverity()) //
.isEqualTo(INFO);
assertThat(violation2.getSource()) //
.isEqualTo("removed.FacadeReadOnlyHandler");
}
}

0 comments on commit 18593cc

Please sign in to comment.