AclStrategyProviderImpl implements BeanFactoryAware, AclStrategyProvider { @Override public AclStrategy strategyFor(Class<?> entityClass) { AclStrategy strategy = defaultStrategy; if (activator.isDisabled()) { logger.debug("ACL disabled"); strategy = allowAllStrategy; } else { String strategyBeanName = strategyBeanName(entityClass); strategy = useIfPresent(loadStrategyBean(strategyBeanName)); } logger.debug("Using acl strategy on '{}' : {}", entityClass.getSimpleName(), strategy); return strategy; } AclStrategyProviderImpl(AclProperties properties, AclSecurityActivator activator,
      AclStrategy allowAllStrategy); @Override void setBeanFactory(BeanFactory beanFactory); @Override void setDefaultStrategy(AclStrategy strategy); @Override AclStrategy strategyFor(Class<?> entityClass);  }
@Test public void test_provider_for_allowAllStrategy() { assertThat(strategyFor(AllowedToAllObject.class)).isSameAs(allowAllStrategy); }
@Test public void test_provider_for_denyAllStrategy() { assertThat(strategyFor(DeniedToAllObject.class)).isSameAs(denyAllStrategy); }
@Test public void should_provider_return_defaultStrategy_when_no_strategy() { assertThat(strategyFor(NoStrategyObject.class)).isSameAs(defaultAclStrategy); }
@Test public void should_provider_return_defaultStrategy_when_no_acl_annotation() { assertThat(strategyFor(NoAclObject.class)).isSameAs(defaultAclStrategy); }
@Test public void should_provider_return_defaultStrategy_when_unknown_strategy() { assertThat(strategyFor(UnknownStrategyObject.class)).isSameAs(defaultAclStrategy); }
@Test public void should_use_specified_strategy_when_override_set() { assertThat(properties.getOverrideStrategy()).isNull(); properties.setOverrideStrategy("denyAllStrategy"); try { assertThat(strategyFor(UnknownStrategyObject.class)).isSameAs(denyAllStrategy); } finally { properties.setOverrideStrategy(null); } }
@Test public void should_use_allowAll_strategy_when_disabled() { activator.disable(); try { assertThat(strategyFor(DeniedToAllObject.class)).isSameAs(allowAllStrategy); } finally { activator.enable(); } }