Search in sources :

Example 91 with Feature

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

Example 92 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureStoreJCacheTest method testDeleteFeature.

/**
 * TDD.
 */
@Test
public void testDeleteFeature() throws Exception {
    // Given
    assertFf4j.assertThatFeatureExist(F1);
    Feature tmpf1 = testedStore.read(F1);
    int initialNumber = testedStore.readAll().size();
    // When
    testedStore.delete(F1);
    // Then
    assertFf4j.assertThatStoreHasSize(initialNumber - 1);
    assertFf4j.assertThatFeatureDoesNotExist(F1);
    // End, Reinit initial state
    testedStore.create(tmpf1);
    assertFf4j.assertThatFeatureExist(F1);
}
Also used : Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 93 with Feature

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

Example 94 with Feature

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

Example 95 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class AbstractFeatureStore method removeRoleFromFeature.

/**
 * {@inheritDoc}
 */
@Override
public void removeRoleFromFeature(String flipId, String roleName) {
    Util.assertParamHasLength(roleName, "roleName (#2)");
    // retrieve
    Feature f = read(flipId);
    f.getPermissions().remove(roleName);
    // persist modification
    update(f);
}
Also used : Feature(org.ff4j.core.Feature)

Aggregations

Feature (org.ff4j.core.Feature)295 Test (org.junit.Test)144 PropertyString (org.ff4j.property.PropertyString)53 HashMap (java.util.HashMap)38 HashSet (java.util.HashSet)27 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 Property (org.ff4j.property.Property)16 LinkedHashMap (java.util.LinkedHashMap)15 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)15 Map (java.util.Map)14 XmlParser (org.ff4j.conf.XmlParser)14 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 FeatureAccessException (org.ff4j.exception.FeatureAccessException)13 InputStream (java.io.InputStream)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 Set (java.util.Set)10 Response (javax.ws.rs.core.Response)10 FlippingStrategy (org.ff4j.core.FlippingStrategy)10 CouchDbFeature (org.ff4j.couchdb.document.CouchDbFeature)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9