diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-12 10:46:52 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-14 12:11:52 +0100 |
commit | 01d79f9f3b76f137da1aafb71895683a45fae977 (patch) | |
tree | a53522250ea00c6721b24ce7a7950f4d4110e28f /sonar-db/src/test | |
parent | ff766539d309bbaaa416b2ce05d8d478086b6176 (diff) | |
download | sonarqube-01d79f9f3b76f137da1aafb71895683a45fae977.tar.gz sonarqube-01d79f9f3b76f137da1aafb71895683a45fae977.zip |
SONAR-8445 move SQ 6.2 migrations out of Ruby
Diffstat (limited to 'sonar-db/src/test')
47 files changed, 1 insertions, 2466 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java index 0502ecf2ce8..36c2faf4ff6 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java @@ -29,6 +29,6 @@ public class MigrationStepModuleTest { public void verify_count_of_added_MigrationStep_types() { ComponentContainer container = new ComponentContainer(); new MigrationStepModule().configure(container); - assertThat(container.size()).isEqualTo(123); + assertThat(container.size()).isEqualTo(99); } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest.java deleted file mode 100644 index e22b538357d..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class AddIsRootColumnOnTableUsersTest { - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddIsRootColumnOnTableUsersTest.class, "table_users.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddIsRootColumnOnTableUsers underTest = new AddIsRootColumnOnTableUsers(dbTester.database()); - - @Test - public void add_nullable_boolean_column_is_root() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "is_root", Types.BOOLEAN, null, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest.java deleted file mode 100644 index 009d442b074..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - - -public class AddOrganizationUuidToGroupRolesTest { - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToGroupRolesTest.class, "previous-group_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToGroupRoles underTest = new AddOrganizationUuidToGroupRoles(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("group_roles", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest.java deleted file mode 100644 index 8563a41d481..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class AddOrganizationUuidToGroupsTest { - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToGroupsTest.class, "previous-groups.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToGroups underTest = new AddOrganizationUuidToGroups(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("groups", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java deleted file mode 100644 index 72ce123d756..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class AddOrganizationUuidToPermissionTemplatesTest { - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToPermissionTemplatesTest.class, "previous-permission_templates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToPermissionTemplates underTest = new AddOrganizationUuidToPermissionTemplates(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("permission_templates", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest.java deleted file mode 100644 index bd0a671a6ee..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - - -public class AddOrganizationUuidToUserRolesTest { - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, AddOrganizationUuidToUserRolesTest.class, "previous-user_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private AddOrganizationUuidToUserRoles underTest = new AddOrganizationUuidToUserRoles(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("user_roles", "organization_uuid", Types.VARCHAR, 40, true); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateDefaultOrganizationTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/CreateDefaultOrganizationTest.java deleted file mode 100644 index 60944c12e4e..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateDefaultOrganizationTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.core.util.UuidFactory; -import org.sonar.db.DbTester; -import org.sonar.db.organization.OrganizationDto; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class CreateDefaultOrganizationTest { - private static final String DEFAULT_ORGANIZATION_KEY = "default-organization"; - private static final String DEFAULT_ORGANIZATION_NAME = "Default Organization"; - private static final String INTERNAL_PROPERTY_ORGANIZATION_DEFAULT = "organization.default"; - - private System2 system2 = mock(System2.class); - - @Rule - public final DbTester dbTester = DbTester.createForSchema(system2, CreateDefaultOrganizationTest.class, "organizations_and_internal_properties.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UuidFactory uuidFactory = mock(UuidFactory.class); - private CreateDefaultOrganization underTest = new CreateDefaultOrganization(dbTester.database(), system2, uuidFactory); - - @Test - public void execute_insert_data_in_organizations_and_internal_properties_when_it_does_not_exist() throws SQLException { - long now = 1_222_999L; - String uuid = "a uuid"; - when(system2.now()).thenReturn(now); - when(uuidFactory.create()).thenReturn(uuid); - - underTest.execute(); - - OrganizationDto organizationDto = dbTester.getDbClient().organizationDao().selectByKey(dbTester.getSession(), DEFAULT_ORGANIZATION_KEY).get(); - assertThat(organizationDto.getUuid()).isEqualTo(uuid); - assertThat(organizationDto.getKey()).isEqualTo(DEFAULT_ORGANIZATION_KEY); - assertThat(organizationDto.getName()).isEqualTo(DEFAULT_ORGANIZATION_NAME); - assertThat(organizationDto.getDescription()).isNull(); - assertThat(organizationDto.getUrl()).isNull(); - assertThat(organizationDto.getAvatarUrl()).isNull(); - assertThat(organizationDto.getCreatedAt()).isEqualTo(now); - assertThat(organizationDto.getUpdatedAt()).isEqualTo(now); - - verifyInternalProperty(uuid); - } - - @Test - public void execute_inserts_internal_property_if_default_organization_already_exists() throws SQLException { - long past = 2_999_033L; - String uuid = "uuidAAAA"; - insertExistingOrganization(uuid, past); - verifyExistingOrganization(uuid, past); - - underTest.execute(); - - // existing organization is unchanged - verifyExistingOrganization(uuid, past); - - // internal property created - verifyInternalProperty(uuid); - } - - private void verifyInternalProperty(String expectedUuid) { - assertThat(dbTester.getDbClient().internalPropertiesDao().selectByKey(dbTester.getSession(), INTERNAL_PROPERTY_ORGANIZATION_DEFAULT)) - .contains(expectedUuid); - } - - @Test - public void execute_has_no_effect_if_organization_and_internal_property_already_exist() throws SQLException { - long past = 2_999_033L; - String uuid = "uuidAAAA"; - insertExistingOrganization(uuid, past); - insertExistingInternalProperty(uuid); - verifyExistingOrganization(uuid, past); - verifyInternalProperty(uuid); - - underTest.execute(); - - verifyExistingOrganization(uuid, past); - verifyInternalProperty(uuid); - } - - @Test - public void execute_is_reentrant() throws SQLException { - when(system2.now()).thenReturn(1_222_999L); - when(uuidFactory.create()).thenReturn("a uuid"); - - underTest.execute(); - - underTest.execute(); - } - - private void insertExistingInternalProperty(String uuid) { - dbTester.getDbClient().internalPropertiesDao().save(dbTester.getSession(), INTERNAL_PROPERTY_ORGANIZATION_DEFAULT, uuid); - dbTester.commit(); - } - - private void insertExistingOrganization(String uuid, long past) { - when(system2.now()).thenReturn(past); - dbTester.getDbClient().organizationDao().insert(dbTester.getSession(), - new OrganizationDto() - .setUuid(uuid) - .setKey(DEFAULT_ORGANIZATION_KEY) - .setName("whatever")); - dbTester.commit(); - } - - private void verifyExistingOrganization(String uuid, long past) { - OrganizationDto organizationDto = dbTester.getDbClient().organizationDao().selectByKey(dbTester.getSession(), DEFAULT_ORGANIZATION_KEY).get(); - assertThat(organizationDto.getUuid()).isEqualTo(uuid); - assertThat(organizationDto.getKey()).isEqualTo(DEFAULT_ORGANIZATION_KEY); - assertThat(organizationDto.getName()).isEqualTo("whatever"); - assertThat(organizationDto.getDescription()).isNull(); - assertThat(organizationDto.getUrl()).isNull(); - assertThat(organizationDto.getAvatarUrl()).isNull(); - assertThat(organizationDto.getCreatedAt()).isEqualTo(past); - assertThat(organizationDto.getUpdatedAt()).isEqualTo(past); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableOrganizationsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableOrganizationsTest.java deleted file mode 100644 index 9e04995d81c..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableOrganizationsTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CreateTableOrganizationsTest { - private static final String TABLE_ORGANIZATIONS = "organizations"; - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableOrganizationsTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableOrganizations underTest = new CreateTableOrganizations(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_ORGANIZATIONS)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "kee", Types.VARCHAR, 32, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "name", Types.VARCHAR, 64, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "description", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "url", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "avatar_url", Types.VARCHAR, 256, true); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "created_at", Types.BIGINT, null, false); - dbTester.assertColumnDefinition(TABLE_ORGANIZATIONS, "updated_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE_ORGANIZATIONS, "pk_" + TABLE_ORGANIZATIONS, "uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java deleted file mode 100644 index 6783927dd26..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class CreateTableWebhookDeliveriesTest { - - private static final String TABLE = "webhook_deliveries"; - - @Rule - public final DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, CreateTableWebhookDeliveriesTest.class, "empty.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateTableWebhookDeliveries underTest = new CreateTableWebhookDeliveries(dbTester.database()); - - @Test - public void creates_table_on_empty_db() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE)).isEqualTo(0); - - dbTester.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "component_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "ce_task_uuid", Types.VARCHAR, 40, false); - dbTester.assertColumnDefinition(TABLE, "name", Types.VARCHAR, 100, false); - dbTester.assertColumnDefinition(TABLE, "url", Types.VARCHAR, 2000, false); - dbTester.assertColumnDefinition(TABLE, "success", Types.BOOLEAN, null, false); - dbTester.assertColumnDefinition(TABLE, "http_status", Types.INTEGER, null, true); - dbTester.assertColumnDefinition(TABLE, "duration_ms", Types.INTEGER, null, true); - dbTester.assertColumnDefinition(TABLE, "payload", Types.CLOB, null, false); - dbTester.assertColumnDefinition(TABLE, "error_stacktrace", Types.CLOB, null, true); - dbTester.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false); - dbTester.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid"); - dbTester.assertIndex(TABLE, "component_uuid", "component_uuid"); - dbTester.assertIndex(TABLE, "ce_task_uuid", "ce_task_uuid"); - } - - @Test - public void migration_is_not_reentrant() throws SQLException { - underTest.execute(); - - expectedException.expect(IllegalStateException.class); - - underTest.execute(); - } - - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/DeletePermissionShareDashboardTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/DeletePermissionShareDashboardTest.java deleted file mode 100644 index 96af154fbad..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/DeletePermissionShareDashboardTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DeletePermissionShareDashboardTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeletePermissionShareDashboardTest.class, "roles.sql"); - - private DeletePermissionShareDashboard underTest = new DeletePermissionShareDashboard(db.database()); - - @Test - public void delete_permissions() throws SQLException { - // combinations of group permissions to be kept - db.executeInsert("group_roles", "id", "1", "group_id", null, "resource_id", null, "role", "admin"); - db.executeInsert("group_roles", "id", "2", "group_id", null, "resource_id", "1", "role", "issueadmin"); - db.executeInsert("group_roles", "id", "3", "group_id", "1", "resource_id", null, "role", "admin"); - db.executeInsert("group_roles", "id", "4", "group_id", "1", "resource_id", "1", "role", "issueadmin"); - - // combinations of group permissions to be removed (even if it does make sense to have "shareDashboard" - // on projects) - db.executeInsert("group_roles", "id", "5", "group_id", null, "resource_id", null, "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "6", "group_id", null, "resource_id", "1", "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "7", "group_id", "1", "resource_id", null, "role", "shareDashboard"); - db.executeInsert("group_roles", "id", "8", "group_id", "1", "resource_id", "1", "role", "shareDashboard"); - - // combinations of user permissions to be kept - db.executeInsert("user_roles", "id", "1", "user_id", "100", "resource_id", null, "role", "admin"); - db.executeInsert("user_roles", "id", "2", "user_id", "100", "resource_id", "1", "role", "issueadmin"); - - // combinations of user permissions to be removed (even if it does make sense to have "shareDashboard" - // on projects) - db.executeInsert("user_roles", "id", "3", "user_id", "100", "resource_id", null, "role", "shareDashboard"); - db.executeInsert("user_roles", "id", "4", "user_id", "100", "resource_id", "1", "role", "shareDashboard"); - - underTest.execute(); - - assertThat(db.countRowsOfTable("group_roles")).isEqualTo(4); - assertThat(db.countSql("select count(id) from group_roles where role='shareDashboard'")).isEqualTo(0); - - assertThat(db.countRowsOfTable("user_roles")).isEqualTo(2); - assertThat(db.countSql("select count(id) from user_roles where role='shareDashboard'")).isEqualTo(0); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/DropIssueFiltersTableTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/DropIssueFiltersTableTest.java deleted file mode 100644 index 068d2058edb..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/DropIssueFiltersTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class DropIssueFiltersTableTest { - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropIssueFiltersTableTest.class, "schema.sql"); - - private DropIssueFiltersTables underTest = new DropIssueFiltersTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("issue_filters"); - db.assertTableDoesNotExist("issue_filter_favourites"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("issue_filters"); - db.assertTableDoesNotExist("issue_filter_favourites"); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/DropMeasureFiltersTableTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/DropMeasureFiltersTableTest.java deleted file mode 100644 index 6b6479d55af..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/DropMeasureFiltersTableTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class DropMeasureFiltersTableTest { - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropMeasureFiltersTableTest.class, "schema.sql"); - - private DropMeasureFiltersTables underTest = new DropMeasureFiltersTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("measure_filters"); - db.assertTableDoesNotExist("measure_filter_favourites"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("measure_filters"); - db.assertTableDoesNotExist("measure_filter_favourites"); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/DropRelatedDashboardTablesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/DropRelatedDashboardTablesTest.java deleted file mode 100644 index 7d8fd690e85..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/DropRelatedDashboardTablesTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class DropRelatedDashboardTablesTest { - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, DropRelatedDashboardTablesTest.class, "schema.sql"); - - private DropRelatedDashboardTables underTest = new DropRelatedDashboardTables(db.database()); - - @Test - public void delete_tables() throws SQLException { - underTest.execute(); - - db.assertTableDoesNotExist("widget_properties"); - db.assertTableDoesNotExist("widgets"); - db.assertTableDoesNotExist("active_dashboards"); - db.assertTableDoesNotExist("dashboards"); - } - - @Test - public void migration_is_re_entrant() throws Exception { - underTest.execute(); - underTest.execute(); - - db.assertTableDoesNotExist("widget_properties"); - db.assertTableDoesNotExist("widgets"); - db.assertTableDoesNotExist("active_dashboards"); - db.assertTableDoesNotExist("dashboards"); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java deleted file mode 100644 index b74843a91dc..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnGroupRolesTest { - - private static final String TABLE_GROUP_ROLES = "group_roles"; - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnGroupRolesTest.class, - "in_progress_group_roles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnGroupRoles underTest = new MakeOrganizationUuidNotNullOnGroupRoles(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertGroupRole(1, true); - insertGroupRole(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertGroupRole(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_GROUP_ROLES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertGroupRole(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_GROUP_ROLES, - "ID", valueOf(id), - "GROUP_ID", id + 10, - "ROLE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java deleted file mode 100644 index 207ae0b12b0..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnGroupsTest { - - private static final String TABLE_GROUPS = "groups"; - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnGroupsTest.class, - "in_progress_groups.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnGroups underTest = new MakeOrganizationUuidNotNullOnGroups(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertGroup(1, true); - insertGroup(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertGroup(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_GROUPS, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertGroup(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_GROUPS, - "ID", valueOf(id), - "NAME", valueOf(id + 10), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java deleted file mode 100644 index 9afc8f36028..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static java.lang.String.valueOf; - - -public class MakeOrganizationUuidNotNullOnPermissionTemplatesTest { - - private static final String TABLE_PERMISSION_TEMPLATES = "permission_templates"; - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnPermissionTemplatesTest.class, - "in_progress_permission_templates.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnPermissionTemplates underTest = new MakeOrganizationUuidNotNullOnPermissionTemplates(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertTemplate(1, true); - insertTemplate(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertTemplate(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_PERMISSION_TEMPLATES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertTemplate(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_PERMISSION_TEMPLATES, - "ID", valueOf(id), - "NAME", valueOf(id + 10), - "KEE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java deleted file mode 100644 index 5ba5b9d0687..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static java.lang.String.valueOf; - -public class MakeOrganizationUuidNotNullOnUserRolesTest { - - private static final String TABLE_USER_ROLES = "user_roles"; - - @Rule - public DbTester db = DbTester.createForSchema(System2.INSTANCE, MakeOrganizationUuidNotNullOnUserRolesTest.class, - "in_progress_user_roles.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeOrganizationUuidNotNullOnUserRoles underTest = new MakeOrganizationUuidNotNullOnUserRoles(db.database()); - - @Test - public void migration_sets_uuid_column_not_nullable_on_empty_table() throws SQLException { - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_sets_uuid_column_not_nullable_on_populated_table() throws SQLException { - insertUserRole(1, true); - insertUserRole(2, true); - - underTest.execute(); - - verifyColumnDefinition(); - } - - @Test - public void migration_fails_if_some_row_has_a_null_uuid() throws SQLException { - insertUserRole(1, false); - - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Fail to execute"); - - underTest.execute(); - } - - private void verifyColumnDefinition() { - db.assertColumnDefinition(TABLE_USER_ROLES, "organization_uuid", Types.VARCHAR, 40, false); - } - - private String insertUserRole(long id, boolean hasUuid) { - String uuid = "uuid_" + id; - db.executeInsert( - TABLE_USER_ROLES, - "ID", valueOf(id), - "USER_ID", id + 10, - "ROLE", valueOf(id + 100), - "ORGANIZATION_UUID", hasUuid ? "uuid_" + id : null); - return uuid; - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest.java deleted file mode 100644 index 6d128a6dc7e..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -public class MakeRootColumnNotNullOnTableUsersTest { - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, MakeRootColumnNotNullOnTableUsersTest.class, "users_with_nullable_root.sql"); - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MakeRootColumnNotNullOnTableUsers underTest = new MakeRootColumnNotNullOnTableUsers(dbTester.database()); - - @Test - public void execute_make_column_is_root_not_nullable() throws SQLException { - underTest.execute(); - - dbTester.assertColumnDefinition("users", "is_root", Types.BOOLEAN, null, false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - underTest.execute(); - - underTest.execute(); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest.java deleted file mode 100644 index df1b638305e..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateIsRootColumnOnTableUsersTest { - private static final String USERS_TABLE = "users"; - private static final String ROLE_ADMIN = "admin"; - - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateIsRootColumnOnTableUsersTest.class, "users_and_permissions_tables.sql"); - - private PopulateIsRootColumnOnTableUsers underTest = new PopulateIsRootColumnOnTableUsers(dbTester.database()); - - @Test - public void execute_on_empty_users_table_has_no_effect() throws SQLException { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(USERS_TABLE)).isEqualTo(0); - } - - @Test - public void execute_sets_active_user_with_no_permission_has_not_root() throws SQLException { - insertUser("foo", true); - - underTest.execute(); - - verifySingleUser("foo", false); - } - - @Test - public void execute_sets_inactive_user_with_no_permission_has_not_root() throws SQLException { - insertUser("foo", false); - dbTester.commit(); - - underTest.execute(); - - verifySingleUser("foo", false); - } - - @Test - public void execute_sets_active_user_with_admin_role_has_root() throws SQLException { - long userId = insertUser("foo", true); - insertRole(userId, ROLE_ADMIN); - - underTest.execute(); - - verifySingleUser("foo", true); - } - - @Test - public void execute_sets_inactive_user_with_admin_role_has_not_root() throws SQLException { - long userId = insertUser("bar", false); - insertRole(userId, ROLE_ADMIN); - - underTest.execute(); - - verifySingleUser("bar", false); - } - - @Test - public void execute_sets_active_user_in_group_with_admin_role_has_root() throws SQLException { - long userId = insertUser("doo", true); - long groupId = insertGroup("admin group"); - insertGroupRole(groupId, ROLE_ADMIN); - addUserToGroup(userId, groupId); - - underTest.execute(); - - verifySingleUser("doo", true); - } - - @Test - public void execute_sets_inactive_user_in_group_with_admin_role_has_not_root() throws SQLException { - long userId = insertUser("bar", false); - long groupId = insertGroup("admin group"); - insertGroupRole(groupId, ROLE_ADMIN); - addUserToGroup(userId, groupId); - - underTest.execute(); - - verifySingleUser("bar", false); - } - - @Test - public void migration_is_reentrant() throws SQLException { - long adminGroupId = insertGroup("admin group"); - insertGroupRole(adminGroupId, ROLE_ADMIN); - long groupId = insertGroup("other group"); - long[] userIds = { - insertUser("inactive_direct_admin", false), - insertUser("active_direct_admin", true), - insertUser("inactive_group_admin", false), - insertUser("active_group_admin", true), - insertUser("group_and_direct_admin", true), - insertUser("group_perm_user", true), - insertUser("no_perm_user", true), - insertUser("all_groups_user", true) - }; - // inactive_direct_admin - insertRole(userIds[0], ROLE_ADMIN); - // active_direct_admin - insertRole(userIds[1], ROLE_ADMIN); - // inactive_group_admin - addUserToGroup(userIds[2], adminGroupId); - // active_group_admin - addUserToGroup(userIds[3], adminGroupId); - // group_and_direct_admin - addUserToGroup(userIds[4], adminGroupId); - insertRole(userIds[4], ROLE_ADMIN); - // group_perm_user - addUserToGroup(userIds[5], groupId); - // all_groups_user - addUserToGroup(userIds[7], adminGroupId); - addUserToGroup(userIds[7], groupId); - - underTest.execute(); - verifyUsers(); - - underTest.execute(); - verifyUsers(); - } - - private void verifyUsers() { - verifyUser("inactive_direct_admin", false); - verifyUser("active_direct_admin", true); - verifyUser("inactive_group_admin", false); - verifyUser("active_group_admin", true); - verifyUser("group_and_direct_admin", true); - verifyUser("group_perm_user", false); - verifyUser("all_groups_user", true); - verifyUser("no_perm_user", false); - } - - private void insertRole(long userId, String role) { - dbTester.executeInsert("user_roles", "user_id", userId, "role", role); - dbTester.commit(); - } - - private long insertUser(String login, boolean active) { - dbTester.executeInsert(USERS_TABLE, "login", login, "active", active); - dbTester.commit(); - return (Long) dbTester.selectFirst("select id as \"id\" from users where login = '" + login + "'").get("id"); - } - - private long insertGroup(String groupName) { - dbTester.executeInsert("groups", "name", groupName); - dbTester.commit(); - return (Long) dbTester.selectFirst("select id as \"id\" from groups where name = '" + groupName + "'").get("id"); - } - - private void insertGroupRole(long groupId, String role) { - dbTester.executeInsert("group_roles", "group_id", groupId, "role", role); - dbTester.commit(); - } - - private void addUserToGroup(long userId, long groupId) { - dbTester.executeInsert("groups_users", "user_id", userId, "group_id", groupId); - dbTester.commit(); - } - - private void verifySingleUser(String login, boolean root) { - List<Map<String, Object>> rows = dbTester.select("select login as \"login\", is_root as \"isRoot\" from users"); - assertThat(rows).hasSize(1); - Map<String, Object> row = rows.iterator().next(); - assertThat(row.get("login")).isEqualTo(login); - assertThat(row.get("isRoot")).isEqualTo(root); - } - - private void verifyUser(String login, boolean root) { - Map<String, Object> row = dbTester.selectFirst("select login as \"login\", is_root as \"isRoot\" from users where login = '" + login + "'"); - assertThat(row.get("isRoot")).isEqualTo(root); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java deleted file mode 100644 index a045faeb6a7..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfGroupRolesTest { - - private static final String TABLE_GROUP_ROLES = "group_roles"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfGroupRolesTest.class, "group_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfGroupRoles underTest = new PopulateOrganizationUuidOfGroupRoles(dbTester.database()); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert("group_roles", "group_id", "1", "role", "admin", "organization_uuid", null); - dbTester.executeInsert("group_roles", "group_id", "2", "role", "viewever", "organization_uuid", null); - dbTester.executeInsert("group_roles", "group_id", "3", "role", "viewever", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from group_roles where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_GROUP_ROLES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest.java deleted file mode 100644 index 4b0c8555821..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.api.utils.internal.TestSystem2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfGroupsTest { - - private static final String TABLE_GROUPS = "groups"; - private static final String AN_ORG_UUID = "org1"; - - private System2 system2 = new TestSystem2().setNow(1_500_000_000L); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Rule - public DbTester dbTester = DbTester.createForSchema(system2, PopulateOrganizationUuidOfGroupsTest.class, "user_groups.sql"); - - private PopulateOrganizationUuidOfGroups underTest = new PopulateOrganizationUuidOfGroups(dbTester.database(), system2); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert(TABLE_GROUPS, "name", "group1", "organization_uuid", null); - dbTester.executeInsert(TABLE_GROUPS, "name", "group2", "organization_uuid", null); - dbTester.executeInsert(TABLE_GROUPS, "name", "group3", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("groups")).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from groups where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void execute_is_reentrant() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - dbTester.executeInsert(TABLE_GROUPS, "name", "group1"); - - underTest.execute(); - - underTest.execute(); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable("groups")).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } - -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java deleted file mode 100644 index b7ffbb7356b..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfPermissionTemplatesTest { - - private static final String TABLE_PERMISSION_TEMPLATES = "permission_templates"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfPermissionTemplatesTest.class, "permission_templates.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfPermissionTemplates underTest = new PopulateOrganizationUuidOfPermissionTemplates(dbTester.database(), System2.INSTANCE); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t1", "name", "T1", "organization_uuid", null); - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t2", "name", "T2", "organization_uuid", null); - dbTester.executeInsert(TABLE_PERMISSION_TEMPLATES, "kee", "t3", "name", "T3", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_PERMISSION_TEMPLATES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from permission_templates where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_PERMISSION_TEMPLATES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest.java deleted file mode 100644 index 0c32fe89491..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.db.version.v62; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PopulateOrganizationUuidOfUserRolesTest { - - private static final String TABLE_USER_ROLES = "user_roles"; - private static final String AN_ORG_UUID = "org1"; - - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, PopulateOrganizationUuidOfUserRolesTest.class, "user_roles.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private PopulateOrganizationUuidOfUserRoles underTest = new PopulateOrganizationUuidOfUserRoles(dbTester.database()); - - @Test - public void execute_fails_with_ISE_if_default_organization_internal_property_is_not_set() throws SQLException { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("Default organization uuid is missing"); - - underTest.execute(); - } - @Test - public void migration_populates_missing_organization_uuids() throws SQLException { - dbTester.executeInsert("user_roles", "user_id", "1", "role", "admin", "organization_uuid", null); - dbTester.executeInsert("user_roles", "user_id", "2", "role", "viewever", "organization_uuid", null); - dbTester.executeInsert("user_roles", "user_id", "3", "role", "viewever", "organization_uuid", AN_ORG_UUID); - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(3); - assertThat(dbTester.countSql("select count(1) from user_roles where organization_uuid='" + AN_ORG_UUID + "'")).isEqualTo(3); - } - - @Test - public void migration_has_no_effect_on_empty_table() throws SQLException { - insertDefaultOrganizationInternalProperty(AN_ORG_UUID); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_USER_ROLES)).isEqualTo(0); - } - - private void insertDefaultOrganizationInternalProperty(String defaultOrganizationUuid) { - dbTester.executeInsert("internal_properties", "kee", "organization.default", "is_empty", false, "text_value", defaultOrganizationUuid); - } -} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest.java b/sonar-db/src/test/java/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest.java deleted file mode 100644 index 89d9663f5cb..00000000000 --- a/sonar-db/src/test/java/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.db.version.v62; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.tngtech.java.junit.dataprovider.DataProvider; -import com.tngtech.java.junit.dataprovider.DataProviderRunner; -import com.tngtech.java.junit.dataprovider.UseDataProvider; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.sonar.api.utils.System2; -import org.sonar.db.DbTester; -import org.sonar.db.version.MigrationStep; - -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(DataProviderRunner.class) -public class UpdateQualityGateConditionsOnCoverageTest { - - private static final String TABLE_QUALITY_GATES = "quality_gates"; - private static final String TABLE_QUALITY_GATE_CONDITIONS = "quality_gate_conditions"; - - @Rule - public DbTester dbTester = DbTester.createForSchema(System2.INSTANCE, UpdateQualityGateConditionsOnCoverageTest.class, "schema.sql"); - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private MigrationStep underTest = new UpdateQualityGateConditionsOnCoverage(dbTester.database()); - - @Test - public void move_overall_coverage_condition_to_coverage() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_overall_coverage_condition_to_coverage_when_overall_coverage_exists_condition_on_overall_coverage_exists() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void remove_it_coverage_condition_when_overall_coverage_condition_exists_and_no_coverage_condition() throws Exception { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("overall_coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void keep_coverage_condition_when_no_overall_and_it_coverage() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void remove_it_coverage_condition_when_coverage_condition_exists_and_no_overall_coverage_condition() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("coverage"), null, "GT", "10", null); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_it_coverage_condition_to_coverage_when_only_it_coverage_condition() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = inserSampleMetrics(); - long qualityGateId = insertQualityGate("default"); - insertQualityGateCondition(qualityGateId, metricIdsByMetricKeys.get("it_coverage"), null, "GT", "10", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(1); - verifyConditions(qualityGateId, new QualityGateCondition("coverage", null, "GT", "10", null)); - } - - @Test - public void move_new_coverage_conditions() throws SQLException { - Map<String, Long> metricIdsByMetricKeys = insertMetrics("new_coverage", "new_overall_coverage", "new_it_coverage"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_coverage"), 1L, "GT", "10", null); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_overall_coverage"), 1L, "GT", "7", "15"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get("new_it_coverage"), 2L, "LT", "8", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get("new_overall_coverage"), 2L, "GT", "15", null); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get("new_it_coverage"), 2L, "GT", null, "5"); - long qualityGate3 = insertQualityGate("qualityGate3"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get("new_it_coverage"), 3L, "GT", null, "5"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(3); - verifyConditions(qualityGate1, new QualityGateCondition("new_coverage", 1L, "GT", "7", "15")); - verifyConditions(qualityGate2, new QualityGateCondition("new_coverage", 2L, "GT", "15", null)); - verifyConditions(qualityGate3, new QualityGateCondition("new_coverage", 3L, "GT", null, "5")); - } - - @DataProvider - public static Object[][] metricKeys() { - List<String> metrics = ImmutableList.of( - "coverage", "lines_to_cover", "uncovered_lines", "line_coverage", "conditions_to_cover", "uncovered_conditions", "branch_coverage"); - Object[][] res = new Object[metrics.size()][3]; - int i = 0; - for (String metricKey : metrics) { - res[i][0] = metricKey; - res[i][1] = "overall_" + metricKey; - res[i][2] = "it_" + metricKey; - i++; - } - return res; - } - - @Test - @UseDataProvider("metricKeys") - public void move_conditions_from_many_quality_gates_on_all_metrics(String coverageKey, String overallCoverageKey, String itCoverageKey) throws SQLException { - Map<String, Long> metricIdsByMetricKeys = insertMetrics(coverageKey, overallCoverageKey, itCoverageKey, "other"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(coverageKey), null, "GT", "10", null); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(overallCoverageKey), null, "GT", "7", "15"); - insertQualityGateCondition(qualityGate1, metricIdsByMetricKeys.get(itCoverageKey), null, "LT", "8", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get(overallCoverageKey), null, "GT", "15", null); - insertQualityGateCondition(qualityGate2, metricIdsByMetricKeys.get(itCoverageKey), null, "GT", null, "5"); - long qualityGate3 = insertQualityGate("qualityGate3"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get(itCoverageKey), null, "GT", null, "5"); - insertQualityGateCondition(qualityGate3, metricIdsByMetricKeys.get("other"), null, "GT", "11", null); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(4); - verifyConditions(qualityGate1, new QualityGateCondition(coverageKey, null, "GT", "7", "15")); - verifyConditions(qualityGate2, new QualityGateCondition(coverageKey, null, "GT", "15", null)); - verifyConditions(qualityGate3, new QualityGateCondition(coverageKey, null, "GT", null, "5"), new QualityGateCondition("other", null, "GT", "11", null)); - } - - @Test - public void does_not_update_conditions_on_none_related_coverage_metrics() throws Exception { - insertMetrics(); - long metric1 = insertMetric("metric1"); - long metric2 = insertMetric("metric2"); - long qualityGate1 = insertQualityGate("qualityGate1"); - insertQualityGateCondition(qualityGate1, metric1, null, "GT", "10", null); - long qualityGate2 = insertQualityGate("qualityGate2"); - insertQualityGateCondition(qualityGate2, metric2, null, "LT", null, "20"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isEqualTo(2); - verifyConditions(qualityGate1, new QualityGateCondition("metric1", null, "GT", "10", null)); - verifyConditions(qualityGate2, new QualityGateCondition("metric2", null, "LT", null, "20")); - } - - @Test - public void does_nothing_when_no_quality_gates() throws Exception { - insertMetrics("coverage", "new_coverage", "overall_coverage"); - - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - @Test - public void does_nothing_when_no_metrics() throws Exception { - underTest.execute(); - - assertThat(dbTester.countRowsOfTable(TABLE_QUALITY_GATE_CONDITIONS)).isZero(); - } - - private Map<String, Long> inserSampleMetrics() { - return insertMetrics("coverage", "overall_coverage", "it_coverage"); - } - - private Map<String, Long> insertMetrics(String... metrics) { - Map<String, Long> metricIdsByMetricKeys = new HashMap<>(); - for (String metricKey : metrics) { - metricIdsByMetricKeys.put(metricKey, insertMetric(metricKey)); - } - return metricIdsByMetricKeys; - } - - private long insertMetric(String key) { - dbTester.executeInsert("metrics", "NAME", key); - return (Long) dbTester.selectFirst(dbTester.getSession(), format("select id as \"id\" from metrics where name='%s'", key)).get("id"); - } - - private long insertQualityGate(String qualityGate) { - dbTester.executeInsert(TABLE_QUALITY_GATES, "NAME", qualityGate); - return (Long) dbTester.selectFirst(dbTester.getSession(), format("select id as \"id\" from %s where name='%s'", TABLE_QUALITY_GATES, qualityGate)).get("id"); - } - - private long insertQualityGateCondition(long qualityGateId, long metricId, @Nullable Long period, String operator, @Nullable String error, @Nullable String warning) { - Map<String, Object> values = new HashMap<>(ImmutableMap.of("QGATE_ID", qualityGateId, "METRIC_ID", metricId, "OPERATOR", operator)); - if (period != null) { - values.put("PERIOD", period); - } - if (error != null) { - values.put("VALUE_ERROR", error); - } - if (warning != null) { - values.put("VALUE_WARNING", warning); - } - dbTester.executeInsert(TABLE_QUALITY_GATE_CONDITIONS, values); - return (Long) dbTester - .selectFirst(dbTester.getSession(), format("select id as \"id\" from %s where qgate_id='%s' and metric_id='%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId, metricId)) - .get("id"); - } - - private void verifyConditions(long qualityGateId, QualityGateCondition... expectedConditions) { - List<Map<String, Object>> results = dbTester.select(dbTester.getSession(), - format("select m.name as \"metricKey\", qgc.period as \"period\", qgc.operator as \"operator\", qgc.value_error as \"error\", qgc.value_warning as \"warning\" from %s qgc " + - "inner join metrics m on m.id=qgc.metric_id " + - "where qgc.qgate_id = '%s'", TABLE_QUALITY_GATE_CONDITIONS, qualityGateId)); - List<QualityGateCondition> conditions = results.stream().map(QualityGateCondition::new).collect(Collectors.toList()); - assertThat(conditions).containsOnly(expectedConditions); - } - - private static class QualityGateCondition { - String metricKey; - Long period; - String operator; - String valueError; - String valueWarning; - - public QualityGateCondition(String metricKey, @Nullable Long period, String operator, @Nullable String valueError, @Nullable String valueWarning) { - this.metricKey = metricKey; - this.period = period; - this.operator = operator; - this.valueError = valueError; - this.valueWarning = valueWarning; - } - - QualityGateCondition(Map<String, Object> map) { - this.metricKey = (String) map.get("metricKey"); - this.period = (Long) map.get("period"); - this.operator = (String) map.get("operator"); - this.valueError = (String) map.get("error"); - this.valueWarning = (String) map.get("warning"); - } - - public String getMetricKey() { - return metricKey; - } - - @CheckForNull - public Long getPeriod() { - return period; - } - - public String getOperator() { - return operator; - } - - @CheckForNull - public String getValueError() { - return valueError; - } - - @CheckForNull - public String getValueWarning() { - return valueWarning; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - QualityGateCondition that = (QualityGateCondition) o; - return new EqualsBuilder() - .append(metricKey, that.getMetricKey()) - .append(period, that.getPeriod()) - .append(operator, that.getOperator()) - .append(valueError, that.getValueError()) - .append(valueWarning, that.getValueWarning()) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(15, 31) - .append(metricKey) - .append(period) - .append(operator) - .append(valueError) - .append(valueWarning) - .toHashCode(); - } - - @Override - public String toString() { - return "QualityGateCondition{" + - "metricKey='" + metricKey + '\'' + - ", period=" + period + - ", operator=" + operator + - ", valueError='" + valueError + '\'' + - ", valueWarning='" + valueWarning + '\'' + - '}'; - } - } - -} diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql deleted file mode 100644 index 8c4967278f8..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddIsRootColumnOnTableUsersTest/table_users.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql deleted file mode 100644 index a711f616070..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupRolesTest/previous-group_roles.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql deleted file mode 100644 index 250a9a8f45b..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToGroupsTest/previous-groups.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql deleted file mode 100644 index a690318b027..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToPermissionTemplatesTest/previous-permission_templates.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql deleted file mode 100644 index 75957baf6e7..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/AddOrganizationUuidToUserRolesTest/previous-user_roles.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); - -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql deleted file mode 100644 index 26cf56a69f2..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateDefaultOrganizationTest/organizations_and_internal_properties.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "ORGANIZATIONS" ( - "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, - "KEE" VARCHAR(32) NOT NULL, - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(256), - "URL" VARCHAR(256), - "AVATAR_URL" VARCHAR(256), - "CREATED_AT" BIGINT NOT NULL, - "UPDATED_AT" BIGINT NOT NULL -); -CREATE UNIQUE INDEX "PK_ORGANIZATIONS" ON "ORGANIZATIONS" ("UUID"); -CREATE UNIQUE INDEX "ORGANIZATION_KEY" ON "ORGANIZATIONS" ("KEE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableOrganizationsTest/empty.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableOrganizationsTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableOrganizationsTest/empty.sql +++ /dev/null diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest/empty.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest/empty.sql deleted file mode 100644 index e69de29bb2d..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/CreateTableWebhookDeliveriesTest/empty.sql +++ /dev/null diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/DeletePermissionShareDashboardTest/roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/DeletePermissionShareDashboardTest/roles.sql deleted file mode 100644 index 4d08a027079..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/DeletePermissionShareDashboardTest/roles.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); - - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropIssueFiltersTableTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/DropIssueFiltersTableTest/schema.sql deleted file mode 100644 index e842593fef6..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropIssueFiltersTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "ISSUE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_LOGIN" VARCHAR(255), - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE INDEX "ISSUE_FILTERS_NAME" ON "ISSUE_FILTERS" ("NAME"); - - -CREATE TABLE "ISSUE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_LOGIN" VARCHAR(255) NOT NULL, - "ISSUE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "ISSUE_FILTER_FAVS_USER" ON "ISSUE_FILTER_FAVOURITES" ("USER_LOGIN"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropMeasureFiltersTableTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/DropMeasureFiltersTableTest/schema.sql deleted file mode 100644 index f7331d4bb8a..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropMeasureFiltersTableTest/schema.sql +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE "MEASURE_FILTERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "SHARED" BOOLEAN NOT NULL DEFAULT FALSE, - "USER_ID" INTEGER, - "DESCRIPTION" VARCHAR(4000), - "DATA" CLOB(2147483647), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); -CREATE INDEX "MEASURE_FILTERS_NAME" ON "MEASURE_FILTERS" ("NAME"); - - -CREATE TABLE "MEASURE_FILTER_FAVOURITES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER NOT NULL, - "MEASURE_FILTER_ID" INTEGER NOT NULL, - "CREATED_AT" TIMESTAMP -); -CREATE INDEX "MEASURE_FILTER_FAVS_USERID" ON "MEASURE_FILTER_FAVOURITES" ("USER_ID"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropRelatedDashboardTablesTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/DropRelatedDashboardTablesTest/schema.sql deleted file mode 100644 index 6456acc22fd..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/DropRelatedDashboardTablesTest/schema.sql +++ /dev/null @@ -1,47 +0,0 @@ -CREATE TABLE "ACTIVE_DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "USER_ID" INTEGER, - "ORDER_INDEX" INTEGER -); -CREATE INDEX "ACTIVE_DASHBOARDS_DASHBOARDID" ON "ACTIVE_DASHBOARDS" ("DASHBOARD_ID"); -CREATE INDEX "ACTIVE_DASHBOARDS_USERID" ON "ACTIVE_DASHBOARDS" ("USER_ID"); - - -CREATE TABLE "DASHBOARDS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_LAYOUT" VARCHAR(20), - "SHARED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "WIDGETS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "DASHBOARD_ID" INTEGER NOT NULL, - "WIDGET_KEY" VARCHAR(256) NOT NULL, - "NAME" VARCHAR(256), - "DESCRIPTION" VARCHAR(1000), - "COLUMN_INDEX" INTEGER, - "ROW_INDEX" INTEGER, - "CONFIGURED" BOOLEAN, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, - "RESOURCE_ID" INTEGER -); -CREATE INDEX "WIDGETS_WIDGETKEY" ON "WIDGETS" ("WIDGET_KEY"); -CREATE INDEX "WIDGETS_DASHBOARDS" ON "WIDGETS" ("DASHBOARD_ID"); - - -CREATE TABLE "WIDGET_PROPERTIES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "WIDGET_ID" INTEGER NOT NULL, - "KEE" VARCHAR(100), - "TEXT_VALUE" VARCHAR(4000) -); -CREATE INDEX "WIDGET_PROPERTIES_WIDGETS" ON "WIDGET_PROPERTIES" ("WIDGET_ID"); - - diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql deleted file mode 100644 index b7c45cfd68e..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupRolesTest/in_progress_group_roles.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql deleted file mode 100644 index 4a6fd1f49b9..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnGroupsTest/in_progress_groups.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql deleted file mode 100644 index 163e5ecb021..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnPermissionTemplatesTest/in_progress_permission_templates.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql deleted file mode 100644 index e4d1b024417..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeOrganizationUuidNotNullOnUserRolesTest/in_progress_user_roles.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql deleted file mode 100644 index 733b337f897..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/MakeRootColumnNotNullOnTableUsersTest/users_with_nullable_root.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "IS_ROOT" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql deleted file mode 100644 index 54ad1ab20d0..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateIsRootColumnOnTableUsersTest/users_and_permissions_tables.sql +++ /dev/null @@ -1,52 +0,0 @@ -CREATE TABLE "USERS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "LOGIN" VARCHAR(255), - "NAME" VARCHAR(200), - "EMAIL" VARCHAR(100), - "CRYPTED_PASSWORD" VARCHAR(40), - "SALT" VARCHAR(40), - "ACTIVE" BOOLEAN DEFAULT TRUE, - "SCM_ACCOUNTS" VARCHAR(4000), - "EXTERNAL_IDENTITY" VARCHAR(255), - "EXTERNAL_IDENTITY_PROVIDER" VARCHAR(100), - "USER_LOCAL" BOOLEAN, - "IS_ROOT" BOOLEAN, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT -); -CREATE UNIQUE INDEX "USERS_LOGIN" ON "USERS" ("LOGIN"); -CREATE INDEX "USERS_UPDATED_AT" ON "USERS" ("UPDATED_AT"); - -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "USER_ROLES_RESOURCE" ON "USER_ROLES" ("RESOURCE_ID"); -CREATE INDEX "USER_ROLES_USER" ON "USER_ROLES" ("USER_ID"); - -CREATE TABLE "GROUPS_USERS" ( - "USER_ID" INTEGER, - "GROUP_ID" INTEGER -); -CREATE INDEX "INDEX_GROUPS_USERS_ON_GROUP_ID" ON "GROUPS_USERS" ("GROUP_ID"); -CREATE INDEX "INDEX_GROUPS_USERS_ON_USER_ID" ON "GROUPS_USERS" ("USER_ID"); -CREATE UNIQUE INDEX "GROUPS_USERS_UNIQUE" ON "GROUPS_USERS" ("GROUP_ID", "USER_ID"); - -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql deleted file mode 100644 index 775ab11911e..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupRolesTest/group_roles.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE "GROUP_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "GROUP_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE INDEX "GROUP_ROLES_RESOURCE" ON "GROUP_ROLES" ("RESOURCE_ID"); - -CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_ID", "ROLE"); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); - -CREATE UNIQUE INDEX "UNIQ_INTERNAL_PROPERTIES" ON "INTERNAL_PROPERTIES" ("KEE"); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql deleted file mode 100644 index 0ee6f37fe25..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfGroupsTest/user_groups.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "GROUPS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(500), - "DESCRIPTION" VARCHAR(200), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql deleted file mode 100644 index cc29ea296da..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfPermissionTemplatesTest/permission_templates.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "PERMISSION_TEMPLATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "NAME" VARCHAR(100) NOT NULL, - "KEE" VARCHAR(100) NOT NULL, - "DESCRIPTION" VARCHAR(4000), - "KEY_PATTERN" VARCHAR(500), - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql deleted file mode 100644 index 8448b6e6002..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/PopulateOrganizationUuidOfUserRolesTest/user_roles.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE "USER_ROLES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "ORGANIZATION_UUID" VARCHAR(40), - "USER_ID" INTEGER, - "RESOURCE_ID" INTEGER, - "ROLE" VARCHAR(64) NOT NULL -); - -CREATE TABLE "INTERNAL_PROPERTIES" ( - "KEE" VARCHAR(50) NOT NULL PRIMARY KEY, - "IS_EMPTY" BOOLEAN NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "CLOB_VALUE" CLOB, - "CREATED_AT" BIGINT -); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql deleted file mode 100644 index 39a62ddfdc6..00000000000 --- a/sonar-db/src/test/resources/org/sonar/db/version/v62/UpdateQualityGateConditionsOnCoverageTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "QUALITY_GATES" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(100) NOT NULL, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); -CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME"); - - -CREATE TABLE "QUALITY_GATE_CONDITIONS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "QGATE_ID" INTEGER, - "METRIC_ID" INTEGER, - "OPERATOR" VARCHAR(3), - "VALUE_ERROR" VARCHAR(64), - "VALUE_WARNING" VARCHAR(64), - "PERIOD" INTEGER, - "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP, -); - -CREATE TABLE "METRICS" ( - "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), - "NAME" VARCHAR(64) NOT NULL, - "DESCRIPTION" VARCHAR(255), - "DIRECTION" INTEGER NOT NULL DEFAULT 0, - "DOMAIN" VARCHAR(64), - "SHORT_NAME" VARCHAR(64), - "QUALITATIVE" BOOLEAN NOT NULL DEFAULT FALSE, - "VAL_TYPE" VARCHAR(8), - "USER_MANAGED" BOOLEAN DEFAULT FALSE, - "ENABLED" BOOLEAN DEFAULT TRUE, - "WORST_VALUE" DOUBLE, - "BEST_VALUE" DOUBLE, - "OPTIMIZED_BEST_VALUE" BOOLEAN, - "HIDDEN" BOOLEAN, - "DELETE_HISTORICAL_DATA" BOOLEAN, - "DECIMAL_SCALE" INTEGER -); -CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS" ("NAME"); |