From 356f32fa759fdf4b9801194b26fc8dcc877dc3fc Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 1 Feb 2011 23:57:10 +0300 Subject: [PATCH] SONAR-2137: Fix updating of past violations * Database field rule_failures.failure_level should be updatable * Change corresponding unit test --- .../test/java/org/sonar/batch/index/ViolationPersisterTest.java | 2 +- .../ViolationPersisterTest/shouldUpdateViolation-result.xml | 2 +- .../java/org/sonar/api/database/model/RuleFailureModel.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java index b307e8dbe67..55f30b32257 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java @@ -76,7 +76,7 @@ public class ViolationPersisterTest extends AbstractDbUnitTestCase { @Test public void shouldUpdateViolation() { Violation violation = Violation.create(rule1, javaFile) - .setLineId(20).setCost(55.6); + .setLineId(20).setCost(55.6).setSeverity(RulePriority.MINOR); RuleFailureModel model = getSession().getSingleResult(RuleFailureModel.class, "id", 1); violationPersister.saveOrUpdateViolation(new Project("project"), violation, model, null); diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml index 816cb6a6edc..b54b33d0fe2 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ViolationPersisterTest/shouldUpdateViolation-result.xml @@ -18,6 +18,6 @@ scope="FIL" qualifier="CLA" created_at="2008-11-01 13:58:00.00" version="[null]" path="" status="U" islast="false" depth="3" /> - + diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/RuleFailureModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/RuleFailureModel.java index f47f8b724c5..66a7ccb3172 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/RuleFailureModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/RuleFailureModel.java @@ -42,7 +42,7 @@ public class RuleFailureModel extends BaseIdentifiable { @Column(name = "rule_id", updatable = false, nullable = false) private Integer ruleId; - @Column(name = "failure_level", updatable = false, nullable = false) + @Column(name = "failure_level", updatable = true, nullable = false) @Enumerated(EnumType.ORDINAL) private RulePriority priority; -- 2.39.5