Search in sources :

Example 26 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class AbstractPropertyStoreJunitTest method updateKOdoesnotExist2.

/**
 * TDD.
 */
@Test(expected = PropertyNotFoundException.class)
public void updateKOdoesnotExist2() {
    // Given
    Assert.assertFalse(testedStore.existProperty("invalid"));
    // When
    testedStore.updateProperty(new PropertyString("invalid", "abc"));
    // Expected error
    Assert.fail();
}
Also used : PropertyString(org.ff4j.property.PropertyString) Test(org.junit.Test)

Example 27 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class JdbcFeatureStoreSchemaTest method testCreateCustomProperties.

@SuppressWarnings("unchecked")
@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 28 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class MappingUtilsTest method testJsonCustomProperties.

@Test
public void testJsonCustomProperties() {
    // Given
    Map<String, Property<?>> props = new HashMap<String, Property<?>>();
    props.put("f1", new PropertyString("f1", "v1"));
    props.put("f2", new PropertyString("f2", "v2"));
    // When
    String expression = JsonUtils.customPropertiesAsJson(props);
    // Then
    Assert.assertNotNull(expression);
}
Also used : PropertyString(org.ff4j.property.PropertyString) HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 29 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class PropertyStoreTestSupport method updateKOPropertyNotFound.

/**
 * TDD.
 */
@Test(expected = PropertyNotFoundException.class)
public void updateKOPropertyNotFound() {
    // When
    PropertyString ps = new PropertyString("does-not-exist");
    testedStore.updateProperty(ps);
}
Also used : PropertyString(org.ff4j.property.PropertyString) Test(org.junit.Test)

Example 30 with PropertyString

use of org.ff4j.property.PropertyString in project ff4j by ff4j.

the class PropertyStoreTestSupport method readOK.

// ------------------ read --------------------
@Test
public void readOK() {
    // Given
    testedStore.createProperty(new PropertyString("toto", "ff4j"));
    // When
    Property<?> ap = testedStore.readProperty("toto");
    // Then
    Assert.assertNotNull(ap);
    Assert.assertNotNull(ap.getName());
    Assert.assertEquals("toto", ap.getName());
    Assert.assertEquals("ff4j", ap.getValue());
    Assert.assertEquals("ff4j", ap.asString());
    Assert.assertNull(ap.getFixedValues());
}
Also used : PropertyString(org.ff4j.property.PropertyString) Test(org.junit.Test)

Aggregations

PropertyString (org.ff4j.property.PropertyString)54 Test (org.junit.Test)52 Feature (org.ff4j.core.Feature)18 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)11 Property (org.ff4j.property.Property)6 HashSet (java.util.HashSet)5 Set (java.util.Set)4 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)4 HashMap (java.util.HashMap)3 FF4j (org.ff4j.FF4j)3 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)3 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 DataSource (javax.sql.DataSource)2 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)2 PropertyJsonBean (org.ff4j.property.util.PropertyJsonBean)2 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)2 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1