### Question:
ExpiryDateEditText extends StripeEditText { public boolean isDateValid() { return mIsDateValid; } ExpiryDateEditText(Context context);  ExpiryDateEditText(Context context, AttributeSet attrs);  ExpiryDateEditText(Context context, AttributeSet attrs, int defStyleAttr); boolean isDateValid(); @Nullable @Size(2) int[] getValidDateFields(); void setExpiryDateEditListener(ExpiryDateEditListener expiryDateEditListener);  }### Answer:
@Test public void afterAddingFinalDigit_whenGoingFromInvalidToValid_callsListener() { if (Calendar.getInstance().get(Calendar.YEAR) > 2059) { fail("Update the code with a date that is still valid. Also, hello from the past."); } mExpiryDateEditText.append("1"); mExpiryDateEditText.append("2"); mExpiryDateEditText.append("5"); verifyZeroInteractions(mExpiryDateEditListener); mExpiryDateEditText.append("9"); assertTrue(mExpiryDateEditText.isDateValid()); verify(mExpiryDateEditListener, times(1)).onExpiryDateComplete(); }
@Test public void afterAddingFinalDigit_whenDeletingItem_revertsToInvalidState() { if (Calendar.getInstance().get(Calendar.YEAR) > 2059) { fail("Update the code with a date that is still valid. Also, hello from the past."); } mExpiryDateEditText.append("12"); mExpiryDateEditText.append("59"); assertTrue(mExpiryDateEditText.isDateValid()); ViewTestUtils.sendDeleteKeyEvent(mExpiryDateEditText); verify(mExpiryDateEditListener, times(1)).onExpiryDateComplete(); assertFalse(mExpiryDateEditText.isDateValid()); }