StringIdGeneratorAlphaNumericImpl implements StringIdGenerator { @Override public boolean isValidId(String id) { return id != null && id.length() == length && checkChars(id); } StringIdGeneratorAlphaNumericImpl();  StringIdGeneratorAlphaNumericImpl(int length); @Override String generateNewId(Object optionalDto); @Override boolean isValidId(String id); int getLength(); void setLength(int length); String getAlphabet(); void setAlphabet(String alphabet);  }
@Test public void testIsValidId() { StringIdGenerator f = new StringIdGeneratorAlphaNumericImpl(); for (int i = 0; i < 1000; i++) { String result = f.generateNewId(null); assertNotNull(result); assertEquals(8, result.length()); assertTrue(f.isValidId(result)); } }