@@ -23,6 +23,7 @@ import io.kotest.assertions.throwables.shouldThrow
23
23
import io.kotest.core.spec.style.WordSpec
24
24
import io.kotest.matchers.collections.beEmpty
25
25
import io.kotest.matchers.collections.containExactly
26
+ import io.kotest.matchers.collections.containExactlyInAnyOrder
26
27
import io.kotest.matchers.collections.shouldHaveSize
27
28
import io.kotest.matchers.maps.beEmpty as beEmptyMap
28
29
import io.kotest.matchers.maps.containExactly
@@ -44,6 +45,7 @@ import java.io.IOException
44
45
45
46
import org.ossreviewtoolkit.downloader.DownloadException
46
47
import org.ossreviewtoolkit.model.ArtifactProvenance
48
+ import org.ossreviewtoolkit.model.FileList
47
49
import org.ossreviewtoolkit.model.Hash
48
50
import org.ossreviewtoolkit.model.HashAlgorithm
49
51
import org.ossreviewtoolkit.model.Identifier
@@ -52,11 +54,13 @@ import org.ossreviewtoolkit.model.LicenseFinding
52
54
import org.ossreviewtoolkit.model.Package
53
55
import org.ossreviewtoolkit.model.PackageType
54
56
import org.ossreviewtoolkit.model.Provenance
57
+ import org.ossreviewtoolkit.model.ProvenanceResolutionResult
55
58
import org.ossreviewtoolkit.model.RemoteArtifact
56
59
import org.ossreviewtoolkit.model.RepositoryProvenance
57
60
import org.ossreviewtoolkit.model.ScanResult
58
61
import org.ossreviewtoolkit.model.ScanSummary
59
62
import org.ossreviewtoolkit.model.ScannerDetails
63
+ import org.ossreviewtoolkit.model.ScannerRun
60
64
import org.ossreviewtoolkit.model.SourceCodeOrigin
61
65
import org.ossreviewtoolkit.model.TextLocation
62
66
import org.ossreviewtoolkit.model.UnknownProvenance
@@ -73,6 +77,7 @@ import org.ossreviewtoolkit.scanner.provenance.NestedProvenanceScanResult
73
77
import org.ossreviewtoolkit.scanner.provenance.PackageProvenanceResolver
74
78
import org.ossreviewtoolkit.scanner.provenance.ProvenanceDownloader
75
79
import org.ossreviewtoolkit.utils.ort.createOrtTempDir
80
+ import org.ossreviewtoolkit.utils.spdx.SpdxConstants
76
81
77
82
@Suppress(" LargeClass" )
78
83
class ScannerTest : WordSpec ({
@@ -987,6 +992,57 @@ class ScannerTest : WordSpec({
987
992
}
988
993
}
989
994
995
+ " ScannerRun.padNoneLicenseFindings()" should {
996
+ " add NONE license findings for files without findings" {
997
+ val provenance = RepositoryProvenance (
998
+ VcsInfo (type = VcsType .GIT , url = "https://github.com/example.git", revision = "revision"),
999
+ "revision"
1000
+ )
1001
+
1002
+ val run = ScannerRun .EMPTY .copy(
1003
+ provenances = setOf(
1004
+ ProvenanceResolutionResult (
1005
+ id = Identifier ("maven::example:1.0"),
1006
+ packageProvenance = provenance
1007
+ )
1008
+ ),
1009
+ scanResults = setOf(
1010
+ ScanResult (
1011
+ provenance = provenance,
1012
+ scanner = ScannerDetails .EMPTY ,
1013
+ summary = ScanSummary .EMPTY .copy(
1014
+ licenseFindings = setOf(
1015
+ LicenseFinding ("MIT ", TextLocation ("file1.txt", 1, 1))
1016
+ )
1017
+ )
1018
+ )
1019
+ ),
1020
+ files = setOf(
1021
+ FileList (
1022
+ provenance = provenance,
1023
+ files = setOf(
1024
+ FileList .Entry (
1025
+ path = "file1.txt",
1026
+ sha1 = "1111111111111111111111111111111111111111"
1027
+ ),
1028
+ FileList .Entry (
1029
+ path = "file2.txt",
1030
+ sha1 = "2222222222222222222222222222222222222222"
1031
+ )
1032
+ )
1033
+ )
1034
+ )
1035
+ )
1036
+
1037
+ val paddedRun = run.padNoneLicenseFindings()
1038
+
1039
+ paddedRun.scanResults.single().summary.licenseFindings should containExactlyInAnyOrder(
1040
+ LicenseFinding ("MIT ", TextLocation ("file1.txt", 1, 1)),
1041
+ LicenseFinding (SpdxConstants .NONE , TextLocation ("file2.txt", TextLocation .UNKNOWN_LINE ))
1042
+ )
1043
+ }
1044
+ }
1045
+
990
1046
// TODO: Add tests for combinations of different types of storage readers and writers.
991
1047
// TODO: Add tests for using multiple types of scanner wrappers at once.
992
1048
// TODO: Add tests for a complex example with multiple types of scanner wrappers and storages.
0 commit comments