Skip to content

Commit

Permalink
feat(api): Change RuleViolation API to return ones without packages
Browse files Browse the repository at this point in the history
As RuleViolations may exists without packages associated with them,
RuleViolationService returns them with possible null packageId

Signed-off-by: Kamil Bielecki <kamil.bielecki@pl.bosch.com>
  • Loading branch information
Kamil Bielecki authored and oheger-bosch committed Oct 24, 2024
1 parent 3fcc53f commit a3f4a76
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/v1/model/src/commonMain/kotlin/RuleViolation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ data class RuleViolation(
val severity: Severity,
val message: String,
val howToFix: String,
val packageId: Identifier?
val packageId: Identifier? = null
)
16 changes: 3 additions & 13 deletions core/src/test/kotlin/api/RunsRouteIntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion services/hierarchy/src/main/kotlin/RuleViolationService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 20 additions & 1 deletion services/hierarchy/src/test/kotlin/RuleViolationServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {

Expand Down Expand Up @@ -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
}
}
}
}
Expand Down Expand Up @@ -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"
)
)

Expand Down

0 comments on commit a3f4a76

Please sign in to comment.