diff options
author | David Gageot <david@gageot.net> | 2012-10-05 10:09:39 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-10-05 10:09:39 +0200 |
commit | 1bd03f2eebdfa1b56c1ce410081223b2b646754f (patch) | |
tree | 7402e98f1c61ef6466e0a6d6ad407f740d8ac06e /plugins/sonar-checkstyle-plugin/src/test | |
parent | 8e94477d8a7e41f5835e9554f71d007453461339 (diff) | |
download | sonarqube-1bd03f2eebdfa1b56c1ce410081223b2b646754f.tar.gz sonarqube-1bd03f2eebdfa1b56c1ce410081223b2b646754f.zip |
SONAR-3724 Validate rule repositories in unit tests
Diffstat (limited to 'plugins/sonar-checkstyle-plugin/src/test')
-rw-r--r-- | plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java index b42b99357d8..9c6daac1e04 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java @@ -19,10 +19,12 @@ */ package org.sonar.plugins.checkstyle; +import org.junit.Before; import org.junit.Test; import org.sonar.api.platform.ServerFileSystem; import org.sonar.api.rules.Rule; import org.sonar.api.rules.XMLRuleParser; +import org.sonar.test.i18n.RuleRepositoryTestHelper; import java.util.List; @@ -30,13 +32,26 @@ import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; public class CheckstyleRuleRepositoryTest { + CheckstyleRuleRepository repository; + + @Before + public void setUpRuleRepository() { + repository = new CheckstyleRuleRepository(mock(ServerFileSystem.class), new XMLRuleParser()); + } @Test public void loadRepositoryFromXml() { - ServerFileSystem fileSystem = mock(ServerFileSystem.class); - CheckstyleRuleRepository repository = new CheckstyleRuleRepository(fileSystem, new XMLRuleParser()); List<Rule> rules = repository.createRules(); + + assertThat(repository.getKey()).isEqualTo("checkstyle"); assertThat(rules.size()).isEqualTo(129); } + @Test + public void should_provide_a_name_and_description_for_each_rule() { + List<Rule> rules = RuleRepositoryTestHelper.createRulesWithNameAndDescription("checkstyle", repository); + + assertThat(rules).onProperty("name").excludes(null, ""); + assertThat(rules).onProperty("description").excludes(null, ""); + } } |