RepeatableRandom { public static <T> T randomElementOf(Collection<T> collection) { return instancedRepeatableRandom.randomElementOf(collection); } private  RepeatableRandom(); static void initialiseWithSeed(long masterSeed); static void initialiseWithFixedValue(double fixedValue); static void clear(); static InstancedRepeatableRandom newInstance(); static double nextDouble(); static double nextDouble(double origin, double bound); static int nextInt(int bound); static boolean nextBoolean(); static UUID nextUUID(); static long nextLong(); static double nextGaussian(); static void shuffle(List<T> list); static void shuffle(T[] array); static T randomElementOf(Collection<T> collection); static T randomElementOf(List<T> list); static final double MIN_FIXED_VALUE; static final double MAX_FIXED_VALUE; }
@Test public void seededRandom_selectsItemFromListDeterministically() { List<Integer> input = Arrays.asList(1, 2, 3, 4, 5); testFunctionDeterminism(() -> RepeatableRandom.randomElementOf(input), "randomElementOfList"); }
@Test public void seededRandom_selectsItemFromCollectionDeterministically() { Set<Integer> input = new LinkedHashSet<>(Arrays.asList(1, 2, 3, 4, 5)); testFunctionDeterminism(() -> RepeatableRandom.randomElementOf(input), "randomElementOfList"); }