TokenGeneratorImpl implements TokenGenerator { @Override public String generateToken() { SecureRandom random = new SecureRandom(); return new BigInteger(130, random).toString(32); }  @Override String generateToken(); @Override String generateToken(int maxLength);  }
@Test public void testGenerateToken() throws Exception { final String value1 = sut.generateToken(); final String value2 = sut.generateToken(); assertTrue(StringUtils.hasText(value1)); assertTrue(StringUtils.hasText(value2)); assertNotEquals(value1, value2); }
@Test public void testGenerateToken1() throws Exception { final int maxLength = 7; final String value1 = sut.generateToken(maxLength); final String value2 = sut.generateToken(maxLength); assertTrue(StringUtils.hasText(value1)); assertTrue(StringUtils.hasText(value2)); assertNotEquals(value1, value2); assertTrue(value1.length() <= maxLength); assertTrue(value2.length() <= maxLength); }