public static <T extends BaseGeocacheFilter> boolean testSingleDb(final GeocacheFilterType type, final Action1<Geocache> cacheSetter, final Action1<T> filterSetter, final Boolean expectedResult) {
        if (expectedResult == null) {
            return false;
        }

        final Pair<Geocache, T> data = prepareData(type, cacheSetter, filterSetter);
        final Geocache cache = data.first;
        final T filter = data.second;

        final String geocode = "GCFILTERTEST" + DB_CACHE_INDEX.addAndGet(1);
        cache.setGeocode(geocode);

        final AndGeocacheFilter filterConfig = new AndGeocacheFilter();
        filterConfig.addChild(filter);
        final GeocodeGeocacheFilter geocodeFilter = new GeocodeGeocacheFilter();
        geocodeFilter.getStringFilter().setTextValue(geocode);
        filterConfig.addChild(geocodeFilter);

        final GeocacheFilter gcFilter = GeocacheFilter.create("", false, false, filterConfig);
        final SearchResult sr;
        try {
            DataStore.storeIntoDatabase(cache);
            sr = DataStore.getBatchOfStoredCaches(null, -1, gcFilter, null, false, 1);

        } finally {
            DataStore.removeCache(cache.getGeocode(), EnumSet.of(LoadFlags.RemoveFlag.CACHE, LoadFlags.RemoveFlag.DB));
        }


        final SqlBuilder sqlBuilder = new SqlBuilder("cache-table", new String[]{"*"});
        filter.addToSql(sqlBuilder);
        final String descr = "DB: Wrong test result for filter: " + filter.getConfig() + "/cache: " + cache + "/SQL: " + sqlBuilder.toString();

        if (sr.getCount() > 1) {
            fail("DB: very wrong result, cnt=" + sr.getCount() + " for '" + descr + "'");
        }

        final boolean result = sr.getCount() == 1 && sr.getGeocodes().iterator().next().equals(geocode);

        assertThat(result).as(descr).isEqualTo(expectedResult);

        return result;
    }
Standard method. Tests for a given cache and filter whether it is correctly filtered via logic AND DB!
main/src/androidTest/java/cgeo/geocaching/filters/GeocacheFilterTestUtils.java