CodeGenerator { public static String generateUid() { return generateCode( CODESIZE ); }  static String generateUid(); static String generateCode( int codeSize ); static boolean isValidUid( String code ); static String getRandomUrlToken(); static final String letters; static final String ALLOWED_CHARS; static final int NUMBER_OF_CODEPOINTS; static final int CODESIZE; }
@Test public void testGetUid() { int numberOfCodes = 500; Set<String> codes = new HashSet<>(); for ( int n = 0; n < numberOfCodes; ++n ) { String code = CodeGenerator.generateUid(); assertTrue( code.substring( 0, 1 ).matches( "[a-zA-Z]" ) ); assertTrue( code.matches( "[0-9a-zA-Z]{11}" ) ); assertTrue( codes.add( code ) ); } }