use of org.ff4j.core.FeatureStore in project ff4j by ff4j.
the class FeatureStoreMongoDBCore1Test method emptyListAttributes.
/**
* LazyBSONObjectList vs BasicBSONObjectList
*/
@Test
@Ignore
public void emptyListAttributes() throws UnknownHostException {
DBCollection features = getMongoClient().getDB("FF4J").getCollection("feature");
// When
FeatureStore mongoStore = new FeatureStoreMongoDB(features, "ff4j.xml");
// Then (no error)
Assert.assertTrue(mongoStore.readAll().keySet().size() > 0);
}
use of org.ff4j.core.FeatureStore in project ff4j by ff4j.
the class RedisCacheManagerTestIT method testPutGet.
@Test
public void testPutGet() {
// Initializing cache manager
FF4JCacheManager cache = new FF4jCacheManagerRedis();
// Initializing Features for test
FeatureStore store = new InMemoryFeatureStore(TEST_FEATURES_FILE);
Feature fold = store.read(F4);
// Put in Cache
cache.putFeature(fold);
// Retrieve object
Feature fcached = cache.getFeature(F4);
Assert.assertEquals(fcached.getUid(), fold.getUid());
Assert.assertEquals(fcached.getPermissions(), fold.getPermissions());
}
use of org.ff4j.core.FeatureStore in project ff4j by ff4j.
the class FF4jCliDisplay method displayEnvironments.
/**
* Display a table of available environments.
*
* @param envs
* environnements in config file
*/
public static void displayEnvironments(Map<String, FF4j> envs) {
yellow("+--------------------+----------+------------+-------+----------+\n");
System.out.print("|");
cyan(" Environments ");
yellow("|");
cyan(" Features ");
yellow("|");
cyan(" Properties ");
yellow("|");
cyan(" Audit ");
yellow("|");
cyan(" Security ");
yellow("|\n");
System.out.println("+--------------------+----------+------------+-------+----------+");
for (Map.Entry<String, FF4j> entries : envs.entrySet()) {
FeatureStore fs = entries.getValue().getFeatureStore();
PropertyStore ps = entries.getValue().getPropertiesStore();
yellow("| ");
green(StringUtils.rightPad(entries.getKey(), 18));
yellow("| ");
String featureStore = "---";
if (fs != null) {
featureStore = String.valueOf(fs.readAll().size());
}
white(StringUtils.rightPad(featureStore, 8));
yellow("| ");
String propertyStore = "---";
if (fs != null) {
propertyStore = String.valueOf(ps.listPropertyNames().size());
}
white(StringUtils.rightPad(propertyStore, 10));
yellow("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
if (entries.getValue().isEnableAudit()) {
green(" ON ");
} else {
red(" OFF ");
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
yellow("|");
AnsiTerminal.textAttribute(AnsiTextAttribute.BOLD);
if (entries.getValue().getAuthorizationsManager() != null) {
green(" ON ");
} else {
red(" OFF ");
}
AnsiTerminal.textAttribute(AnsiTextAttribute.CLEAR);
yellow("|\n");
}
System.out.println("+--------------------+----------+------------+-------+----------+");
System.out.println("");
}
use of org.ff4j.core.FeatureStore in project ff4j by ff4j.
the class MappingUtilsTest method testJsonMapping.
@Test
public void testJsonMapping() {
JsonUtils.permissionsAsJson(null);
JsonUtils.customPropertiesAsJson(null);
JsonUtils.customPropertiesAsJson(new HashMap<String, Property<?>>());
FeatureStore store1 = new InMemoryFeatureStore();
FF4jCacheProxy proxy = new FF4jCacheProxy(store1, null, null);
JsonUtils.cacheJson(proxy);
}
use of org.ff4j.core.FeatureStore in project ff4j by ff4j.
the class ConsoleOperations method importFile.
/**
* User action to import Features from a properties files.
*
* @param in
* inpustream from configuration file
* @throws IOException
* Error raised if the configuration cannot be read
*/
public static void importFile(FF4j ff4j, InputStream in) throws IOException {
FeatureStore store = ff4j.getFeatureStore();
XmlConfig xmlConfig = new XmlParser().parseConfigurationFile(in);
Map<String, Feature> mapsOfFeat = xmlConfig.getFeatures();
for (Entry<String, Feature> feature : mapsOfFeat.entrySet()) {
if (store.exist(feature.getKey())) {
store.update(feature.getValue());
} else {
store.create(feature.getValue());
}
}
LOGGER.info(mapsOfFeat.size() + " features have been imported.");
PropertyStore pstore = ff4j.getPropertiesStore();
Map<String, Property<?>> mapsOfProperties = xmlConfig.getProperties();
for (Entry<String, Property<?>> p : mapsOfProperties.entrySet()) {
if (pstore.existProperty(p.getKey())) {
pstore.updateProperty(p.getValue());
} else {
pstore.createProperty(p.getValue());
}
}
LOGGER.info(mapsOfProperties.size() + " features have been imported.");
}
Aggregations