### Question:
RandomAlphanumericGenerator implements Generator<String> { @Override public String next() { return RandomStringUtils.randomAlphanumeric(length); } RandomAlphanumericGenerator(int length); @Override String next();  }### Answer:
@Test public void shouldReturnRandomAlphaNumericString() { int length = 33; Generator<String> randomAlphaNumericGenerator = new RandomAlphanumericGenerator(length); int letters = 0; int numbers = 0; Set<String> generatedStrings = newHashSet(); for (int i = 0; i < 100; i++) { String nextString = randomAlphaNumericGenerator.next(); generatedStrings.add(nextString); if (CharMatcher.JAVA_LETTER.matchesAnyOf(nextString)) { letters++; } if (CharMatcher.JAVA_DIGIT.matchesAnyOf(nextString)) { numbers++; } assertThat(nextString.length(), is(33)); assertThat(JAVA_LETTER_OR_DIGIT.matchesAllOf(nextString), is(true)); } assertThat(generatedStrings, hasSize(100)); assertThat(letters, greaterThan(5)); assertThat(numbers, greaterThan(5)); }
@Test public void shouldGenerateBlankString() { assertThat(new RandomAlphabeticStringGenerator(0).next(), is("")); }