UidValidity { public static UidValidity generate() { return fromSupplier(RANDOM::nextLong); } private  UidValidity(long uidValidity); static UidValidity generate(); static UidValidity of(long uidValidity); static boolean isValid(long uidValidityAsLong); boolean isValid(); long asLong(); @Override final boolean equals(Object obj); @Override final int hashCode(); @Override String toString();  }
@Disabled("On average upon generating 1.000.000 UidValidity we notice 125 duplicates") @Test void randomShouldNotLeadToCollision() { int count = 1000000; long distinctCount = IntStream.range(0, count) .mapToObj(any -> UidValidity.generate()) .distinct() .count(); assertThat(distinctCount).isEqualTo(count); }