01: package liquibase.database.structure;
02:
03: import static org.junit.Assert.*;
04: import org.junit.Test;
05:
06: public class PrimaryKeyTest {
07:
08: @Test
09: public void setColumn_singlePKColumn() {
10: PrimaryKey pk = new PrimaryKey();
11: pk.addColumnName(0, "id");
12:
13: assertEquals(1, pk.getColumnNamesAsList().size());
14: }
15:
16: @Test
17: public void setColumn_outOfOrder() {
18: PrimaryKey pk = new PrimaryKey();
19: pk.addColumnName(1, "id2");
20: pk.addColumnName(0, "id1");
21:
22: assertEquals(2, pk.getColumnNamesAsList().size());
23: assertEquals("id1", pk.getColumnNamesAsList().get(0));
24: assertEquals("id2", pk.getColumnNamesAsList().get(1));
25: }
26:
27: @Test
28: public void setColumn_inOrder() {
29: PrimaryKey pk = new PrimaryKey();
30: pk.addColumnName(0, "id1");
31: pk.addColumnName(1, "id2");
32:
33: assertEquals(2, pk.getColumnNamesAsList().size());
34: assertEquals("id1", pk.getColumnNamesAsList().get(0));
35: assertEquals("id2", pk.getColumnNamesAsList().get(1));
36: }
37: }
|