View Javadoc
1   package org.csveed.bean;
2   
3   import static org.junit.jupiter.api.Assertions.assertNotNull;
4   import static org.junit.jupiter.api.Assertions.assertNull;
5   import static org.junit.jupiter.api.Assertions.assertThrows;
6   
7   import org.csveed.common.Column;
8   import org.csveed.report.CsvException;
9   import org.csveed.test.model.BeanLotsOfIgnores;
10  import org.csveed.test.model.BeanWithWrongAnnotation;
11  import org.csveed.test.model.BeanWithoutGettersAndSetters;
12  import org.junit.jupiter.api.Test;
13  
14  public class BeanParserTest {
15  
16      @Test
17      public void noGettersAndSetters() {
18          BeanParser beanParser = new BeanParser();
19          BeanInstructions instructions = beanParser.getBeanInstructions(BeanWithoutGettersAndSetters.class);
20          assertNull(instructions.getProperties().fromName(new Column("a")));
21      }
22  
23      @Test
24      public void caseInsensitivity() {
25          BeanParser beanParser = new BeanParser();
26          BeanInstructions instructions = beanParser.getBeanInstructions(BeanLotsOfIgnores.class);
27          assertNotNull(instructions.getProperties().fromName(new Column("takeThis1")));
28          assertNotNull(instructions.getProperties().fromName(new Column("takethis1")));
29      }
30  
31      @Test
32      public void wrongAnnotation() {
33          BeanParser beanParser = new BeanParser();
34          assertThrows(CsvException.class, () ->  {
35              beanParser.getBeanInstructions(BeanWithWrongAnnotation.class);
36          });
37      }
38  
39  }