for (String function : securityFunctionDao.getSecurityFunctionsForRole(role))
@Test public void testGetSecurityFunctionsByRole() throws Exception { // Create role and function. SecurityRoleEntity securityRoleEntity = securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE); SecurityFunctionEntity securityFunctionEntity = securityFunctionDaoTestHelper.createSecurityFunctionEntity(SECURITY_FUNCTION); // Validate that no security functions are returned for the role. assertTrue(securityFunctionDao.getSecurityFunctionsForRole(SECURITY_ROLE).isEmpty()); // Add new role to functions mapping. SecurityRoleFunctionEntity securityRoleFunctionEntity = new SecurityRoleFunctionEntity(); securityRoleFunctionEntity.setSecurityRole(securityRoleEntity); securityRoleFunctionEntity.setSecurityFunction(securityFunctionEntity); herdDao.saveAndRefresh(securityRoleFunctionEntity); // Since the functions method is cached, the test function still will not be retrieved. assertTrue(securityFunctionDao.getSecurityFunctionsForRole(SECURITY_ROLE).isEmpty()); // Clear the cache and retrieve the functions again. cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear(); // Validate that test security function mapped to the role is now retrieved. assertEquals(Arrays.asList(SECURITY_FUNCTION), securityFunctionDao.getSecurityFunctionsForRole(SECURITY_ROLE)); }