Search in sources :

Example 6 with PropertyJsonBean

use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.

the class PropertyFactoryTest method testCreatePropertyOK.

@Test
public void testCreatePropertyOK() {
    PropertyJsonBean jsonBean = new PropertyJsonBean(new PropertyString("p1", "v1"));
    Assert.assertNotNull(PropertyFactory.createProperty(jsonBean));
}
Also used : PropertyString(org.ff4j.property.PropertyString) PropertyJsonBean(org.ff4j.property.util.PropertyJsonBean) Test(org.junit.Test)

Example 7 with PropertyJsonBean

use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.

the class PropertyTest method testPropertyJsonBeanFromScratch.

@Test
public void testPropertyJsonBeanFromScratch() {
    PropertyJsonBean jb = new PropertyJsonBean();
    jb.setName("name");
    jb.setType(PropertyString.class.getName());
    jb.setFixedValues(Util.set("AMER", "EUROP"));
    jb.setValue("AMER");
    Assert.assertNotNull(jb.toString());
}
Also used : PropertyString(org.ff4j.property.PropertyString) PropertyJsonBean(org.ff4j.property.util.PropertyJsonBean) Test(org.junit.Test)

Example 8 with PropertyJsonBean

use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.

the class PropertyTest method testPropertyJsonBean.

@Test
public void testPropertyJsonBean() {
    PropertyString p2 = new PropertyString("p2", "EAST", Util.set("EAST", "WEST", "SOUTH", "NORTH"));
    PropertyJsonBean jb = new PropertyJsonBean(p2);
    jb.setDescription("descs");
    Assert.assertNotNull(jb);
    Assert.assertNotNull(jb.getName());
    Assert.assertNotNull(jb.getType());
    Assert.assertNotNull(jb.getDescription());
    Assert.assertNotNull(jb.getFixedValues());
    Assert.assertNotNull(jb.getValue());
    Assert.assertNotNull(jb.asProperty());
}
Also used : PropertyString(org.ff4j.property.PropertyString) PropertyJsonBean(org.ff4j.property.util.PropertyJsonBean) Test(org.junit.Test)

Example 9 with PropertyJsonBean

use of org.ff4j.property.util.PropertyJsonBean in project ff4j by ff4j.

the class MongoPropertyMapper method fromStore.

/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public Property<?> fromStore(Document dbObject) {
    PropertyJsonBean pf = new PropertyJsonBean();
    pf.setName((String) dbObject.get(PROPERTY_NAME));
    pf.setDescription((String) dbObject.get(PROPERTY_DESCRIPTION));
    pf.setType((String) dbObject.get(PROPERTY_TYPE));
    pf.setValue((String) dbObject.get(PROPERTY_VALUE));
    if (dbObject.containsKey(PROPERTY_FIXEDVALUES)) {
        ArrayList<String> dbList = (ArrayList<String>) dbObject.get(PROPERTY_FIXEDVALUES);
        if (dbList != null) {
            for (Object item : dbList) {
                pf.addFixedValue((String) item);
            }
        }
    }
    return pf.asProperty();
}
Also used : ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject) PropertyJsonBean(org.ff4j.property.util.PropertyJsonBean)

Aggregations

PropertyJsonBean (org.ff4j.property.util.PropertyJsonBean)9 PropertyString (org.ff4j.property.PropertyString)4 Test (org.junit.Test)4 DBObject (com.mongodb.DBObject)3 BasicDBList (com.mongodb.BasicDBList)2 ArrayList (java.util.ArrayList)2 BasicDBObject (com.mongodb.BasicDBObject)1 Property (org.ff4j.property.Property)1