From 665aa8751ae7b55b0a9e931bd9e921d4c27bf9f6 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Tue, 28 Nov 2023 08:52:51 +0100 Subject: [PATCH] test(requirements): Add a test for core plugins to be found Signed-off-by: Sebastian Schuberth --- .../src/funTest/kotlin/RequirementsCommandFunTest.kt | 9 +++++++++ .../requirements/src/main/kotlin/RequirementsCommand.kt | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/commands/requirements/src/funTest/kotlin/RequirementsCommandFunTest.kt b/plugins/commands/requirements/src/funTest/kotlin/RequirementsCommandFunTest.kt index b20e9d5cd718b..3d3ded18a3e36 100644 --- a/plugins/commands/requirements/src/funTest/kotlin/RequirementsCommandFunTest.kt +++ b/plugins/commands/requirements/src/funTest/kotlin/RequirementsCommandFunTest.kt @@ -22,6 +22,8 @@ package org.ossreviewtoolkit.plugins.commands.requirements import com.github.ajalt.clikt.testing.test import io.kotest.core.spec.style.StringSpec +import io.kotest.matchers.collections.beEmpty +import io.kotest.matchers.shouldNot import io.kotest.matchers.shouldNotBe class RequirementsCommandFunTest : StringSpec({ @@ -29,4 +31,11 @@ class RequirementsCommandFunTest : StringSpec({ // Status code 1 is only returned if there was an error while instantiating a class via reflection. RequirementsCommand().test().statusCode shouldNotBe 1 } + + "Core plugins are found" { + val plugins = RequirementsCommand().getPluginsByType() + + plugins.keys shouldNot beEmpty() + plugins.values.flatten() shouldNot beEmpty() + } }) diff --git a/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt b/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt index 32115848467f2..d59316077444d 100644 --- a/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt +++ b/plugins/commands/requirements/src/main/kotlin/RequirementsCommand.kt @@ -112,7 +112,7 @@ class RequirementsCommand : OrtCommand( } } - private fun getPluginsByType(): Map> { + internal fun getPluginsByType(): Map> { val pluginClasses = reflections.getSubTypesOf(Plugin::class.java) val pluginTypes = pluginClasses.mapNotNull { clazz ->