### Question:
Cookies { public void remove(String cookie) { List<Header> cookieHeaders = getHeader(HttpHeaders.COOKIE); for (Header header: cookieHeaders) { List<HttpCookie> cookieList = getAllCookiesFromHeader(header); cookieList = cookieList.stream() .filter(c -> !c.getName().equalsIgnoreCase(cookie)) .collect(Collectors.toList()); if (cookieList.isEmpty()) { request.removeHeaders(HttpHeaders.COOKIE); } else { request.setHeader(getCookieHeader(cookieList)); } } } private  Cookies(HttpRequest request); static Cookies of(HttpRequest request); List<HttpCookie> getAll(); List<HttpCookie> get(String needle); void set(HttpCookie cookie); void remove(String cookie);  }### Answer:
@Test void givenRequestWithCookieHeaderWithSingleCookie_whenRemoveCookie_thenRemovesCookieAndHeader() { doReturn(new Header[] { cookieSingle}).when(request).getHeaders(HttpHeaders.COOKIE); underTest.remove("cookie"); verify(request).removeHeaders(HttpHeaders.COOKIE); }
@Test void givenRequestWithCookieHeaderWithMultipleCookies_whenRemoveCookie_thenRemovesCookie() { doReturn(new Header[] { cookieMultiple}).when(request).getHeaders(HttpHeaders.COOKIE); ArgumentCaptor<Header> argument = ArgumentCaptor.forClass(Header.class); underTest.remove("cookie1"); verify(request).setHeader(argument.capture()); assertThat(argument.getValue().toString(), is("Cookie: cookie2=cookie2;cookie3=cookie3")); }