### Question:
CardUtils { static boolean isValidCardLength(@Nullable String cardNumber) { return cardNumber != null && isValidCardLength(cardNumber, getPossibleCardType(cardNumber, false)); }  @NonNull @Card.CardBrand static String getPossibleCardType(@Nullable String cardNumber); static boolean isValidCardNumber(@Nullable String cardNumber);  }### Answer:
@Test public void isValidCardLength_whenValidVisaNumber_returnsTrue() { assertTrue(CardUtils.isValidCardLength("4242424242424242")); }
@Test public void isValidCardLength_whenValidJCBNumber_returnsTrue() { assertTrue(CardUtils.isValidCardLength("3530111333300000")); }
@Test public void isValidCardLength_whenValidDiscover_returnsTrue() { assertTrue(CardUtils.isValidCardLength("6011000990139424")); }
@Test public void isValidCardLength_whenValidDinersClub_returnsTrue() { assertTrue(CardUtils.isValidCardLength("30569309025904")); }
@Test public void isValidCardLength_whenValidMasterCard_returnsTrue() { assertTrue(CardUtils.isValidCardLength("5555555555554444")); }
@Test public void isValidCardLength_whenValidAmEx_returnsTrue() { assertTrue(CardUtils.isValidCardLength("378282246310005")); }
@Test public void isValidCardLength_whenNull_returnsFalse() { assertFalse(CardUtils.isValidCardLength(null)); }
@Test public void isValidCardLength_whenVisaStyleNumberButDinersClubLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("42424242424242")); }
@Test public void isValidCardLength_whenVisaStyleNumberButAmExLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("424242424242424")); }
@Test public void isValidCardLength_whenAmExStyleNumberButVisaLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("3782822463100050")); }
@Test public void isValidCardLength_whenAmExStyleNumberButDinersClubLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("37828224631000")); }
@Test public void isValidCardLength_whenDinersClubStyleNumberButVisaLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("3056930902590400")); }
@Test public void isValidCardLength_whenDinersClubStyleNumberStyleNumberButAmexLength_returnsFalse() { assertFalse(CardUtils.isValidCardLength("305693090259040")); }
@Test public void isValidCardLengthWithBrand_whenBrandUnknown_alwaysReturnsFalse() { String validVisa = "4242424242424242"; assertTrue(CardUtils.isValidCardLength(validVisa)); assertFalse(CardUtils.isValidCardLength(validVisa, Card.UNKNOWN)); }