Search in sources :

Example 11 with H2

use of org.sonar.db.dialect.H2 in project sonarqube by SonarSource.

the class VarcharColumnDefTest method generate_sql_type.

@Test
public void generate_sql_type() throws Exception {
    VarcharColumnDef def = new VarcharColumnDef.Builder().setColumnName("issues").setLimit(10).setIsNullable(true).build();
    assertThat(def.generateSqlType(new H2())).isEqualTo("VARCHAR (10)");
    assertThat(def.generateSqlType(new PostgreSql())).isEqualTo("VARCHAR (10)");
    assertThat(def.generateSqlType(new MySql())).isEqualTo("VARCHAR (10)");
    assertThat(def.generateSqlType(new MsSql())).isEqualTo("NVARCHAR (10)");
    assertThat(def.generateSqlType(new Oracle())).isEqualTo("VARCHAR (10 CHAR)");
}
Also used : PostgreSql(org.sonar.db.dialect.PostgreSql) MySql(org.sonar.db.dialect.MySql) H2(org.sonar.db.dialect.H2) MsSql(org.sonar.db.dialect.MsSql) Oracle(org.sonar.db.dialect.Oracle) Test(org.junit.Test)

Example 12 with H2

use of org.sonar.db.dialect.H2 in project sonarqube by SonarSource.

the class BigIntegerColumnDefTest method generate_sql_type.

@Test
public void generate_sql_type() throws Exception {
    BigIntegerColumnDef def = new BigIntegerColumnDef.Builder().setColumnName("issues").setIsNullable(true).build();
    assertThat(def.generateSqlType(new H2())).isEqualTo("BIGINT");
    assertThat(def.generateSqlType(new PostgreSql())).isEqualTo("BIGINT");
    assertThat(def.generateSqlType(new MsSql())).isEqualTo("BIGINT");
    assertThat(def.generateSqlType(new MySql())).isEqualTo("BIGINT");
    assertThat(def.generateSqlType(new Oracle())).isEqualTo("NUMBER (38)");
}
Also used : PostgreSql(org.sonar.db.dialect.PostgreSql) MySql(org.sonar.db.dialect.MySql) H2(org.sonar.db.dialect.H2) MsSql(org.sonar.db.dialect.MsSql) Oracle(org.sonar.db.dialect.Oracle) Test(org.junit.Test)

Example 13 with H2

use of org.sonar.db.dialect.H2 in project sonarqube by SonarSource.

the class AlterColumnsBuilderTest method updateColumn_throws_IAE_if_default_value_is_defined.

/**
   * As we want DEFAULT value to be removed from all tables, it is supported
   * only on creation of tables and columns, not on alter.
   */
@Test
public void updateColumn_throws_IAE_if_default_value_is_defined() {
    BooleanColumnDef column = newBooleanColumnDefBuilder().setColumnName("enabled").setIsNullable(false).setDefaultValue(false).build();
    AlterColumnsBuilder alterColumnsBuilder = new AlterColumnsBuilder(new H2(), TABLE_NAME);
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage("Default value is not supported on alter of column 'enabled'");
    alterColumnsBuilder.updateColumn(column);
}
Also used : BooleanColumnDef(org.sonar.server.platform.db.migration.def.BooleanColumnDef) H2(org.sonar.db.dialect.H2) Test(org.junit.Test)

Example 14 with H2

use of org.sonar.db.dialect.H2 in project sonarqube by SonarSource.

the class CreateIndexBuilderTest method throw_NPE_when_adding_null_column.

@Test
public void throw_NPE_when_adding_null_column() {
    expectedException.expect(NullPointerException.class);
    expectedException.expectMessage("Column cannot be null");
    new CreateIndexBuilder(new H2()).setTable("issues").setName("issues_key").addColumn(null).build();
}
Also used : H2(org.sonar.db.dialect.H2) Test(org.junit.Test)

Example 15 with H2

use of org.sonar.db.dialect.H2 in project sonarqube by SonarSource.

the class CreateIndexBuilderTest method throw_IAE_if_table_name_is_not_valid.

@Test
public void throw_IAE_if_table_name_is_not_valid() {
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Table name must be lower case and contain only alphanumeric chars or '_', got '(not valid)'");
    new CreateIndexBuilder(new H2()).setTable("(not valid)").setName("issues_key").addColumn(newVarcharColumnDefBuilder().setColumnName("kee").setLimit(10).build()).build();
}
Also used : H2(org.sonar.db.dialect.H2) Test(org.junit.Test)

Aggregations

H2 (org.sonar.db.dialect.H2)18 Test (org.junit.Test)17 MsSql (org.sonar.db.dialect.MsSql)7 MySql (org.sonar.db.dialect.MySql)7 Oracle (org.sonar.db.dialect.Oracle)7 PostgreSql (org.sonar.db.dialect.PostgreSql)7 ResourceTypes (org.sonar.api.resources.ResourceTypes)1 Page (org.sonar.api.web.page.Page)1 PluginRepository (org.sonar.core.platform.PluginRepository)1 BooleanColumnDef (org.sonar.server.platform.db.migration.def.BooleanColumnDef)1 PageRepository (org.sonar.server.ui.PageRepository)1 WsActionTester (org.sonar.server.ws.WsActionTester)1