SmartRegisterClients extends ArrayList<SmartRegisterClient> { public SmartRegisterClients applyFilterWithFP(final ServiceModeOption serviceModeOption, SortOption sortOption, final FilterOption... filterOptions) { SmartRegisterClients results = new SmartRegisterClients(); Iterables.addAll(results, Iterables.filter(this, new Predicate<SmartRegisterClient>() { @Override public boolean apply(SmartRegisterClient client) { boolean isClientToBeFiltered = true; for (FilterOption filterOption : filterOptions) { isClientToBeFiltered = isClientToBeFiltered && filterOption.filter(client); } return isClientToBeFiltered; } })); serviceModeOption.apply(); return sortOption.sort(results); }  SmartRegisterClients applyFilter(final FilterOption villageFilter, final ServiceModeOption serviceModeOption,
                                            final FilterOption searchFilter, SortOption sortOption); SmartRegisterClients applyFilterWithFP(final ServiceModeOption serviceModeOption, SortOption sortOption, final FilterOption... filterOptions);  }
@Test public void ShouldReturnFilteredListForFP() { when(applicationContext.getString(R.string.fp_register_service_mode_condom)).thenReturn("Condom"); SmartRegisterClients originalClients = getFPSmartRegisterClientsWithProperDetails(); SmartRegisterClients filteredClients = originalClients.applyFilterWithFP(fpAllMethodsServiceMode, new NameSort(), new FPMethodFilter("condom")); assertEquals(2, filteredClients.size()); assertEquals("Akshara", filteredClients.get(0).name()); assertEquals("Bhagya", filteredClients.get(1).name()); }