@Test
    void verifyExistingCookieInResponse() {
        val context = getCookieGenerationContext();
        val request = new MockHttpServletRequest();
        val response = new MockHttpServletResponse();
        val cookieValueManager = new NoOpCookieValueManager(tenantExtractor);
        val gen = CookieUtils.buildCookieRetrievingGenerator(cookieValueManager, context);

        var cookie = gen.addCookie(request, response, "some-value");
        assertNotNull(cookie);
        var headers = response.getHeaders("Set-Cookie");
        assertEquals(1, headers.size());
        assertTrue(headers.getFirst().contains(context.getName() + '=' + cookie.getValue()));

        cookie = gen.addCookie(request, response, "updated-value");
        assertNotNull(cookie);
        headers = response.getHeaders("Set-Cookie");
        assertEquals(1, headers.size());
        assertTrue(headers.getFirst().contains(context.getName() + '=' + cookie.getValue()));
    }
This is {@link CookieRetrievingCookieGeneratorTests}.

@author Misagh Moayyed
@since 6.0.0
core/cas-server-core-cookie/src/test/java/org/apereo/cas/web/support/CookieRetrievingCookieGeneratorTests.java