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.*;
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()));
}
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;
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.");
}
}