1
2
3
4
5
6
7
8
9
10
11 package org.csveed.bean;
12
13 import static org.junit.jupiter.api.Assertions.assertNotNull;
14 import static org.junit.jupiter.api.Assertions.assertNull;
15 import static org.junit.jupiter.api.Assertions.assertThrows;
16
17 import org.csveed.common.Column;
18 import org.csveed.report.CsvException;
19 import org.csveed.test.model.BeanLotsOfIgnores;
20 import org.csveed.test.model.BeanWithWrongAnnotation;
21 import org.csveed.test.model.BeanWithoutGettersAndSetters;
22 import org.junit.jupiter.api.Test;
23
24
25
26
27 class BeanParserTest {
28
29
30
31
32 @Test
33 void noGettersAndSetters() {
34 BeanParser beanParser = new BeanParser();
35 BeanInstructions instructions = beanParser.getBeanInstructions(BeanWithoutGettersAndSetters.class);
36 assertNull(instructions.getProperties().fromName(new Column("a")));
37 }
38
39
40
41
42 @Test
43 void caseInsensitivity() {
44 BeanParser beanParser = new BeanParser();
45 BeanInstructions instructions = beanParser.getBeanInstructions(BeanLotsOfIgnores.class);
46 assertNotNull(instructions.getProperties().fromName(new Column("takeThis1")));
47 assertNotNull(instructions.getProperties().fromName(new Column("takethis1")));
48 }
49
50
51
52
53 @Test
54 void wrongAnnotation() {
55 BeanParser beanParser = new BeanParser();
56 assertThrows(CsvException.class, () -> beanParser.getBeanInstructions(BeanWithWrongAnnotation.class));
57 }
58
59 }