Search in sources :

Example 21 with PonderationStrategy

use of org.ff4j.strategy.PonderationStrategy in project ff4j by ff4j.

the class PonderationStrategyTest method testInitializations.

@Test
public void testInitializations() {
    PonderationStrategy pfs = new DarkLaunchStrategy();
    pfs.setWeight(0.5);
    new DarkLaunchStrategy(0.5);
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) DarkLaunchStrategy(org.ff4j.strategy.DarkLaunchStrategy) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 22 with PonderationStrategy

use of org.ff4j.strategy.PonderationStrategy in project ff4j by ff4j.

the class FeatureStoreNeo4jLimitTest method testChangeGroup.

@Test
public void testChangeGroup() {
    try (Transaction tx = graphDb.beginTx()) {
        graphDb.execute("CREATE " + " (h0:FF4J_FEATURE_GROUP { name:'h0' }),\n" + " (h1:FF4J_FEATURE { uid:'h1', enable:false, description:'second', roles:['USER'] }),\n" + " (h1)-[:MEMBER_OF]->(h0);");
        tx.success();
    }
    Feature f1 = testedStore.read("h1");
    Property<?> newP = new PropertyString("ppp", "vvv");
    newP.setDescription("a description");
    f1.addProperty(newP);
    FlippingStrategy fs = new PonderationStrategy(0.1);
    fs.getInitParams().put("p1", "v1");
    fs.getInitParams().put("p2", "v2");
    f1.setFlippingStrategy(fs);
    f1.setGroup("g2");
    testedStore.update(f1);
    Assert.assertEquals("g2", testedStore.read("h1").getGroup());
    f1.getFlippingStrategy().getInitParams().put("p3", "v3");
    testedStore.update(f1);
    testedStore.setGraphDb(testedStore.getGraphDb());
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) PropertyString(org.ff4j.property.PropertyString) Transaction(org.neo4j.graphdb.Transaction) FlippingStrategy(org.ff4j.core.FlippingStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Aggregations

PonderationStrategy (org.ff4j.strategy.PonderationStrategy)22 Test (org.junit.Test)22 Feature (org.ff4j.core.Feature)19 PropertyString (org.ff4j.property.PropertyString)9 FlippingStrategy (org.ff4j.core.FlippingStrategy)4 HashMap (java.util.HashMap)2 Property (org.ff4j.property.Property)2 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)2 HashSet (java.util.HashSet)1 FF4j (org.ff4j.FF4j)1 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)1 DarkLaunchStrategy (org.ff4j.strategy.DarkLaunchStrategy)1 Transaction (org.neo4j.graphdb.Transaction)1