@Test public void clean_with_a_null_number_fails() { this.expectedEx.expect(IllegalArgumentException.class); CardNumberCleaner.clean(null); }
public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); } }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  static String clean(String cardNumber); }
CardNumberCleaner { public static String clean(String cardNumber) { checkNotNull("Invalid card number", cardNumber); if (!isInputAcceptable(cardNumber)) { throw new IllegalArgumentException("Invalid card number (unauthorized characters)"); } return cardNumber.replaceAll("[^\\d]", ""); }  static String clean(String cardNumber);  }