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"));
}
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);
}
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);
}
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());
}
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);
}
Aggregations