@Test
    void testCacheStats() {
        var dao = new CachingPersonAttributeDaoImpl();
        dao.setCachedPersonAttributesDao(stubDao);
        dao.setUsernameAttributeProvider(new SimpleUsernameAttributeProvider(DEFAULT_ATTR));
        dao.setUserInfoCache(new HashMap<>());
        dao.afterPropertiesSet();

        assertEquals(0, dao.getQueries());
        assertEquals(0, dao.getMisses());

        var result = dao.getPerson("edalquist");
        validateUser1(result.getAttributes());
        assertEquals(1, dao.getQueries());
        assertEquals(1, dao.getMisses());

        result = dao.getPerson("edalquist");
        validateUser1(result.getAttributes());
        assertEquals(2, dao.getQueries());
        assertEquals(1, dao.getMisses());

        result = dao.getPerson("nobody");
        assertNull(result);
        assertEquals(3, dao.getQueries());
        assertEquals(2, dao.getMisses());

        result = dao.getPerson("awp9");
        validateUser2(result.getAttributes());
        assertEquals(4, dao.getQueries());
        assertEquals(3, dao.getMisses());

        result = dao.getPerson("nobody");
        assertNull(result);
        assertEquals(5, dao.getQueries());
        assertEquals(4, dao.getMisses());

        result = dao.getPerson("awp9");
        validateUser2(result.getAttributes());
        assertEquals(6, dao.getQueries());
        assertEquals(4, dao.getMisses());

        result = dao.getPerson("edalquist");
        validateUser1(result.getAttributes());
        assertEquals(7, dao.getQueries());
        assertEquals(4, dao.getMisses());
    }
This is {@link CachingPersonAttributeDaoTests}.

@author Misagh Moayyed
@since 7.1.0
support/cas-server-support-person-directory-core/src/test/java/org/apereo/cas/persondir/CachingPersonAttributeDaoTests.java