]> source.dussan.org Git - sonarqube.git/commitdiff
improved unit test
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Tue, 26 Sep 2017 11:05:17 +0000 (13:05 +0200)
committerDaniel Schwarz <daniel.schwarz@sonarsource.com>
Tue, 26 Sep 2017 12:26:50 +0000 (14:26 +0200)
This avoids false positives in RegisterRuleTest that were caused by unique key collisions of randomly generated keys.

server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java

index 94d7440b88d982304b54063a3755ff739a668c62..b3202d0d02e311367f447730064a78bbad77b656 100644 (file)
@@ -190,10 +190,11 @@ public class RegisterRulesTest {
     // register many rules
     execute(context -> {
       RulesDefinition.NewRepository repo = context.createRepository("fake", "java");
-      IntStream.range(0, numberOfRules).forEach(i ->
-        repo.createRule(randomAlphanumeric(5))
-        .setName(randomAlphanumeric(20))
-        .setHtmlDescription(randomAlphanumeric(20)));
+      IntStream.range(0, numberOfRules)
+        .mapToObj(i -> "rule-" + i)
+        .forEach(ruleKey -> repo.createRule(ruleKey)
+          .setName(randomAlphanumeric(20))
+          .setHtmlDescription(randomAlphanumeric(20)));
       repo.done();
     });