From 85ad745aaee19225e0abbb11abd167e39a8b1e95 Mon Sep 17 00:00:00 2001 From: Godin Date: Wed, 8 Dec 2010 19:22:18 +0000 Subject: SONAR-1809: Export / import alerts attached to a quality profile --- .../test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java | 5 +++-- .../sonar/plugins/checkstyle/SonarWayWithFindbugsProfileTest.java | 3 ++- .../java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins/sonar-checkstyle-plugin') diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java index 23a39650517..fef7df549a4 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java @@ -22,6 +22,7 @@ package org.sonar.plugins.checkstyle; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.sonar.api.measures.MetricFinder; import org.sonar.api.profiles.ProfileDefinition; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.profiles.XMLProfileParser; @@ -40,7 +41,7 @@ public class SonarWayProfileTest { @Test public void shouldCreateProfile() { - ProfileDefinition sonarWay = new SonarWayProfile(new XMLProfileParser(newRuleFinder())); + ProfileDefinition sonarWay = new SonarWayProfile(new XMLProfileParser(newRuleFinder(), mock(MetricFinder.class))); ValidationMessages validation = ValidationMessages.create(); RulesProfile profile = sonarWay.createProfile(validation); assertThat(profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size(), greaterThan(1)); @@ -49,7 +50,7 @@ public class SonarWayProfileTest { private RuleFinder newRuleFinder() { RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer(){ + when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer() { public Rule answer(InvocationOnMock iom) throws Throwable { return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]); } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayWithFindbugsProfileTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayWithFindbugsProfileTest.java index d5af6c0b236..c53eff084ca 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayWithFindbugsProfileTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayWithFindbugsProfileTest.java @@ -22,6 +22,7 @@ package org.sonar.plugins.checkstyle; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.sonar.api.measures.MetricFinder; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.profiles.XMLProfileParser; import org.sonar.api.rules.Rule; @@ -39,7 +40,7 @@ public class SonarWayWithFindbugsProfileTest { @Test public void shouldBeSameAsSonarWay() { RuleFinder ruleFinder = newRuleFinder(); - SonarWayProfile sonarWay = new SonarWayProfile(new XMLProfileParser(ruleFinder)); + SonarWayProfile sonarWay = new SonarWayProfile(new XMLProfileParser(ruleFinder, mock(MetricFinder.class))); RulesProfile withoutFindbugs = sonarWay.createProfile(ValidationMessages.create()); RulesProfile withFindbugs = new SonarWayWithFindbugsProfile(sonarWay).createProfile(ValidationMessages.create()); assertThat(withFindbugs.getActiveRules().size(), is(withoutFindbugs.getActiveRules().size())); diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java index 147006e30eb..4f2bb9361d8 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java @@ -23,6 +23,7 @@ import org.hamcrest.core.Is; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.sonar.api.measures.MetricFinder; import org.sonar.api.profiles.ProfileDefinition; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.profiles.XMLProfileParser; @@ -39,7 +40,7 @@ import static org.mockito.Mockito.when; public class SunConventionsProfileTest { @Test public void shouldCreateProfile() { - ProfileDefinition definition = new SunConventionsProfile(new XMLProfileParser(newRuleFinder())); + ProfileDefinition definition = new SunConventionsProfile(new XMLProfileParser(newRuleFinder(), mock(MetricFinder.class))); ValidationMessages validation = ValidationMessages.create(); RulesProfile sunProfile = definition.createProfile(validation); assertThat(sunProfile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size(), greaterThan(1)); -- cgit v1.2.3