diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 17:22:57 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 17:22:57 +0000 |
commit | aef2286bf00aca219862aa62ef5dcac4bb9d2e9a (patch) | |
tree | 185ed172e4fd630b1b14c07b072e049fee6c4494 /sonar-server/src/test | |
parent | 4592819b97fd656bd857e319b6c26c008e2f50f2 (diff) | |
download | sonarqube-aef2286bf00aca219862aa62ef5dcac4bb9d2e9a.tar.gz sonarqube-aef2286bf00aca219862aa62ef5dcac4bb9d2e9a.zip |
SONAR-1229 Export/Import a given Sonar quality profile
Diffstat (limited to 'sonar-server/src/test')
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/rules/DeprecatedProfilesTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/rules/DeprecatedProfilesTest.java b/sonar-server/src/test/java/org/sonar/server/rules/DeprecatedProfilesTest.java new file mode 100644 index 00000000000..1d94991ce8e --- /dev/null +++ b/sonar-server/src/test/java/org/sonar/server/rules/DeprecatedProfilesTest.java @@ -0,0 +1,55 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2009 SonarSource SA + * 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.server.rules; + +import org.junit.Test; +import org.sonar.api.rules.RulePriority; +import org.sonar.server.rules.DeprecatedProfiles; + +import static org.hamcrest.Matchers.is; +import static org.hamcrest.core.IsNull.nullValue; +import static org.junit.Assert.assertThat; + +public class DeprecatedProfilesTest { + @Test + public void testCreate() { + DeprecatedProfiles.DefaultProfileDefinition def = DeprecatedProfiles.DefaultProfileDefinition.create("sonar way", "java"); + assertThat(def.getName(), is("sonar way")); + assertThat(def.getLanguage(), is("java")); + } + + @Test + public void testActivateRule() { + DeprecatedProfiles.DefaultProfileDefinition def = DeprecatedProfiles.DefaultProfileDefinition.create("sonar way", "java"); + def.activateRule("checkstyle", "IllegalRegexp", RulePriority.BLOCKER); + def.activateRule("pmd", "NullPointer", RulePriority.INFO); + + assertThat(def.getRules().size(), is(2)); + assertThat(def.getRulesByRepositoryKey("checkstyle").size(), is(1)); + assertThat(def.getRulesByRepositoryKey("checkstyle").get(0).getPriority(), is(RulePriority.BLOCKER)); + } + + @Test + public void priorityIsOptional() { + DeprecatedProfiles.DefaultProfileDefinition def = DeprecatedProfiles.DefaultProfileDefinition.create("sonar way", "java"); + def.activateRule("checkstyle", "IllegalRegexp", null); + assertThat(def.getRules().get(0).getPriority(), nullValue()); + } +} |