*/
public class RecordTest extends AbstractTest {
@Test
public void testComparableRecords() throws Exception {
Table1Record r1 = create.newRecord(Table1.TABLE1);
Table2Record r2 = create.newRecord(Table2.TABLE2);
Table4Record r4a = create.newRecord(Table4.TABLE4);
Table4Record r4b = create.newRecord(Table4.TABLE4);
// Incomparable (incompatible) records
try {
r1.compareTo(r4a);
fail();
}
catch (ClassCastException expected) {}
// Comparable records
assertEquals(0, r1.compareTo(r2));
assertEquals(0, r4a.compareTo(r4b));
r2.setValue(Table2.FIELD_ID2, 1);
assertEquals(1, r1.compareTo(r2));
r2.setValue(Table2.FIELD_NAME2, "1");
assertEquals(1, r1.compareTo(r2));
r1.setValue(Table1.FIELD_ID1, 1);
assertEquals(1, r1.compareTo(r2));
r1.setValue(Table1.FIELD_NAME1, "1");
assertEquals(0, r1.compareTo(r2));
r2.setValue(Table2.FIELD_ID2, null);
assertEquals(-1, r1.compareTo(r2));
// Arrays
r4b.setValue(Table4.FIELD_ARRAY4, new Object[] { 1 });
assertEquals(1, r4a.compareTo(r4b));