1
2
3
4
5
6
7
8
9
10
11 package org.csveed.bean;
12
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertNotNull;
15 import static org.junit.jupiter.api.Assertions.assertNull;
16 import static org.junit.jupiter.api.Assertions.assertTrue;
17
18 import java.beans.IntrospectionException;
19 import java.beans.PropertyDescriptor;
20
21 import org.csveed.bean.conversion.Converter;
22 import org.csveed.test.converters.BeanSimpleConverter;
23 import org.csveed.test.model.BeanSimple;
24 import org.csveed.test.model.BeanVariousNotAnnotated;
25 import org.junit.jupiter.api.Test;
26
27
28
29
30 class BeanPropertyTest {
31
32
33
34
35
36
37
38 @Test
39 void construct() throws IntrospectionException {
40 BeanProperty property = new BeanProperty();
41 Converter<BeanSimple> converter = new BeanSimpleConverter();
42 PropertyDescriptor propertyDescriptor = new PropertyDescriptor("name", BeanSimple.class);
43 property.setConverter(converter);
44 property.setColumnIndex(3);
45 property.setColumnName("name");
46 property.setPropertyDescriptor(propertyDescriptor);
47 property.setRequired(true);
48 assertEquals(converter, property.getConverter());
49 assertEquals(3, property.getColumnIndex());
50 assertEquals("name", property.getColumnName());
51 assertEquals(propertyDescriptor, property.getPropertyDescriptor());
52 assertTrue(property.isRequired());
53 }
54
55
56
57
58
59
60
61 @Test
62 void numberClass() throws IntrospectionException {
63 BeanProperty property = new BeanProperty();
64 property.setPropertyDescriptor(new PropertyDescriptor("number", BeanVariousNotAnnotated.class));
65 assertNotNull(property.getNumberClass());
66 }
67
68
69
70
71
72
73
74 @Test
75 void notANumberClass() throws IntrospectionException {
76 BeanProperty property = new BeanProperty();
77 property.setPropertyDescriptor(new PropertyDescriptor("name", BeanSimple.class));
78 assertNull(property.getNumberClass());
79 }
80
81 }