### Question:
VerhoeffIdentifierValidator extends BaseHyphenatedIdentifierValidator { @Override protected int getCheckDigit(String undecoratedIdentifier) { int[] a = getBase(Integer.parseInt(undecoratedIdentifier), undecoratedIdentifier.length()); insertCheck(a); return a[0]; } VerhoeffIdentifierValidator(); @Override String getAllowedCharacters(); @Override String getName(); @Override boolean isValid(String identifier); @Override String getValidIdentifier(String undecoratedIdentifier);  }### Answer:
@Test public void checkDigit_shouldChangeWhenAdjacentCharsAreTransposed() { VerhoeffIdentifierValidator validator = new VerhoeffIdentifierValidator(); String test; int checkDigit; String pre; String post; int failures = 0; StringBuilder failureMsg = new StringBuilder(); char c; char d; final String lineSeparator = System.getProperty("line.separator"); for (String allowedIdentifier: allowedIdentifiers) { for (int i = 0; i < allowedIdentifier.length(); i++) { checkDigit = validator.getCheckDigit(allowedIdentifier); for (int j = 1; j < allowedIdentifier.length(); j++) { c = allowedIdentifier.charAt(j - 1); d = allowedIdentifier.charAt(j); if (c != d) { pre = allowedIdentifier.substring(0, j - 1); post = allowedIdentifier.substring(j + 1); test = pre + d + c + post; if (checkDigit == validator.getCheckDigit(test)) { failureMsg.append("Check digits for '"); failureMsg.append(allowedIdentifier); failureMsg.append("' and '"); failureMsg.append(test); failureMsg.append("' should be different, both were "); failureMsg.append(checkDigit); failureMsg.append(lineSeparator); failures++; } } } allowedIdentifier = allowedIdentifier.substring(1, allowedIdentifier.length()) + allowedIdentifier.charAt(0); } } assertTrue(failures + " transposed digits were not detected:\n" + failureMsg, failures == 0); }