Skip to content

Commit c28f005

Browse files
committedFeb 11, 2025
test(model): Move SimpleLicenseInfoProvider to TestUtils
Enable re-use in an upcoming change. Signed-off-by: Frank Viernau <x9fviern@zeiss.com>
1 parent 8ba5d1d commit c28f005

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
 

‎model/src/test/kotlin/licenses/LicenseInfoResolverTest.kt

-7
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,6 @@ private fun createLicenseInfo(
726726
)
727727
)
728728

729-
private class SimpleLicenseInfoProvider(licenseInfo: List<LicenseInfo>) : LicenseInfoProvider {
730-
private val licenseInfoById = licenseInfo.associateBy { it.id }
731-
732-
override fun get(id: Identifier) =
733-
licenseInfoById[id] ?: throw IllegalArgumentException("No license info for '${id.toCoordinates()}' available.")
734-
}
735-
736729
private fun Map<String, List<TextLocation>>.toFindingsSet(): Set<LicenseFinding> =
737730
flatMap { (license, locations) ->
738731
locations.map { LicenseFinding(license, it) }

‎model/src/test/kotlin/licenses/TestUtils.kt

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import io.kotest.matchers.Matcher
2323
import io.kotest.matchers.collections.containExactly
2424
import io.kotest.matchers.neverNullMatcher
2525

26+
import org.ossreviewtoolkit.model.Identifier
2627
import org.ossreviewtoolkit.utils.spdx.SpdxExpression
2728
import org.ossreviewtoolkit.utils.spdx.SpdxSingleLicenseExpression
2829

@@ -33,3 +34,10 @@ fun containLicensesExactly(vararg licenses: String): Matcher<Iterable<ResolvedLi
3334

3435
containExactly(expected).test(actual)
3536
}
37+
38+
class SimpleLicenseInfoProvider(licenseInfo: List<LicenseInfo>) : LicenseInfoProvider {
39+
private val licenseInfoById = licenseInfo.associateBy { it.id }
40+
41+
override fun get(id: Identifier) =
42+
licenseInfoById[id] ?: throw IllegalArgumentException("No license info for '${id.toCoordinates()}' available.")
43+
}

0 commit comments

Comments
 (0)
Please sign in to comment.