1
2
3
4
5
6
7
8
9
10
11 package org.csveed.row;
12
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14 import static org.junit.jupiter.api.Assertions.assertThrows;
15
16 import org.csveed.api.Header;
17 import org.csveed.report.CsvException;
18 import org.junit.jupiter.api.Test;
19
20
21
22
23 class HeaderTest {
24
25
26
27
28 @Test
29 void getNonExistingColumnName() {
30 Header header = new HeaderImpl(createLine("alpha"));
31 assertThrows(CsvException.class, () -> header.getIndex("does-not-exist"));
32 }
33
34
35
36
37 @Test
38 void getNonExistingColumnIndex() {
39 Header header = new HeaderImpl(createLine("alpha"));
40 assertThrows(CsvException.class, () -> header.getName(13));
41 }
42
43
44
45
46 @Test
47 void toLowerCase() {
48 Header header = new HeaderImpl(createLine("Alpha"));
49 assertEquals("Alpha", header.getName(1));
50 assertEquals(1, header.getIndex("Alpha"));
51 }
52
53
54
55
56
57
58
59
60
61 protected LineWithInfo createLine(String cell) {
62 LineWithInfo line = new LineWithInfo();
63 line.addCell(cell);
64 return line;
65 }
66 }