From aef2286bf00aca219862aa62ef5dcac4bb9d2e9a Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Mon, 6 Sep 2010 17:22:57 +0000 Subject: SONAR-1229 Export/Import a given Sonar quality profile --- .../sonar/server/rules/DeprecatedProfilesTest.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 sonar-server/src/test/java/org/sonar/server/rules/DeprecatedProfilesTest.java (limited to 'sonar-server/src/test') 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()); + } +} -- cgit v1.2.3