### Question:
ApiKeyGenerator { public static String generate() { return generate(32); } private  ApiKeyGenerator(); static String generate(); static String generate(final int chars);  }### Answer:
@Test public void defaultGenerateTest() { String key = ApiKeyGenerator.generate(); Assert.assertEquals(32, key.length()); Assert.assertTrue(pattern.matcher(key).matches()); }
@Test public void generateTest() { String key = ApiKeyGenerator.generate(4096); Assert.assertEquals(4096, key.length()); Assert.assertTrue(pattern.matcher(key).matches()); }