IdGenerator { public static String generate() { long time = new Date().getTime(); String head = stringify(time); return head + nextTail(); }  static String generate();  }
@Test public void testGenerate() throws InterruptedException { String a = IdGenerator.generate(); Thread.sleep(2); String b = IdGenerator.generate(); assertNotEquals(a, b); }
@Test public void testQuickGenerate() { Set<String> ids = new HashSet<>(); for (int i=0; i<58; i++) { String id = IdGenerator.generate(); assertThat(ids.add(id), is(true)); } }