Search in sources :

Example 31 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 32 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 33 with Feature

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

Example 34 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 35 with Feature

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());
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Feature(org.ff4j.core.Feature) PropertyInt(org.ff4j.property.PropertyInt) Test(org.junit.Test)

Aggregations

Feature (org.ff4j.core.Feature)258 Test (org.junit.Test)136 PropertyString (org.ff4j.property.PropertyString)49 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)29 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 LinkedHashMap (java.util.LinkedHashMap)15 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 Property (org.ff4j.property.Property)12 Set (java.util.Set)11 FeatureAccessException (org.ff4j.exception.FeatureAccessException)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 XmlParser (org.ff4j.conf.XmlParser)10 InputStream (java.io.InputStream)9 Map (java.util.Map)9 FlippingStrategy (org.ff4j.core.FlippingStrategy)9 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)9 ClientResponse (com.sun.jersey.api.client.ClientResponse)8 ArrayList (java.util.ArrayList)8 Response (javax.ws.rs.core.Response)8