@Test
public void testGenerateRandomAlphaNumericString_withProvidedRandom() {

    int length = 10;
    StringBuilder strBuilder = new StringBuilder();
    for (int i = 0; i < length; i++) {
        strBuilder.append("a");
    }
    Random rand = mock(Random.class);
    when(rand.nextInt(anyInt())).thenReturn(0);
    String result = RandomStringUtils.generateRandomAlphaNumericString(length, rand);
    assertEquals(length, result.length());
    assertEquals(strBuilder.toString(), result);
}