Search in sources :

Example 51 with Feature

use of org.ff4j.core.Feature 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 52 with Feature

use of org.ff4j.core.Feature 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 53 with Feature

use of org.ff4j.core.Feature 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 54 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class ReleaseDateFlipStrategyTest method testFutureOK.

@Test
public void testFutureOK() throws ParseException {
    Feature f = ff4j.getFeature("future1");
    ReleaseDateFlipStrategy rds = (ReleaseDateFlipStrategy) f.getFlippingStrategy();
    Assert.assertFalse(rds.evaluate("future1", null, null));
}
Also used : ReleaseDateFlipStrategy(org.ff4j.strategy.time.ReleaseDateFlipStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 55 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class CoreFeatureStoreTestSupport method testAddFeature.

/**
 * TDD.
 */
@Test
public void testAddFeature() throws Exception {
    // Given
    assertFf4j.assertThatFeatureDoesNotExist(FEATURE_NEW);
    // When
    Set<String> rights = new HashSet<String>(Arrays.asList(new String[] { ROLE_USER }));
    Feature fp = new Feature(FEATURE_NEW, true, "description", G1, rights);
    testedStore.create(fp);
    // Then
    assertFf4j.assertThatStoreHasSize(EXPECTED_FEATURES_NUMBERS + 1);
    assertFf4j.assertThatFeatureExist(FEATURE_NEW);
    assertFf4j.assertThatFeatureIsInGroup(FEATURE_NEW, G1);
    // End, return to initial state
    testedStore.delete(FEATURE_NEW);
    assertFf4j.assertThatFeatureDoesNotExist(FEATURE_NEW);
}
Also used : PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Feature (org.ff4j.core.Feature)295 Test (org.junit.Test)144 PropertyString (org.ff4j.property.PropertyString)53 HashMap (java.util.HashMap)38 HashSet (java.util.HashSet)27 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 Property (org.ff4j.property.Property)16 LinkedHashMap (java.util.LinkedHashMap)15 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)15 Map (java.util.Map)14 XmlParser (org.ff4j.conf.XmlParser)14 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 FeatureAccessException (org.ff4j.exception.FeatureAccessException)13 InputStream (java.io.InputStream)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 Set (java.util.Set)10 Response (javax.ws.rs.core.Response)10 FlippingStrategy (org.ff4j.core.FlippingStrategy)10 CouchDbFeature (org.ff4j.couchdb.document.CouchDbFeature)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9