Ejemplo n.º 1
0
 @Test
 public void testReportDiff() {
   String[][] cols = {
     {"a", "b"},
     {"c", "d"}
   };
   String[][] rows = {
     {"r1", "r2"},
     {"r3", "r4"}
   };
   Integer[][] mainData = {
     {3, 4},
     {5, 6}
   };
   Integer[][] diffData = {
     {3, 4},
     {5, 7}
   };
   ReportContent diffReport =
       JTableDiff.produceReportDiff(
           new ReportContent<String, String, Integer>(rows, cols, mainData, cols),
           new ReportContent<String, String, Integer>(rows, cols, diffData, cols));
   String onlyDiffs = StringTableDiff.diffReportToString(TableDiff.onlyTheDiffs(diffReport));
   assertEquals(
       onlyDiffs,
       "+-----+----------+\n"
           + "|a |b |b         |\n"
           + "|c |d |d         |\n"
           + "+-----+----------+\n"
           + "|r3|r4|[-6-]{+7+}|\n"
           + "+-----+----------+\n");
 }
Ejemplo n.º 2
0
 @Test
 public void testArraySlicing() {
   String[][] arrayTable = {
     {" ", "c11", "c21", "c31"},
     {" ", "c12", "c22", "c32"},
     {"r1", "m11", "m21", "m31"},
     {"r2", "m12", "m22", "m32"}
   };
   ReportContent table1 = JTableDiff.reportContentFromArray(arrayTable, 1, 2);
   arrayTable[3][3] = "mD32iff";
   arrayTable[0][2] = "c21Diff";
   ReportContent table2 = JTableDiff.reportContentFromArray(arrayTable, 1, 2);
   ReportContent diffReport2 = JTableDiff.produceReportDiff(table1, table2);
   String diffs2 = StringTableDiff.diffReportToString(TableDiff.onlyTheDiffs(diffReport2));
   assertEquals(
       diffs2,
       "+--+---------------------------+\n"
           + "|  |c21{+Diff+}|c31            |\n"
           + "|  |c22        |c32            |\n"
           + "+--+---------------------------+\n"
           + "|r2|m22        |m{+D+}32{+iff+}|\n"
           + "+--+---------------------------+\n");
 }