### Question:
CreditCardTypeConverter implements TypeConverter<String> { public String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors) { String cardNumber = input.replaceAll("\\D", ""); if (getCardType(cardNumber) != null) { return cardNumber; } errors.add(new ScopedLocalizableError("converter.creditCard", "invalidCreditCard")); return null; }  void setLocale(Locale locale); String convert(String input, Class<? extends String> targetType, Collection<ValidationError> errors); static Type getCardType(String cardNumber);  }### Answer:
@Test(groups = "fast") public void validNumber() { CreditCardTypeConverter c = new CreditCardTypeConverter(); Assert.assertEquals(c.convert("4111111111111111", String.class, new ArrayList<ValidationError>()), "4111111111111111"); }
@Test(groups = "fast") public void invalidNumber() { CreditCardTypeConverter c = new CreditCardTypeConverter(); Assert.assertNull(c.convert("4111111111111110", String.class, new ArrayList<ValidationError>())); }
@Test(groups = "fast") public void stripNonNumericCharacters() { CreditCardTypeConverter c = new CreditCardTypeConverter(); Assert.assertEquals(c.convert("4111-1111-1111-1111", String.class, new ArrayList<ValidationError>()), "4111111111111111"); }