use of org.ff4j.core.Feature 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);
}
use of org.ff4j.core.Feature 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);
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreJCacheTest method testReadFullFeature.
/**
* TDD.
*/
@Test
public void testReadFullFeature() {
// Given
assertFf4j.assertThatFeatureExist(F4);
// When
Feature f = testedStore.read(F4);
// Then
Assert.assertEquals(f.getUid(), F4);
Assert.assertTrue(f.getDescription() != null && !"".equals(f.getDescription()));
Assert.assertTrue(f.getPermissions() != null && !f.getPermissions().isEmpty());
assertFf4j.assertThatFeatureHasRole(F4, ROLE_ADMIN);
assertFf4j.assertThatFeatureIsInGroup(F4, G1);
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreJCacheTest method testClear.
@Test
public void testClear() {
// Given
Assert.assertNotNull(testedStore);
Map<String, Feature> before = testedStore.readAll();
Assert.assertFalse(before.isEmpty());
// When
testedStore.clear();
// Then
Assert.assertTrue(testedStore.readAll().isEmpty());
// / Reinit
for (String pName : before.keySet()) {
testedStore.create(before.get(pName));
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreJCacheTest method testUpdateEditPropertyAddFixedValues.
/**
* TDD.
*/
@Test
@SuppressWarnings("unchecked")
public void testUpdateEditPropertyAddFixedValues() {
// Given
assertFf4j.assertThatFeatureExist(F1);
Feature myFeature = ff4j.getFeatureStore().read(F1);
myFeature = ff4j.getFeatureStore().read(F1);
myFeature.addProperty(new PropertyInt("digitValue", 2, Util.set(0, 1, 2, 3)));
ff4j.getFeatureStore().update(myFeature);
assertFf4j.assertThatFeatureHasProperty(F1, "digitValue");
Set<Integer> fixValues = (Set<Integer>) ff4j.getFeatureStore().read(//
F1).getCustomProperties().get("digitValue").getFixedValues();
Assert.assertEquals(4, fixValues.size());
// When
myFeature = ff4j.getFeatureStore().read(F1);
PropertyInt p1 = new PropertyInt("digitValue");
p1.setFixedValues(Util.set(0, 1, 2, 3, 4));
p1.setValue(4);
myFeature.getCustomProperties().put(p1.getName(), p1);
testedStore.update(myFeature);
// Then
Set<Integer> fixValues2 = (Set<Integer>) ff4j.getFeatureStore().read(//
F1).getCustomProperties().get("digitValue").getFixedValues();
Assert.assertEquals(5, fixValues2.size());
}
Aggregations