本文整理汇总了Java中org.togglz.core.repository.FeatureState类的典型用法代码示例。如果您正苦于以下问题:Java FeatureState类的具体用法?Java FeatureState怎么用?Java FeatureState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureState类属于org.togglz.core.repository包,在下文中一共展示了FeatureState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: from
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
public static RemoteFeatureState from(FeatureState featureState) {
RemoteFeatureState remoteFeatureState = new RemoteFeatureState();
RemoteFeature feature = new RemoteFeature();
Feature featureFromGivenState = featureState.getFeature();
feature.setName(featureFromGivenState.name());
if(featureFromGivenState instanceof FeatureMetaData) {
FeatureMetaData metaData = (FeatureMetaData) featureFromGivenState;
feature.setLabel(metaData.getLabel());
feature.setEnabledByDefault(metaData.isEnabledByDefault());
}
remoteFeatureState.setFeature(feature);
remoteFeatureState.setEnabled(featureState.isEnabled());
remoteFeatureState.setStrategyId(featureState.getStrategyId());
remoteFeatureState.setParameters(new HashMap<>(2));
featureState.getParameterMap().forEach((k,v) -> remoteFeatureState.getParameters().put(k, v));
return remoteFeatureState;
}
开发者ID:ImmobilienScout24,项目名称:switchman,代码行数:21,代码来源:RemoteFeatureState.java
示例2: createInMemoryStateRepository
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
private StateRepository createInMemoryStateRepository() {
return new StateRepository() {
Logger LOG = getLogger(TogglzConfiguration.class);
private Map<String, FeatureState> featureStore = new ConcurrentHashMap<>();
@Autowired
UserProvider userProvider;
@Override
public FeatureState getFeatureState(final Feature feature) {
if (featureStore.containsKey(feature.name())) {
return featureStore.get(feature.name());
}
return new FeatureState(feature, false);
}
@Override
public void setFeatureState(final FeatureState featureState) {
featureStore.put(featureState.getFeature().name(), featureState);
LOG.info((!StringUtils.isEmpty(userProvider.getCurrentUser().getName()) ? "User '" + userProvider.getCurrentUser().getName() + "'" : "Unknown user")
+ (featureState.isEnabled() ? " enabled " : " disabled ") + "feature " + featureState.getFeature().name());
}
};
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:27,代码来源:InMemoryFeatureStateRepositoryConfiguration.java
示例3: decode
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected FeatureState decode(final Document document) {
final String name = document.getString(NAME);
final Boolean enabled = document.getBoolean(ENABLED);
final String strategy = document.getString(STRATEGY);
final Map<String, String> parameters = document.get(PARAMETERS, Map.class);
final FeatureState featureState = new FeatureState(resolveEnumValue(name));
featureState.setEnabled(enabled);
featureState.setStrategyId(strategy);
for (final Map.Entry<String, String> parameter : parameters.entrySet()) {
featureState.setParameter(parameter.getKey(), parameter.getValue());
}
return featureState;
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:18,代码来源:MongoTogglzRepository.java
示例4: shouldLoadFeatureState
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void shouldLoadFeatureState() throws Exception {
// Given
final FeatureState featureState = new FeatureState(TestFeatures.TEST_FEATURE_1);
featureState.setEnabled(true);
featureState.setStrategyId("someStrategy");
featureState.setParameter("someKey1", "someValue1");
featureState.setParameter("someKey2", "someValue2");
testee.create(featureState);
// When
final FeatureState loadedFeatureState = testee.getFeatureState(TestFeatures.TEST_FEATURE_1);
// Then
assertThat(loadedFeatureState.getFeature(), is(TestFeatures.TEST_FEATURE_1));
assertThat(loadedFeatureState.getStrategyId(), is("someStrategy"));
assertThat(loadedFeatureState.isEnabled(), is(true));
assertThat(loadedFeatureState.getParameter("someKey1"), is("someValue1"));
assertThat(loadedFeatureState.getParameter("someKey2"), is("someValue2"));
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:21,代码来源:MongoTogglzRepositoryTest.java
示例5: shouldSetFeatureState
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void shouldSetFeatureState() throws Exception {
// Given
final FeatureState featureState = new FeatureState(TestFeatures.TEST_FEATURE_1);
featureState.setEnabled(true);
featureState.setStrategyId("someStrategy");
featureState.setParameter("someKey1", "someValue1");
featureState.setParameter("someKey2", "someValue2");
// When
testee.setFeatureState(featureState);
final Optional<FeatureState> loadedFeatureState = testee.findOne(TestFeatures.TEST_FEATURE_1.name());
// Then
assertThat(loadedFeatureState.isPresent(), is(true));
assertThat(loadedFeatureState.get().getFeature(), is(TestFeatures.TEST_FEATURE_1));
assertThat(loadedFeatureState.get().getStrategyId(), is("someStrategy"));
assertThat(loadedFeatureState.get().isEnabled(), is(true));
assertThat(loadedFeatureState.get().getParameter("someKey1"), is("someValue1"));
assertThat(loadedFeatureState.get().getParameter("someKey2"), is("someValue2"));
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:22,代码来源:MongoTogglzRepositoryTest.java
示例6: shouldLoadAllFeatureStates
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void shouldLoadAllFeatureStates() throws Exception {
// Given
final FeatureState featureState1 = new FeatureState(TestFeatures.TEST_FEATURE_1);
featureState1.setEnabled(true);
featureState1.setStrategyId("someStrategy");
featureState1.setParameter("someKey1", "someValue1");
featureState1.setParameter("someKey2", "someValue2");
testee.create(featureState1);
final FeatureState featureState2 = new FeatureState(TestFeatures.TEST_FEATURE_2);
featureState2.setEnabled(true);
featureState2.setStrategyId("someStrategy2");
featureState2.setParameter("someKey3", "someValue3");
featureState2.setParameter("someKey4", "someValue4");
testee.create(featureState2);
// When
final List<FeatureState> loadedFeatureStates = testee.findAll();
// Then
assertThat(loadedFeatureStates.size(), is(2));
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:24,代码来源:MongoTogglzRepositoryTest.java
示例7: getFeatureState_should_return_null_when_name_not_found_exception_is_wrapped
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_return_null_when_name_not_found_exception_is_wrapped() throws Exception{
final Appender<ILoggingEvent> mockAppender = TestLogUtils.addMockAppenderLog();
// Given
doReturn(context).when(repository).getInitialContext();
// stub expected behavior of lookup method
NamingException exception = new NamingException("jndi exception");
exception.initCause(new NameNotFoundException("invalid name"));
doThrow(exception).when(context).lookup(anyString());
// When
FeatureState feature = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature).isNull();
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:18,代码来源:PaasJndiStateRepositoryTest.java
示例8: getFeatureState_should_log_a_warn_when_name_not_found_exception_is_wrapped
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_log_a_warn_when_name_not_found_exception_is_wrapped() throws Exception{
final Appender<ILoggingEvent> mockAppender = addMockAppenderLog();
// Given
doReturn(context).when(repository).getInitialContext();
// stub expected behavior of lookup method
NamingException exception = new NamingException("jndi exception");
exception.initCause(new NameNotFoundException("invalid name"));
doThrow(exception).when(context).lookup(anyString());
// When
FeatureState feature = repository.getFeatureState(MyFeature.FEATURE1);
// Then
verify(mockAppender).doAppend(logEventMatches(Level.WARN, "FEATURE1"));
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:18,代码来源:PaasJndiStateRepositoryTest.java
示例9: getFeatureManager
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
public synchronized FeatureManager getFeatureManager() {
if (featureManager == null) {
featureManager = new FeatureManagerBuilder()
.featureEnum(Feature.class)
.stateRepository(new InMemoryStateRepository())
.userProvider(new NoOpUserProvider())
.build();
// enable experimental features only if "-Dexperimental=true" was set on start
boolean enabled = System.getProperty("experimental") != null
&& System.getProperty("experimental").equalsIgnoreCase("true");
featureManager.setFeatureState(new FeatureState(Feature.HIGHLIGHT_FILTER_MATCHES, enabled));
}
return featureManager;
}
开发者ID:mathisdt,项目名称:sdb2,代码行数:21,代码来源:FeatureManagerProvider.java
示例10: setFeatureState
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
public void setFeatureState(FeatureState state) {
de.is24.common.togglz.service.domain.FeatureState featureStateFromRepo = featureStateRepository.findByFeatureName(state.getFeature().name());
RemoteFeatureState remoteFeatureState = RemoteFeatureState.from(state);
if (featureStateFromRepo != null) {
featureStateFromRepo.setFeature(remoteFeatureState.getFeature());
featureStateFromRepo.setEnabled(remoteFeatureState.getEnabled());
featureStateFromRepo.setStrategyId(remoteFeatureState.getStrategyId());
featureStateFromRepo.setParameters(remoteFeatureState.getParameters());
featureStateRepository.save(featureStateFromRepo);
} else {
featureStateRepository.save((de.is24.common.togglz.service.domain.FeatureState) remoteFeatureState);
}
}
开发者ID:ImmobilienScout24,项目名称:switchman,代码行数:15,代码来源:RepositoryWritingFeatureManager.java
示例11: setFeatureState
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
public void setFeatureState(FeatureState state) {
if (state.isEnabled()) {
activeFeatures.add(state.getFeature().name());
} else {
activeFeatures.remove(state.getFeature().name());
}
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:9,代码来源:TestFeatureManager.java
示例12: encode
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
protected Document encode(final FeatureState value) {
final Document document = new Document();
document.append(NAME, value.getFeature().name());
document.append(ENABLED, value.isEnabled());
document.append(STRATEGY, value.getStrategyId());
document.append(PARAMETERS, value.getParameterMap());
return document;
}
开发者ID:otto-de,项目名称:edison-microservice,代码行数:12,代码来源:MongoTogglzRepository.java
示例13: setFeatureState
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Override
public void setFeatureState(FeatureState featureState) {
String featureName = featureState.getFeature().name();
try {
InitialContext jndiContext = getInitialContext();
jndiContext.rebind(featureName, Boolean.toString(featureState.isEnabled()));
String users = StringUtils.join(featureState.getUsers(), ", ");
//for(String user:featureState.getUsers()) users += user+", ";
jndiContext.rebind(featureName+".users", users);
} catch (NamingException e) {
logger.error("unable to save state of feature "+featureName+" in jndi",e);
}
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:14,代码来源:PaasJndiStateRepository.java
示例14: getFeatureState_should_fetch_state_from_jndi_when_feature_is_defined_in_jndi
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_fetch_state_from_jndi_when_feature_is_defined_in_jndi() throws Exception{
// Given
when(context.lookup("FEATURE1")).thenReturn("false");
when(context.lookup("FEATURE2")).thenReturn("true");
// When
FeatureState feature1 = repository.getFeatureState(MyFeature.FEATURE1);
FeatureState feature2 = repository.getFeatureState(MyFeature.FEATURE2);
// Then
assertThat(feature1.isEnabled()).isFalse();
assertThat(feature2.isEnabled()).isTrue();
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:15,代码来源:PaasJndiStateRepositoryTest.java
示例15: getFeatureState_should_fetch_users_from_jndi_when_defined_in_jndi
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_fetch_users_from_jndi_when_defined_in_jndi() throws Exception{
// Given
when(context.lookup("FEATURE1")).thenReturn("true");
when(context.lookup("FEATURE1.users")).thenReturn("user1, user2, user3");
// When
FeatureState feature1 = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature1.getUsers()).containsOnly("user1","user2","user3");
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:13,代码来源:PaasJndiStateRepositoryTest.java
示例16: getFeatureState_should_return_empty_users_list_when_users_list_is_empty
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_return_empty_users_list_when_users_list_is_empty() throws Exception{
// Given
when(context.lookup("FEATURE1")).thenReturn("true");
when(context.lookup("FEATURE1.users")).thenReturn("");
// When
FeatureState feature1 = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature1.getUsers()).isEmpty();
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:13,代码来源:PaasJndiStateRepositoryTest.java
示例17: getFeatureState_should_ignore_spaces_around_comma_in_user_list
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_ignore_spaces_around_comma_in_user_list() throws Exception{
// Given
when(context.lookup("FEATURE1")).thenReturn("true");
when(context.lookup("FEATURE1.users")).thenReturn("user1 name , user2 name , user3 name ");
// When
FeatureState feature1 = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature1.getUsers()).containsOnly("user1 name","user2 name","user3 name");
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:13,代码来源:PaasJndiStateRepositoryTest.java
示例18: getFeatureState_should_ignore_last_comma_in_user_list
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_ignore_last_comma_in_user_list() throws Exception{
// Given
when(context.lookup("FEATURE1")).thenReturn("true");
when(context.lookup("FEATURE1.users")).thenReturn("user1, user2, user3,");
// When
FeatureState feature1 = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature1.getUsers()).containsOnly("user1","user2","user3");
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:13,代码来源:PaasJndiStateRepositoryTest.java
示例19: getFeatureState_should_return_null_when_feature_is_not_defined_in_jndi
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_return_null_when_feature_is_not_defined_in_jndi() throws Exception{
// Given
doThrow(new NameNotFoundException("jndi test error")).when(context).lookup(anyString());
// When
FeatureState feature = repository.getFeatureState(MyFeature.FEATURE1);
// Then
assertThat(feature).isNull();
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:12,代码来源:PaasJndiStateRepositoryTest.java
示例20: getFeatureState_should_log_a_warn_when_feature_is_not_defined_in_jndi
import org.togglz.core.repository.FeatureState; //导入依赖的package包/类
@Test
public void getFeatureState_should_log_a_warn_when_feature_is_not_defined_in_jndi() throws Exception{
final Appender<ILoggingEvent> mockAppender = addMockAppenderLog();
// Given
doThrow(new NameNotFoundException("jndi test error")).when(context).lookup(anyString());
// When
FeatureState feature = repository.getFeatureState(MyFeature.FEATURE1);
// Then
verify(mockAppender).doAppend(logEventMatches(Level.WARN, "FEATURE1"));
}
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:14,代码来源:PaasJndiStateRepositoryTest.java
注:本文中的org.togglz.core.repository.FeatureState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论