private void internalTest(final DefaultCsrfTokenGenerator generator, final boolean rotate) {
        final WebContext context = MockWebContext.create();
        final SessionStore sessionStore = new MockSessionStore();
        val token = generator.get(context, sessionStore);
        assertNotNull(token);
        val token2 = (String) sessionStore.get(context, Pac4jConstants.CSRF_TOKEN).orElse(null);
        assertEquals(token, token2);
        final long expirationDate = (Long) sessionStore.get(context, Pac4jConstants.CSRF_TOKEN_EXPIRATION_DATE).orElse(null);
        val nowPlusTtl = new Date().getTime() + 1000 * generator.getTtlInSeconds();
        assertTrue(expirationDate > nowPlusTtl - 1000);
        assertTrue(expirationDate < nowPlusTtl + 1000);
        var newToken = generator.get(context, sessionStore);
        val token3 = (String) sessionStore.get(context, Pac4jConstants.PREVIOUS_CSRF_TOKEN).orElse(null);
        val token4 = (String) sessionStore.get(context, Pac4jConstants.CSRF_TOKEN).orElse(null);
        assertEquals(token, token3);
        assertEquals(token4, newToken);
        if (rotate) {
            assertNotEquals(token, token4);
        } else {
            assertEquals(token, token4);
        }
    }
Tests {@link DefaultCsrfTokenGenerator}.

@author Jerome Leleu
@since 1.8.0
pac4j-core/src/test/java/org/pac4j/core/matching/matcher/csrf/DefaultCsrfTokenGeneratorTests.java