@Test public void isInputAcceptable_rejects_any_other_character() { String[] numbers = {"1a234567", "1A234567", "1+234567", "1%234567", "1\n234567", "1\t234567"}; for (String number : numbers) { boolean accept = CardNumberCleaner.isInputAcceptable(number); assertFalse(accept); } }
protected static boolean isInputAcceptable(String cardNumber) { String regex = "[0-9"; for (String spacing : CreditCard4J.ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS) { regex += spacing; } regex += "]*"; return cardNumber.matches(regex); }
CardNumberCleaner { protected static boolean isInputAcceptable(String cardNumber) { String regex = "[0-9"; for (String spacing : CreditCard4J.ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS) { regex += spacing; } regex += "]*"; return cardNumber.matches(regex); } }
CardNumberCleaner { protected static boolean isInputAcceptable(String cardNumber) { String regex = "[0-9"; for (String spacing : CreditCard4J.ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS) { regex += spacing; } regex += "]*"; return cardNumber.matches(regex); }  }
CardNumberCleaner { protected static boolean isInputAcceptable(String cardNumber) { String regex = "[0-9"; for (String spacing : CreditCard4J.ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS) { regex += spacing; } regex += "]*"; return cardNumber.matches(regex); }  static String clean(String cardNumber); }
CardNumberCleaner { protected static boolean isInputAcceptable(String cardNumber) { String regex = "[0-9"; for (String spacing : CreditCard4J.ALLOWED_CARD_NUMBERS_SPACING_CHARACTERS) { regex += spacing; } regex += "]*"; return cardNumber.matches(regex); }  static String clean(String cardNumber);  }