use of org.ff4j.core.FlippingStrategy in project ff4j by ff4j.
the class ClientFilterStrategyTest method testInitialisationProgram.
@Test
public void testInitialisationProgram() {
FlippingStrategy fs = new ClientFilterStrategy("Pierre, Paul, Jacques");
fs.init("f1", null);
fs.init("f1", new HashMap<String, String>());
new WhiteListStrategy();
new WhiteListStrategy("Pierre");
// Working
new BlackListStrategy();
FlippingStrategy bl2 = new BlackListStrategy("Pierre");
FlippingExecutionContext context = new FlippingExecutionContext();
context.putString("clientHostName", "localhost");
Assert.assertTrue(bl2.evaluate("f1", new InMemoryFeatureStore(), context));
context.putString("clientHostName", "Pierre");
Assert.assertFalse(bl2.evaluate("f1", new InMemoryFeatureStore(), context));
}
use of org.ff4j.core.FlippingStrategy in project ff4j by ff4j.
the class FeatureStoreJCacheTest method testUpdateFeatureCoreData.
/**
* TDD.
*/
@Test
public void testUpdateFeatureCoreData() {
// Parameters
String newDescription = "new-description";
FlippingStrategy newStrategy = new PonderationStrategy(0.12);
// Given
assertFf4j.assertThatFeatureExist(F1);
Assert.assertFalse(newDescription.equals(testedStore.read(F1).getDescription()));
// When
Feature fpBis = testedStore.read(F1);
fpBis.setDescription(newDescription);
fpBis.setFlippingStrategy(newStrategy);
testedStore.update(fpBis);
// Then
Feature updatedFeature = testedStore.read(F1);
Assert.assertTrue(newDescription.equals(updatedFeature.getDescription()));
Assert.assertNotNull(updatedFeature.getFlippingStrategy());
Assert.assertEquals(newStrategy.toString(), updatedFeature.getFlippingStrategy().toString());
}
use of org.ff4j.core.FlippingStrategy 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());
}
Aggregations