]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1829: Use severity instead of priority
authorGodin <mandrikov@gmail.com>
Tue, 7 Dec 2010 17:42:40 +0000 (17:42 +0000)
committerGodin <mandrikov@gmail.com>
Tue, 7 Dec 2010 17:42:40 +0000 (17:42 +0000)
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ViolationsDecoratorTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/NewViolationsDecoratorTest.java
plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/visitor/AccessorVisitorTest.java
plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/bridges/FunctionComplexityDistributionBridgeTest.java
sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java
sonar-batch/src/test/java/org/sonar/batch/index/ViolationPersisterTest.java
sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/MessageDispatcher.java

index 866d02d4d19c7bb871eb2b585a7490c7667a5c09..1abffdfb8f3fb625df60b28196cd90f0438eaf7a 100644 (file)
@@ -135,10 +135,10 @@ public class ViolationsDecoratorTest {
 
   private List<Violation> createViolations() {
     List<Violation> violations = new ArrayList<Violation>();
-    violations.add(Violation.create(ruleA1, resource).setPriority(RulePriority.CRITICAL));
-    violations.add(Violation.create(ruleA1, resource).setPriority(RulePriority.CRITICAL));
-    violations.add(Violation.create(ruleA2, resource).setPriority(RulePriority.MAJOR));
-    violations.add(Violation.create(ruleB1, resource).setPriority(RulePriority.MINOR));
+    violations.add(Violation.create(ruleA1, resource).setSeverity(RulePriority.CRITICAL));
+    violations.add(Violation.create(ruleA1, resource).setSeverity(RulePriority.CRITICAL));
+    violations.add(Violation.create(ruleA2, resource).setSeverity(RulePriority.MAJOR));
+    violations.add(Violation.create(ruleB1, resource).setSeverity(RulePriority.MINOR));
     return violations;
   }
 }
index dca4168ca4535869351a129fe99d12993230e97b..2fd987589aa79dc215f7c52d1ba7ef73eba5502f 100644 (file)
@@ -125,8 +125,8 @@ public class NewViolationsDecoratorTest {
 
   @Test
   public void shouldClearCacheAfterExecution() {
-    Violation violation1 = Violation.create(rule1, resource).setPriority(RulePriority.CRITICAL).setCreatedAt(rightNow);
-    Violation violation2 = Violation.create(rule2, resource).setPriority(RulePriority.CRITICAL).setCreatedAt(rightNow);
+    Violation violation1 = Violation.create(rule1, resource).setSeverity(RulePriority.CRITICAL).setCreatedAt(rightNow);
+    Violation violation2 = Violation.create(rule2, resource).setSeverity(RulePriority.CRITICAL).setCreatedAt(rightNow);
     when(context.getViolations()).thenReturn(Arrays.asList(violation1)).thenReturn(Arrays.asList(violation2));
 
     decorator.decorate(resource, context);
@@ -162,12 +162,12 @@ public class NewViolationsDecoratorTest {
 
   private List<Violation> createViolations() {
     List<Violation> violations = new ArrayList<Violation>();
-    violations.add(Violation.create(rule1, resource).setPriority(RulePriority.CRITICAL).setCreatedAt(rightNow));
-    violations.add(Violation.create(rule1, resource).setPriority(RulePriority.CRITICAL).setCreatedAt(tenDaysAgo));
-    violations.add(Violation.create(rule2, resource).setPriority(RulePriority.MAJOR).setCreatedAt(fiveDaysAgo));
-    violations.add(Violation.create(rule2, resource).setPriority(RulePriority.MAJOR).setCreatedAt(tenDaysAgo));
-    violations.add(Violation.create(rule3, resource).setPriority(RulePriority.MINOR).setCreatedAt(fiveDaysAgo));
-    violations.add(Violation.create(rule3, resource).setPriority(RulePriority.MINOR).setCreatedAt(tenDaysAgo));
+    violations.add(Violation.create(rule1, resource).setSeverity(RulePriority.CRITICAL).setCreatedAt(rightNow));
+    violations.add(Violation.create(rule1, resource).setSeverity(RulePriority.CRITICAL).setCreatedAt(tenDaysAgo));
+    violations.add(Violation.create(rule2, resource).setSeverity(RulePriority.MAJOR).setCreatedAt(fiveDaysAgo));
+    violations.add(Violation.create(rule2, resource).setSeverity(RulePriority.MAJOR).setCreatedAt(tenDaysAgo));
+    violations.add(Violation.create(rule3, resource).setSeverity(RulePriority.MINOR).setCreatedAt(fiveDaysAgo));
+    violations.add(Violation.create(rule3, resource).setSeverity(RulePriority.MINOR).setCreatedAt(tenDaysAgo));
     return violations;
   }
 
index c5cf68529192325a7a9642259a2beda0c59f9c3e..9295075d8366bcfd74d5a7fd8d5be3a86311cc21 100644 (file)
  */
 package org.sonar.java.ast.visitor;
 
-import static org.junit.Assert.assertEquals;
-import static org.sonar.java.ast.SquidTestUtils.getFile;
-
 import org.junit.Test;
 import org.sonar.java.ast.JavaAstScanner;
 import org.sonar.java.squid.JavaSquidConfiguration;
 import org.sonar.squid.Squid;
 import org.sonar.squid.api.SourceCode;
-import org.sonar.squid.api.SquidConfiguration;
 import org.sonar.squid.measures.Metric;
 
+import static org.junit.Assert.assertEquals;
+import static org.sonar.java.ast.SquidTestUtils.getFile;
+
 public class AccessorVisitorTest {
 
   private Squid squid;
index 9b78844f544c04290a1f75a8647dc963af0e3f06..d5203779f6a6b655db9e88e4ff63711d71f77788 100644 (file)
 package org.sonar.plugins.squid.bridges;\r
 \r
 import org.junit.Test;\r
-import static org.mockito.Mockito.verify;\r
-import static org.mockito.Mockito.never;\r
-import static org.mockito.Matchers.*;\r
-import org.sonar.api.resources.JavaPackage;\r
-import org.sonar.api.resources.JavaFile;\r
 import org.sonar.api.measures.CoreMetrics;\r
 import org.sonar.api.measures.Measure;\r
+import org.sonar.api.resources.JavaFile;\r
+import org.sonar.api.resources.JavaPackage;\r
 import org.sonar.api.test.IsMeasure;\r
-import static org.hamcrest.Matchers.any;\r
 \r
-public class FunctionComplexityDistributionBridgeTest extends BridgeTestCase{\r
+import static org.mockito.Matchers.argThat;\r
+import static org.mockito.Matchers.eq;\r
+import static org.mockito.Mockito.never;\r
+import static org.mockito.Mockito.verify;\r
+\r
+public class FunctionComplexityDistributionBridgeTest extends BridgeTestCase {\r
 \r
   @Test\r
   public void functionComplexityDistribution() {\r
index 324f8f0f01b91a9581c650257e993df4d43eb215..8f7a9f1e8727c456bab803df5ba74c87a9da4d17 100644 (file)
@@ -404,7 +404,7 @@ public final class DefaultIndex extends SonarIndex {
           }
 
         } else {
-          violation.setPriority(activeRule.getSeverity());
+          violation.setSeverity(activeRule.getSeverity());
           doAddViolation(violation, bucket);
         }
       }
index a0d4ae27679b57c1fe57c4f5fdcd49a338862d16..f9bd575af86df486e8db3cecb1b1e89872c5c1b1 100644 (file)
@@ -59,12 +59,12 @@ public class ViolationPersisterTest extends AbstractDbUnitTestCase {
   @Test
   public void shouldSaveViolations() {
     Violation violation1a = Violation.create(rule1, javaFile)
-        .setPriority(RulePriority.CRITICAL).setLineId(20).setCost(55.6)
+        .setSeverity(RulePriority.CRITICAL).setLineId(20).setCost(55.6)
         .setMessage("the message");
     Violation violation1b = Violation.create(rule1, javaFile)
-        .setPriority(RulePriority.CRITICAL).setLineId(50).setCost(80.0);
+        .setSeverity(RulePriority.CRITICAL).setLineId(50).setCost(80.0);
     Violation violation2 = Violation.create(rule2, javaFile)
-        .setPriority(RulePriority.MINOR);
+        .setSeverity(RulePriority.MINOR);
     Project project = new Project("project");
 
     violationPersister.saveViolation(project, violation1a);
index 47c48f28a6652865fbcad08323141d1031b58527..5885b2f5035c6e80425b73877900dcea253dabb1 100644 (file)
@@ -99,7 +99,7 @@ public class MessageDispatcher {
     Violation violation = Violation.create(new Rule(check.getRepositoryKey(), check.getTemplateKey()), resource);
     violation.setLineId(message.getLine());
     violation.setMessage(message.getText(Locale.ENGLISH));
-    violation.setPriority(RulePriority.fromCheckPriority(check.getPriority()));
+    violation.setSeverity(RulePriority.fromCheckPriority(check.getPriority()));
     context.saveViolation(violation);
   }
 
@@ -108,4 +108,4 @@ public class MessageDispatcher {
     checksByChecker.clear();
   }
 
-}
\ No newline at end of file
+}