AppsPresenter { protected List<App> filter(String filter) { List<App> installedApps = appsProvider.findInstalledApps(); List<App> result = new ArrayList<>(installedApps); for (App app : installedApps) { if (!app.matches(filter)) { result.remove(app); } } return result; } AppsPresenter(AppsActivity appsActivity, AppsProvider appsProvider); void showAllApps(); void filterApps(String text);  }
@Test public void should_filter() throws Exception { when(appsProvider.findInstalledApps()).thenReturn(Arrays.asList(new App("AAA"), new App("BBB"))); List<App> result = appsPresenter.filter("A"); assertThat(result).hasSize(1); assertThat(result.get(0).title).isEqualTo("AAA"); }