View Javadoc
1   package org.csveed.bean;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   import static org.junit.jupiter.api.Assertions.assertNotNull;
5   import static org.junit.jupiter.api.Assertions.assertNull;
6   import static org.junit.jupiter.api.Assertions.assertTrue;
7   
8   import java.beans.IntrospectionException;
9   import java.beans.PropertyDescriptor;
10  
11  import org.csveed.bean.conversion.Converter;
12  import org.csveed.test.converters.BeanSimpleConverter;
13  import org.csveed.test.model.BeanSimple;
14  import org.csveed.test.model.BeanVariousNotAnnotated;
15  import org.junit.jupiter.api.Test;
16  
17  public class BeanPropertyTest {
18  
19      @Test
20      public void construct() throws IntrospectionException {
21          BeanProperty property = new BeanProperty();
22          Converter<BeanSimple> converter = new BeanSimpleConverter();
23          PropertyDescriptor propertyDescriptor = new PropertyDescriptor("name", BeanSimple.class);
24          property.setConverter(converter);
25          property.setColumnIndex(3);
26          property.setColumnName("name");
27          property.setPropertyDescriptor(propertyDescriptor);
28          property.setRequired(true);
29          assertEquals(converter, property.getConverter());
30          assertEquals(3, property.getColumnIndex());
31          assertEquals("name", property.getColumnName());
32          assertEquals(propertyDescriptor, property.getPropertyDescriptor());
33          assertTrue(property.isRequired());
34      }
35  
36      @Test
37      public void numberClass() throws IntrospectionException {
38          BeanProperty property = new BeanProperty();
39          property.setPropertyDescriptor(new PropertyDescriptor("number", BeanVariousNotAnnotated.class));
40          assertNotNull(property.getNumberClass());
41      }
42  
43      @Test
44      public void notANumberClass() throws IntrospectionException {
45          BeanProperty property = new BeanProperty();
46          property.setPropertyDescriptor(new PropertyDescriptor("name", BeanSimple.class));
47          assertNull(property.getNumberClass());
48      }
49  
50  }