View Javadoc
1   package org.csveed.bean;
2   
3   import static org.junit.jupiter.api.Assertions.assertFalse;
4   import static org.junit.jupiter.api.Assertions.assertTrue;
5   
6   import org.csveed.common.Column;
7   import org.junit.jupiter.api.Test;
8   
9   public class DynamicColumnTest {
10  
11      @Test
12      public void advanceAndReset() {
13          int startColumn = 5;
14          int numberOfColumns = 7;
15          DynamicColumn column = new DynamicColumn(new Column(startColumn));
16          for (int i = 0; i < numberOfColumns - startColumn + 1; i++) {
17              column.advanceDynamicColumn();
18              assertFalse(column.atFirstDynamicColumn(), "Must not be at first column now");
19              column.checkForReset(numberOfColumns);
20          }
21          assertTrue(column.atFirstDynamicColumn(), "Must be at first dynamic column now");
22      }
23  
24      @Test
25      public void weHaveNoDynamicColumns() {
26          DynamicColumn column = new DynamicColumn(null);
27          column.advanceDynamicColumn(); // should have no effect
28          assertTrue(column.atFirstDynamicColumn(), "Must be at first dynamic column now"); // always the case if empty
29      }
30  
31      @Test
32      public void activeDynamicColumns() {
33          Column activeColumn = new Column(4);
34          Column inactiveColumn = new Column(5);
35          DynamicColumn dynamicColumn = new DynamicColumn(activeColumn);
36          assertTrue(dynamicColumn.isDynamicColumnActive(activeColumn), "Column "+activeColumn.getColumnIndex()+" must be active");
37          assertFalse(dynamicColumn.isDynamicColumnActive(inactiveColumn), "Column "+inactiveColumn.getColumnIndex()+" must be active");
38      }
39  }