diff --git a/api/v1/model/src/commonMain/kotlin/RuleViolation.kt b/api/v1/model/src/commonMain/kotlin/RuleViolation.kt index a47a57abe..37334a4e4 100644 --- a/api/v1/model/src/commonMain/kotlin/RuleViolation.kt +++ b/api/v1/model/src/commonMain/kotlin/RuleViolation.kt @@ -29,5 +29,5 @@ data class RuleViolation( val severity: Severity, val message: String, val howToFix: String, - val packageId: Identifier? + val packageId: Identifier? = null ) diff --git a/core/src/test/kotlin/api/RunsRouteIntegrationTest.kt b/core/src/test/kotlin/api/RunsRouteIntegrationTest.kt index a8385dc10..5e1e98a0b 100644 --- a/core/src/test/kotlin/api/RunsRouteIntegrationTest.kt +++ b/core/src/test/kotlin/api/RunsRouteIntegrationTest.kt @@ -1240,15 +1240,10 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ "Message-3", "How_to_fix-3" ), - // 2nd record after sort by "rule" + // 2nd record after sort by "rule", without package identifier OrtRuleViolation( "a-Rule-4", - Identifier( - "Maven", - "org.apache.test", - "adv-loggger", - "0.0.1-alpha" - ), + null, "License-4", "CONCLUDED", Severity.WARNING, @@ -1301,12 +1296,7 @@ class RunsRouteIntegrationTest : AbstractIntegrationTest({ ), OrtRuleViolation( "Rule-2-obsolete", - Identifier( - "Maven", - "com.fasterxml.jackson.core.obsolete", - "jackson-databind", - "2.9.6" - ), + null, "License-2-obsolete", "DETECTED", Severity.ERROR, diff --git a/services/hierarchy/src/main/kotlin/RuleViolationService.kt b/services/hierarchy/src/main/kotlin/RuleViolationService.kt index 7d7796495..fab27e1ea 100644 --- a/services/hierarchy/src/main/kotlin/RuleViolationService.kt +++ b/services/hierarchy/src/main/kotlin/RuleViolationService.kt @@ -47,7 +47,7 @@ class RuleViolationService(private val db: Database) { val join = RuleViolationsTable innerJoin EvaluatorRunsRuleViolationsTable innerJoin EvaluatorRunsTable innerJoin - EvaluatorJobsTable innerJoin + EvaluatorJobsTable leftJoin IdentifiersTable join.select( diff --git a/services/hierarchy/src/test/kotlin/RuleViolationServiceTest.kt b/services/hierarchy/src/test/kotlin/RuleViolationServiceTest.kt index e43a4a557..c112eeb35 100644 --- a/services/hierarchy/src/test/kotlin/RuleViolationServiceTest.kt +++ b/services/hierarchy/src/test/kotlin/RuleViolationServiceTest.kt @@ -56,7 +56,7 @@ class RuleViolationServiceTest : WordSpec() { val ortRun = createRuleViolationEntries() val results = service.listForOrtRunId(ortRun.id).data - results shouldHaveSize 2 + results shouldHaveSize 3 with(results[0]) { @@ -90,6 +90,16 @@ class RuleViolationServiceTest : WordSpec() { version shouldBe "2.9.6" } } + + with(results[2]) { + rule shouldBe "Rule-3-no-id" + license shouldBe "License-3" + licenseSource shouldBe "DETECTED" + severity shouldBe Severity.HINT + message shouldBe "Message-3" + howToFix shouldBe "How_to_fix-3" + packageId shouldBe null + } } } } @@ -123,6 +133,15 @@ class RuleViolationServiceTest : WordSpec() { Severity.ERROR, "Message-2", "How_to_fix-2" + ), + OrtRuleViolation( + "Rule-3-no-id", + null, + "License-3", + "DETECTED", + Severity.HINT, + "Message-3", + "How_to_fix-3" ) )