@Test public void testAddedMultiColPK() { Schema s1 = makeBaseSchema(); Table t1 = s1.getTable("t1"); PrimaryKeyConstraint constraint = new PrimaryKeyConstraint(t1, t1.getColumn("a"), t1.getColumn("b")); 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)); }
public NistDML181() { super("NistDML181"); Table tableLongNamedPeople = this.createTable("LONG_NAMED_PEOPLE"); tableLongNamedPeople.createColumn("FIRSTNAME", new VarCharDataType(373)); tableLongNamedPeople.createColumn("LASTNAME", new VarCharDataType(373)); tableLongNamedPeople.createColumn("AGE", new IntDataType()); this.createPrimaryKeyConstraint( tableLongNamedPeople, tableLongNamedPeople.getColumn("FIRSTNAME"), tableLongNamedPeople.getColumn("LASTNAME")); Table tableOrders = this.createTable("ORDERS"); tableOrders.createColumn("FIRSTNAME", new VarCharDataType(373)); tableOrders.createColumn("LASTNAME", new VarCharDataType(373)); tableOrders.createColumn("TITLE", new VarCharDataType(80)); tableOrders.createColumn("COST", new NumericDataType(5, 2)); this.createForeignKeyConstraint( tableOrders, Arrays.asList(tableOrders.getColumn("FIRSTNAME"), tableOrders.getColumn("LASTNAME")), tableLongNamedPeople, Arrays.asList( tableLongNamedPeople.getColumn("FIRSTNAME"), tableLongNamedPeople.getColumn("LASTNAME"))); }
public ArtistTerm() { super("ArtistTerm"); Table tableArtists = this.createTable("artists"); tableArtists.createColumn("artist_id", new TextDataType()); this.createPrimaryKeyConstraint(tableArtists, tableArtists.getColumn("artist_id")); Table tableMbtags = this.createTable("mbtags"); tableMbtags.createColumn("mbtag", new TextDataType()); this.createPrimaryKeyConstraint(tableMbtags, tableMbtags.getColumn("mbtag")); Table tableTerms = this.createTable("terms"); tableTerms.createColumn("term", new TextDataType()); this.createPrimaryKeyConstraint(tableTerms, tableTerms.getColumn("term")); Table tableArtistMbtag = this.createTable("artist_mbtag"); tableArtistMbtag.createColumn("artist_id", new TextDataType()); tableArtistMbtag.createColumn("mbtag", new TextDataType()); this.createForeignKeyConstraint( tableArtistMbtag, tableArtistMbtag.getColumn("artist_id"), tableArtists, tableArtists.getColumn("artist_id")); this.createForeignKeyConstraint( tableArtistMbtag, tableArtistMbtag.getColumn("mbtag"), tableMbtags, tableMbtags.getColumn("mbtag")); Table tableArtistTerm = this.createTable("artist_term"); tableArtistTerm.createColumn("artist_id", new TextDataType()); tableArtistTerm.createColumn("term", new TextDataType()); this.createForeignKeyConstraint( tableArtistTerm, tableArtistTerm.getColumn("artist_id"), tableArtists, tableArtists.getColumn("artist_id")); this.createForeignKeyConstraint( tableArtistTerm, tableArtistTerm.getColumn("term"), tableTerms, tableTerms.getColumn("term")); }