本文整理汇总了Java中org.togglz.core.repository.FeatureState.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureState.setEnabled方法的具体用法?Java FeatureState.setEnabled怎么用?Java FeatureState.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.togglz.core.repository.FeatureState
的用法示例。
在下文中一共展示了FeatureState.setEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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"));
}
示例3: 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"));
}
示例4: 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));
}
示例5: getFeatureState
import org.togglz.core.repository.FeatureState; //导入方法依赖的package包/类
public FeatureState getFeatureState(Feature feature) {
DataFindRequest request = new DataFindRequest(entityName, version);
request.where(withValue("application", eq, application));
request.select(
Projection.array("features",
withValue("feature", eq, feature.name()),
true,
Projection.includeFieldRecursively("*"),
null
)
);
try {
LBTogglz[] result = lbClient.data(request, LBTogglz[].class);
if (result != null && result.length==1&&result[0].getFeatures()!=null && result[0].getFeatures().size()==1) {
LBTogglz.Toggle toggle = result[0].getFeatures().iterator().next();
FeatureState state = new FeatureState(feature);
state.setEnabled(toggle.isEnabled());
String strategyValue = toggle.getStrategy();
if (strategyValue!=null) {
state.setStrategyId(strategyValue.trim());
}
List<LBTogglz.Toggle.Parameter> parameters = toggle.getParameters();
if (parameters!=null) {
for (LBTogglz.Toggle.Parameter parameter : parameters) {
state.setParameter(parameter.getKey(), parameter.getValue().trim());
}
}
return state;
}
} catch (LightblueException e) {
e.printStackTrace();
}
return null;
}