ExpirationDateEditText extends ErrorEditText implements TextWatcher, View.OnClickListener { @Override public boolean isValid() { return isOptional() || DateValidator.isValid(getMonth(), getYear()); } ExpirationDateEditText(Context context);  ExpirationDateEditText(Context context, AttributeSet attrs);  ExpirationDateEditText(Context context, AttributeSet attrs, int defStyle); @Override void setOnClickListener(OnClickListener l); @Override void onClick(View v); String getMonth(); String getYear(); @Override boolean isValid(); @Override String getErrorMessage(); @Override void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter); @Override void afterTextChanged(Editable editable); @Override void beforeTextChanged(CharSequence s, int start, int count, int after);  }
@Test public void isValid_returnsFalseForInvalidDate() { assertFalse(mView.isValid()); }
@Test public void isValid_returnsTrueForValidDate() { setText("12" + getCurrent2DigitYear()); assertTrue(mView.isValid()); }
@Test public void isValid_returnsTrueForInvalidDateWhenOptional() { mView.setOptional(true); assertTrue(mView.isValid()); }