Search in sources :

Example 31 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jDroolsDRLFilesXml method testDroolsStrategyDRLFiles.

@Test
public void testDroolsStrategyDRLFiles() {
    // Given
    FF4j ff4j = new FF4j("ff4j-drl.xml");
    // When
    Assert.assertTrue(ff4j.exist("f1"));
    // Then
    Assert.assertTrue(ff4j.check("f1"));
}
Also used : FF4j(org.ff4j.FF4j) Test(org.junit.Test)

Example 32 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FF4jDroolsKBaseProgrammatic method testDroolsStrategyFromkBaseName.

@Test
public void testDroolsStrategyFromkBaseName() {
    // Given
    FF4j ff4j = new FF4j();
    // When
    Feature f1 = new Feature("f1", true);
    f1.setFlippingStrategy(new FF4jDroolsFlippingStrategy("ff4jDroolsStrategy"));
    ff4j.createFeature(f1);
    Assert.assertTrue(ff4j.exist("f1"));
    // Then
    Assert.assertTrue(ff4j.check("f1"));
}
Also used : FF4j(org.ff4j.FF4j) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 33 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class EventRepositoryTestSupport method setUp.

/**
 * {@inheritDoc}
 */
@Before
public void setUp() throws Exception {
    ff4j = new FF4j();
    ff4j.setFeatureStore(new InMemoryFeatureStore("test-ff4j-features.xml"));
    ff4j.setPropertiesStore(new InMemoryPropertyStore("test-ff4j-features.xml"));
    ff4j.setEventRepository(initRepository());
    repo = ff4j.getEventRepository();
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) FF4j(org.ff4j.FF4j) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) Before(org.junit.Before)

Example 34 with FF4j

use of org.ff4j.FF4j 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("");
}
Also used : FF4j(org.ff4j.FF4j) PropertyString(org.ff4j.property.PropertyString) HashMap(java.util.HashMap) Map(java.util.Map) FeatureStore(org.ff4j.core.FeatureStore) PropertyStore(org.ff4j.property.store.PropertyStore)

Example 35 with FF4j

use of org.ff4j.FF4j in project ff4j by ff4j.

the class FeatureStoreTestSupport method setUp.

/**
 * {@inheritDoc}
 */
@Before
public void setUp() throws Exception {
    ff4j = new FF4j();
    ff4j.setFeatureStore(initStore());
    testedStore = ff4j.getFeatureStore();
    assertFf4j = new AssertFf4j(ff4j);
    assertFf4j.setPause(enablePause());
}
Also used : AssertFf4j(org.ff4j.test.AssertFf4j) FF4j(org.ff4j.FF4j) Before(org.junit.Before)

Aggregations

FF4j (org.ff4j.FF4j)60 Test (org.junit.Test)41 Before (org.junit.Before)9 Feature (org.ff4j.core.Feature)8 ArrayList (java.util.ArrayList)4 PropertyString (org.ff4j.property.PropertyString)4 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)4 AssertFf4j (org.ff4j.test.AssertFf4j)4 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)3 Date (java.util.Date)2 HashSet (java.util.HashSet)2 PropertyStoreAuditProxy (org.ff4j.audit.proxy.PropertyStoreAuditProxy)2 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)2 FeatureStore (org.ff4j.core.FeatureStore)2 PropertyDate (org.ff4j.property.PropertyDate)2 PropertyStore (org.ff4j.property.store.PropertyStore)2 SpringSecurityAuthorisationManager (org.ff4j.security.SpringSecurityAuthorisationManager)2 TestConstantsFF4j (org.ff4j.test.TestConstantsFF4j)2 ApiConfig (org.ff4j.web.ApiConfig)2 ApiConfigBuilder (org.ff4j.web.ApiConfigBuilder)2