### Question:
ExpiryDateEditText extends StripeEditText { @Nullable @Size(2) public int[] getValidDateFields() { if (!mIsDateValid) { return null; } int [] monthYearPair = new int[2]; String rawNumericInput = getText().toString().replaceAll("/", ""); String[] dateFields = DateUtils.separateDateStringParts(rawNumericInput); try { monthYearPair[0] = Integer.parseInt(dateFields[0]); monthYearPair[1] = DateUtils.convertTwoDigitYearToFour(Integer.parseInt(dateFields[1])); } catch (NumberFormatException numEx) { return null; } return monthYearPair; } 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 getValidDateFields_whenDataIsValid_returnsExpectedValues() { assertTrue(Calendar.getInstance().get(Calendar.YEAR) < 2050); mExpiryDateEditText.append("12"); mExpiryDateEditText.append("50"); int [] retrievedDate = mExpiryDateEditText.getValidDateFields(); assertNotNull(retrievedDate); assertEquals(12, retrievedDate[0]); assertEquals(2050, retrievedDate[1]); }
@Test public void getValidDateFields_whenDateIsValidFormatButExpired_returnsNull() { assertTrue(Calendar.getInstance().get(Calendar.YEAR) < 2080); mExpiryDateEditText.append("12"); mExpiryDateEditText.append("12"); assertNull(mExpiryDateEditText.getValidDateFields()); }
@Test public void getValidDateFields_whenDateIsIncomplete_returnsNull() { mExpiryDateEditText.append("4"); assertNull(mExpiryDateEditText.getValidDateFields()); }
@Test public void getValidDateFields_whenDateIsValidAndThenChangedToInvalid_returnsNull() { assertTrue(Calendar.getInstance().get(Calendar.YEAR) < 2050); mExpiryDateEditText.append("12"); mExpiryDateEditText.append("50"); ViewTestUtils.sendDeleteKeyEvent(mExpiryDateEditText); assertNull(mExpiryDateEditText.getValidDateFields()); }