Skip to content

Commit afb90be

Browse files
Copilottomasbjerre
andcommitted
test: add test for SrcDir combined with sourcepath when exactly one SrcDir exists
Co-authored-by: tomasbjerre <439571+tomasbjerre@users.noreply.github.com>
1 parent 9d446d8 commit afb90be

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

violations-lib/src/test/java/se/bjurr/violations/lib/FindbugsTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,23 @@ public void testThatViolationsCanBeParsedFromSpotbugs() {
117117
.isEqualTo("20");
118118
}
119119

120+
@Test
121+
public void testThatSrcDirIsCombinedWithSourcepathWhenExactlyOneSrcDir() {
122+
final String rootFolder = getRootFolder();
123+
final Set<Violation> actual =
124+
violationsApi() //
125+
.withPattern(".*/findbugs/spotbugs-one-srcdir\\.xml$") //
126+
.inFolder(rootFolder) //
127+
.findAll(FINDBUGS) //
128+
.violations();
129+
130+
assertThat(actual) //
131+
.hasSize(1);
132+
final Violation violation0 = new ArrayList<>(actual).get(0);
133+
assertThat(violation0.getFile()) //
134+
.isEqualTo("/builds/my-project/module-a/src/main/java/com/example/Foo.java");
135+
}
136+
120137
@Test
121138
public void testThatViolationsCanBeParsedFromSpotbugs2() {
122139
final String rootFolder = getRootFolder();
@@ -133,6 +150,4 @@ public void testThatViolationsCanBeParsedFromSpotbugs2() {
133150
assertThat(violation0.getFile()) //
134151
.isEqualTo("se/bjurr/violations/lib/reports/ReportsFinder.java");
135152
}
136-
137153
}
138-
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<BugCollection version="4.0.0" sequence="0" timestamp="1570255404454" analysisTimestamp="1570255404481" release="">
4+
<Project projectName="module-a">
5+
<SrcDir>/builds/my-project/module-a/src/main/java</SrcDir>
6+
</Project>
7+
<BugInstance type="MS_EXPOSE_REP" priority="1" rank="7" abbrev="MS" category="MALICIOUS_CODE">
8+
<Class classname="com.example.Foo">
9+
<SourceLine classname="com.example.Foo" start="1" end="50" sourcefile="Foo.java" sourcepath="com/example/Foo.java"/>
10+
</Class>
11+
<Method classname="com.example.Foo" name="getValues" signature="()[Ljava/lang/Object;" isStatic="false">
12+
<SourceLine classname="com.example.Foo" start="42" end="42" sourcefile="Foo.java" sourcepath="com/example/Foo.java"/>
13+
</Method>
14+
<SourceLine classname="com.example.Foo" start="42" end="42" sourcefile="Foo.java" sourcepath="com/example/Foo.java"/>
15+
</BugInstance>
16+
<Errors errors="0" missingClasses="0"></Errors>
17+
<FindBugsSummary timestamp="Wed, 12 Sep 2018 18:19:36 +0200" total_classes="1" referenced_classes="1" total_bugs="1" total_size="50" num_packages="1" java_version="1.8.0" vm_version="25.0" cpu_seconds="1.00" clock_seconds="1.00" peak_mbytes="100.00" alloc_mbytes="512.00" gc_seconds="0.01" priority_1="1">
18+
<PackageStats package="com.example" total_bugs="1" total_types="1" total_size="50">
19+
<ClassStats class="com.example.Foo" sourceFile="Foo.java" interface="false" size="50" bugs="1"/>
20+
</PackageStats>
21+
</FindBugsSummary>
22+
<ClassFeatures></ClassFeatures>
23+
<History></History>
24+
</BugCollection>

0 commit comments

Comments
 (0)