Search in sources :

Example 1 with BeanProperty

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

the class TypeDescriptorTests method nestedPropertyTypeMapTwoLevels.

@Test
public void nestedPropertyTypeMapTwoLevels() throws Exception {
    final BeanProperty property = BeanProperty.valueOf(getClass(), "test4");
    TypeDescriptor t1 = TypeDescriptor.nested(property.getField(), 2);
    assertThat(t1.getType()).isEqualTo(String.class);
}
Also used : BeanProperty(cn.taketoday.beans.BeanProperty) Test(org.junit.jupiter.api.Test)

Example 2 with BeanProperty

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

the class TypeDescriptorTests method propertyComplex.

@Test
public void propertyComplex() throws Exception {
    BeanProperty complexProperty = BeanProperty.valueOf(getClass(), "complexProperty");
    TypeDescriptor desc = complexProperty.getTypeDescriptor();
    assertThat(desc.getMapKeyDescriptor().getType()).isEqualTo(String.class);
    assertThat(desc.getMapValueDescriptor().getElementDescriptor().getElementDescriptor().getType()).isEqualTo(Integer.class);
}
Also used : BeanProperty(cn.taketoday.beans.BeanProperty) Test(org.junit.jupiter.api.Test)

Example 3 with BeanProperty

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

the class TypeDescriptorTests method propertyGenericType.

@Test
void propertyGenericType() throws Exception {
    GenericType<Integer> genericBean = new IntegerType();
    BeanProperty property = BeanProperty.valueOf(genericBean.getClass().getMethod("getProperty"), genericBean.getClass().getMethod("setProperty", Integer.class));
    TypeDescriptor desc = property.getTypeDescriptor();
    assertThat(desc.getType()).isEqualTo(Integer.class);
}
Also used : BeanProperty(cn.taketoday.beans.BeanProperty) Test(org.junit.jupiter.api.Test)

Example 4 with BeanProperty

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

the class TypeDescriptorTests method propertyGenericTypeList.

@Test
void propertyGenericTypeList() throws Exception {
    GenericType<Integer> genericBean = new IntegerType();
    BeanProperty property = BeanProperty.valueOf(genericBean.getClass().getMethod("getListProperty"), genericBean.getClass().getMethod("setListProperty", List.class));
    TypeDescriptor desc = property.getTypeDescriptor();
    assertThat(desc.getType()).isEqualTo(List.class);
    assertThat(desc.getElementDescriptor().getType()).isEqualTo(Integer.class);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) BeanProperty(cn.taketoday.beans.BeanProperty) Test(org.junit.jupiter.api.Test)

Example 5 with BeanProperty

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

the class TypeDescriptorTests method propertyGenericClassList.

@Test
void propertyGenericClassList() throws Exception {
    IntegerClass genericBean = new IntegerClass();
    BeanProperty property = BeanProperty.valueOf(genericBean.getClass().getMethod("getListProperty"), genericBean.getClass().getMethod("setListProperty", List.class), IntegerClass.class);
    TypeDescriptor desc = property.getTypeDescriptor();
    assertThat(desc.getType()).isEqualTo(List.class);
    assertThat(desc.getElementDescriptor().getType()).isEqualTo(Integer.class);
    assertThat(desc.getAnnotation(MethodAnnotation1.class)).isNotNull();
    assertThat(desc.hasAnnotation(MethodAnnotation1.class)).isTrue();
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) BeanProperty(cn.taketoday.beans.BeanProperty) Test(org.junit.jupiter.api.Test)

Aggregations

BeanProperty (cn.taketoday.beans.BeanProperty)42 Test (org.junit.jupiter.api.Test)22 JdbcBeanMetadata (cn.taketoday.jdbc.result.JdbcBeanMetadata)8 BeanWrapperImpl (cn.taketoday.beans.BeanWrapperImpl)6 ArrayList (java.util.ArrayList)6 List (java.util.List)4 BeanMetadata (cn.taketoday.beans.BeanMetadata)2 NotWritablePropertyException (cn.taketoday.beans.NotWritablePropertyException)2 SimpleTypeConverter (cn.taketoday.beans.SimpleTypeConverter)2 TypeMismatchException (cn.taketoday.beans.TypeMismatchException)2 PropertyAccessor (cn.taketoday.core.reflect.PropertyAccessor)2 DataRetrievalFailureException (cn.taketoday.dao.DataRetrievalFailureException)2 InvalidDataAccessApiUsageException (cn.taketoday.dao.InvalidDataAccessApiUsageException)2 Method (java.lang.reflect.Method)2 ResultSet (java.sql.ResultSet)2 ResultSetMetaData (java.sql.ResultSetMetaData)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2