### Question:
RandomIdProvider implements SessionIdProvider { @Override public String newId() { final byte[] bytes = new byte[length]; random.nextBytes(bytes); return new String(encode(bytes)); } RandomIdProvider();   RandomIdProvider(int length); @Override String newId(); @Override String readId(String value); @Override void configure(SessionConfiguration configuration);  }### Answer:
@Test public void testNewId() { RandomIdProvider provider = new RandomIdProvider(); assertEquals(40, provider.newId().length()); assertThat(provider.newId(), RegexMatchers.matchesPattern("[A-Za-z0-9_\\-]{40}")); }
@Test public void testNewIdWith40Characters() { RandomIdProvider provider = new RandomIdProvider(40); assertEquals(56, provider.newId().length()); assertThat(provider.newId(), RegexMatchers.matchesPattern("[A-Za-z0-9_\\-]{56}")); }