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;
}
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"));
}
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);
}
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));
}
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);
}
Aggregations