### Question:
BucketedTextChangeListener implements TextWatcher { @SuppressLint("SetTextI18n") @Override public void onTextChanged(CharSequence s, int ignoredParam1, int ignoredParam2, int ignoredParam3) { final String numericContents = s.toString().replaceAll(" ", "").replaceAll(placeHolder, ""); final int enteredContentLength = Math.min(numericContents.length(), expectedContentLength); final String enteredContent = numericContents.substring(0, enteredContentLength); editText.removeTextChangedListener(this); editText.setText(enteredContent + postFixes[expectedContentLength - enteredContentLength]); editText.setSelection(enteredContentLength); editText.addTextChangedListener(this); if (enteredContentLength == expectedContentLength && callback != null) { callback.whileComplete(); } else if (callback != null) { callback.whileIncomplete(); } } BucketedTextChangeListener(EditText editText, int expectedContentLength, String
            placeHolder, ContentChangeCallback callback); @Override void beforeTextChanged(CharSequence s, int start, int count, int after); @SuppressLint("SetTextI18n") @Override void onTextChanged(CharSequence s, int ignoredParam1, int ignoredParam2, int
            ignoredParam3); @Override void afterTextChanged(Editable s);  }### Answer:
@Test public void testTextChange_empty() { textChangeListener.onTextChanged("------", anyInt, anyInt, anyInt); testListener(editText, "------", 0, false); }
@Test public void testTextChange_atIndex0() { textChangeListener.onTextChanged("1------", anyInt, anyInt, anyInt); testListener(editText, "1-----", 1, false); }
@Test public void testTextChange_atIndex1() { textChangeListener.onTextChanged("12-----", anyInt, anyInt, anyInt); testListener(editText, "12----", 2, false); }
@Test public void testTextChange_atIndex5() { textChangeListener.onTextChanged("123456-", anyInt, anyInt, anyInt); testListener(editText, "123456", 6, true); }
@Test public void testTextChange_exceedingMaxLength() { textChangeListener.onTextChanged("1234567", anyInt, anyInt, anyInt); testListener(editText, "123456", 6, true); }
@Test public void testTextChange_onClear() { textChangeListener.onTextChanged("", anyInt, anyInt, anyInt); testListener(editText, "------", 0, false); }
@Test public void testTextChange_onPartialClear() { textChangeListener.onTextChanged("123", anyInt, anyInt, anyInt); testListener(editText, "123---", 3, false); }
@Test public void testTextChange_onIncorrectInsertion() { textChangeListener.onTextChanged("1--3--", anyInt, anyInt, anyInt); testListener(editText, "13----", 2, false); }