From 6ce3647990273f62d0f289ee8db6c135f2718458 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Tue, 26 Sep 2017 13:05:17 +0200 Subject: [PATCH] improved unit test This avoids false positives in RegisterRuleTest that were caused by unique key collisions of randomly generated keys. --- .../java/org/sonar/server/rule/RegisterRulesTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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(); }); -- 2.39.5