@@ -26,6 +26,7 @@ import io.kotest.matchers.collections.containExactly
2626import io.kotest.matchers.collections.containExactlyInAnyOrder
2727import io.kotest.matchers.collections.haveSize
2828import io.kotest.matchers.collections.shouldContain
29+ import io.kotest.matchers.collections.shouldContainExactly
2930import io.kotest.matchers.collections.shouldHaveSingleElement
3031import io.kotest.matchers.collections.shouldNotContain
3132import io.kotest.matchers.should
@@ -46,9 +47,44 @@ import org.ossreviewtoolkit.model.config.RepositoryConfiguration
4647import org.ossreviewtoolkit.model.config.Resolutions
4748import org.ossreviewtoolkit.model.config.RuleViolationResolution
4849import org.ossreviewtoolkit.model.config.RuleViolationResolutionReason
50+ import org.ossreviewtoolkit.utils.ort.ProcessedDeclaredLicense
51+ import org.ossreviewtoolkit.utils.spdx.toSpdx
4952import org.ossreviewtoolkit.utils.test.readOrtResult
5053
5154class OrtResultTest : WordSpec ({
55+ " applyPackageCurations()" should {
56+ " apply a single package curation with a declared license mapping" {
57+ val licenseUrl = " https://www.nuget.org/packages/CommandLineParser/2.9.1/license"
58+
59+ val pkg = Package .EMPTY .copy(
60+ declaredLicenses = setOf(licenseUrl)
61+ )
62+
63+ val curation = PackageCuration (
64+ id = pkg.id,
65+ data = PackageCurationData (
66+ declaredLicenseMapping = mapOf(
67+ licenseUrl to "MIT ".toSpdx()
68+ )
69+ )
70+ )
71+
72+ applyPackageCurations(setOf(pkg), listOf(curation)).shouldContainExactly(
73+ CuratedPackage (
74+ metadata = Package .EMPTY .copy(
75+ declaredLicenses = setOf(licenseUrl),
76+ declaredLicensesProcessed = ProcessedDeclaredLicense (
77+ spdxExpression = "MIT ".toSpdx(),
78+ mapped = mapOf(licenseUrl to "MIT ".toSpdx()),
79+ unmapped = emptySet()
80+ )
81+ ),
82+ curations = listOf(curation.data)
83+ )
84+ )
85+ }
86+ }
87+
5288 " getDependencies()" should {
5389 " be able to get all direct dependencies of a package" {
5490 val ortResult = readOrtResult("/sbt-multi-project-example-expected-output.yml")
0 commit comments