Search in sources :

Example 6 with PonderationStrategy

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

the class JdbcFeatureStoreSchemaTest method testworkWithSchema.

@Test
public void testworkWithSchema() {
    // Given
    testedStore.createSchema();
    Assert.assertFalse(testedStore.exist("fx"));
    // When
    Feature fullFeature = new Feature("fx", true);
    fullFeature.setPermissions(Util.set("toto", "tata"));
    fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
    Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
    fullFeature.setCustomProperties(customProperties);
    testedStore.create(fullFeature);
    // Then
    Assert.assertTrue(testedStore.exist("fx"));
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 7 with PonderationStrategy

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

the class JdbcFeatureStoreSchemaTest method testCreateCustomProperties.

@Test
public void testCreateCustomProperties() {
    testedStore.createSchema();
    // When
    Feature fullFeature = new Feature("fx", true);
    fullFeature.setPermissions(Util.set("toto", "tata"));
    fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
    Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
    fullFeature.setCustomProperties(customProperties);
    testedStore.create(fullFeature);
    testedStore.createCustomProperties("fx", null);
    Property<?> p1 = new PropertyString("p1");
    p1.setFixedValues(null);
    Property<String> p2 = new PropertyString("p2");
    p2.setFixedValues(Util.set("v1", "v3"));
    testedStore.createCustomProperties("fx", Arrays.asList(p2, p1));
    testedStore.createCustomProperties("fx", null);
}
Also used : PonderationStrategy(org.ff4j.strategy.PonderationStrategy) PropertyString(org.ff4j.property.PropertyString) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 8 with PonderationStrategy

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

the class PonderationStrategyTest method testInitializationThroughIOc.

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

Example 9 with PonderationStrategy

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

the class CoreFeatureStoreTestSupport 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 10 with PonderationStrategy

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

the class FeatureStoreTestSupport 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)

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