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