UIDCorrelationIdGenerator implements java.util.function.Supplier<String> { @Override public String get() { return UUID.randomUUID().toString(); }  @Override String get();  }
@Test void testIdsAreUniqueOverMultipleInstances() { int numGenerators = 5; int numIds = 100000; UIDCorrelationIdGenerator[] generators = new UIDCorrelationIdGenerator[numGenerators]; for (int generator = 0; generator < numGenerators; generator++) { generators[generator] = new UIDCorrelationIdGenerator(); } HashSet<String> idSet = new HashSet<>(); for (int id = 0; id < numIds; id++) { for (int generator = 0; generator < numGenerators; generator++) { idSet.add(generators[generator].get()); } } assertEquals(idSet.size(), numGenerators * numIds); }