ExpirationDateEditText extends ErrorEditText implements TextWatcher, View.OnClickListener { public String getYear() { String string = getString(); if (string.length() == 4 || string.length() == 6) { return getString().substring(2); } return ""; } 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 getYear() { assertEquals("getYear() should be \"\" if text is empty", "", mView.getYear()); setText("01"); assertEquals("", mView.getYear()); type('1'); assertEquals("getYear() doesn't return unformatted years", "", mView.getYear()); type('8'); assertEquals("18", mView.getYear()); setText("012018"); assertEquals("getYear() will return 4-digit years", "2018", mView.getYear()); }