@@ -28,23 +28,23 @@ import io.kotest.matchers.should
2828import io.kotest.matchers.shouldBe
2929import io.kotest.matchers.string.shouldStartWith
3030
31- import java.io.File
3231import java.time.Instant
3332
3433import org.ossreviewtoolkit.model.Issue
3534import org.ossreviewtoolkit.model.LicenseFinding
3635import org.ossreviewtoolkit.model.ScanSummary
3736import org.ossreviewtoolkit.model.Severity
3837import org.ossreviewtoolkit.model.TextLocation
38+ import org.ossreviewtoolkit.utils.test.readResource
3939import org.ossreviewtoolkit.utils.test.transformingCollectionMatcher
4040
4141class ScanCodeResultParserTest : FreeSpec ({
4242 " generateSummary()" - {
4343 " for ScanCode 32.0.8 should" - {
4444 " get license mappings even without '--license-references'" {
45- val resultFile = getAssetFile(" scancode-32.0.8_spdx-expression-parse_no-license-references.json")
45+ val result = readResource("/ scancode-32.0.8_spdx-expression-parse_no-license-references.json")
4646
47- val summary = parseResult(resultFile ).toScanSummary()
47+ val summary = parseResult(result ).toScanSummary()
4848
4949 with(summary.licenseFindings) {
5050 shouldHaveSize(18)
@@ -54,9 +54,9 @@ class ScanCodeResultParserTest : FreeSpec({
5454 }
5555
5656 " get file-level findings with the 'preferFileLicense' option" {
57- val resultFile = getAssetFile(" scancode-32.0.8_spdx-expression-parse_no-license-references.json")
57+ val result = readResource("/ scancode-32.0.8_spdx-expression-parse_no-license-references.json")
5858
59- val summary = parseResult(resultFile ).toScanSummary(preferFileLicense = true)
59+ val summary = parseResult(result ).toScanSummary(preferFileLicense = true)
6060
6161 summary.licenseFindings.map { it.license.toString() } should containExactlyInAnyOrder(
6262 "LicenseRef -scancode-generic-cla AND MIT ",
@@ -70,9 +70,9 @@ class ScanCodeResultParserTest : FreeSpec({
7070
7171 " for ScanCode 32.1.0 should" - {
7272 " contain findings that stem from referenced files" {
73- val resultFile = getAssetFile(" scancode-32.1.0_from_file-reference.json")
73+ val result = readResource("/ scancode-32.1.0_from_file-reference.json")
7474
75- val summary = parseResult(resultFile ).toScanSummary()
75+ val summary = parseResult(result ).toScanSummary()
7676
7777 summary.licenseFindings should containExactlyInAnyOrder(
7878 LicenseFinding (
@@ -150,7 +150,7 @@ class ScanCodeResultParserTest : FreeSpec({
150150 }
151151
152152 for (version in 1..MAX_SUPPORTED_OUTPUT_FORMAT_MAJOR_VERSION ) {
153- val resultFile = getAssetFile(" scancode-output-format-$version.0.0_mime-types-2.1.18.json")
153+ val resultFile = readResource("/ scancode-output-format-$version.0.0_mime-types-2.1.18.json")
154154 val summary = parseResult(resultFile).toScanSummary()
155155
156156 " for output format $version .0.0 should" - {
@@ -255,5 +255,3 @@ private fun containCopyrightsExactly(vararg copyrights: Pair<String, List<TextLo
255255 summary.copyrightFindings.groupBy { it.statement }.entries
256256 .map { (key, value) -> key to value.map { it.location } }
257257 }
258-
259- private fun getAssetFile (path : String ): File = File (" src/test/assets" , path).absoluteFile
0 commit comments