Repository: netty/netty
File: codec-base/src/test/java/io/netty/handler/codec/DefaultHeadersTest.java (Java)

Code before:
        assertTrue(headers.containsAny(of("h1"), of("value"), containsPredicate));
        assertFalse(headers.containsAny(of("h1"), of("missing"), containsPredicate));
    }

    @Test
    public void containsAnyHandlesHashCollisions() {
        TestDefaultHeaders headers = new TestDefaultHeaders(new HashingStrategy<CharSequence>() {
            @Override
            public int hashCode(CharSequence obj) {
                return 0; // force collisions
            }

            @Override
            public boolean equals(CharSequence a, CharSequence b) {
                return a.equals(b);
            }
        });

        headers.add(of("name1"), of("value1"));
        headers.add(of("name2"), of("value2"));

        BiPredicate<CharSequence, CharSequence> eq = Object::equals;

        assertTrue(headers.containsAny(of("name1"), of("value1"), eq));
        assertTrue(headers.containsAny(of("name2"), of("value2"), eq));
        assertFalse(headers.containsAny(of("name1"), of("no"), eq));
    }

    @Test
    public void containsAnyShouldValidateArguments() {
        final TestDefaultHeaders headers = newInstance();
        headers.add(of("n"), of("v"));

        assertThrows(NullPointerException.class, () -> headers.containsAny(null, of("v"), (stored, arg) -> false));

        assertThrows(NullPointerException.class, () -> headers.containsAny(of("n"), of("v"), null));
    }
}


Review comment (suggestion):
```suggestion
        assertFalse(headers.containsAny(of("name1"), of("no"), eq));
        assertFalse(headers.containsAny(of("name1"), of("value2"), eq));
        assertFalse(headers.containsAny(of("name2"), of("value1"), eq));
```

This would also be an interesting case to test.

Code after:
        assertTrue(headers.containsAny(of("h1"), of("value"), containsPredicate));
        assertFalse(headers.containsAny(of("h1"), of("missing"), containsPredicate));
    }

    @Test
    public void containsAnyHandlesHashCollisions() {
        TestDefaultHeaders headers = new TestDefaultHeaders(new HashingStrategy<CharSequence>() {
            @Override
            public int hashCode(CharSequence obj) {
                return 0; // force collisions
            }

            @Override
            public boolean equals(CharSequence a, CharSequence b) {
                return a.equals(b);
            }
        });

        headers.add(of("name1"), of("value1"));
        headers.add(of("name2"), of("value2"));

        BiPredicate<CharSequence, CharSequence> eq = Object::equals;

        assertTrue(headers.containsAny(of("name1"), of("value1"), eq));
        assertTrue(headers.containsAny(of("name2"), of("value2"), eq));
        assertFalse(headers.containsAny(of("name1"), of("no"), eq));
        assertFalse(headers.containsAny(of("name1"), of("value2"), eq));
        assertFalse(headers.containsAny(of("name2"), of("value1"), eq));
    }

    @Test
    public void containsAnyShouldValidateArguments() {
        final TestDefaultHeaders headers = newInstance();
        headers.add(of("n"), of("v"));

        assertThrows(NullPointerException.class, () -> headers.containsAny(null, of("v"), (stored, arg) -> false));

        assertThrows(NullPointerException.class, () -> headers.containsAny(of("n"), of("v"), null));
    }
}