@Test
    public void testFilter() {
        final Handle h = h2Extension.getSharedHandle();

        int id = 0;
        for (final String name : new String[] {null, "john", "lennon", "would have liked", "java"}) {
            h.execute("insert into something (id, name) values (?, ?)", ++id, name);
        }

        final ResultIterable<String> ri1 = h.createQuery("select name from something").mapTo(String.class);

        assertThatThrownBy(() -> ri1.filter(null)).isInstanceOf(NullPointerException.class)
                .hasMessage("Filter required");

        final var startsWithJPredicate = new Predicate<String>() {
            int times;
            @Override
            public boolean test(final String s) {
                times++;
                return s != null && s.startsWith("j");
            }
        };
        final var containsHPredicate = new Predicate<String>() {
            int times;
            @Override
            public boolean test(final String s) {
                times++;
                return s.contains("h");
            }
        };

        final ResultIterable<String> ri2 = ri1
                .filter(startsWithJPredicate)
                .filter(containsHPredicate);

        // as iteration has not yet taken place, test filters were not invoked
        assertThat(startsWithJPredicate.times).isZero();
        assertThat(containsHPredicate.times).isZero();

        assertThat(ri1).isNotSameAs(ri2);

        final ResultIterator<String> iter = ri2.iterator();
        // mess with the resultset by calling hasNext repeatedly
        IntStream.range(0, 5).forEach(i -> assertThat(iter).hasNext());

        final List<String> results = new ArrayList<>();
        while (iter.hasNext()) {
            results.add(iter.next());
        }

        // the first filter should have seen all records
        assertThat(startsWithJPredicate.times).isEqualTo(5);
        // the second filter only two records that matched the first filter
        assertThat(containsHPredicate.times).isEqualTo(2);

        assertThatThrownBy(iter::next).isInstanceOf(NoSuchElementException.class)
                .hasMessage("No more filtered results");

        assertThat(results).containsExactly("john");
    }
Test bean with a single member {@code name} of type {@link CharSequence}.
core/src/test/java/org/jdbi/v3/core/statement/TestQueries.java