@Test public void testIdenticalSchemas() { Schema s1 = makeBaseSchema(); Schema s2 = makeBaseSchema(); assertNull( "The changed constraint between identical schemas should be " + "null", ChangedConstraintFinder.getDifferentConstraint(s1, s2)); }
@Test public void testAddedPK() { Schema s1 = makeBaseSchema(); Table t1 = s1.getTable("t1"); PrimaryKeyConstraint constraint = new PrimaryKeyConstraint(t1, t1.getColumn("a")); s1.setPrimaryKeyConstraint(constraint); Schema s2 = makeBaseSchema(); assertEquals( "The changed constraint when adding a PK should be the PK", constraint, ChangedConstraintFinder.getDifferentConstraint(s1, s2)); }
@Test public void testIdenticalSchemasWithUnique() { Schema s1 = makeBaseSchema(); Table s1t1 = s1.getTable("t1"); UniqueConstraint s1constraint = new UniqueConstraint(s1t1, s1t1.getColumn("a")); s1.addUniqueConstraint(s1constraint); Schema s2 = makeBaseSchema(); Table s2t1 = s2.getTable("t1"); UniqueConstraint s2constraint = new UniqueConstraint(s2t1, s2t1.getColumn("a")); s2.addUniqueConstraint(s2constraint); assertNull( "The changed constraint between identical schemas should be " + "null", ChangedConstraintFinder.getDifferentConstraint(s1, s2)); }
@Test public void testPKMismatch() { Schema s1 = makeBaseSchema(); Table s1t1 = s1.getTable("t1"); PrimaryKeyConstraint s1constraint = new PrimaryKeyConstraint(s1t1, s1t1.getColumn("a"), s1t1.getColumn("b")); s1.setPrimaryKeyConstraint(s1constraint); Schema s2 = makeBaseSchema(); Table s2t1 = s2.getTable("t1"); PrimaryKeyConstraint s2constraint = new PrimaryKeyConstraint(s2t1, s2t1.getColumn("a")); s2.setPrimaryKeyConstraint(s2constraint); assertEquals( "The changed constraint with mismatched PKs should be the PK", s2constraint, ChangedConstraintFinder.getDifferentConstraint(s1, s2)); }