Search in sources :

Example 1 with PonderationStrategy

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

the class FeatureStoreJCacheTest method testUpdateRemoveFlippingStrategy.

/**
 * TDD.
 */
@Test
public void testUpdateRemoveFlippingStrategy() {
    // Given
    assertFf4j.assertThatFeatureExist(F3);
    Feature myFeature = ff4j.getFeatureStore().read(F3);
    myFeature.setFlippingStrategy(new PonderationStrategy(0.1));
    testedStore.update(myFeature);
    assertFf4j.assertThatFeatureHasFlippingStrategy(F3);
    // When
    Feature myFeature2 = ff4j.getFeatureStore().read(F3);
    myFeature2.setFlippingStrategy(null);
    testedStore.update(myFeature2);
    // Then
    assertFf4j.assertThatFeatureDoesNotHaveFlippingStrategy(F3);
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 2 with PonderationStrategy

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

the class FeatureStoreJCacheTest method testUpdateEditFlippingStrategy.

/**
 * TDD.
 */
@Test
public void testUpdateEditFlippingStrategy() {
    // Given
    assertFf4j.assertThatFeatureExist(F3);
    // When
    Feature myFeature = ff4j.getFeatureStore().read(F3);
    myFeature.setFlippingStrategy(new PonderationStrategy(0.1));
    testedStore.update(myFeature);
    // Then
    assertFf4j.assertThatFeatureHasFlippingStrategy(F3);
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 3 with PonderationStrategy

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

the class FF4jTest method testEmptyPermission.

@Test
public void testEmptyPermission() {
    FF4j ff4j = new FF4j();
    ff4j.createFeature("f1", true);
    ff4j.setAuthorizationsManager(new DefinedPermissionSecurityManager("a", new HashSet<String>()));
    Assert.assertTrue(ff4j.checkOveridingStrategy("f1", new PonderationStrategy(1d)));
    Assert.assertTrue(ff4j.isAllowed(ff4j.getFeature("f1")));
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) FF4j(org.ff4j.FF4j) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with PonderationStrategy

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

the class FeatureTest method testCopyConstructorFeature.

@Test
public void testCopyConstructorFeature() {
    Feature f = new Feature("abc", true, "samething", "groupA", Util.set("a", "b"));
    f.getPermissions().add("USER");
    f.setFlippingStrategy(new PonderationStrategy(0.5d));
    f.getCustomProperties().put("p1", new PropertyString("p1", "v1"));
    f.getCustomProperties().put("p2", new PropertyString("p1", "v1", Util.set("v1", "v2")));
    Feature f2 = new Feature(f);
    Assert.assertEquals(f2.getUid(), f.getUid());
    Assert.assertEquals(f2.getPermissions(), f.getPermissions());
    new Feature("f3", true, "samething", "groupA", Util.set("a", "b"), null);
    new Feature(new Feature("f4", true));
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 5 with PonderationStrategy

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

the class FeatureTest method testFullToStringImpl.

@Test
public void testFullToStringImpl() {
    List<String> auths = Arrays.asList(new String[] { "something" });
    Feature f = new Feature("ok", true, "grp1", "description", auths, new PonderationStrategy());
    Assert.assertTrue(f.toString().contains("ok"));
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) PropertyString(org.ff4j.property.PropertyString) 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