### Question:
ServerCookieEncoder extends CookieEncoder { String encode(String name, String value) { return encode(new DefaultCookie(name, value)); } private  ServerCookieEncoder(boolean strict);   }### Answer:
@Test public void removesMaxAgeInFavourOfExpireIfDateIsInThePast() { String cookieValue = "hp_pos=\"\"; Domain=.dev-hotels.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/"; Cookie cookie = ClientCookieDecoder.LAX.decode(cookieValue); String encodedCookieValue = ServerCookieEncoder.LAX.encode(cookie); assertThat(encodedCookieValue, not(containsString("Max-Age=0"))); assertThat(encodedCookieValue, containsString("Expires=Thu, 01 Jan 1970 00:00")); }
@Test public void willNotModifyMaxAgeIfPositive() { String cookieValue = "hp_pos=\"\"; Domain=.dev-hotels.com; Max-Age=50; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/"; Cookie cookie = ClientCookieDecoder.LAX.decode(cookieValue); assertThat(cookie.maxAge(), is(50L)); assertThat(ServerCookieEncoder.LAX.encode(cookie), containsString("Max-Age=50")); }
@Test public void setValidSameSite() { DefaultCookie cookie = new DefaultCookie("key", "value"); cookie.setSameSite(SameSite.Lax); cookie.setDomain(".domain.com"); cookie.setMaxAge(50); assertThat(ServerCookieEncoder.LAX.encode(cookie), containsString("Lax")); }