@Test
public void shouldSetCookieAndPersistForValidSession() throws IOException {

    HttpSessionImpl session = new HttpSessionImpl("123", System.currentTimeMillis());
    servletContext.handleSession(session, response);
    verify(sessionStorage, times(1)).persistSession(session);
    assertThat(response.getCookies().size(), is(greaterThan(0)));
    for (Cookie cookie : response.getCookies()) {
        if (cookie.getName().equals(HttpSessionImpl.COOKIE_NAME)) {
            assertThat(cookie.getValue(), is(not(nullValue())));
            return;
        }
    }
    fail("Session cookie was not set.");
}