From: Daniel Schwarz Date: Tue, 26 Sep 2017 11:05:17 +0000 (+0200) Subject: improved unit test X-Git-Tag: 6.6-RC1~238 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6ce3647990273f62d0f289ee8db6c135f2718458;p=sonarqube.git improved unit test This avoids false positives in RegisterRuleTest that were caused by unique key collisions of randomly generated keys. --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index 94d7440b88d..b3202d0d02e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -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(); });