### Question:
CountryAdapter extends ArrayAdapter { @NonNull @Override public Filter getFilter() { return mFilter; } CountryAdapter(Context context, List<String> countries); @Override int getCount(); @Override String getItem(int i); @Override long getItemId(int i); @Override View getView(int i, View view, ViewGroup viewGroup); @NonNull @Override Filter getFilter();  }### Answer:
@Test public void filter_whenCountryInputNoMatch_showsAllResults() { Filter filter = mCountryAdapter.getFilter(); filter.filter("NONEXISTANT COUNTRY"); int countryLength = mCountryAdapter.mCountries.size(); assertEquals(mCountryAdapter.mSuggestions.size(), countryLength); }
@Test public void filter_whenCountryInputMatches_filters() { Filter filter = mCountryAdapter.getFilter(); int countryLength = mCountryAdapter.mCountries.size(); filter.filter("a"); assertTrue(mCountryAdapter.mSuggestions.size() < countryLength); for (String suggestedCountry: mCountryAdapter.mSuggestions) { assertTrue(suggestedCountry.toLowerCase().startsWith("a")); } }
@Test public void filter_whenCountryInputMatchesExactly_showsAllResults() { Filter filter = mCountryAdapter.getFilter(); int countryLength = mCountryAdapter.mCountries.size(); filter.filter("Uganda"); assertEquals(mCountryAdapter.mSuggestions.size(), countryLength); }