View Javadoc

1   package liquibase.change.core;
2   
3   import liquibase.change.AbstractChangeTest;
4   import liquibase.database.Database;
5   import static org.junit.Assert.*;
6   import org.junit.Test;
7   
8   /**
9    * Tests for {@link CreateSequenceChange}
10   */
11  public class CreateSequenceChangeTest extends AbstractChangeTest {
12  
13      @Override
14      @Test
15      public void getRefactoringName() throws Exception {
16          assertEquals("Create Sequence", new CreateSequenceChange().getChangeMetaData().getDescription());
17      }
18  
19      @Override
20      @Test
21      public void generateStatement() throws Exception {
22  //        new DatabaseTestTemplate().testOnAllDatabases(new DatabaseTest() {
23  //            public void performTest(Database database) throws Exception {
24  //                if (!database.supportsSequences()) {
25  //                    return;
26  //                }
27  //
28  //                CreateSequenceChange change = new CreateSequenceChange();
29  //                change.setSchemaName("SCHEMA_NAME");
30  //                change.setSequenceName("SEQ_NAME");
31  //                change.setIncrementBy(new BigInteger("1"));
32  //                change.setMinValue(new BigInteger("2"));
33  //                change.setMaxValue(new BigInteger("3"));
34  //                change.setOrdered(true);
35  //                change.setStartValue(new BigInteger("4"));
36  //
37  //                SqlStatement[] sqlStatements = change.generateStatements(database);
38  //                assertEquals(1, sqlStatements.length);
39  //                assertTrue(sqlStatements[0] instanceof CreateSequenceStatement);
40  //
41  //                assertEquals("SCHEMA_NAME", ((CreateSequenceStatement) sqlStatements[0]).getSchemaName());
42  //                assertEquals("SEQ_NAME", ((CreateSequenceStatement) sqlStatements[0]).getSequenceName());
43  //                assertEquals(new BigInteger("1"), ((CreateSequenceStatement) sqlStatements[0]).getIncrementBy());
44  //                assertEquals(new BigInteger("2"), ((CreateSequenceStatement) sqlStatements[0]).getMinValue());
45  //                assertEquals(new BigInteger("3"), ((CreateSequenceStatement) sqlStatements[0]).getMaxValue());
46  //                assertEquals(new BigInteger("4"), ((CreateSequenceStatement) sqlStatements[0]).getStartValue());
47  //                assertEquals(true, ((CreateSequenceStatement) sqlStatements[0]).getOrdered());
48  //            }
49  //        });
50      }
51  
52      @Override
53      @Test
54      public void getConfirmationMessage() throws Exception {
55          CreateSequenceChange change = new CreateSequenceChange();
56          change.setSequenceName("SEQ_NAME");
57  
58          assertEquals("Sequence SEQ_NAME created", change.getConfirmationMessage());
59      }
60  
61      @Override
62      protected boolean changeIsUnsupported(Database database) {
63          return !database.supportsSequences();
64      }
65  }