/** * Randomize a {@code double} value between 0.0 (inclusive) and the specified value (exclusive). */ public double nextDouble(double d) { return nextDouble(d, false); }
/** * Randomize a {@code double} value between 0.0 (inclusive) and the specified value (inclusive or exclusive as * required). * * @param inclusive * Whether or not, the returned value should include the given one. */ public double nextDouble(double d, boolean inclusive) { if (d <= 0.0D) { throw new IllegalArgumentException("d must be greater than 0!"); } // Randomize a double double rand = nextDouble(); // If the returned value should not include the given one, // make sure that the randomized float is not exactly 1.0 if (!inclusive) { while (rand == 1.0D) { rand = nextDouble(); } } return rand * d; }
private static VdsStatistics randomVdsStatistics() { RandomUtils random = RandomUtils.instance(); VdsStatistics vdsStatistics = new VdsStatistics(); vdsStatistics.setCpuIdle(random.nextDouble()); vdsStatistics.setCpuLoad(random.nextDouble()); vdsStatistics.setCpuSys(random.nextDouble()); vdsStatistics.setCpuUser(random.nextDouble()); vdsStatistics.setMemAvailable(random.nextLong()); vdsStatistics.setMemFree(random.nextLong()); vdsStatistics.setMemShared(random.nextLong()); vdsStatistics.setUsageCpuPercent(random.nextInt()); vdsStatistics.setUsageMemPercent(random.nextInt()); vdsStatistics.setUsageNetworkPercent(random.nextInt()); vdsStatistics.setCpuOverCommitTimeStamp(new Date(random.nextLong())); return vdsStatistics; }
private static void random(Method m, Object model) throws Exception { Object value = null; if (takesString(m)) { value = garble(m); } else if (takesShort(m)) { value = (short) rand(100); } else if (takesInteger(m)) { value = rand(100); } else if (takesLong(m)) { value = (long) rand(1000000000); } else if (takesBoolean(m)) { value = RandomUtils.instance().nextBoolean(); } else if (takesDouble(m)) { value = RandomUtils.instance().nextDouble(); } if (value != null) { m.invoke(model, value); } }
vdsDynamic.setCpuThreads(random.nextInt()); vdsDynamic.setCpuModel(random.nextString(10)); vdsDynamic.setCpuSpeedMh(random.nextDouble()); vdsDynamic.setIfTotalSpeed(random.nextString(10)); vdsDynamic.setKvmEnabled(random.nextBoolean());