diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-03-22 10:49:35 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-03-22 10:49:35 +0100 |
commit | ec15548ef761899b1162f9b8210196e0b4e222be (patch) | |
tree | 0531b15a283d12d98a57855305c8186c0c0e2456 /sonar-core | |
parent | d42c6a3993cc9b1e40b3fd6006008dd9b902822e (diff) | |
download | sonarqube-ec15548ef761899b1162f9b8210196e0b4e222be.tar.gz sonarqube-ec15548ef761899b1162f9b8210196e0b4e222be.zip |
SONAR-3879 Replace rule status enumeration in the annotation by a string
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java | 13 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/rule/RuleStatusTest.java | 43 |
2 files changed, 54 insertions, 2 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java index 08938291178..6cf50c12a44 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleStatus.java @@ -19,10 +19,19 @@ */ package org.sonar.core.rule; +import java.util.EnumSet; + public enum RuleStatus { READY, BETA, DEPRECATED, REMOVED; - public static RuleStatus defaultValue() { - return RuleStatus.READY; + public static String defaultValue() { + return RuleStatus.READY.name(); } + + public static final EnumSet<RuleStatus> STATUS_FOR_PLUGIN = EnumSet.range(READY, DEPRECATED); + + public final boolean isAvailableForPlugin() { + return STATUS_FOR_PLUGIN.contains(this); + } + } diff --git a/sonar-core/src/test/java/org/sonar/core/rule/RuleStatusTest.java b/sonar-core/src/test/java/org/sonar/core/rule/RuleStatusTest.java new file mode 100644 index 00000000000..f42bb8563f7 --- /dev/null +++ b/sonar-core/src/test/java/org/sonar/core/rule/RuleStatusTest.java @@ -0,0 +1,43 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ + +package org.sonar.core.rule; + +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +public class RuleStatusTest { + + @Test + public void should_validate_status_for_user() { + assertThat(RuleStatus.READY.isAvailableForPlugin()).isTrue(); + assertThat(RuleStatus.BETA.isAvailableForPlugin()).isTrue(); + assertThat(RuleStatus.DEPRECATED.isAvailableForPlugin()).isTrue(); + + assertThat(RuleStatus.REMOVED.isAvailableForPlugin()).isFalse(); + } + + @Test + public void should_return_ready_as_default_value() { + assertThat(RuleStatus.defaultValue()).isEqualTo("READY"); + } + +} |