import ch.inftec.ju.db.DbRowUtils.DbRowBuilder;
public class DbRowUtilsTest {
@Test
public void testEqualsAndHashCode() {
DbRowBuilder r1Builder = DbRowUtils.newDbRow();
DbRowBuilder r2Builder = DbRowUtils.newDbRow();
r1Builder.addValue("col1", 1, 1);
Assert.assertFalse(r1Builder.getRow().equals(r2Builder.getRow()));
Assert.assertFalse(r1Builder.getRow().hashCode() == r2Builder.getRow().hashCode());
r2Builder.addValue("col2", 2, 2);
Assert.assertFalse(r1Builder.getRow().equals(r2Builder.getRow()));
Assert.assertFalse(r1Builder.getRow().hashCode() == r2Builder.getRow().hashCode());
r1Builder.addValue("col2", 2, 2);
r2Builder.addValue("col1", 1, 1);
// Still false, because order doesn't match
Assert.assertFalse(r1Builder.getRow().equals(r2Builder.getRow()));
Assert.assertFalse(r1Builder.getRow().hashCode() == r2Builder.getRow().hashCode());
DbRowBuilder r3Builder = DbRowUtils.newDbRow();
r3Builder.addValue("col1", 1, 1);
r3Builder.addValue("col2", 2, 2);
Assert.assertTrue(r1Builder.getRow().hashCode() == r3Builder.getRow().hashCode());
Assert.assertTrue(r1Builder.getRow().equals(r3Builder.getRow()));
Assert.assertTrue(r3Builder.getRow().equals(r1Builder.getRow()));
Assert.assertTrue(r1Builder.getRow().equals(r1Builder.getRow()));
Assert.assertFalse(r1Builder.getRow().equals(null));
Assert.assertFalse(r1Builder.getRow().equals(this));
}