List of usage examples for org.apache.commons.text RandomStringGenerator generate
public String generate(final int length)
Generates a random string, containing the specified number of code points.
From source file:org.trellisldp.test.CommonTests.java
/** * Get a randomized Slug header with an appropriate suffix. * @param suffix the suffix//from w w w . j av a2 s. c om * @return a randomized header name */ default String generateRandomValue(final String suffix) { final RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('a', 'z').build(); return generator.generate(16) + "-" + suffix; }
From source file:tech.tablesaw.filters.SearchPerformanceTest.java
private static void generateData(int observationCount, LocalDateTime dateTime, Table table) { // createFromCsv pools of random values RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange(32, 127).build(); while (concepts.size() <= CONCEPT_COUNT) { concepts.add(generator.generate(30)); }/*from ww w . j a v a2s .co m*/ while (dates.size() <= numberOfRecordsInTable) { dates.add(PackedLocalDateTime.pack(dateTime.plusMinutes(1))); } DateTimeColumn dateColumn = table.dateTimeColumn("date"); StringColumn conceptColumn = table.stringColumn("concept"); DoubleColumn lowValues = table.doubleColumn("lowValue"); DoubleColumn highValues = table.doubleColumn("highValue"); // sample from the pools to write the data for (int i = 0; i < observationCount; i++) { dateColumn.appendInternal(dates.getLong(i)); conceptColumn.append(concepts.get(RandomUtils.nextInt(0, concepts.size()))); lowValues.append(RandomUtils.nextDouble(0, 1_000_000)); highValues.append(RandomUtils.nextDouble(0, 1_000_000)); } }
From source file:tech.tablesaw.filters.TimeDependentFilteringTest.java
private static void generateData(int observationCount, Table table) { // createFromCsv pools of random values RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange(32, 127).build(); while (concepts.size() <= CONCEPT_COUNT) { concepts.add(generator.generate(30)); }/* ww w . j a v a 2 s . c om*/ while (patientIds.size() <= PATIENT_COUNT) { patientIds.add(RandomUtils.nextInt(0, 2_000_000_000)); } while (dates.size() <= size) { dates.add(PackedLocalDate.pack(randomDate())); } DateColumn dateColumn = table.dateColumn("date"); StringColumn conceptColumn = table.stringColumn("concept"); DoubleColumn valueColumn = table.doubleColumn("value"); DoubleColumn patientColumn = table.doubleColumn("patient"); // sample from the pools to write the data for (int i = 0; i < observationCount; i++) { dateColumn.appendInternal(dates.getInt(RandomUtils.nextInt(0, dates.size()))); conceptColumn.append(concepts.get(RandomUtils.nextInt(0, concepts.size()))); valueColumn.append(RandomUtils.nextDouble(0f, 100_000f)); patientColumn.append(patientIds.getInt(RandomUtils.nextInt(0, patientIds.size()))); } }