DefaultFeatureManager implements FeatureManager { @Override public boolean isActive(Feature feature) { Validate.notNull(feature, "feature is required"); FeatureState state = stateRepository.getFeatureState(feature); if (state == null) { state = getMetaData(feature).getDefaultFeatureState(); } if (state.isEnabled()) { String strategyId = state.getStrategyId(); if (strategyId == null || strategyId.isEmpty()) { return true; } FeatureUser user = userProvider.getCurrentUser(); for (ActivationStrategy strategy : strategyProvider.getActivationStrategies()) { if (strategy.getId().equalsIgnoreCase(strategyId)) { return strategy.isActive(state, user); } } } return false; } DefaultFeatureManager(String name, FeatureProvider featureProvider, StateRepository stateRepository,
        UserProvider userProvider, ActivationStrategyProvider activationStrategyProvider); @Override String getName(); @Override Set<Feature> getFeatures(); @Override FeatureMetaData getMetaData(Feature feature); @Override boolean isActive(Feature feature); @Override FeatureState getFeatureState(Feature feature); @Override void setFeatureState(FeatureState state); @Override List<ActivationStrategy> getActivationStrategies(); @Override FeatureUser getCurrentFeatureUser(); @Override String toString();  }
@Test public void testIsActive() { featureUserProvider.setFeatureUser(null); assertFalse(manager.isActive(MyFeatures.DELETE_USERS)); featureUserProvider.setFeatureUser(new SimpleFeatureUser("admin", false)); assertTrue(manager.isActive(MyFeatures.DELETE_USERS)); featureUserProvider.setFeatureUser(new SimpleFeatureUser("somebody", false)); assertFalse(manager.isActive(MyFeatures.DELETE_USERS)); featureUserProvider.setFeatureUser(null); assertFalse(manager.isActive(MyFeatures.EXPERIMENTAL)); assertFalse(manager.isActive(MyFeatures.MISSING_STRATEGY)); assertTrue(manager.isActive(MyFeatures.EMPTY_STRATEGY)); }