ExpirationDateEditText extends ErrorEditText implements TextWatcher, View.OnClickListener { public String getMonth() { String string = getString(); if (string.length() < 2) { return ""; } return getString().substring(0,2); } 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 getMonth() { assertEquals("getMonth() should be \"\" if text is empty", "", mView.getMonth()); setText("1"); assertEquals("", mView.getMonth()); setText("01"); assertEquals("01", mView.getMonth()); setText("0218"); assertEquals("02", mView.getMonth()); setText("032018"); assertEquals("03", mView.getMonth()); }