Search in sources :

Example 76 with Feature

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

the class FeatureStoreEhCache method disable.

/**
 * {@inheritDoc}
 */
@Override
public void disable(String uid) {
    // Read from redis, feature not found if no present
    Feature f = read(uid);
    // Update within Object
    f.disable();
    // Serialization and update key, update TTL
    update(f);
}
Also used : Feature(org.ff4j.core.Feature)

Example 77 with Feature

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

the class EhCacheCacheManagerTest2 method initialize.

@Before
public /**
 * Init cache.
 */
void initialize() {
    cacheManager = new FeatureCacheProviderEhCache();
    // Stores in memory
    ff4j = new FF4j();
    ff4j.createFeature(new Feature("f1", false));
    // Enable caching using EHCACHE
    ff4j.cache(cacheManager);
// How to access cacheManager from FF4J
// ff4j.getCacheProxy().getCacheManager();
}
Also used : FF4j(org.ff4j.FF4j) Feature(org.ff4j.core.Feature) Before(org.junit.Before)

Example 78 with Feature

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

the class EhCacheCacheManagerTest2 method testPlayingWithCache.

@Test
public void testPlayingWithCache() {
    // Update with Check
    Assert.assertFalse(cacheManager.listCachedFeatureNames().contains("f1"));
    ff4j.check("f1");
    Assert.assertTrue(cacheManager.listCachedFeatureNames().contains("f1"));
    // Updated for create/update
    Assert.assertFalse(cacheManager.listCachedFeatureNames().contains("f3"));
    ff4j.createFeature(new Feature("f3", false));
    Assert.assertTrue(cacheManager.listCachedFeatureNames().contains("f3"));
    ff4j.enable("f3");
    // Is cache also updated ?
    Assert.assertFalse(cacheManager.listCachedFeatureNames().contains("f3"));
    // Updated for deletion
    ff4j.check("f3");
    Assert.assertTrue(cacheManager.listCachedFeatureNames().contains("f3"));
    ff4j.delete("f3");
    Assert.assertFalse(cacheManager.listCachedFeatureNames().contains("f3"));
}
Also used : Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 79 with Feature

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

the class FeatureStoreJCacheTest method testUpdateRemoveProperty.

/**
 * TDD.
 */
@Test
public void testUpdateRemoveProperty() {
    // Given
    assertFf4j.assertThatFeatureExist(F1);
    // assertFf4j.assertThatFeatureHasProperty(F1, "ppint");
    // When
    Feature myFeature = ff4j.getFeatureStore().read(F1);
    myFeature.getCustomProperties().remove("ppint");
    testedStore.update(myFeature);
    // Then
    assertFf4j.assertThatFeatureHasNotProperty(F1, "p1");
}
Also used : Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 80 with Feature

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

the class MongoFeatureMapper method fromStore.

/**
 * {@inheritDoc}
 */
@Override
public Feature fromStore(Document document) {
    String featUid = document.getString(FEATURE_UUID);
    boolean status = document.getBoolean(FEATURE_ENABLE);
    Feature f = new Feature(featUid, status);
    f.setDescription(document.getString(FEATURE_DESCRIPTION));
    f.setGroup(document.getString(FEATURE_GROUPNAME));
    f.setPermissions(mapAuthorization(document));
    f.setFlippingStrategy(mapStrategy(featUid, document));
    f.setCustomProperties(mapCustomProperties(document));
    return f;
}
Also used : Feature(org.ff4j.core.Feature)

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