### Question:
RandomEnumGenerator implements Generator<T> { @Override @SuppressWarnings("unchecked") public T next() { return enums[random.nextInt(enums.length)]; } RandomEnumGenerator(@Nonnull Class<T> enumClass); @Override @SuppressWarnings("unchecked") //generated class is always of type T T next();  }### Answer:
@Test public void shouldGenerateEnumRandomly() { Generator<SomeEnum> randomEnumGenerator = new RandomEnumGenerator<>(SomeEnum.class); EnumSet<SomeEnum> enumSet = EnumSet.noneOf(SomeEnum.class); for (int i = 0; i < 20; i++) { enumSet.add(randomEnumGenerator.next()); } assertThat(enumSet, contains(SomeEnum.FIRST, SomeEnum.SECOND, SomeEnum.THIRD)); }