diff options
author | Jenkins CI <ci@sonarsource.com> | 2015-07-09 15:50:59 +0200 |
---|---|---|
committer | Jenkins CI <ci@sonarsource.com> | 2015-07-09 15:50:59 +0200 |
commit | 0bdf27c47c0bd9c5f642fd397be58f7d4ddd3a1a (patch) | |
tree | 92afa12539f2b3a5fbcdd3b43e080f2728dd6aab /sonar-batch/src/test/java | |
parent | 726c1fa0cfb2d0e27df0ed3de1dbed6ffdaf2377 (diff) | |
parent | ca253b85929fa9c372e285b617a7c8991d89698b (diff) | |
download | sonarqube-0bdf27c47c0bd9c5f642fd397be58f7d4ddd3a1a.tar.gz sonarqube-0bdf27c47c0bd9c5f642fd397be58f7d4ddd3a1a.zip |
Automatic merge from branch-5.1
* origin/branch-5.1:
SONAR-6706 org.sonar.api.rules.ActiveRule.getRule().getTemplate() is always null on batch
Diffstat (limited to 'sonar-batch/src/test/java')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java index bfa14cf91bc..092bfb42250 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java @@ -19,13 +19,12 @@ */ package org.sonar.batch.rule; +import java.util.Arrays; import org.junit.Test; -import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; import org.sonar.api.config.Settings; import org.sonar.api.profiles.RulesProfile; - -import java.util.Arrays; +import org.sonar.api.rule.RuleKey; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.fail; @@ -35,7 +34,6 @@ import static org.mockito.Mockito.when; public class RulesProfileProviderTest { ModuleQProfiles qProfiles = mock(ModuleQProfiles.class); - ActiveRules activeRules = new ActiveRulesBuilder().build(); Settings settings = new Settings(); RulesProfileProvider provider = new RulesProfileProvider(); @@ -44,7 +42,7 @@ public class RulesProfileProviderTest { QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java"); when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile)); - RulesProfile profile = provider.provide(qProfiles, activeRules, settings); + RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings); // merge of all profiles assertThat(profile).isNotNull().isInstanceOf(RulesProfileWrapper.class); @@ -66,12 +64,23 @@ public class RulesProfileProviderTest { QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java"); when(qProfiles.findByLanguage("java")).thenReturn(qProfile); - RulesProfile profile = provider.provide(qProfiles, activeRules, settings); + RulesProfile profile = provider.provide(qProfiles, new ActiveRulesBuilder().build(), settings); // no merge, directly the old hibernate profile assertThat(profile).isNotNull(); assertThat(profile.getLanguage()).isEqualTo("java"); assertThat(profile.getName()).isEqualTo("Sonar way"); - ; + } + + @Test + public void support_rule_templates() { + QProfile qProfile = new QProfile().setKey("java-sw").setName("Sonar way").setLanguage("java"); + when(qProfiles.findAll()).thenReturn(Arrays.asList(qProfile)); + ActiveRulesBuilder activeRulesBuilder = new ActiveRulesBuilder(); + activeRulesBuilder.create(RuleKey.of("java", "S001")).setTemplateRuleKey("T001").setLanguage("java").activate(); + + RulesProfile profile = provider.provide(qProfiles, activeRulesBuilder.build(), settings); + + assertThat(profile.getActiveRule("java", "S001").getRule().getTemplate().getKey()).isEqualTo("T001"); } } |