Only characters with supported encoding should be used by DB tests.
import java.util.Arrays;
import java.util.function.Consumer;
-import org.apache.commons.lang.RandomStringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.rule.RuleParamType;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.sonar.db.rule.RuleTesting.newRule;
import static org.sonar.db.rule.RuleTesting.newRuleDto;
public RuleParamDto insertRuleParam(RuleDto rule) {
RuleParamDto param = new RuleParamDto();
param.setRuleId(rule.getId());
- param.setName(RandomStringUtils.random(10));
+ param.setName(randomAlphabetic(10));
param.setType(RuleParamType.STRING.type());
db.getDbClient().ruleDao().insertRuleParam(db.getSession(), rule.getDefinition(), param);
db.commit();
import static com.google.common.collect.ImmutableSet.copyOf;
import static com.google.common.collect.Sets.newHashSet;
import static java.util.Objects.requireNonNull;
-import static org.apache.commons.lang.RandomStringUtils.random;
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.apache.commons.lang.math.RandomUtils.nextInt;
}
public static RuleKey randomRuleKeyOfMaximumLength() {
- return RuleKey.of(random(255), random(200));
+ return RuleKey.of(randomAlphabetic(255), randomAlphabetic(200));
}
public static Consumer<RuleDefinitionDto> setRepositoryKey(String repositoryKey) {
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
-import org.apache.commons.lang.RandomStringUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.lang.String.format;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
import static org.assertj.core.api.Assertions.assertThat;
}
private int insertNewGroup(String organizationUuid) {
- String groupName = RandomStringUtils.random(10);
+ String groupName = randomAlphabetic(10);
db.executeInsert("GROUPS", "NAME", groupName, "ORGANIZATION_UUID", organizationUuid);
return ((Long) db.selectFirst(format("select ID from groups where name='%s' and organization_uuid='%s'", groupName, organizationUuid)).get("ID")).intValue();
}
import org.sonar.server.platform.db.migration.version.v63.DefaultOrganizationUuidProviderImpl;
import static java.lang.String.valueOf;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang.math.RandomUtils.nextLong;
import static org.assertj.core.api.Assertions.assertThat;
}
private int insertGroup(String organizationUuid) {
- String name = "name" + RandomStringUtils.random(20);
+ String name = "name" + randomAlphabetic(20);
db.executeInsert(
"GROUPS",
"ORGANIZATION_UUID", organizationUuid,
import static java.util.stream.Collectors.joining;
import static java.util.stream.IntStream.range;
import static java.util.stream.Stream.of;
-import static org.apache.commons.lang.RandomStringUtils.random;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
import static org.mockito.Mockito.doReturn;
@Test
public void should_only_provide_project_for_certain_qualifiers() throws Exception {
- String query = random(10);
+ String query = randomAlphabetic(10);
ComponentDto view = db.components().insertView(organization, v -> v.setName(query));
ComponentDto subView = db.components().insertComponent(ComponentTesting.newSubView(view).setName(query));
import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder;
import static java.util.Collections.emptyList;
-import static org.apache.commons.lang.RandomStringUtils.random;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
Component component = mock(Component.class);
DbClient dbClient = mock(DbClient.class);
ComponentDao componentDao = mock(ComponentDao.class);
- String projectKey = random(20);
+ String projectKey = randomAlphabetic(20);
doReturn(component).when(treeRootHolder).getRoot();
doReturn(projectKey).when(component).getKey();
*/
package org.sonar.server.qualityprofile.index;
-import org.apache.commons.lang.RandomStringUtils;
import org.sonar.api.rule.Severity;
import org.sonar.db.qualityprofile.ActiveRuleKey;
import org.sonar.db.rule.RuleTesting;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+
public class ActiveRuleDocTesting {
public static ActiveRuleDoc newDoc() {
public static ActiveRuleDoc newDoc(ActiveRuleKey key) {
return new ActiveRuleDoc(key)
- .setOrganizationUuid(RandomStringUtils.random(40))
+ .setOrganizationUuid(randomAlphabetic(40))
.setSeverity(Severity.CRITICAL)
.setInheritance(null).setCreatedAt(150000000L)
.setUpdatedAt(160000000L);