### Question:
Randoms { static int getCreditCardCheckDigit(final String number) { int sum = 0; final int remainder = (number.length() + 1) % 2; for (int i = 0; i < number.length(); i++) { int digit = Integer.parseInt(number.substring(i, (i + 1))); if ((i % 2) == remainder) { digit = digit * 2; if (digit > 9) { digit -= 9; } } sum += digit; } final int mod = sum % 10; final int checkDigit = ((mod == 0) ? 0 : 10 - mod); return checkDigit; }  static String randomString(final int length); static char randomChar(); static String randomString(); static String randomEmailAddress(); static String randomPhoneNumber(); static DateTime randomDateTime(); static LocalDateTime randomLocalDateTime(); static LocalDate randomLocalDate(); static LocalTime randomLocalTime(); static E randomEnum(final Class<E> enumClass); static Set<E> randomEnumSet(final Class<E> enumClass); static E randomEnumInSet(final Set<E> enumSet); static Set<T> randomSubset(final Set<T> set); static int randomInt(final int max); static float randomFloat(); static double randomDouble(); static long randomLong(); static boolean randomBoolean(); static BigDecimal randomBigDecimal(final int maxValue, final int precision); static BigDecimal randomPositiveBigDecimal(final int maxValue, final int precision); static int randomIntInRange(final int from, final int to); static String randomCreditCardNumber(final String prefix); static String randomId(); static T randomItem(final T[] array); static T randomItem(final Collection<T> collection); static Set<String> randomIdSet();  }### Answer:
@Test public void shouldGetCheckDigit() { final Map<String, Integer> knownCheckDigits = new HashMap<String, Integer>(); knownCheckDigits.put("37144963539843", Integer.valueOf(1)); knownCheckDigits.put("3434343434343", Integer.valueOf(4)); knownCheckDigits.put("401288888888188", Integer.valueOf(1)); knownCheckDigits.put("411111111111111", Integer.valueOf(1)); knownCheckDigits.put("545454545454545", Integer.valueOf(4)); knownCheckDigits.put("540400000000006", Integer.valueOf(8)); knownCheckDigits.put("675964982643845", Integer.valueOf(3)); knownCheckDigits.put("679999010000000001", Integer.valueOf(9)); for (final Entry<String, Integer> entry : knownCheckDigits.entrySet()) { final int checkDigit = Randoms.getCreditCardCheckDigit(entry.getKey()); assertEquals("Check digit not as expected", entry.getValue(), Integer.valueOf(checkDigit)); } }