@Test void testHasAclClassFalseCached() { String type = "MyType"; when(jdbcTemplate.queryForObject( "select count(*) from acl_class WHERE class = ?", new Object[] {type}, Integer.class)) .thenReturn(0); assertFalse(mutableAclClassService.hasAclClass(type)); assertFalse(mutableAclClassService.hasAclClass(type)); verifyZeroInteractions(aclCache); verify(jdbcTemplate, times(1)) .queryForObject( "select count(*) from acl_class WHERE class = ?", new Object[] {type}, Integer.class); }
@SuppressWarnings("ConstantConditions") @Override public boolean hasAclClass(String type) { boolean result = aclClassCache.get( type, t -> jdbcTemplate.queryForObject( SQL_COUNT_ACL_CLASS, new Object[] {t}, Integer.class)) > 0; LOGGER.trace("hasAclClass({}): {}", type, result); return result; }
MutableAclClassServiceImpl implements MutableAclClassService { @SuppressWarnings("ConstantConditions") @Override public boolean hasAclClass(String type) { boolean result = aclClassCache.get( type, t -> jdbcTemplate.queryForObject( SQL_COUNT_ACL_CLASS, new Object[] {t}, Integer.class)) > 0; LOGGER.trace("hasAclClass({}): {}", type, result); return result; } }
MutableAclClassServiceImpl implements MutableAclClassService { @SuppressWarnings("ConstantConditions") @Override public boolean hasAclClass(String type) { boolean result = aclClassCache.get( type, t -> jdbcTemplate.queryForObject( SQL_COUNT_ACL_CLASS, new Object[] {t}, Integer.class)) > 0; LOGGER.trace("hasAclClass({}): {}", type, result); return result; } MutableAclClassServiceImpl(JdbcTemplate jdbcTemplate, AclCache aclCache); }
MutableAclClassServiceImpl implements MutableAclClassService { @SuppressWarnings("ConstantConditions") @Override public boolean hasAclClass(String type) { boolean result = aclClassCache.get( type, t -> jdbcTemplate.queryForObject( SQL_COUNT_ACL_CLASS, new Object[] {t}, Integer.class)) > 0; LOGGER.trace("hasAclClass({}): {}", type, result); return result; } MutableAclClassServiceImpl(JdbcTemplate jdbcTemplate, AclCache aclCache); @Transactional @Override void createAclClass(String type, Class<?> idType); @Transactional @Override void deleteAclClass(String type); @Override void clearCache(); @SuppressWarnings("ConstantConditions") @Override boolean hasAclClass(String type); @Override Collection<String> getAclClassTypes(); }
MutableAclClassServiceImpl implements MutableAclClassService { @SuppressWarnings("ConstantConditions") @Override public boolean hasAclClass(String type) { boolean result = aclClassCache.get( type, t -> jdbcTemplate.queryForObject( SQL_COUNT_ACL_CLASS, new Object[] {t}, Integer.class)) > 0; LOGGER.trace("hasAclClass({}): {}", type, result); return result; } MutableAclClassServiceImpl(JdbcTemplate jdbcTemplate, AclCache aclCache); @Transactional @Override void createAclClass(String type, Class<?> idType); @Transactional @Override void deleteAclClass(String type); @Override void clearCache(); @SuppressWarnings("ConstantConditions") @Override boolean hasAclClass(String type); @Override Collection<String> getAclClassTypes();  }