Search in sources :

Example 11 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreAwsSSM method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    List<Parameter> parameters = getParameters();
    Map<String, Property<?>> properties = new HashMap<>();
    for (Parameter parameter : parameters) {
        properties.put(parameter.name().replace(path + "/", ""), new PropertyString(parameter.value()));
    }
    return properties;
}
Also used : PropertyString(org.ff4j.property.PropertyString) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property)

Example 12 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class StoreMapper method fromFeatureStore.

public static Feature fromFeatureStore(ArangoDBFeature f) {
    Map<String, Property<?>> customProperties = convertMap(f.getCustomProperties(), StoreMapper::fromPropertyStore);
    Feature feature = new Feature(f.getId());
    feature.setEnable(f.isEnable());
    feature.setDescription(f.getDescription());
    feature.setGroup(f.getGroup());
    feature.setPermissions(f.getPermissions());
    feature.setFlippingStrategy(f.getFlippingStrategy());
    feature.setCustomProperties(customProperties);
    return feature;
}
Also used : ArangoDBProperty(org.ff4j.arangodb.document.ArangoDBProperty) Property(org.ff4j.property.Property) ArangoDBFeature(org.ff4j.arangodb.document.ArangoDBFeature) Feature(org.ff4j.core.Feature)

Example 13 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class JdbcFeatureStoreSchemaTest method testworkWithSchema.

@Test
public void testworkWithSchema() {
    // Given
    testedStore.createSchema();
    Assert.assertFalse(testedStore.exist("fx"));
    // When
    Feature fullFeature = new Feature("fx", true);
    fullFeature.setPermissions(Util.set("toto", "tata"));
    fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
    Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
    fullFeature.setCustomProperties(customProperties);
    testedStore.create(fullFeature);
    // Then
    Assert.assertTrue(testedStore.exist("fx"));
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 14 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class JdbcFeatureStoreSchemaTest method testCreateCustomProperties.

@Test
public void testCreateCustomProperties() {
    testedStore.createSchema();
    // When
    Feature fullFeature = new Feature("fx", true);
    fullFeature.setPermissions(Util.set("toto", "tata"));
    fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
    Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
    fullFeature.setCustomProperties(customProperties);
    testedStore.create(fullFeature);
    testedStore.createCustomProperties("fx", null);
    Property<?> p1 = new PropertyString("p1");
    p1.setFixedValues(null);
    Property<String> p2 = new PropertyString("p2");
    p2.setFixedValues(Util.set("v1", "v3"));
    testedStore.createCustomProperties("fx", Arrays.asList(p2, p1));
    testedStore.createCustomProperties("fx", null);
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) PropertyString(org.ff4j.property.PropertyString) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 15 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class MappingUtilsTest method testJsonCustomProperties.

@Test
public void testJsonCustomProperties() {
    // Given
    Map<String, Property<?>> props = new HashMap<String, Property<?>>();
    props.put("f1", new PropertyString("f1", "v1"));
    props.put("f2", new PropertyString("f2", "v2"));
    // When
    String expression = JsonUtils.customPropertiesAsJson(props);
    // Then
    Assert.assertNotNull(expression);
}
Also used : PropertyString(org.ff4j.property.PropertyString) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property) Test(org.junit.Test)

Aggregations

Property (org.ff4j.property.Property)56 HashMap (java.util.HashMap)20 PropertyString (org.ff4j.property.PropertyString)20 Test (org.junit.Test)20 Feature (org.ff4j.core.Feature)16 Map (java.util.Map)11 InputStream (java.io.InputStream)9 XmlParser (org.ff4j.conf.XmlParser)7 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)7 LinkedHashMap (java.util.LinkedHashMap)6 XmlConfig (org.ff4j.conf.XmlConfig)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 FeatureStore (org.ff4j.core.FeatureStore)4 PropertyAccessException (org.ff4j.exception.PropertyAccessException)4 PropertyStore (org.ff4j.property.store.PropertyStore)4 IOException (java.io.IOException)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3