Search in sources :

Example 11 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 12 with PonderationStrategy

use of org.ff4j.strategy.PonderationStrategy 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());
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) FlippingStrategy(org.ff4j.core.FlippingStrategy) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 13 with PonderationStrategy

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

the class FeatureStoreJCacheTest method testUpdateAddFlippingStrategy.

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

Example 14 with PonderationStrategy

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

the class FeatureStoreTestSupport 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 15 with PonderationStrategy

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

the class FeatureStoreTestSupport 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());
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) FlippingStrategy(org.ff4j.core.FlippingStrategy) 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