use of org.ff4j.property.Property in project ff4j by ff4j.
the class FF4jConfiguration method getProperties.
/**
* {@inheritDoc}
*/
@Override
public Properties getProperties(String key) {
Properties props = new Properties();
if (key == null)
return props;
Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
if (prop.getKey().startsWith(key)) {
props.put(prop.getKey(), prop.getValue().getValue());
}
}
return props;
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class FF4jConfiguration method subset.
/**
* {@inheritDoc}
*/
@Override
public Configuration subset(String prefix) {
Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
PropertyStore ps = new InMemoryPropertyStore();
for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
if (prop.getKey().startsWith(prefix)) {
ps.createProperty(prop.getValue());
}
}
return new FF4jConfiguration(ps);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class FeatureXmlParserTest method testParsingALL.
@Test
public void testParsingALL() throws IOException {
// Given
XmlParser parser = new XmlParser();
InputStream in = getClass().getClassLoader().getResourceAsStream("ff4j-parser-all.xml");
// When
XmlConfig conf = parser.parseConfigurationFile(in);
// Then
Map<String, Feature> features = conf.getFeatures();
Assert.assertNotNull(features);
// Then
Map<String, Property<?>> properties = conf.getProperties();
Assert.assertNotNull(properties);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class FF4jTest method testImportProperties.
@Test
public void testImportProperties() {
FF4j ff4j = new FF4j();
List<Property<?>> listOfProperties = new ArrayList<Property<?>>();
listOfProperties.add(new PropertyString("p1", "v1"));
ff4j.importProperties(listOfProperties);
Assert.assertTrue(ff4j.getPropertiesStore().existProperty("p1"));
// no Error
ff4j.importProperties(null);
}
use of org.ff4j.property.Property in project ff4j by ff4j.
the class AbstractPropertyStoreJunitTest method clear.
/**
* TDD.
*/
@Test
public void clear() {
// Given
Assert.assertNotNull(testedStore);
Map<String, Property<?>> before = testedStore.readAllProperties();
Assert.assertFalse(before.isEmpty());
// When
testedStore.clear();
// Then
Assert.assertTrue(testedStore.readAllProperties().isEmpty());
// / Reinit
for (String pName : before.keySet()) {
testedStore.createProperty(before.get(pName));
}
}
Aggregations