コード例 #1
0
 @Test
 public void constructor() {
   AddAutoIncrementChange change = new AddAutoIncrementChange();
   assertEquals("addAutoIncrement", change.getChangeMetaData().getName());
   assertEquals("Set Column as Auto-Increment", change.getChangeMetaData().getDescription());
   assertEquals("column", change.getChangeMetaData().getAppliesTo().iterator().next());
 }
コード例 #2
0
  @Override
  @Test
  public void generateStatement() throws Exception {
    AddAutoIncrementChange change = new AddAutoIncrementChange();
    change.setSchemaName("SCHEMA_NAME");
    change.setTableName("TABLE_NAME");
    change.setColumnName("COLUMN_NAME");
    change.setColumnDataType("DATATYPE(255)");

    testChangeOnAllExcept(
        change,
        new GenerateAllValidator() {
          public void validate(SqlStatement[] sqlStatements, Database database) {

            assertEquals(1, sqlStatements.length);
            assertTrue(sqlStatements[0] instanceof AddAutoIncrementStatement);
            assertEquals(
                "SCHEMA_NAME", ((AddAutoIncrementStatement) sqlStatements[0]).getSchemaName());
            assertEquals(
                "TABLE_NAME", ((AddAutoIncrementStatement) sqlStatements[0]).getTableName());
            assertEquals(
                "COLUMN_NAME", ((AddAutoIncrementStatement) sqlStatements[0]).getColumnName());
            assertEquals(
                "DATATYPE(255)",
                ((AddAutoIncrementStatement) sqlStatements[0]).getColumnDataType());
          }
        },
        PostgresDatabase.class);
    testChange(
        change,
        new GenerateAllValidator() {
          public void validate(SqlStatement[] sqlStatements, Database database) {

            assertEquals(3, sqlStatements.length);
            assertTrue(sqlStatements[0] instanceof CreateSequenceStatement);
            assertTrue(sqlStatements[1] instanceof SetNullableStatement);
            assertTrue(sqlStatements[2] instanceof AddDefaultValueStatement);
          }
        },
        PostgresDatabase.class);
  }
コード例 #3
0
  @Override
  @Test
  public void getConfirmationMessage() throws Exception {
    AddAutoIncrementChange change = new AddAutoIncrementChange();
    change.setSchemaName("SCHEMA_NAME");
    change.setTableName("TABLE_NAME");
    change.setColumnName("COLUMN_NAME");
    change.setColumnDataType("DATATYPE(255)");

    assertEquals("Auto-increment added to TABLE_NAME.COLUMN_NAME", change.getConfirmationMessage());
  }
コード例 #4
0
 @Test
 public void changeMetaDataCreatedCorrectly() {
   AddAutoIncrementChange change = new AddAutoIncrementChange();
   ChangeMetaData metaData = change.getChangeMetaData();
   assertEquals("addAutoIncrement", metaData.getName());
 }