@Test
void parseInvalidCookie() {

    var headers = new HeaderMap();
    headers.put(Headers.COOKIE, "value");
    var exchange = mock(HttpServerExchange.class);
    when(exchange.getRequestHeaders()).thenReturn(headers);
    // refer to io.undertow.UndertowMessages.tooManyCookies
    // refer to io.undertow.UndertowMessages.couldNotParseCookie
    when(exchange.requestCookies())
            .thenThrow(new IllegalStateException("UT000046: The number of cookies sent exceeded the maximum of 200"))
            .thenThrow(new IllegalArgumentException("UT000069: Could not parse set cookie header value"));
    assertThatThrownBy(() -> parser.parseCookies(null, exchange))
            .isInstanceOf(BadRequestException.class)
            .satisfies(e -> assertThat(((BadRequestException) e).errorCode()).isEqualTo("INVALID_COOKIE"));
    assertThatThrownBy(() -> parser.parseCookies(null, exchange))
            .isInstanceOf(BadRequestException.class)
            .satisfies(e -> assertThat(((BadRequestException) e).errorCode()).isEqualTo("INVALID_COOKIE"));
}