View Javadoc
1   /*
2    *
3    *  The DbUnit Database Testing Framework
4    *  Copyright (C)2002-2008, DbUnit.org
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or (at your option) any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   *
20   */
21  package org.dbunit.assertion;
22  
23  import org.dbunit.dataset.ITable;
24  
25  /**
26   * Value object to hold the difference of a single data cell found while
27   * comparing data.
28   * <p>
29   * Inspired by the XMLUnit framework.
30   * </p>
31   *
32   * @author gommma (gommma AT users.sourceforge.net)
33   * @author Last changed by: $Author$
34   * @version $Revision$ $Date$
35   * @since 2.4.0
36   * @since 2.6.0 added failMessage
37   */
38  public class Difference
39  {
40      private ITable expectedTable;
41      private ITable actualTable;
42      private int rowIndex;
43      private String columnName;
44      private Object expectedValue;
45      private Object actualValue;
46      private String failMessage;
47  
48      public Difference(final ITable expectedTable, final ITable actualTable,
49              final int rowIndex, final String columnName,
50              final Object expectedValue, final Object actualValue)
51      {
52          this(expectedTable, actualTable, rowIndex, columnName, expectedValue,
53                  actualValue, "");
54      }
55  
56      public Difference(final ITable expectedTable, final ITable actualTable,
57              final int rowIndex, final String columnName,
58              final Object expectedValue, final Object actualValue,
59              final String failMessage)
60      {
61          this.expectedTable = expectedTable;
62          this.actualTable = actualTable;
63          this.rowIndex = rowIndex;
64          this.columnName = columnName;
65          this.expectedValue = expectedValue;
66          this.actualValue = actualValue;
67          this.failMessage = failMessage;
68      }
69  
70      @Override
71      public String toString()
72      {
73          final StringBuilder sb = new StringBuilder();
74          sb.append(getClass().getName()).append("[");
75          sb.append("expectedTable=").append(expectedTable);
76          sb.append(", actualTable=").append(actualTable);
77          sb.append(", rowIndex=").append(rowIndex);
78          sb.append(", columnName=").append(columnName);
79          sb.append(", expectedValue=").append(expectedValue);
80          sb.append(", actualValue=").append(actualValue);
81          sb.append(", failMessage=").append(failMessage);
82          sb.append("]");
83          return sb.toString();
84      }
85  
86      public ITable getExpectedTable()
87      {
88          return expectedTable;
89      }
90  
91      public ITable getActualTable()
92      {
93          return actualTable;
94      }
95  
96      public int getRowIndex()
97      {
98          return rowIndex;
99      }
100 
101     public String getColumnName()
102     {
103         return columnName;
104     }
105 
106     public Object getExpectedValue()
107     {
108         return expectedValue;
109     }
110 
111     public Object getActualValue()
112     {
113         return actualValue;
114     }
115 
116     public String getFailMessage()
117     {
118         return failMessage;
119     }
120 
121     public void setFailMessage(final String failMessage)
122     {
123         this.failMessage = failMessage;
124     }
125 }