/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
public static CustomMeasureDto newCustomMeasureDto() { return new CustomMeasureDto() .setDescription(RandomStringUtils.randomAlphanumeric(255)) .setTextValue(RandomStringUtils.randomAlphanumeric(255)) .setUserUuid("userUuid" + RandomStringUtils.randomAlphanumeric(100)) .setValue(RandomUtils.nextDouble()) .setMetricId(RandomUtils.nextInt()) .setComponentUuid(RandomStringUtils.randomAlphanumeric(50)) .setCreatedAt(System2.INSTANCE.now()) .setUpdatedAt(System2.INSTANCE.now()); } }
public static MetricDto newMetricDto() { Metric.ValueType[] metricTypes = Metric.ValueType.values(); return new MetricDto() .setId(RandomUtils.nextInt()) .setKey(RandomStringUtils.randomAlphanumeric(64)) .setShortName(RandomStringUtils.randomAlphanumeric(64)) .setValueType(metricTypes[RandomUtils.nextInt(metricTypes.length - 1)].name()) .setDomain(RandomStringUtils.randomAlphanumeric(64)) .setDescription(RandomStringUtils.randomAlphanumeric(250)) .setBestValue(RandomUtils.nextDouble()) .setDeleteHistoricalData(RandomUtils.nextBoolean()) .setDirection(RandomUtils.nextInt()) .setHidden(RandomUtils.nextBoolean()) .setEnabled(true) .setOptimizedBestValue(RandomUtils.nextBoolean()) .setQualitative(RandomUtils.nextBoolean()) .setUserManaged(RandomUtils.nextBoolean()) .setWorstValue(RandomUtils.nextDouble()); } }
/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
@Override public Double random() { return RandomUtils.nextDouble(); }
public static Double randomDouble() { return RandomUtils.nextDouble(); }
/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
/** * <p>Returns the next pseudorandom, uniformly distributed float value * between <code>0.0</code> and <code>1.0</code> from the Math.random() * sequence.</p> * * @return the random double */ public static double nextDouble() { return nextDouble(JVM_RANDOM); }
public double upTo(final double max) { return RandomUtils.nextDouble() * max; } }
/** * Build a random {@link Double}. For example * <p/> * <code> * Double aRandomHeight = RandomBuilder.aRandomDouble(); * </code> * * @return a random {@link Double}. */ public static Double aRandomDouble() { return Double.valueOf(nextDouble()); }
@Override public BigDecimal random() { return BigDecimal.valueOf(RandomUtils.nextDouble()); }
public static double randomDouble(double min, double max) { if (Double.isInfinite(max - min)) { throw new IllegalArgumentException("range of double is infinty"); } return min + RandomUtils.nextDouble() * (max - min); }
public static double randomDouble(int min, int max) { return RandomUtils.nextDouble() + RandomUtils.nextInt(max - min); }
@Override public DateTime random() { DateTime now = DateTime.now(); long min = now.minus(Years.TWO).getMillis(); long max = now.plus(Years.TWO).getMillis(); double random = RandomUtils.nextDouble() * (max - min) + min; return new DateTime(Double.valueOf(random).longValue()); }
@Programmatic public double any() { return fake.booleans().coinFlip() ? RandomUtils.nextDouble(fake.random) * Double.MAX_VALUE : -RandomUtils.nextDouble(fake.random) * Double.MAX_VALUE; }
@Test public void noMethodIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getMethodIdentForId(METHOD_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getMethodIdent()).thenReturn(METHOD_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Methods.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_CLASS_FQN))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_NAME))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_SIGNATURE))); }
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(jmxDefinitionDataIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getValueAsDouble()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME, String.valueOf(JMX_ATTR))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
private void doWrite(BlockCompressedDataOutputStream outputStream) throws IOException { outputStream.writeFloat(RandomUtils.nextFloat()); outputStream.writeDouble(RandomUtils.nextDouble()); outputStream.writeLong(RandomUtils.nextLong()); outputStream.writeInt(RandomUtils.nextInt()); outputStream.writeShort(0); outputStream.writeBoolean(RandomUtils.nextBoolean()); outputStream.writeBytes("test"); outputStream.writeByte(RandomUtils.nextInt()); outputStream.writeChar(TEST_CHAR_ID); outputStream.writeChars("test"); outputStream.flush(); }