01: /*
02: * User: Michael Rettig
03: * Date: Aug 31, 2002
04: * Time: 6:46:53 PM
05: */
06: package net.sourceforge.jaxor.tests;
07:
08: import junit.framework.TestCase;
09: import net.sourceforge.jaxor.MetaField;
10: import net.sourceforge.jaxor.PrimaryKeySet;
11: import net.sourceforge.jaxor.api.FieldAdapter;
12: import net.sourceforge.jaxor.mappers.FieldAdapterImpl;
13: import net.sourceforge.jaxor.mappers.LongMapper;
14:
15: public class PrimaryKeySetTest extends TestCase {
16:
17: public void testEquality() {
18: PrimaryKeySet set = new PrimaryKeySet(new FieldAdapter[0]);
19: PrimaryKeySet set2 = new PrimaryKeySet(new FieldAdapter[0]);
20: assertEquals(set, set2);
21: }
22:
23: public void testInequality() {
24: PrimaryKeySet set = new PrimaryKeySet(createMapper());
25: PrimaryKeySet set2 = new PrimaryKeySet(new FieldAdapter[0]);
26: assertTrue(!set.equals(set2));
27: }
28:
29: public void testEqualsWithMappers() {
30: PrimaryKeySet set = new PrimaryKeySet(createMapper());
31: PrimaryKeySet set2 = new PrimaryKeySet(createMapper());
32: assertEquals(set, set2);
33:
34: assertEquals(set2.deepCopy(), set2);
35: }
36:
37: public void testNotEqualsWithMappers() {
38: PrimaryKeySet set = new PrimaryKeySet(createMapper());
39: FieldAdapterImpl abstractMapper = new FieldAdapterImpl(
40: new MetaField("name2", false, LongMapper.class), null);
41: PrimaryKeySet set2 = new PrimaryKeySet(abstractMapper);
42: assertTrue(
43: "we don't care about the metafield only the values for comparing",
44: set.equals(set2));
45: }
46:
47: private FieldAdapterImpl[] createMapper() {
48: return new FieldAdapterImpl[] { new FieldAdapterImpl(
49: new MetaField("name", false, LongMapper.class), null) };
50: }
51:
52: }
|