@Transactional @Test public void whenGetUserAuthorityTwiceThenTheSecondTimeShouldGetFromCache() { List<Map<String, Set<?>>> permittedData = authorizationService.getPermittedData(1007, ACTION_CREATION); assertThat(permittedData).flatExtracting("env") .contains(141, 142); assertThat(permittedData).flatExtracting("subsys_design") .contains("1002_1000000014", "1002_1000000013", "1002_1000000015"); TestDatabase.executeSql(dataSource, "delete from adm_role_user where id_adm_role=1 and id_adm_user='1001'"); permittedData = authorizationService.getPermittedData(1007, ACTION_CREATION); assertThat(permittedData).flatExtracting("env") .contains(141, 142); assertThat(permittedData).flatExtracting("subsys_design") .contains("1002_1000000013", "1002_1000000014", "1002_1000000015"); }
@Cacheable("authorizationService-getPermittedData") @Override public List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action) { UserCiTypeAuthority userAuthority = getUserAuthority(ciTypeId); return userAuthority.getPermittedData(action); }
AuthorizationServiceImpl implements AuthorizationService { @Cacheable("authorizationService-getPermittedData") @Override public List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action) { UserCiTypeAuthority userAuthority = getUserAuthority(ciTypeId); return userAuthority.getPermittedData(action); } }
AuthorizationServiceImpl implements AuthorizationService { @Cacheable("authorizationService-getPermittedData") @Override public List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action) { UserCiTypeAuthority userAuthority = getUserAuthority(ciTypeId); return userAuthority.getPermittedData(action); }  }
AuthorizationServiceImpl implements AuthorizationService { @Cacheable("authorizationService-getPermittedData") @Override public List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action) { UserCiTypeAuthority userAuthority = getUserAuthority(ciTypeId); return userAuthority.getPermittedData(action); }  @Override void authorizeCiData(int ciTypeId, Object ciData, String action); @Override boolean isCiDataPermitted(int ciTypeId, Object ciData, String action); @Cacheable("authorizationService-isCiTypePermitted") @Override boolean isCiTypePermitted(int ciTypeId, String action); @Cacheable("authorizationService-getPermittedData") @Override List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action); void setSecurityEnabled(boolean securityEnabled); }
AuthorizationServiceImpl implements AuthorizationService { @Cacheable("authorizationService-getPermittedData") @Override public List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action) { UserCiTypeAuthority userAuthority = getUserAuthority(ciTypeId); return userAuthority.getPermittedData(action); }  @Override void authorizeCiData(int ciTypeId, Object ciData, String action); @Override boolean isCiDataPermitted(int ciTypeId, Object ciData, String action); @Cacheable("authorizationService-isCiTypePermitted") @Override boolean isCiTypePermitted(int ciTypeId, String action); @Cacheable("authorizationService-getPermittedData") @Override List<Map<String, Set<?>>> getPermittedData(int ciTypeId, String action); void setSecurityEnabled(boolean securityEnabled);  }