CvvEditText extends ErrorEditText implements TextWatcher { @Override public boolean isValid() { return isOptional() || getText().toString().length() == getSecurityCodeLength(); } CvvEditText(Context context);  CvvEditText(Context context, AttributeSet attrs);  CvvEditText(Context context, AttributeSet attrs, int defStyle); void setCardType(CardType cardType); void setMask(boolean mask); @Override void afterTextChanged(Editable editable); @Override boolean isValid(); @Override String getErrorMessage(); @Override void beforeTextChanged(CharSequence s, int start, int count, int after);  }
@Test public void isValid_returnsFalseForInvalidCvv() { assertFalse(mView.isValid()); }
@Test public void isValid_returnsTrueForValidCvv() { type("123"); assertTrue(mView.isValid()); }
@Test public void isValid_returnsTrueForInvalidCvvWhenOptional() { mView.setOptional(true); assertTrue(mView.isValid()); }