]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5067 Use a MessageException when activating already activated rules on a profile
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 26 Feb 2014 14:01:17 +0000 (15:01 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 26 Feb 2014 15:57:00 +0000 (16:57 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java

index d0abfb4bf924c0eac8fd7f8468747a73c985cc50..8d9bacef6f5880d165a127200b20add3c8984392 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.sonar.api.rules.ActiveRule;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
+import org.sonar.api.utils.MessageException;
 
 import javax.annotation.CheckForNull;
 import javax.persistence.*;
@@ -377,7 +378,7 @@ public class RulesProfile implements Cloneable {
         return input.getRule().equals(rule);
       }
     })) {
-      throw new IllegalStateException(String.format(
+      throw MessageException.of(String.format(
         "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.",
         getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey()));
     }
index 79275aa24224baefc52a386cf32f25c88b6ecc15..b13a38226da093e0177d5df9a3e9885583e036b5 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.api.profiles;
 import org.junit.Test;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
+import org.sonar.api.utils.MessageException;
 
 import static org.fest.assertions.Assertions.assertThat;
 import static org.fest.assertions.Fail.fail;
@@ -71,7 +72,7 @@ public class RulesProfileTest {
       profile.activateRule(rule, null);
       fail();
     } catch (Exception e) {
-      assertThat(e).isInstanceOf(IllegalStateException.class)
+      assertThat(e).isInstanceOf(MessageException.class)
         .hasMessage("The definition of the profile 'Default' (language 'java') contains multiple occurrences of the 'repo:key1' rule. The plugin which declares this profile should fix this.");
     }
   }