Search in sources :

Example 46 with PropertyValue

use of cn.taketoday.beans.PropertyValue in project today-infrastructure by TAKETODAY.

the class RequestContextDataBinderTests method doTestTony.

/**
 * Must contain: forname=Tony surname=Blair age=50
 */
protected void doTestTony(PropertyValues pvs) throws Exception {
    assertThat(pvs.toArray().length == 3).as("Contains 3").isTrue();
    assertThat(pvs.contains("forname")).as("Contains forname").isTrue();
    assertThat(pvs.contains("surname")).as("Contains surname").isTrue();
    assertThat(pvs.contains("age")).as("Contains age").isTrue();
    boolean condition1 = !pvs.contains("tory");
    assertThat(condition1).as("Doesn't contain tory").isTrue();
    PropertyValue[] pvArray = pvs.toArray();
    Map<String, String> m = new HashMap<>();
    m.put("forname", "Tony");
    m.put("surname", "Blair");
    m.put("age", "50");
    for (PropertyValue pv : pvArray) {
        Object val = m.get(pv.getName());
        assertThat(val != null).as("Can't have unexpected value").isTrue();
        boolean condition = val instanceof String;
        assertThat(condition).as("Val i string").isTrue();
        assertThat(val.equals(pv.getValue())).as("val matches expected").isTrue();
        m.remove(pv.getName());
    }
    assertThat(m.size() == 0).as("Map size is 0").isTrue();
}
Also used : HashMap(java.util.HashMap) PropertyValue(cn.taketoday.beans.PropertyValue)

Aggregations

PropertyValue (cn.taketoday.beans.PropertyValue)46 PropertyValues (cn.taketoday.beans.PropertyValues)28 Test (org.junit.jupiter.api.Test)22 ConfigurablePropertyAccessor (cn.taketoday.beans.ConfigurablePropertyAccessor)6 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)6 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)6 MultiValueMap (cn.taketoday.core.MultiValueMap)6 List (java.util.List)6 Map (java.util.Map)6 BeanMetadata (cn.taketoday.beans.BeanMetadata)4 BeanWrapper (cn.taketoday.beans.BeanWrapper)4 BeanWrapperImpl (cn.taketoday.beans.BeanWrapperImpl)4 BooleanTestBean (cn.taketoday.beans.BooleanTestBean)4 NumberTestBean (cn.taketoday.beans.NumberTestBean)4 BeanDefinition (cn.taketoday.beans.factory.config.BeanDefinition)4 IndexedTestBean (cn.taketoday.beans.testfixture.beans.IndexedTestBean)4 Nullable (cn.taketoday.lang.Nullable)4 RequestContextDataBinder (cn.taketoday.web.bind.RequestContextDataBinder)4 ArrayList (java.util.ArrayList)4 AnnotationAwareAspectJAutoProxyCreator (cn.taketoday.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator)2