View Javadoc

1   package org.kuali.student.common.test.util;
2   
3   import java.util.List;
4   
5   import static org.junit.Assert.assertEquals;
6   
7   /**
8    * Helps create a dynamic list of object tester
9    * @author Mezba Mahtab
10   */
11  public class ListOfObjectTester {
12  
13      public void check(List<? extends Object> expectedList, List<? extends Object> actualList) {
14          if (expectedList.size () != actualList.size ()) {
15              this.dump(expectedList, actualList);
16          }
17          assertEquals(expectedList.size(), actualList.size());
18          for (int i = 0; i < expectedList.size(); i++) {
19              Object expected = expectedList.get(i);
20              Object actual = actualList.get(i);
21              assertEquals(expected, actual);
22          }
23      }
24  
25      public void dump (List<? extends Object> expectedList, List<? extends Object> actualList) {
26          System.out.println ("Original List");
27          this.dump(expectedList);
28          System.out.println ("Updated List");
29          this.dump(actualList);
30      }
31  
32      public void dump(List<? extends Object> list) {
33          for (int i = 0; i < list.size(); i++) {
34              String expected = list.get(i).toString();
35              System.out.println(i + ".) " + expected);
36          }
37      }
38  
39  }