예제 #1
0
  @Test(expected = IllegalStateException.class)
  public void test_apply_alterColumn_doesNotExist() {

    MTable base = base();

    AlterColumn alterColumn = new AlterColumn();
    alterColumn.setTableName(base.getName());
    alterColumn.setColumnName("DoesNotExist");
    alterColumn.setType("integer");
    base.apply(alterColumn);
  }
예제 #2
0
  @Test
  public void test_apply_alterColumn_type() {

    MTable base = base();

    AlterColumn alterColumn = new AlterColumn();
    alterColumn.setTableName(base.getName());
    alterColumn.setColumnName("id");
    alterColumn.setType("uuid");
    base.apply(alterColumn);

    assertThat(base.getColumn("id").getType()).isEqualTo("uuid");
  }
예제 #3
0
  @Test
  public void test_compare_modifyColumn() throws Exception {

    ModelDiff diff = new ModelDiff();
    diff.compareTables(base(), newTableModifiedColumn());

    List<Object> createChanges = diff.getApplyChanges();
    assertThat(createChanges).hasSize(1);

    AlterColumn alterColumn = (AlterColumn) createChanges.get(0);
    assertThat(alterColumn.getColumnName()).isEqualTo("name");
    assertThat(alterColumn.getType()).isEqualTo("varchar(30)");
    assertThat(alterColumn.isNotnull()).isEqualTo(true);
    assertThat(alterColumn.getUnique()).isNull();
    assertThat(alterColumn.getCheckConstraint()).isNull();
    assertThat(alterColumn.getReferences()).isNull();

    assertThat(diff.getDropChanges()).hasSize(0);
  }