Browse Source

SONAR-21643 Migrate db tests migration to Junit5

 #
tags/10.5.0.89998
Léo Geoffroy 2 months ago
parent
commit
4a921c76d4
100 changed files with 711 additions and 669 deletions
  1. 4
    0
      server/sonar-db-core/build.gradle
  2. 14
    1
      server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java
  3. 6
    0
      server/sonar-db-migration/build.gradle
  4. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/charset/SelectExecutorIT.java
  5. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/charset/SqlExecutorIT.java
  6. 10
    10
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplIT.java
  7. 9
    9
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplIT.java
  8. 8
    8
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplIT.java
  9. 34
    15
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderIT.java
  10. 11
    11
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderIT.java
  11. 27
    27
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/step/DataChangeIT.java
  12. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/step/ForceReloadingOfAllPluginsIT.java
  13. 5
    5
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v00/CreateInitialSchemaIT.java
  14. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v00/PopulateInitialSchemaIT.java
  15. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/AddNclocToProjectsIT.java
  16. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/CreateScimGroupsTableIT.java
  17. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/CreateUniqueIndexForScimGroupsUuidIT.java
  18. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsIT.java
  19. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsIT.java
  20. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsIT.java
  21. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsIT.java
  22. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsIT.java
  23. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsIT.java
  24. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsIT.java
  25. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropScimUserProvisioningIT.java
  26. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropSonarScimEnabledPropertyIT.java
  27. 12
    12
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyIT.java
  28. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/MakeColumnUserLocalNotNullableInUsersIT.java
  29. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/PopulateNclocForForProjectsIT.java
  30. 8
    8
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/RemoveOrphanRulesFromQualityProfilesIT.java
  31. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/UpdateUserLocalValueInUsersIT.java
  32. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddCodeVariantsColumnInIssuesTableIT.java
  33. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddIsMainColumnInProjectBranchesIT.java
  34. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddReportSchedulesTableIT.java
  35. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddReportSubscriptionsTableIT.java
  36. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AlterIsMainColumnInProjectBranchesIT.java
  37. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateExternalGroupsTableIT.java
  38. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexForEmailOnUsersTableIT.java
  39. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexForScmAccountOnScmAccountsTableIT.java
  40. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexOnExternalIdAndIdentityOnExternalGroupsTableIT.java
  41. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateProjectUuidInUserTokensIT.java
  42. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateScmAccountsTableIT.java
  43. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateUniqueIndexForReportSchedulesTableIT.java
  44. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateUniqueIndexForReportSubscriptionsTableIT.java
  45. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/DropProjectKeyInUserTokensIT.java
  46. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/DropScmAccountsInUsersIT.java
  47. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/FixDifferentUuidsForSubportfoliosIT.java
  48. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseKeeColumnSizeInInternalPropertiesIT.java
  49. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseTaskTypeColumnSizeInCeActivityIT.java
  50. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseTaskTypeColumnSizeInCeQueueIT.java
  51. 14
    14
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/MigrateScmAccountsFromUsersToScmAccountsIT.java
  52. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateProjectUuidInUserTokensIT.java
  53. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateReportSchedulesIT.java
  54. 7
    7
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateReportSubscriptionsIT.java
  55. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RemoveOrphanUserTokensIT.java
  56. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RemoveReportPropertiesIT.java
  57. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RenameColumnComponentUuidInPropertiesIT.java
  58. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/UpdateIsMainColumnInProjectBranchesIT.java
  59. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/AddCleanCodeAttributeInRulesIT.java
  60. 13
    13
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT.java
  61. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateAnticipatedTransitionsTableIT.java
  62. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateBooleanPurgedColumnInSnapshotsIT.java
  63. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateGithubOrganizationsGroupsTableIT.java
  64. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexCreatedAtInWebhookDeliveriesIT.java
  65. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInCeActivityIT.java
  66. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInCeQueueIT.java
  67. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInGroupRolesIT.java
  68. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInUserRolesIT.java
  69. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidCreatedAtInWebhookDeliveriesIT.java
  70. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInProjectBranchesIT.java
  71. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexRootComponentUuidInSnapshotsIT.java
  72. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexTaskUuidCreatedAtInWebhookDeliveriesIT.java
  73. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesIT.java
  74. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIssueImpactsTableIT.java
  75. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreatePreviousNonCompliantValueInNewCodePeriodsIT.java
  76. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateRulesDefaultImpactsTableIT.java
  77. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateUniqueConstraintOnIssuesImpactsIT.java
  78. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateUniqueConstraintOnRulesDefaultImpactsIT.java
  79. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInGroupRolesIT.java
  80. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInSnapshotsIT.java
  81. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInUserRolesIT.java
  82. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInWebhookDeliveriesIT.java
  83. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexMainComponentUuidInCeActivityIT.java
  84. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexMainComponentUuidInCeQueueIT.java
  85. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexOnMainBranchProjectUuidIT.java
  86. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexProjectUuidInWebhookDeliveriesIT.java
  87. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexTaskUuidInWebhookDeliveriesIT.java
  88. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexWebhookUuidInWebhookDeliveriesIT.java
  89. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropMainBranchProjectUuidInComponentsIT.java
  90. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropPurgeStatusColumnInSnapshotsIT.java
  91. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropTableProjectMappingsIT.java
  92. 8
    8
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/FixSqaleIndexMetricDescriptionIT.java
  93. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/IncreaseIsLastKeyInCeActivityIT.java
  94. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/IncreaseMainIsLastKeyInCeActivityIT.java
  95. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/MakeProjectUuidNullableInUserDismissedMessagesIT.java
  96. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/MakePurgedColumnNotNullableInSnapshotsIT.java
  97. 10
    10
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateCleanCodeAttributeColumnInRulesIT.java
  98. 18
    18
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java
  99. 6
    6
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulatePurgedColumnInSnapshotsIT.java
  100. 0
    0
      server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/RenameBuildDateInSnapshotsIT.java

+ 4
- 0
server/sonar-db-core/build.gradle View File

@@ -26,12 +26,15 @@ dependencies {
testImplementation 'com.microsoft.sqlserver:mssql-jdbc'
testImplementation 'com.oracle.database.jdbc:ojdbc11'
testImplementation 'com.tngtech.java:junit-dataprovider'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.postgresql:postgresql'
testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'

testImplementation project(':sonar-testing-harness')

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testRuntimeOnly 'com.h2database:h2'
testRuntimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
testRuntimeOnly 'com.oracle.database.jdbc:ojdbc11'
@@ -43,6 +46,7 @@ dependencies {
testFixturesApi 'org.apache.commons:commons-collections4'

testFixturesImplementation 'com.oracle.database.jdbc:ojdbc11'
testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api'

testFixturesCompileOnly 'com.google.code.findbugs:jsr305'
}

+ 14
- 1
server/sonar-db-core/src/testFixtures/java/org/sonar/db/CoreDbTester.java View File

@@ -20,12 +20,15 @@
package org.sonar.db;

import org.apache.commons.lang.StringUtils;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* This class should be called using @Rule.
* Data is truncated between each tests. The schema is created between each test.
*/
public class CoreDbTester extends AbstractDbTester<CoreTestDb> {
public class CoreDbTester extends AbstractDbTester<CoreTestDb> implements BeforeEachCallback, AfterEachCallback {

private CoreDbTester(CoreTestDb testDb) {
super(testDb);
@@ -55,4 +58,14 @@ public class CoreDbTester extends AbstractDbTester<CoreTestDb> {
protected void after() {
db.stop();
}

@Override
public void afterEach(ExtensionContext extensionContext) throws Exception {
after();
}

@Override
public void beforeEach(ExtensionContext extensionContext) throws Exception {
before();
}
}

+ 6
- 0
server/sonar-db-migration/build.gradle View File

@@ -24,6 +24,7 @@ dependencies {
testImplementation 'com.squareup.okhttp3:mockwebserver'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.mindrot:jbcrypt'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.xmlunit:xmlunit-core'
@@ -34,14 +35,19 @@ dependencies {
testImplementation testFixtures(project(':server:sonar-db-core'))

testFixturesImplementation 'org.sonarsource.orchestrator:sonar-orchestrator-junit4'
testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api'
testFixturesImplementation testFixtures(project(':server:sonar-db-core'))

testRuntimeOnly 'com.h2database:h2'
testRuntimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
testRuntimeOnly 'com.oracle.database.jdbc:ojdbc11'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testRuntimeOnly 'org.postgresql:postgresql'
}

test {
systemProperty 'orchestrator.configUrl', System.getProperty('orchestrator.configUrl')
// Enabling the JUnit Platform (see https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-gradle)
useJUnitPlatform()
}

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/charset/SelectExecutorIT.java View File

@@ -21,21 +21,21 @@ package org.sonar.server.platform.db.migration.charset;

import java.sql.Connection;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;

import static org.assertj.core.api.Assertions.assertThat;

public class SelectExecutorIT {
class SelectExecutorIT {

@Rule
public CoreDbTester dbTester = CoreDbTester.createForSchema(SelectExecutorIT.class, "users_table.sql");
@RegisterExtension
public final CoreDbTester dbTester = CoreDbTester.createForSchema(SelectExecutorIT.class, "users_table.sql");

SqlExecutor underTest = new SqlExecutor();

@Test
public void testExecuteQuery() throws Exception {
void testExecuteQuery() throws Exception {
insertUser("him", "Him");
insertUser("her", "Her");


+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/charset/SqlExecutorIT.java View File

@@ -22,13 +22,13 @@ package org.sonar.server.platform.db.migration.charset;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;

import static org.assertj.core.api.Assertions.assertThat;

public class SqlExecutorIT {
class SqlExecutorIT {

private static final String LOGIN_DB_COLUMN = "login";
private static final String NAME_DB_COLUMN = "name";
@@ -37,11 +37,11 @@ public class SqlExecutorIT {

private SqlExecutor underTest = new SqlExecutor();

@Rule
public CoreDbTester dbTester = CoreDbTester.createForSchema(SqlExecutorIT.class, "users_table.sql");
@RegisterExtension
public final CoreDbTester dbTester = CoreDbTester.createForSchema(SqlExecutorIT.class, "users_table.sql");

@Test
public void executeSelect_executes_PreparedStatement() throws Exception {
void executeSelect_executes_PreparedStatement() throws Exception {
dbTester.executeInsert(USERS_DB_TABLE, LOGIN_DB_COLUMN, "login1", NAME_DB_COLUMN, "name one", IS_ROOT_DB_COLUMN, false);
dbTester.executeInsert(USERS_DB_TABLE, LOGIN_DB_COLUMN, "login2", NAME_DB_COLUMN, "name two", IS_ROOT_DB_COLUMN, false);

@@ -57,7 +57,7 @@ public class SqlExecutorIT {
}

@Test
public void executeUpdate_executes_PreparedStatement() throws Exception {
void executeUpdate_executes_PreparedStatement() throws Exception {
dbTester.executeInsert(USERS_DB_TABLE, LOGIN_DB_COLUMN, "the_login", NAME_DB_COLUMN, "the name", IS_ROOT_DB_COLUMN, false);

try (Connection connection = dbTester.openConnection()) {

+ 10
- 10
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImplIT.java View File

@@ -23,8 +23,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Arrays;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.MigrationStep;
import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep;
@@ -34,40 +34,40 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

public class MigrationHistoryImplIT {
@Rule
public CoreDbTester dbTester = CoreDbTester.createForSchema(MigrationHistoryImplIT.class, "schema_migration.sql");
class MigrationHistoryImplIT {
@RegisterExtension
public final CoreDbTester dbTester = CoreDbTester.createForSchema(MigrationHistoryImplIT.class, "schema_migration.sql");

private MigrationHistoryMeddler migrationHistoryMeddler = mock(MigrationHistoryMeddler.class);
private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database(), migrationHistoryMeddler);

@Test
public void start_does_not_fail_if_table_history_exists_and_calls_meddler() {
void start_does_not_fail_if_table_history_exists_and_calls_meddler() {
underTest.start();

verify(migrationHistoryMeddler).meddle(underTest);
}

@Test
public void getLastMigrationNumber_returns_empty_if_history_table_is_empty() {
void getLastMigrationNumber_returns_empty_if_history_table_is_empty() {
assertThat(underTest.getLastMigrationNumber()).isEmpty();
}

@Test
public void getLastMigrationNumber_returns_last_version_assuming_version_are_only_number() throws SQLException {
void getLastMigrationNumber_returns_last_version_assuming_version_are_only_number() throws SQLException {
insert(12, 5, 30, 8);

assertThat(underTest.getLastMigrationNumber()).contains(30L);
}

@Test
public void done_fails_with_NPE_if_argument_is_null() {
void done_fails_with_NPE_if_argument_is_null() {
assertThatThrownBy(() -> underTest.done(null))
.isInstanceOf(NullPointerException.class);
}

@Test
public void done_adds_migration_number_to_table() {
void done_adds_migration_number_to_table() {
underTest.done(new RegisteredMigrationStep(12, "aa", MigrationStep.class));

assertThat(underTest.getLastMigrationNumber()).contains(12L);

+ 9
- 9
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/MigrationHistoryTableImplIT.java View File

@@ -23,30 +23,30 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.db.dialect.MsSql;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.db.dialect.MsSql;

import static org.assertj.core.api.Assertions.assertThat;

public class MigrationHistoryTableImplIT {
class MigrationHistoryTableImplIT {
private static final String TABLE_SCHEMA_MIGRATIONS = "schema_migrations";

@Rule
public MigrationDbTester dbTester = MigrationDbTester.createEmpty();
@RegisterExtension
public final MigrationDbTester dbTester = MigrationDbTester.createEmpty();

private MigrationHistoryTableImpl underTest = new MigrationHistoryTableImpl(dbTester.database());
private final MigrationHistoryTableImpl underTest = new MigrationHistoryTableImpl(dbTester.database());

@Test
public void start_creates_table_on_empty_schema() {
void start_creates_table_on_empty_schema() {
underTest.start();

verifyTable();
}

@Test
public void start_does_not_fail_if_table_exists() throws SQLException {
void start_does_not_fail_if_table_exists() throws SQLException {
executeDdl(String.format("create table %s (version %s(255) not null)", TABLE_SCHEMA_MIGRATIONS, getFieldType()));
verifyTable();


+ 8
- 8
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/history/NoTableMigrationHistoryImplIT.java View File

@@ -19,23 +19,23 @@
*/
package org.sonar.server.platform.db.migration.history;

import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoInteractions;

public class NoTableMigrationHistoryImplIT {
@Rule
public MigrationDbTester dbTester = MigrationDbTester.createEmpty();
class NoTableMigrationHistoryImplIT {
@RegisterExtension
public final MigrationDbTester dbTester = MigrationDbTester.createEmpty();

private MigrationHistoryMeddler migrationHistoryMeddler = mock(MigrationHistoryMeddler.class);
private MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database(), migrationHistoryMeddler);
private final MigrationHistoryMeddler migrationHistoryMeddler = mock(MigrationHistoryMeddler.class);
private final MigrationHistoryImpl underTest = new MigrationHistoryImpl(dbTester.database(), migrationHistoryMeddler);

@Test
public void start_fails_with_ISE_if_table_history_does_not_exist() {
void start_fails_with_ISE_if_table_history_does_not_exist() {
assertThatThrownBy(() -> {
underTest.start();
verifyNoInteractions(migrationHistoryMeddler);

+ 34
- 15
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilderIT.java View File

@@ -19,11 +19,13 @@
*/
package org.sonar.server.platform.db.migration.sql;

import java.util.List;
import java.util.Map;
import org.junit.ClassRule;
import org.junit.Test;
import org.sonar.db.dialect.Dialect;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.db.dialect.Dialect;
import org.sonar.server.platform.db.migration.def.TinyIntColumnDef;
import org.sonar.server.platform.db.migration.def.VarcharColumnDef;

@@ -37,16 +39,22 @@ import static org.sonar.server.platform.db.migration.def.IntegerColumnDef.newInt
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.ColumnFlag.AUTO_INCREMENT;

public class CreateTableBuilderIT {
@ClassRule
public static final MigrationDbTester dbTester = MigrationDbTester.createEmpty();
class CreateTableBuilderIT {
@RegisterExtension
public final MigrationDbTester dbTester = MigrationDbTester.createEmpty();

private final Dialect dialect = dbTester.database().getDialect();
private Dialect dialect;
private static int tableNameGenerator = 0;

@BeforeEach
void before() {
dialect = dbTester.database().getDialect();
}

@Test
public void create_no_primary_key_table() {
newCreateTableBuilder()
void create_no_primary_key_table() {
String tableName = createTableName();
new CreateTableBuilder(dialect, tableName)
.addColumn(newBooleanColumnDefBuilder().setColumnName("bool_col_1").build())
.addColumn(newBooleanColumnDefBuilder().setColumnName("bool_col_2").setIsNullable(false).build())
.addColumn(newIntegerColumnDefBuilder().setColumnName("i_col_1").build())
@@ -65,29 +73,35 @@ public class CreateTableBuilderIT {
.addColumn(newBlobColumnDefBuilder().setColumnName("blob_col_2").setIsNullable(false).build())
.build()
.forEach(dbTester::executeDdl);
assertTableAndColumnsExists(tableName, "bool_col_1", "bool_col_2", "i_col_1", "i_col_2", "bi_col_1", "bi_col_2", "clob_col_1",
"clob_col_2", "dec_col_1", "dec_col_2", "tiny_col_1", "tiny_col_2", "varchar_col_1", "varchar_col_2", "blob_col_1", "blob_col_2");
}

@Test
public void create_single_column_primary_key_table() {
newCreateTableBuilder()
void create_single_column_primary_key_table() {
String tableName = createTableName();
new CreateTableBuilder(dialect, tableName)
.addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("bg_col_1").setIsNullable(false).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("varchar_col_2").setLimit(40).setIsNullable(false).build())
.build()
.forEach(dbTester::executeDdl);
assertTableAndColumnsExists(tableName, "bg_col_1", "varchar_col_2");
}

@Test
public void create_multi_column_primary_key_table() {
newCreateTableBuilder()
void create_multi_column_primary_key_table() {
String tableName = createTableName();
new CreateTableBuilder(dialect, tableName)
.addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("bg_col_1").setIsNullable(false).build())
.addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("bg_col_2").setIsNullable(false).build())
.addColumn(newVarcharColumnDefBuilder().setColumnName("varchar_col_2").setLimit(40).setIsNullable(false).build())
.build()
.forEach(dbTester::executeDdl);
assertTableAndColumnsExists(tableName, "bg_col_1", "bg_col_2", "varchar_col_2");
}

@Test
public void create_autoincrement_notnullable_integer_primary_key_table() {
void create_autoincrement_notnullable_integer_primary_key_table() {
String tableName = createTableName();
new CreateTableBuilder(dialect, tableName)
.addPkColumn(newIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
@@ -99,7 +113,7 @@ public class CreateTableBuilderIT {
}

@Test
public void create_autoincrement_notnullable_biginteger_primary_key_table() {
void create_autoincrement_notnullable_biginteger_primary_key_table() {
String tableName = createTableName();
new CreateTableBuilder(dialect, tableName)
.addPkColumn(newBigIntegerColumnDefBuilder().setColumnName("id").setIsNullable(false).build(), AUTO_INCREMENT)
@@ -122,6 +136,11 @@ public class CreateTableBuilderIT {
assertThat(row).containsEntry("val", "toto");
}

private void assertTableAndColumnsExists(String tableName, String... columnNames) {
List<Map<String, Object>> row = dbTester.select(String.format("select %s from %s", String.join(", ", columnNames), tableName));
assertThat(row).isEmpty();
}

private CreateTableBuilder newCreateTableBuilder() {
return new CreateTableBuilder(dialect, createTableName());
}

+ 11
- 11
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderIT.java View File

@@ -23,8 +23,8 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.Optional;
import javax.sql.DataSource;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.db.Database;
import org.sonar.db.dialect.H2;
@@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class DbPrimaryKeyConstraintFinderIT {
class DbPrimaryKeyConstraintFinderIT {

@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DbPrimaryKeyConstraintFinderIT.class, "schema.sql");
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(DbPrimaryKeyConstraintFinderIT.class, "schema.sql");

private final Database dbMock = mock(Database.class);
private final DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(dbMock);
@@ -50,7 +50,7 @@ public class DbPrimaryKeyConstraintFinderIT {
private static final org.sonar.db.dialect.H2 H2 = new H2();

@Test
public void findConstraintName_constraint_exists() throws SQLException {
void findConstraintName_constraint_exists() throws SQLException {
DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
Optional<String> constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY");
assertThat(constraintName).isPresent();
@@ -58,13 +58,13 @@ public class DbPrimaryKeyConstraintFinderIT {
}

@Test
public void findConstraintName_constraint_not_exist_fails_silently() throws SQLException {
void findConstraintName_constraint_not_exist_fails_silently() throws SQLException {
DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
assertThat(underTest.findConstraintName("NOT_EXISTING_TABLE")).isNotPresent();
}

@Test
public void getDbVendorSpecificQuery_mssql() {
void getDbVendorSpecificQuery_mssql() {
when(dbMock.getDialect()).thenReturn(MS_SQL);

assertThat(underTest.getDbVendorSpecificQuery("my_table"))
@@ -72,7 +72,7 @@ public class DbPrimaryKeyConstraintFinderIT {
}

@Test
public void getDbVendorSpecificQuery_postgresql() throws SQLException {
void getDbVendorSpecificQuery_postgresql() throws SQLException {
DataSource dataSource = mock(DataSource.class);
Connection connection = mock(Connection.class);
when(dataSource.getConnection()).thenReturn(connection);
@@ -85,7 +85,7 @@ public class DbPrimaryKeyConstraintFinderIT {
}

@Test
public void getDbVendorSpecificQuery_oracle() {
void getDbVendorSpecificQuery_oracle() {
when(dbMock.getDialect()).thenReturn(ORACLE);

assertThat(underTest.getDbVendorSpecificQuery("my_table"))
@@ -93,7 +93,7 @@ public class DbPrimaryKeyConstraintFinderIT {
}

@Test
public void getDbVendorSpecificQuery_h2() {
void getDbVendorSpecificQuery_h2() {
when(dbMock.getDialect()).thenReturn(H2);

assertThat(underTest.getDbVendorSpecificQuery("my_table"))

+ 27
- 27
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/step/DataChangeIT.java View File

@@ -30,9 +30,9 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.Select.Row;
import org.sonar.server.platform.db.migration.step.Select.RowReader;
@@ -43,21 +43,21 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.fail;

public class DataChangeIT {
class DataChangeIT {

private static final int MAX_BATCH_SIZE = 250;
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DataChangeIT.class, "schema.sql");
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(DataChangeIT.class, "schema.sql");

@Before
@BeforeEach
public void setUp() {
db.executeUpdateSql("truncate table persons");
}

@Test
public void query() throws Exception {
void query() throws Exception {
insertPersons();

AtomicBoolean executed = new AtomicBoolean(false);
@@ -77,7 +77,7 @@ public class DataChangeIT {
}

@Test
public void read_column_types() throws Exception {
void read_column_types() throws Exception {
insertPersons();

List<Object[]> persons = new ArrayList<>();
@@ -99,7 +99,7 @@ public class DataChangeIT {
}

@Test
public void parameterized_query() throws Exception {
void parameterized_query() throws Exception {
insertPersons();

final List<Long> ids = new ArrayList<>();
@@ -113,7 +113,7 @@ public class DataChangeIT {
}

@Test
public void display_current_row_details_if_error_during_get() throws Exception {
void display_current_row_details_if_error_during_get() throws Exception {
insertPersons();

assertThatThrownBy(() -> {
@@ -131,7 +131,7 @@ public class DataChangeIT {
}

@Test
public void display_current_row_details_if_error_during_list() throws Exception {
void display_current_row_details_if_error_during_list() throws Exception {
insertPersons();

assertThatThrownBy(() -> {
@@ -149,7 +149,7 @@ public class DataChangeIT {
}

@Test
public void bad_parameterized_query() throws Exception {
void bad_parameterized_query() throws Exception {
insertPersons();

DataChange change = new DataChange(db.database()) {
@@ -165,7 +165,7 @@ public class DataChangeIT {
}

@Test
public void scroll() throws Exception {
void scroll() throws Exception {
insertPersons();

final List<Long> ids = new ArrayList<>();
@@ -179,7 +179,7 @@ public class DataChangeIT {
}

@Test
public void insert() throws Exception {
void insert() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -203,7 +203,7 @@ public class DataChangeIT {
}

@Test
public void batch_inserts() throws Exception {
void batch_inserts() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -241,7 +241,7 @@ public class DataChangeIT {
}

@Test
public void override_size_of_batch_inserts() throws Exception {
void override_size_of_batch_inserts() throws Exception {
new DataChange(db.database()) {
@Override
public void execute(Context context) throws SQLException {
@@ -275,7 +275,7 @@ public class DataChangeIT {
}

@Test
public void update_null() throws Exception {
void update_null() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -301,7 +301,7 @@ public class DataChangeIT {
}

@Test
public void mass_batch_insert() throws Exception {
void mass_batch_insert() throws Exception {
db.executeUpdateSql("truncate table persons");

final int count = MAX_BATCH_SIZE + 10;
@@ -327,7 +327,7 @@ public class DataChangeIT {
}

@Test
public void scroll_and_update() throws Exception {
void scroll_and_update() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -352,7 +352,7 @@ public class DataChangeIT {
}

@Test
public void display_current_row_details_if_error_during_scroll() throws Exception {
void display_current_row_details_if_error_during_scroll() throws Exception {
insertPersons();

assertThatThrownBy(() -> {
@@ -372,7 +372,7 @@ public class DataChangeIT {
}

@Test
public void mass_update() throws Exception {
void mass_update() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -398,7 +398,7 @@ public class DataChangeIT {
}

@Test
public void row_splitter_should_split_correctly() throws Exception {
void row_splitter_should_split_correctly() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -452,7 +452,7 @@ public class DataChangeIT {
private record PhoneNumberRow(long personId, String phoneNumber){}

@Test
public void display_current_row_details_if_error_during_mass_update() throws Exception {
void display_current_row_details_if_error_during_mass_update() throws Exception {
insertPersons();

assertThatThrownBy(() -> {
@@ -473,7 +473,7 @@ public class DataChangeIT {
}

@Test
public void mass_update_nothing() throws Exception {
void mass_update_nothing() throws Exception {
insertPersons();

new DataChange(db.database()) {
@@ -490,7 +490,7 @@ public class DataChangeIT {
}

@Test
public void bad_mass_update() throws Exception {
void bad_mass_update() throws Exception {
insertPersons();

DataChange change = new DataChange(db.database()) {
@@ -511,7 +511,7 @@ public class DataChangeIT {
}

@Test
public void read_not_null_fields() throws Exception {
void read_not_null_fields() throws Exception {
insertPersons();

List<Object[]> persons = new ArrayList<>();

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/step/ForceReloadingOfAllPluginsIT.java View File

@@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration.step;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.CoreDbTester;
@@ -32,16 +32,16 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.server.platform.db.migration.step.ForceReloadingOfAllPlugins.OVERWRITE_HASH;

public class ForceReloadingOfAllPluginsIT {
class ForceReloadingOfAllPluginsIT {
private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
public CoreDbTester db = CoreDbTester.createForSchema(ForceReloadingOfAllPluginsIT.class, "schema.sql");
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(ForceReloadingOfAllPluginsIT.class, "schema.sql");

private final DataChange underTest = new ForceReloadingOfAllPlugins(db.database());

@Test
public void migration_overwrite_file_hash_on_all_plugins() throws SQLException {
void migration_overwrite_file_hash_on_all_plugins() throws SQLException {
String pluginUuid1 = insertPlugin();
String pluginUuid2 = insertPlugin();

@@ -52,7 +52,7 @@ public class ForceReloadingOfAllPluginsIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String pluginUuid1 = insertPlugin();
String pluginUuid2 = insertPlugin();


+ 5
- 5
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v00/CreateInitialSchemaIT.java View File

@@ -25,23 +25,23 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.assertj.core.api.Assertions.assertThat;

public class CreateInitialSchemaIT {
class CreateInitialSchemaIT {

private static final Set<String> SCHEMAS_TO_IGNORE = Set.of("INFORMATION_SCHEMA", "sys", "SYS", "SYSTEM", "CTXSYS", "MDSYS", "XDB");

@Rule
@RegisterExtension
public final MigrationDbTester dbTester = MigrationDbTester.createForMigrationStep(CreateInitialSchema.class);

private final CreateInitialSchema underTest = new CreateInitialSchema(dbTester.database());

@Test
public void creates_tables_on_empty_db() throws Exception {
void creates_tables_on_empty_db() throws Exception {
underTest.execute();

List<String> tables = new ArrayList<>();

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v00/PopulateInitialSchemaIT.java View File

@@ -27,9 +27,9 @@ import java.util.Random;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.Version;
import org.sonar.core.platform.SonarQubeVersion;
@@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class PopulateInitialSchemaIT {
class PopulateInitialSchemaIT {

private static final long NOW = 1_500L;

@@ -51,18 +51,18 @@ public class PopulateInitialSchemaIT {
private final System2 system2 = mock(System2.class);
private final SonarQubeVersion sonarQubeVersion = mock(SonarQubeVersion.class);

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateInitialSchema.class);

private final PopulateInitialSchema underTest = new PopulateInitialSchema(db.database(), system2, uuidFactory, sonarQubeVersion);

@Before
@BeforeEach
public void setUp() {
when(sonarQubeVersion.get()).thenReturn(version);
}

@Test
public void migration_inserts_users_and_groups() throws SQLException {
void migration_inserts_users_and_groups() throws SQLException {
when(system2.now()).thenReturn(NOW);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/AddNclocToProjectsIT.java View File

@@ -21,22 +21,22 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class AddNclocToProjectsIT {
class AddNclocToProjectsIT {

private static final String TABLE_NAME = "projects";
private static final String COLUMN_NAME = "ncloc";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddNclocToProjects.class);
private final DdlChange underTest = new AddNclocToProjects(db.database());

@Test
public void add_column() throws SQLException {
void add_column() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
@@ -44,7 +44,7 @@ public class AddNclocToProjectsIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/CreateScimGroupsTableIT.java View File

@@ -21,22 +21,22 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
import static org.sonar.server.platform.db.migration.version.v100.CreateScimGroupsTable.TABLE_NAME;

public class CreateScimGroupsTableIT {
@Rule
class CreateScimGroupsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateScimGroupsTable.class);

private final DdlChange underTest = new CreateScimGroupsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();
@@ -48,7 +48,7 @@ public class CreateScimGroupsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/CreateUniqueIndexForScimGroupsUuidIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

@@ -29,13 +29,13 @@ import static org.sonar.server.platform.db.migration.version.v100.CreateScimGrou
import static org.sonar.server.platform.db.migration.version.v100.CreateUniqueIndexForScimGroupsUuid.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v100.CreateUniqueIndexForScimGroupsUuid.INDEX_NAME;

public class CreateUniqueIndexForScimGroupsUuidIT {
@Rule
class CreateUniqueIndexForScimGroupsUuidIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueIndexForScimGroupsUuid.class);
private final DdlChange underTest = new CreateUniqueIndexForScimGroupsUuid(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

underTest.execute();
@@ -44,7 +44,7 @@ public class CreateUniqueIndexForScimGroupsUuidIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidInComponentsIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropBModuleUuidInComponentsIT {
class DropBModuleUuidInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "b_module_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropBModuleUuidInComponents.class);
private final DdlChange underTest = new DropBModuleUuidInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropBModuleUuidPathInComponentsIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropBModuleUuidPathInComponentsIT {
class DropBModuleUuidPathInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "b_module_uuid_path";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropBModuleUuidPathInComponents.class);
private final DdlChange underTest = new DropBModuleUuidPathInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
underTest.execute();
underTest.execute();

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexProjectsModuleUuidInComponentsIT {
class DropIndexProjectsModuleUuidInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "module_uuid";
private static final String INDEX_NAME = "projects_module_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexProjectsModuleUuidInComponents.class);
private final DdlChange underTest = new DropIndexProjectsModuleUuidInComponents(db.database());

@Test
public void drops_index() throws SQLException {
void drops_index() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
}

@Test
public void execute_whenIndexNameWithPrefix_shouldStillDelete() throws SQLException {
void execute_whenIndexNameWithPrefix_shouldStillDelete() throws SQLException {
String alteredIndexName = "idx_1234567891345678916456789_" + INDEX_NAME;
db.renameIndex(TABLE_NAME, INDEX_NAME, alteredIndexName);
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
@@ -52,7 +52,7 @@ public class DropIndexProjectsModuleUuidInComponentsIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsRootUuidInComponentsIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexProjectsRootUuidInComponentsIT {
class DropIndexProjectsRootUuidInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "root_uuid";
private static final String INDEX_NAME = "projects_root_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexProjectsRootUuidInComponents.class);
private final DdlChange underTest = new DropIndexProjectsRootUuidInComponents(db.database());

@Test
public void drops_index() throws SQLException {
void drops_index() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidInComponentsIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropModuleUuidInComponentsIT {
class DropModuleUuidInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "module_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropModuleUuidInComponents.class);
private final DdlChange underTest = new DropModuleUuidInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropModuleUuidPathInComponentsIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropModuleUuidPathInComponentsIT {
class DropModuleUuidPathInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "module_uuid_path";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropModuleUuidPathInComponents.class);
private final DdlChange underTest = new DropModuleUuidPathInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 1500, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropRootUuidInComponentsIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropRootUuidInComponentsIT {
class DropRootUuidInComponentsIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "root_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropRootUuidInComponents.class);
private final DdlChange underTest = new DropRootUuidInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropScimUserProvisioningIT.java View File

@@ -20,21 +20,21 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;

import static org.assertj.core.api.Assertions.assertThat;

public class DropScimUserProvisioningIT {
class DropScimUserProvisioningIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropScimUserProvisioning.class);
private final DataChange underTest = new DropScimUserProvisioning(db.database());

@Test
public void migration_should_truncate_scim_users_table() throws SQLException {
void migration_should_truncate_scim_users_table() throws SQLException {
insertScimUser(1);
insertScimUser(2);

@@ -51,7 +51,7 @@ public class DropScimUserProvisioningIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
insertScimUser(1);
insertScimUser(2);


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/DropSonarScimEnabledPropertyIT.java View File

@@ -21,19 +21,19 @@ package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;

public class DropSonarScimEnabledPropertyIT {
class DropSonarScimEnabledPropertyIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropSonarScimEnabledProperty.class);
private final DataChange underTest = new DropSonarScimEnabledProperty(db.database());

@Test
public void migration_should_remove_scim_property() throws SQLException {
void migration_should_remove_scim_property() throws SQLException {
insertScimProperty(db);

underTest.execute();
@@ -42,7 +42,7 @@ public class DropSonarScimEnabledPropertyIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
insertScimProperty(db);

underTest.execute();

+ 12
- 12
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyIT.java View File

@@ -20,33 +20,33 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.event.Level;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.testfixtures.log.LogTesterJUnit5;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;

import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.server.platform.db.migration.version.v100.LogMessageIfSonarScimEnabledPresentProperty.SONAR_SCIM_ENABLED;

public class LogMessageIfSonarScimEnabledPresentPropertyIT {
class LogMessageIfSonarScimEnabledPresentPropertyIT {

@Rule
public LogTester logger = new LogTester();
@RegisterExtension
public final LogTesterJUnit5 logger = new LogTesterJUnit5();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(LogMessageIfSonarScimEnabledPresentProperty.class);
private final DataChange underTest = new LogMessageIfSonarScimEnabledPresentProperty(db.database());

@Before
@BeforeEach
public void before() {
logger.clear();
}

@Test
public void migration_should_log_message_when_scim_property() throws SQLException {
void migration_should_log_message_when_scim_property() throws SQLException {
db.executeInsert("properties ",
"prop_key", "sonar.scim.enabled",
"is_empty", false,
@@ -66,7 +66,7 @@ public class LogMessageIfSonarScimEnabledPresentPropertyIT {
}

@Test
public void migration_should_not_log_if_no_scim_property() throws SQLException {
void migration_should_not_log_if_no_scim_property() throws SQLException {

underTest.execute();

@@ -74,7 +74,7 @@ public class LogMessageIfSonarScimEnabledPresentPropertyIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.executeInsert("properties ",
"prop_key", "sonar.scim.enabled",
"is_empty", false,

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/MakeColumnUserLocalNotNullableInUsersIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v100;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.BOOLEAN;

public class MakeColumnUserLocalNotNullableInUsersIT {
class MakeColumnUserLocalNotNullableInUsersIT {
private static final String TABLE_NAME = "users";
private static final String COLUMN_NAME = "user_local";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(MakeColumnUserLocalNotNullableInUsers.class);
private final MakeColumnUserLocalNotNullableInUsers underTest = new MakeColumnUserLocalNotNullableInUsers(db.database());

@Test
public void user_local_column_is_not_null() throws SQLException {
void user_local_column_is_not_null() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/PopulateNclocForForProjectsIT.java View File

@@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration.version.v100;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -32,24 +32,24 @@ import org.sonar.server.platform.db.migration.step.DataChange;
import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.assertj.core.api.Assertions.assertThat;

public class PopulateNclocForForProjectsIT {
class PopulateNclocForForProjectsIT {

private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateNclocForForProjects.class);

private final DataChange underTest = new PopulateNclocForForProjects(db.database());

@Test
public void migration_populates_ncloc_for_projects() throws SQLException {
void migration_populates_ncloc_for_projects() throws SQLException {
Map<String, Long> expectedNclocByProjectUuid = populateData();
underTest.execute();
verifyNclocCorrectlyPopulatedForProjects(expectedNclocByProjectUuid);
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
Map<String, Long> expectedNclocByProjectUuid = populateData();
underTest.execute();
// re-entrant

+ 8
- 8
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/RemoveOrphanRulesFromQualityProfilesIT.java View File

@@ -22,9 +22,9 @@ package org.sonar.server.platform.db.migration.version.v100;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.utils.System2;
import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.core.util.UuidFactory;
@@ -37,21 +37,21 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.util.SequenceUuidFactory.UUID_1;

public class RemoveOrphanRulesFromQualityProfilesIT {
class RemoveOrphanRulesFromQualityProfilesIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RemoveOrphanRulesFromQualityProfiles.class);
private final System2 system2 = mock(System2.class);
private final UuidFactory instance = new SequenceUuidFactory();
private final DataChange underTest = new RemoveOrphanRulesFromQualityProfiles(db.database(), instance, system2);

@Before
@BeforeEach
public void before() {
when(system2.now()).thenReturn(1L);
}

@Test
public void migration_should_remove_orphans() throws SQLException {
void migration_should_remove_orphans() throws SQLException {
insertData();

underTest.execute();
@@ -61,7 +61,7 @@ public class RemoveOrphanRulesFromQualityProfilesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
insertData();

// re-entrant

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v100/UpdateUserLocalValueInUsersIT.java View File

@@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration.version.v100;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -33,17 +33,17 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang.RandomStringUtils.randomNumeric;
import static org.assertj.core.api.Assertions.assertThat;

public class UpdateUserLocalValueInUsersIT {
class UpdateUserLocalValueInUsersIT {

private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
public MigrationDbTester db = MigrationDbTester.createForMigrationStep(UpdateUserLocalValueInUsers.class);
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(UpdateUserLocalValueInUsers.class);

private final DataChange underTest = new UpdateUserLocalValueInUsers(db.database());

@Test
public void migration_updates_user_local_if_null() throws SQLException {
void migration_updates_user_local_if_null() throws SQLException {
String userUuid1 = insertUser(true);
String userUuid2 = insertUser(false);
String userUuid3 = insertUser(null);
@@ -56,7 +56,7 @@ public class UpdateUserLocalValueInUsersIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String userUuid1 = insertUser(true);
String userUuid2 = insertUser(false);
String userUuid3 = insertUser(null);

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddCodeVariantsColumnInIssuesTableIT.java View File

@@ -20,31 +20,31 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;

public class AddCodeVariantsColumnInIssuesTableIT {
class AddCodeVariantsColumnInIssuesTableIT {

private static final String TABLE_NAME = "issues";
private static final String COLUMN_NAME = "code_variants";
private static final int COLUMN_SIZE = 4000;

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddCodeVariantsColumnInIssuesTable.class);
private final AddCodeVariantsColumnInIssuesTable underTest = new AddCodeVariantsColumnInIssuesTable(db.database());

@Test
public void migration_should_add_column() throws SQLException {
void migration_should_add_column() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, COLUMN_SIZE, true);
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddIsMainColumnInProjectBranchesIT.java View File

@@ -20,30 +20,30 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.BOOLEAN;

public class AddIsMainColumnInProjectBranchesIT {
class AddIsMainColumnInProjectBranchesIT {

private static final String TABLE_NAME = "project_branches";
private static final String COLUMN_NAME = "is_main";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddIsMainColumnInProjectBranches.class);
private final AddIsMainColumnInProjectBranches underTest = new AddIsMainColumnInProjectBranches(db.database());

@Test
public void is_main_column_exists_with_null_value() throws SQLException {
void is_main_column_exists_with_null_value() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, null);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddReportSchedulesTableIT.java View File

@@ -21,22 +21,22 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.AddReportSchedulesTable.TABLE_NAME;

public class AddReportSchedulesTableIT {
@Rule
class AddReportSchedulesTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddReportSchedulesTable.class);

private final DdlChange underTest = new AddReportSchedulesTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();
@@ -51,7 +51,7 @@ public class AddReportSchedulesTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AddReportSubscriptionsTableIT.java View File

@@ -21,22 +21,22 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.AddReportSubscriptionsTable.TABLE_NAME;

public class AddReportSubscriptionsTableIT {
@Rule
class AddReportSubscriptionsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddReportSubscriptionsTable.class);

private final DdlChange underTest = new AddReportSubscriptionsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();
@@ -51,7 +51,7 @@ public class AddReportSubscriptionsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/AlterIsMainColumnInProjectBranchesIT.java View File

@@ -20,30 +20,30 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.BOOLEAN;

public class AlterIsMainColumnInProjectBranchesIT {
class AlterIsMainColumnInProjectBranchesIT {

private static final String TABLE_NAME = "project_branches";
private static final String COLUMN_NAME = "is_main";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AlterIsMainColumnInProjectBranches.class);
private final AlterIsMainColumnInProjectBranches underTest = new AlterIsMainColumnInProjectBranches(db.database());

@Test
public void execute_shouldNotBeNullable() throws SQLException {
void execute_shouldNotBeNullable() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateExternalGroupsTableIT.java View File

@@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

@@ -32,15 +32,15 @@ import static org.sonar.server.platform.db.migration.version.v101.CreateExternal
import static org.sonar.server.platform.db.migration.version.v101.CreateExternalGroupsTable.GROUP_UUID_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateExternalGroupsTable.TABLE_NAME;

public class CreateExternalGroupsTableIT {
class CreateExternalGroupsTableIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateExternalGroupsTable.class);

private final DdlChange createExternalGroupsTable = new CreateExternalGroupsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

createExternalGroupsTable.execute();
@@ -53,7 +53,7 @@ public class CreateExternalGroupsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

createExternalGroupsTable.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexForEmailOnUsersTableIT.java View File

@@ -20,21 +20,21 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.sonar.server.platform.db.migration.version.v101.CreateIndexForEmailOnUsersTable.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateIndexForEmailOnUsersTable.INDEX_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateIndexForEmailOnUsersTable.TABLE_NAME;

public class CreateIndexForEmailOnUsersTableIT {
@Rule
class CreateIndexForEmailOnUsersTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexForEmailOnUsersTable.class);
private final CreateIndexForEmailOnUsersTable createIndexForEmailOnUsersTable = new CreateIndexForEmailOnUsersTable(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndexForEmailOnUsersTable.execute();
@@ -43,7 +43,7 @@ public class CreateIndexForEmailOnUsersTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndexForEmailOnUsersTable.execute();
createIndexForEmailOnUsersTable.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexForScmAccountOnScmAccountsTableIT.java View File

@@ -20,21 +20,21 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.sonar.server.platform.db.migration.version.v101.CreateIndexForScmAccountOnScmAccountsTable.INDEX_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateScmAccountsTable.SCM_ACCOUNTS_TABLE_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateScmAccountsTable.SCM_ACCOUNT_COLUMN_NAME;

public class CreateIndexForScmAccountOnScmAccountsTableIT {
@Rule
class CreateIndexForScmAccountOnScmAccountsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexForScmAccountOnScmAccountsTable.class);
private final CreateIndexForScmAccountOnScmAccountsTable createIndexForScmAccountOnScmAccountsTable = new CreateIndexForScmAccountOnScmAccountsTable(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(SCM_ACCOUNTS_TABLE_NAME, INDEX_NAME);

createIndexForScmAccountOnScmAccountsTable.execute();
@@ -43,7 +43,7 @@ public class CreateIndexForScmAccountOnScmAccountsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndexForScmAccountOnScmAccountsTable.execute();
createIndexForScmAccountOnScmAccountsTable.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateIndexOnExternalIdAndIdentityOnExternalGroupsTableIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.sonar.server.platform.db.migration.version.v101.CreateExternalGroupsTable.EXTERNAL_GROUP_ID_COLUMN_NAME;
@@ -29,15 +29,15 @@ import static org.sonar.server.platform.db.migration.version.v101.CreateExternal
import static org.sonar.server.platform.db.migration.version.v101.CreateExternalGroupsTable.TABLE_NAME;
import static org.sonar.server.platform.db.migration.version.v101.CreateIndexOnExternalIdAndIdentityOnExternalGroupsTable.INDEX_NAME;

public class CreateIndexOnExternalIdAndIdentityOnExternalGroupsTableIT {
class CreateIndexOnExternalIdAndIdentityOnExternalGroupsTableIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexOnExternalIdAndIdentityOnExternalGroupsTable.class);
private final CreateIndexOnExternalIdAndIdentityOnExternalGroupsTable createIndexOnExternalIdAndIdentityOnExternalGroupsTable = new CreateIndexOnExternalIdAndIdentityOnExternalGroupsTable(
db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndexOnExternalIdAndIdentityOnExternalGroupsTable.execute();
@@ -46,7 +46,7 @@ public class CreateIndexOnExternalIdAndIdentityOnExternalGroupsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndexOnExternalIdAndIdentityOnExternalGroupsTable.execute();
createIndexOnExternalIdAndIdentityOnExternalGroupsTable.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateProjectUuidInUserTokensIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;

public class CreateProjectUuidInUserTokensIT {
class CreateProjectUuidInUserTokensIT {
private static final String TABLE_NAME = "user_tokens";
private static final String COLUMN_NAME = "project_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateProjectUuidInUserTokens.class);
private final CreateProjectUuidInUserTokens underTest = new CreateProjectUuidInUserTokens(db.database());

@Test
public void migration_creates_new_column() throws SQLException {
void migration_creates_new_column() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 40, null);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateScmAccountsTableIT.java View File

@@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

@@ -32,14 +32,14 @@ import static org.sonar.server.platform.db.migration.version.v101.CreateScmAccou
import static org.sonar.server.platform.db.migration.version.v101.CreateScmAccountsTable.SCM_ACCOUNT_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.CreateScmAccountsTable.USER_UUID_COLUMN_NAME;

public class CreateScmAccountsTableIT {
@Rule
class CreateScmAccountsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateScmAccountsTable.class);

private final DdlChange createScmAccountsTable = new CreateScmAccountsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(SCM_ACCOUNTS_TABLE_NAME);

createScmAccountsTable.execute();
@@ -51,7 +51,7 @@ public class CreateScmAccountsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(SCM_ACCOUNTS_TABLE_NAME);

createScmAccountsTable.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateUniqueIndexForReportSchedulesTableIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.sonar.server.platform.db.migration.version.v101.AddReportSchedulesTable.TABLE_NAME;
@@ -30,13 +30,13 @@ import static org.sonar.server.platform.db.migration.version.v101.CreateUniqueIn
import static org.sonar.server.platform.db.migration.version.v101.CreateUniqueIndexForReportSchedulesTable.INDEX_NAME;


public class CreateUniqueIndexForReportSchedulesTableIT {
@Rule
class CreateUniqueIndexForReportSchedulesTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueIndexForReportSchedulesTable.class);
private final CreateUniqueIndexForReportSchedulesTable createUniqueIndexForReportSchedulesTable = new CreateUniqueIndexForReportSchedulesTable(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createUniqueIndexForReportSchedulesTable.execute();
@@ -45,7 +45,7 @@ public class CreateUniqueIndexForReportSchedulesTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createUniqueIndexForReportSchedulesTable.execute();
createUniqueIndexForReportSchedulesTable.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/CreateUniqueIndexForReportSubscriptionsTableIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.sonar.server.platform.db.migration.version.v101.AddReportSubscriptionsTable.TABLE_NAME;
@@ -31,13 +31,13 @@ import static org.sonar.server.platform.db.migration.version.v101.CreateUniqueIn
import static org.sonar.server.platform.db.migration.version.v101.CreateUniqueIndexForReportSubscriptionsTable.INDEX_NAME;


public class CreateUniqueIndexForReportSubscriptionsTableIT {
@Rule
class CreateUniqueIndexForReportSubscriptionsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueIndexForReportSubscriptionsTable.class);
private final CreateUniqueIndexForReportSubscriptionsTable createUniqueIndexForReportSubscriptionsTable = new CreateUniqueIndexForReportSubscriptionsTable(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createUniqueIndexForReportSubscriptionsTable.execute();
@@ -46,7 +46,7 @@ public class CreateUniqueIndexForReportSubscriptionsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createUniqueIndexForReportSubscriptionsTable.execute();
createUniqueIndexForReportSubscriptionsTable.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/DropProjectKeyInUserTokensIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.version.v101.DropProjectKeyInUserTokens.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v101.DropProjectKeyInUserTokens.TABLE_NAME;

public class DropProjectKeyInUserTokensIT {
@Rule
class DropProjectKeyInUserTokensIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropProjectKeyInUserTokens.class);
private final DdlChange underTest = new DropProjectKeyInUserTokens(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 255, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 255, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/DropScmAccountsInUsersIT.java View File

@@ -21,29 +21,29 @@ package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.version.v101.DropScmAccountsInUsers.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v101.DropScmAccountsInUsers.TABLE_NAME;

public class DropScmAccountsInUsersIT {
class DropScmAccountsInUsersIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropScmAccountsInUsers.class);
private final DdlChange dropScmAccountsInUsers = new DropScmAccountsInUsers(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
dropScmAccountsInUsers.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
dropScmAccountsInUsers.execute();
dropScmAccountsInUsers.execute();

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/FixDifferentUuidsForSubportfoliosIT.java View File

@@ -25,26 +25,26 @@ import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.assertj.core.api.Assertions;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.resources.Qualifiers;
import org.sonar.db.MigrationDbTester;

import static java.util.stream.Collectors.toSet;

public class FixDifferentUuidsForSubportfoliosIT {
class FixDifferentUuidsForSubportfoliosIT {
private static final String OLD_UUID = "differentSubPfUuid";
private static final String SUB_PF_KEY = "subPfKey";
private static final String NEW_SUBPF_UUID = "subPfUuid";
private static final String PF_UUID = "pfUuid";
private static final String NEW_CHILD_SUBPF_UUID = "childsubpfUuid";
private static final String OLD_CHILD_SUBPF_UUID = "old_child_subpf_uuid";
@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(FixDifferentUuidsForSubportfolios.class);
private final FixDifferentUuidsForSubportfolios underTest = new FixDifferentUuidsForSubportfolios(db.database());

@Test
public void execute_shouldUpdatePortfoliosAndPortfolioProjectsAndPortfolioReferenceTable() throws SQLException {
void execute_shouldUpdatePortfoliosAndPortfolioProjectsAndPortfolioReferenceTable() throws SQLException {
insertPortfolio("pfKey", PF_UUID);
insertComponent(SUB_PF_KEY, NEW_SUBPF_UUID, PF_UUID, Qualifiers.SUBVIEW);
insertSubPortfolio(SUB_PF_KEY, PF_UUID, PF_UUID, OLD_UUID);
@@ -59,7 +59,7 @@ public class FixDifferentUuidsForSubportfoliosIT {
}

@Test
public void execute_shouldBeRentrant() throws SQLException {
void execute_shouldBeRentrant() throws SQLException {
insertPortfolio("pfKey", PF_UUID);
insertComponent(SUB_PF_KEY, NEW_SUBPF_UUID, PF_UUID, Qualifiers.SUBVIEW);
insertSubPortfolio(SUB_PF_KEY, PF_UUID, PF_UUID, OLD_UUID);
@@ -75,7 +75,7 @@ public class FixDifferentUuidsForSubportfoliosIT {
}

@Test
public void execute_shouldFixUuidForSubPortfolioAtDifferentLevels() throws SQLException {
void execute_shouldFixUuidForSubPortfolioAtDifferentLevels() throws SQLException {
insertPortfolio("pfKey", PF_UUID);

insertComponent(SUB_PF_KEY, NEW_SUBPF_UUID, PF_UUID, Qualifiers.SUBVIEW);

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseKeeColumnSizeInInternalPropertiesIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;
@@ -29,21 +29,21 @@ import static org.sonar.server.platform.db.migration.version.v101.IncreaseKeeCol
import static org.sonar.server.platform.db.migration.version.v101.IncreaseKeeColumnSizeInInternalProperties.NEW_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.IncreaseKeeColumnSizeInInternalProperties.TABLE_NAME;

public class IncreaseKeeColumnSizeInInternalPropertiesIT {
class IncreaseKeeColumnSizeInInternalPropertiesIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(IncreaseKeeColumnSizeInInternalProperties.class);
private final IncreaseKeeColumnSizeInInternalProperties underTest = new IncreaseKeeColumnSizeInInternalProperties(db.database());

@Test
public void execute_increaseColumnSize() throws SQLException {
void execute_increaseColumnSize() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 20, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 20, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseTaskTypeColumnSizeInCeActivityIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;
@@ -29,21 +29,21 @@ import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTy
import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTypeColumnSizeInCeActivity.NEW_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTypeColumnSizeInCeActivity.TABLE_NAME;

public class IncreaseTaskTypeColumnSizeInCeActivityIT {
class IncreaseTaskTypeColumnSizeInCeActivityIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(IncreaseTaskTypeColumnSizeInCeActivity.class);
private final IncreaseTaskTypeColumnSizeInCeActivity underTest = new IncreaseTaskTypeColumnSizeInCeActivity(db.database());

@Test
public void execute_increaseColumnSize() throws SQLException {
void execute_increaseColumnSize() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 15, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 15, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/IncreaseTaskTypeColumnSizeInCeQueueIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;
@@ -29,21 +29,21 @@ import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTy
import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTypeColumnSizeInCeQueue.NEW_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v101.IncreaseTaskTypeColumnSizeInCeQueue.TABLE_NAME;

public class IncreaseTaskTypeColumnSizeInCeQueueIT {
class IncreaseTaskTypeColumnSizeInCeQueueIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(IncreaseTaskTypeColumnSizeInCeQueue.class);
private final IncreaseTaskTypeColumnSizeInCeQueue underTest = new IncreaseTaskTypeColumnSizeInCeQueue(db.database());

@Test
public void execute_increaseColumnSize() throws SQLException {
void execute_increaseColumnSize() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 15, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 15, false);
underTest.execute();
underTest.execute();

+ 14
- 14
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/MigrateScmAccountsFromUsersToScmAccountsIT.java View File

@@ -25,8 +25,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -39,19 +39,19 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.sonar.server.platform.db.migration.version.v101.MigrateScmAccountsFromUsersToScmAccounts.SCM_ACCOUNTS_SEPARATOR_CHAR;

public class MigrateScmAccountsFromUsersToScmAccountsIT {
class MigrateScmAccountsFromUsersToScmAccountsIT {

private static final UuidFactory UUID_FACTORY = UuidFactoryFast.getInstance();
private static final String SCM_ACCOUNT1 = "scmaccount";
private static final String SCM_ACCOUNT2 = "scmaccount2";
private static final String SCM_ACCOUNT_CAMELCASE = "scmAccount3";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(MigrateScmAccountsFromUsersToScmAccounts.class);
private final DataChange migrateScmAccountsFromUsersToScmAccounts = new MigrateScmAccountsFromUsersToScmAccounts(db.database());

@Test
public void execute_whenUserHasNullScmAccounts_doNotInsertInScmAccounts() throws SQLException {
void execute_whenUserHasNullScmAccounts_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid(null);

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -61,7 +61,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasEmptyScmAccounts_doNotInsertInScmAccounts() throws SQLException {
void execute_whenUserHasEmptyScmAccounts_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid("");

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -71,7 +71,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasEmptyScmAccountsWithOneSeparator_doNotInsertInScmAccounts() throws SQLException {
void execute_whenUserHasEmptyScmAccountsWithOneSeparator_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid(String.valueOf(SCM_ACCOUNTS_SEPARATOR_CHAR));

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -81,7 +81,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasEmptyScmAccountsWithTwoSeparators_doNotInsertInScmAccounts() throws SQLException {
void execute_whenUserHasEmptyScmAccountsWithTwoSeparators_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid(SCM_ACCOUNTS_SEPARATOR_CHAR + String.valueOf(SCM_ACCOUNTS_SEPARATOR_CHAR));

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -91,7 +91,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasOneScmAccountWithoutSeparator_insertsInScmAccounts() throws SQLException {
void execute_whenUserHasOneScmAccountWithoutSeparator_insertsInScmAccounts() throws SQLException {
String userUuid = insertUserAndGetUuid(SCM_ACCOUNT1);

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -101,7 +101,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasOneScmAccountWithSeparators_insertsInScmAccounts() throws SQLException {
void execute_whenUserHasOneScmAccountWithSeparators_insertsInScmAccounts() throws SQLException {
String userUuid = insertUserAndGetUuid(format("%s%s%s", SCM_ACCOUNTS_SEPARATOR_CHAR, SCM_ACCOUNT1, SCM_ACCOUNTS_SEPARATOR_CHAR));

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -111,7 +111,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasOneScmAccountWithMixedCase_insertsInScmAccountsInLowerCase() throws SQLException {
void execute_whenUserHasOneScmAccountWithMixedCase_insertsInScmAccountsInLowerCase() throws SQLException {
String userUuid = insertUserAndGetUuid(format("%s%s%s", SCM_ACCOUNTS_SEPARATOR_CHAR, SCM_ACCOUNT_CAMELCASE, SCM_ACCOUNTS_SEPARATOR_CHAR));

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -121,7 +121,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void execute_whenUserHasTwoScmAccount_insertsInScmAccounts() throws SQLException {
void execute_whenUserHasTwoScmAccount_insertsInScmAccounts() throws SQLException {
String userUuid = insertUserAndGetUuid(format("%s%s%s%s%s",
SCM_ACCOUNTS_SEPARATOR_CHAR, SCM_ACCOUNT1, SCM_ACCOUNTS_SEPARATOR_CHAR, SCM_ACCOUNT2, SCM_ACCOUNTS_SEPARATOR_CHAR));

@@ -135,7 +135,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String userUuid = insertUserAndGetUuid(SCM_ACCOUNT1);

migrateScmAccountsFromUsersToScmAccounts.execute();
@@ -146,7 +146,7 @@ public class MigrateScmAccountsFromUsersToScmAccountsIT {
}

@Test
public void migration_should_be_reentrant_if_scm_account_column_dropped() {
void migration_should_be_reentrant_if_scm_account_column_dropped() {
db.executeDdl("alter table users drop column scm_accounts");

assertThatNoException().isThrownBy(migrateScmAccountsFromUsersToScmAccounts::execute);

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateProjectUuidInUserTokensIT.java View File

@@ -23,8 +23,8 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -33,16 +33,16 @@ import org.sonar.server.platform.db.migration.step.DataChange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;

public class PopulateProjectUuidInUserTokensIT {
class PopulateProjectUuidInUserTokensIT {
private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateProjectUuidInUserTokens.class);

private final DataChange underTest = new PopulateProjectUuidInUserTokens(db.database());

@Test
public void migration_populates_project_uuid_for_tokens() throws SQLException {
void migration_populates_project_uuid_for_tokens() throws SQLException {
String project1Uuid = insertProject("project1");
String project2Uuid = insertProject("project2");

@@ -62,7 +62,7 @@ public class PopulateProjectUuidInUserTokensIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String project1Uuid = insertProject("project1");
String project2Uuid = insertProject("project2");


+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateReportSchedulesIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -30,15 +30,15 @@ import org.sonar.server.platform.db.migration.step.DataChange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;

public class PopulateReportSchedulesIT {
@Rule
class PopulateReportSchedulesIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateReportSchedules.class);

private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();
private final DataChange underTest = new PopulateReportSchedules(db.database());

@Test
public void execute_shouldPopulateFromPortfolioProperties() throws SQLException {
void execute_shouldPopulateFromPortfolioProperties() throws SQLException {
insertPortfolio("uuid1");
insertPortfolioProperty("uuid1", "1234");

@@ -50,7 +50,7 @@ public class PopulateReportSchedulesIT {
}

@Test
public void execute_shouldPopulateFromBranchProperties() throws SQLException {
void execute_shouldPopulateFromBranchProperties() throws SQLException {
insertBranch("uuid1");
insertProjectBranchProperty("uuid1", "1234");

@@ -62,7 +62,7 @@ public class PopulateReportSchedulesIT {
}

@Test
public void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
insertBranch("uuid1");
insertPortfolio("uuid1");
insertProjectBranchProperty("uuid1", "1234");

+ 7
- 7
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/PopulateReportSubscriptionsIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -30,15 +30,15 @@ import org.sonar.server.platform.db.migration.step.DataChange;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;

public class PopulateReportSubscriptionsIT {
@Rule
class PopulateReportSubscriptionsIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateReportSubscriptions.class);

private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();
private final DataChange underTest = new PopulateReportSubscriptions(db.database());

@Test
public void execute_shouldPopulateFromPortfolioProperties() throws SQLException {
void execute_shouldPopulateFromPortfolioProperties() throws SQLException {
insertPortfolio("uuid1");
insertPortfolioProperty("uuid1", "1234");

@@ -50,7 +50,7 @@ public class PopulateReportSubscriptionsIT {
}

@Test
public void execute_shouldPopulateFromBranchProperties() throws SQLException {
void execute_shouldPopulateFromBranchProperties() throws SQLException {
insertBranch("uuid1");
insertBranchProperty("uuid1", "1234");

@@ -62,7 +62,7 @@ public class PopulateReportSubscriptionsIT {
}

@Test
public void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
insertBranch("uuid1");
insertPortfolio("uuid1");
insertBranchProperty("uuid1", "1234");

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RemoveOrphanUserTokensIT.java View File

@@ -23,8 +23,8 @@ import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -32,16 +32,16 @@ import org.sonar.server.platform.db.migration.step.DataChange;

import static org.assertj.core.api.Assertions.assertThat;

public class RemoveOrphanUserTokensIT {
class RemoveOrphanUserTokensIT {
private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RemoveOrphanUserTokens.class);

private final DataChange underTest = new RemoveOrphanUserTokens(db.database());

@Test
public void migration_deletes_orphan_tokens() throws SQLException {
void migration_deletes_orphan_tokens() throws SQLException {
String project1Uuid = insertProject("project1");

String token1Uuid = insertUserToken("project1");
@@ -55,7 +55,7 @@ public class RemoveOrphanUserTokensIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String project1Uuid = insertProject("project1");

String token1Uuid = insertUserToken("project1");

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RemoveReportPropertiesIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -29,13 +29,13 @@ import org.sonar.server.platform.db.migration.step.DataChange;

import static org.assertj.core.api.Assertions.assertThat;

public class RemoveReportPropertiesIT {
class RemoveReportPropertiesIT {

private static final String SONAR_GOVERNANCE_REPORT_USER_NOTIFICATION = "sonar.governance.report.userNotification";
private static final String SONAR_GOVERNANCE_REPORT_PROJECT_BRANCH_USER_NOTIFICATION = "sonar.governance.report.project.branch.userNotification";
private static final String SONAR_GOVERNANCE_REPORT_LAST_SEND_TIME_IN_MS = "sonar.governance.report.lastSendTimeInMs";
private static final String SONAR_GOVERNANCE_REPORT_PROJECT_BRANCH_LAST_SEND_TIME_IN_MS = "sonar.governance.report.project.branch.lastSendTimeInMs";
@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RemoveReportProperties.class);

private final DataChange underTest = new RemoveReportProperties(db.database());
@@ -43,7 +43,7 @@ public class RemoveReportPropertiesIT {
private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Test
public void execute_shouldRemoveRelevantPropertiesFromTable() throws SQLException {
void execute_shouldRemoveRelevantPropertiesFromTable() throws SQLException {
insertProperty( "branch_uuid", "user_uuid", SONAR_GOVERNANCE_REPORT_USER_NOTIFICATION, "true");
insertProperty( "portfolio_uuid", "user_uuid", SONAR_GOVERNANCE_REPORT_PROJECT_BRANCH_USER_NOTIFICATION, "true");
insertProperty( "branch_uuid", "user_uuid", SONAR_GOVERNANCE_REPORT_LAST_SEND_TIME_IN_MS, "12");
@@ -57,7 +57,7 @@ public class RemoveReportPropertiesIT {
}

@Test
public void execute_shouldBeIdempotent() throws SQLException {
void execute_shouldBeIdempotent() throws SQLException {
insertProperty( "branch_uuid", "user_uuid", SONAR_GOVERNANCE_REPORT_USER_NOTIFICATION, "true");
insertProperty( "portfolio_uuid", "user_uuid", SONAR_GOVERNANCE_REPORT_PROJECT_BRANCH_USER_NOTIFICATION, "true");


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/RenameColumnComponentUuidInPropertiesIT.java View File

@@ -20,30 +20,30 @@
package org.sonar.server.platform.db.migration.version.v101;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;

public class RenameColumnComponentUuidInPropertiesIT {
class RenameColumnComponentUuidInPropertiesIT {

public static final String TABLE_NAME = "properties";
public static final String NEW_COLUMN_NAME = "entity_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameColumnComponentUuidInProperties.class);
private final RenameColumnComponentUuidInProperties underTest = new RenameColumnComponentUuidInProperties(db.database());

@Test
public void columnIsRenamed() throws SQLException {
void columnIsRenamed() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, NEW_COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, NEW_COLUMN_NAME, VARCHAR, 40, true);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, NEW_COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v101/UpdateIsMainColumnInProjectBranchesIT.java View File

@@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration.version.v101;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.core.util.UuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -31,11 +31,11 @@ import org.sonar.server.platform.db.migration.step.DataChange;

import static org.assertj.core.api.Assertions.assertThat;

public class UpdateIsMainColumnInProjectBranchesIT {
class UpdateIsMainColumnInProjectBranchesIT {

private final UuidFactory uuidFactory = UuidFactoryFast.getInstance();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(UpdateIsMainColumnInProjectBranches.class);

private final DataChange underTest = new UpdateIsMainColumnInProjectBranches(db.database());
@@ -43,7 +43,7 @@ public class UpdateIsMainColumnInProjectBranchesIT {
private static int not_random_value_always_incremented = 0;

@Test
public void migration_updates_is_main_if_row_has_the_same_uuids() throws SQLException {
void migration_updates_is_main_if_row_has_the_same_uuids() throws SQLException {
String branchUuid1 = insertProjectBranch(true);
String branchUuid2 = insertProjectBranch(false);

@@ -54,7 +54,7 @@ public class UpdateIsMainColumnInProjectBranchesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
String branchUuid1 = insertProjectBranch(true);
String branchUuid2 = insertProjectBranch(false);


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/AddCleanCodeAttributeInRulesIT.java View File

@@ -21,28 +21,28 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

public class AddCleanCodeAttributeInRulesIT {
class AddCleanCodeAttributeInRulesIT {
private static final String TABLE_NAME = "rules";
private static final String COLUMN_NAME = "clean_code_attribute";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddCleanCodeAttributeInRules.class);

private final AddCleanCodeAttributeInRules underTest = new AddCleanCodeAttributeInRules(db.database());

@Test
public void execute_whenColumnDoesNotExist_shouldCreateColumn() throws SQLException {
void execute_whenColumnDoesNotExist_shouldCreateColumn() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, true);
}

@Test
public void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 13
- 13
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT.java View File

@@ -20,11 +20,11 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.event.Level;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.testfixtures.log.LogTesterJUnit5;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
@@ -34,22 +34,22 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.server.platform.db.migration.version.v102.AddUserConsentRequiredIfGithubAutoProvisioningEnabled.PROP_KEY;
import static org.sonar.server.platform.db.migration.version.v102.AddUserConsentRequiredIfGithubAutoProvisioningEnabled.PROVISIONING_GITHUB_ENABLED_PROP_KEY;

public class AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT {
class AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT {

@Rule
public LogTester logger = new LogTester();
@RegisterExtension
public final LogTesterJUnit5 logger = new LogTesterJUnit5();

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddUserConsentRequiredIfGithubAutoProvisioningEnabled.class);
private final DataChange underTest = new AddUserConsentRequiredIfGithubAutoProvisioningEnabled(db.database(), new System2(), UuidFactoryFast.getInstance());

@Before
@BeforeEach
public void before() {
logger.clear();
}

@Test
public void migration_whenGitHubAutoProvisioningPropertyNotPresent_shouldNotRequireConsent() throws SQLException {
void migration_whenGitHubAutoProvisioningPropertyNotPresent_shouldNotRequireConsent() throws SQLException {
underTest.execute();

assertThat(logger.logs(Level.WARN)).isEmpty();
@@ -57,7 +57,7 @@ public class AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT {
}

@Test
public void migration_whenGitHubAutoProvisioningDisabled_shouldNotRequireConsent() throws SQLException {
void migration_whenGitHubAutoProvisioningDisabled_shouldNotRequireConsent() throws SQLException {
disableGithubProvisioning();
underTest.execute();

@@ -66,7 +66,7 @@ public class AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT {
}

@Test
public void migration_whenGitHubAutoProvisioningEnabled_shouldRequireConsent() throws SQLException {
void migration_whenGitHubAutoProvisioningEnabled_shouldRequireConsent() throws SQLException {
enableGithubProvisioning();

underTest.execute();
@@ -77,7 +77,7 @@ public class AddUserConsentRequiredIfGithubAutoProvisioningEnabledIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
enableGithubProvisioning();

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateAnticipatedTransitionsTableIT.java View File

@@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

@@ -31,14 +31,14 @@ import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.USER_U
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
import static org.sonar.server.platform.db.migration.version.v102.CreateAnticipatedTransitionsTable.ANTICIPATED_TRANSITIONS_TABLE_NAME;

public class CreateAnticipatedTransitionsTableIT {
@Rule
class CreateAnticipatedTransitionsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateAnticipatedTransitionsTable.class);

private final DdlChange createAnticipatedTransitionsTable = new CreateAnticipatedTransitionsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(ANTICIPATED_TRANSITIONS_TABLE_NAME);

createAnticipatedTransitionsTable.execute();
@@ -58,7 +58,7 @@ public class CreateAnticipatedTransitionsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(ANTICIPATED_TRANSITIONS_TABLE_NAME);

createAnticipatedTransitionsTable.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateBooleanPurgedColumnInSnapshotsIT.java View File

@@ -20,31 +20,31 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.BOOLEAN;

public class CreateBooleanPurgedColumnInSnapshotsIT {
class CreateBooleanPurgedColumnInSnapshotsIT {

private static final String TABLE_NAME = "snapshots";
private static final String COLUMN_NAME = "purged";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateBooleanPurgedColumnInSnapshots.class);

private final CreateBooleanPurgedColumnInSnapshots underTest = new CreateBooleanPurgedColumnInSnapshots(db.database());

@Test
public void execute_whenColumnDoesNotExist_shouldCreatePurgedColumn() throws SQLException {
void execute_whenColumnDoesNotExist_shouldCreatePurgedColumn() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, null);
}

@Test
public void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateGithubOrganizationsGroupsTableIT.java View File

@@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

@@ -31,13 +31,13 @@ import static org.sonar.server.platform.db.migration.version.v102.CreateGithubOr
import static org.sonar.server.platform.db.migration.version.v102.CreateGithubOrganizationsGroupsTable.ORGANIZATION_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v102.CreateGithubOrganizationsGroupsTable.TABLE_NAME;

public class CreateGithubOrganizationsGroupsTableIT {
@Rule
class CreateGithubOrganizationsGroupsTableIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateGithubOrganizationsGroupsTable.class);
private final DdlChange createGithubOrganizationsGroupsTable = new CreateGithubOrganizationsGroupsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

createGithubOrganizationsGroupsTable.execute();
@@ -49,7 +49,7 @@ public class CreateGithubOrganizationsGroupsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);

createGithubOrganizationsGroupsTable.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexCreatedAtInWebhookDeliveriesIT.java View File

@@ -20,22 +20,22 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class CreateIndexCreatedAtInWebhookDeliveriesIT {
class CreateIndexCreatedAtInWebhookDeliveriesIT {

public static final String TABLE_NAME = "webhook_deliveries";
public static final String INDEX_NAME = "wd_created_at";
public static final String EXPECTED_COLUMN = "created_at";
@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexCreatedAtInWebhookDeliveries.class);
private final DdlChange createIndex = new CreateIndexCreatedAtInWebhookDeliveries(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndex.execute();
@@ -44,7 +44,7 @@ public class CreateIndexCreatedAtInWebhookDeliveriesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInCeActivityIT.java View File

@@ -20,17 +20,17 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

public class CreateIndexEntityUuidInCeActivityIT {
@Rule
class CreateIndexEntityUuidInCeActivityIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexEntityUuidInCeActivity.class);
private final CreateIndexEntityUuidInCeActivity createIndex = new CreateIndexEntityUuidInCeActivity(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("ce_activity", "ce_activity_entity_uuid");

createIndex.execute();
@@ -39,7 +39,7 @@ public class CreateIndexEntityUuidInCeActivityIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInCeQueueIT.java View File

@@ -20,17 +20,17 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

public class CreateIndexEntityUuidInCeQueueIT {
@Rule
class CreateIndexEntityUuidInCeQueueIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexEntityUuidInCeQueue.class);
private final CreateIndexEntityUuidInCeQueue createIndex = new CreateIndexEntityUuidInCeQueue(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("ce_queue", "ce_queue_entity_uuid");

createIndex.execute();
@@ -39,7 +39,7 @@ public class CreateIndexEntityUuidInCeQueueIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInGroupRolesIT.java View File

@@ -20,17 +20,17 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

public class CreateIndexEntityUuidInGroupRolesIT {
@Rule
class CreateIndexEntityUuidInGroupRolesIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexEntityUuidInGroupRoles.class);
private final CreateIndexEntityUuidInGroupRoles createIndex = new CreateIndexEntityUuidInGroupRoles(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("group_roles", "group_roles_entity_uuid");

createIndex.execute();
@@ -39,7 +39,7 @@ public class CreateIndexEntityUuidInGroupRolesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexEntityUuidInUserRolesIT.java View File

@@ -20,17 +20,17 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

public class CreateIndexEntityUuidInUserRolesIT {
@Rule
class CreateIndexEntityUuidInUserRolesIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexEntityUuidInUserRoles.class);
private final CreateIndexEntityUuidInUserRoles createIndex = new CreateIndexEntityUuidInUserRoles(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("user_roles", "user_roles_entity_uuid");

createIndex.execute();
@@ -39,7 +39,7 @@ public class CreateIndexEntityUuidInUserRolesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidCreatedAtInWebhookDeliveriesIT.java View File

@@ -20,22 +20,22 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class CreateIndexProjectUuidCreatedAtInWebhookDeliveriesIT {
class CreateIndexProjectUuidCreatedAtInWebhookDeliveriesIT {

public static final String TABLE_NAME = "webhook_deliveries";
public static final String INDEX_NAME = "wd_project_uuid_created_at";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexProjectUuidCreatedAtInWebhookDeliveries.class);
private final DdlChange createIndex = new CreateIndexProjectUuidCreatedAtInWebhookDeliveries(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndex.execute();
@@ -44,7 +44,7 @@ public class CreateIndexProjectUuidCreatedAtInWebhookDeliveriesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInProjectBranchesIT.java View File

@@ -20,19 +20,19 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class CreateIndexProjectUuidInProjectBranchesIT {
@Rule
class CreateIndexProjectUuidInProjectBranchesIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexProjectUuidInProjectBranches.class);
private final CreateIndexProjectUuidInProjectBranches createIndex = new CreateIndexProjectUuidInProjectBranches(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("project_branches", "project_branches_project_uuid");

createIndex.execute();
@@ -41,7 +41,7 @@ public class CreateIndexProjectUuidInProjectBranchesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexRootComponentUuidInSnapshotsIT.java View File

@@ -20,19 +20,19 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class CreateIndexRootComponentUuidInSnapshotsIT {
@Rule
class CreateIndexRootComponentUuidInSnapshotsIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexRootComponentUuidInSnapshots.class);
private final CreateIndexRootComponentUuidInSnapshots createIndex = new CreateIndexRootComponentUuidInSnapshots(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("snapshots", "snapshots_root_component_uuid");

createIndex.execute();
@@ -41,7 +41,7 @@ public class CreateIndexRootComponentUuidInSnapshotsIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexTaskUuidCreatedAtInWebhookDeliveriesIT.java View File

@@ -20,22 +20,22 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class CreateIndexTaskUuidCreatedAtInWebhookDeliveriesIT {
class CreateIndexTaskUuidCreatedAtInWebhookDeliveriesIT {

public static final String TABLE_NAME = "webhook_deliveries";
public static final String INDEX_NAME = "wd_ce_task_uuid_created_at";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexTaskUuidCreatedAtInWebhookDeliveries.class);
private final DdlChange createIndex = new CreateIndexTaskUuidCreatedAtInWebhookDeliveries(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndex.execute();
@@ -44,7 +44,7 @@ public class CreateIndexTaskUuidCreatedAtInWebhookDeliveriesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesIT.java View File

@@ -20,22 +20,22 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesIT {
class CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesIT {

public static final String TABLE_NAME = "webhook_deliveries";
public static final String INDEX_NAME = "wd_webhook_uuid_created_at";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexWebhookUuidCreatedAtInWebhookDeliveries.class);
private final DdlChange createIndex = new CreateIndexWebhookUuidCreatedAtInWebhookDeliveries(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);

createIndex.execute();
@@ -44,7 +44,7 @@ public class CreateIndexWebhookUuidCreatedAtInWebhookDeliveriesIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateIssueImpactsTableIT.java View File

@@ -21,21 +21,21 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class CreateIssueImpactsTableIT {
class CreateIssueImpactsTableIT {
private static final String EXPECTED_TABLE_NAME = "issues_impacts";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIssueImpactsTable.class);

private final DdlChange underTest = new CreateIssueImpactsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);

underTest.execute();
@@ -48,7 +48,7 @@ public class CreateIssueImpactsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreatePreviousNonCompliantValueInNewCodePeriodsIT.java View File

@@ -20,31 +20,31 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;

public class CreatePreviousNonCompliantValueInNewCodePeriodsIT {
class CreatePreviousNonCompliantValueInNewCodePeriodsIT {

private static final String COLUMN_NAME= "previous_non_compliant_value";

private static final String TABLE_NAME = "new_code_periods";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePreviousNonCompliantValueInNewCodePeriods.class);
private final CreatePreviousNonCompliantValueInNewCodePeriods underTest = new CreatePreviousNonCompliantValueInNewCodePeriods(db.database());

@Test
public void execute_whenColumnDoesNotExist_shouldCreatePurgedColumn() throws SQLException {
void execute_whenColumnDoesNotExist_shouldCreatePurgedColumn() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 255, null);
}

@Test
public void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateRulesDefaultImpactsTableIT.java View File

@@ -21,22 +21,22 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;


public class CreateRulesDefaultImpactsTableIT {
class CreateRulesDefaultImpactsTableIT {
private static final String EXPECTED_TABLE_NAME = "rules_default_impacts";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateRulesDefaultImpactsTable.class);

private final DdlChange underTest = new CreateRulesDefaultImpactsTable(db.database());

@Test
public void migration_should_create_a_table() throws SQLException {
void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);

underTest.execute();
@@ -49,7 +49,7 @@ public class CreateRulesDefaultImpactsTableIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateUniqueConstraintOnIssuesImpactsIT.java View File

@@ -20,19 +20,19 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class CreateUniqueConstraintOnIssuesImpactsIT {
@Rule
class CreateUniqueConstraintOnIssuesImpactsIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueConstraintOnIssuesImpacts.class);
private final CreateUniqueConstraintOnIssuesImpacts underTest = new CreateUniqueConstraintOnIssuesImpacts(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("issues_impacts", "uniq_iss_key_sof_qual");

underTest.execute();
@@ -41,7 +41,7 @@ public class CreateUniqueConstraintOnIssuesImpactsIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
underTest.execute();
underTest.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/CreateUniqueConstraintOnRulesDefaultImpactsIT.java View File

@@ -20,20 +20,20 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;




public class CreateUniqueConstraintOnRulesDefaultImpactsIT {
@Rule
class CreateUniqueConstraintOnRulesDefaultImpactsIT {
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueConstraintOnRulesDefaultImpacts.class);
private final CreateUniqueConstraintOnRulesDefaultImpacts underTest = new CreateUniqueConstraintOnRulesDefaultImpacts(db.database());

@Test
public void migration_should_create_index() throws SQLException {
void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist("rules_default_impacts", "uniq_rul_uuid_sof_qual");

underTest.execute();
@@ -42,7 +42,7 @@ public class CreateUniqueConstraintOnRulesDefaultImpactsIT {
}

@Test
public void migration_should_be_reentrant() throws SQLException {
void migration_should_be_reentrant() throws SQLException {
underTest.execute();
underTest.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInGroupRolesIT.java View File

@@ -20,14 +20,14 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.db.MigrationDbTester;



public class DropIndexComponentUuidInGroupRolesIT {
class DropIndexComponentUuidInGroupRolesIT {

private static final String TABLE_NAME = "group_roles";
private static final String COLUMN_NAME = "component_uuid";
@@ -37,12 +37,12 @@ public class DropIndexComponentUuidInGroupRolesIT {
* {@link MigrationDbTester} is not used because we are expecting index with component_uuid to exist. However, renaming the column component_uuid to entity_uuid
* also updated the index
*/
@Rule
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexComponentUuidInGroupRolesIT.class, "schema.sql");
private final DropIndexComponentUuidInGroupRoles underTest = new DropIndexComponentUuidInGroupRoles(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -51,7 +51,7 @@ public class DropIndexComponentUuidInGroupRolesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInSnapshotsIT.java View File

@@ -20,24 +20,24 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropIndexComponentUuidInSnapshotsIT {
class DropIndexComponentUuidInSnapshotsIT {

private static final String TABLE_NAME = "snapshots";
private static final String COLUMN_NAME = "component_uuid";
private static final String INDEX_NAME = "snapshot_component";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexComponentUuidInSnapshots.class);
private final DropIndexComponentUuidInSnapshots underTest = new DropIndexComponentUuidInSnapshots(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -46,7 +46,7 @@ public class DropIndexComponentUuidInSnapshotsIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInUserRolesIT.java View File

@@ -20,14 +20,14 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.db.MigrationDbTester;



public class DropIndexComponentUuidInUserRolesIT {
class DropIndexComponentUuidInUserRolesIT {

private static final String TABLE_NAME = "user_roles";
private static final String COLUMN_NAME = "component_uuid";
@@ -37,12 +37,12 @@ public class DropIndexComponentUuidInUserRolesIT {
* {@link MigrationDbTester} is not used because we are expecting index with component_uuid to exist. However, renaming the column component_uuid to entity_uuid
* also updated the index
*/
@Rule
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexComponentUuidInUserRolesIT.class, "schema.sql");
private final DropIndexComponentUuidInUserRoles underTest = new DropIndexComponentUuidInUserRoles(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -51,7 +51,7 @@ public class DropIndexComponentUuidInUserRolesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexComponentUuidInWebhookDeliveriesIT.java View File

@@ -20,24 +20,24 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropIndexComponentUuidInWebhookDeliveriesIT {
class DropIndexComponentUuidInWebhookDeliveriesIT {

private static final String TABLE_NAME = "webhook_deliveries";
private static final String COLUMN_NAME = "component_uuid";
private static final String INDEX_NAME = "component_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexComponentUuidInWebhookDeliveries.class);
private final DropIndexComponentUuidInWebhookDeliveries underTest = new DropIndexComponentUuidInWebhookDeliveries(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -46,7 +46,7 @@ public class DropIndexComponentUuidInWebhookDeliveriesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexMainComponentUuidInCeActivityIT.java View File

@@ -20,24 +20,24 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropIndexMainComponentUuidInCeActivityIT {
class DropIndexMainComponentUuidInCeActivityIT {

private static final String TABLE_NAME = "ce_activity";
private static final String COLUMN_NAME = "main_component_uuid";
private static final String INDEX_NAME = "ce_activity_main_component";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexMainComponentUuidInCeActivity.class);
private final DropIndexMainComponentUuidInCeActivity underTest = new DropIndexMainComponentUuidInCeActivity(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -46,7 +46,7 @@ public class DropIndexMainComponentUuidInCeActivityIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexMainComponentUuidInCeQueueIT.java View File

@@ -20,24 +20,24 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropIndexMainComponentUuidInCeQueueIT {
class DropIndexMainComponentUuidInCeQueueIT {

private static final String TABLE_NAME = "ce_queue";
private static final String COLUMN_NAME = "main_component_uuid";
private static final String INDEX_NAME = "ce_queue_main_component";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexMainComponentUuidInCeQueue.class);
private final DropIndexMainComponentUuidInCeQueue underTest = new DropIndexMainComponentUuidInCeQueue(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -46,7 +46,7 @@ public class DropIndexMainComponentUuidInCeQueueIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexOnMainBranchProjectUuidIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexOnMainBranchProjectUuidIT {
class DropIndexOnMainBranchProjectUuidIT {
private static final String TABLE_NAME = "components";
private static final String COLUMN_NAME = "main_branch_project_uuid";
private static final String INDEX_NAME = "idx_main_branch_prj_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexOnMainBranchProjectUuid.class);
private final DdlChange underTest = new DropIndexOnMainBranchProjectUuid(db.database());

@Test
public void drops_index() throws SQLException {
void drops_index() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexProjectUuidInWebhookDeliveriesIT.java View File

@@ -20,13 +20,13 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.CoreDbTester;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexProjectUuidInWebhookDeliveriesIT {
class DropIndexProjectUuidInWebhookDeliveriesIT {

private static final String TABLE_NAME = "webhook_deliveries";
private static final String COLUMN_NAME = "project_uuid";
@@ -36,12 +36,12 @@ public class DropIndexProjectUuidInWebhookDeliveriesIT {
* {@link MigrationDbTester} is not used because we are expecting index with component_uuid to exist. However, renaming the column component_uuid to entity_uuid
* also updated the index
*/
@Rule
@RegisterExtension
public final CoreDbTester db = CoreDbTester.createForSchema(DropIndexProjectUuidInWebhookDeliveriesIT.class, "schema.sql");
private final DdlChange underTest = new DropIndexProjectUuidInWebhookDeliveries(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -50,7 +50,7 @@ public class DropIndexProjectUuidInWebhookDeliveriesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexTaskUuidInWebhookDeliveriesIT.java View File

@@ -20,23 +20,23 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexTaskUuidInWebhookDeliveriesIT {
class DropIndexTaskUuidInWebhookDeliveriesIT {

private static final String TABLE_NAME = "webhook_deliveries";
private static final String COLUMN_NAME = "ce_task_uuid";
private static final String INDEX_NAME = "ce_task_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexTaskUuidInWebhookDeliveries.class);
private final DdlChange underTest = new DropIndexTaskUuidInWebhookDeliveries(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -45,7 +45,7 @@ public class DropIndexTaskUuidInWebhookDeliveriesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropIndexWebhookUuidInWebhookDeliveriesIT.java View File

@@ -20,23 +20,23 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

public class DropIndexWebhookUuidInWebhookDeliveriesIT {
class DropIndexWebhookUuidInWebhookDeliveriesIT {

private static final String TABLE_NAME = "webhook_deliveries";
private static final String COLUMN_NAME = "webhook_uuid";
private static final String INDEX_NAME = "idx_wbhk_dlvrs_wbhk_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropIndexWebhookUuidInWebhookDeliveries.class);
private final DdlChange underTest = new DropIndexWebhookUuidInWebhookDeliveries(db.database());

@Test
public void index_is_dropped() throws SQLException {
void index_is_dropped() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();
@@ -45,7 +45,7 @@ public class DropIndexWebhookUuidInWebhookDeliveriesIT {
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);

underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropMainBranchProjectUuidInComponentsIT.java View File

@@ -21,29 +21,29 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DdlChange;

import static org.sonar.server.platform.db.migration.version.v102.DropMainBranchProjectUuidInComponents.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v102.DropMainBranchProjectUuidInComponents.TABLE_NAME;

public class DropMainBranchProjectUuidInComponentsIT {
class DropMainBranchProjectUuidInComponentsIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropMainBranchProjectUuidInComponents.class);
private final DdlChange underTest = new DropMainBranchProjectUuidInComponents(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropPurgeStatusColumnInSnapshotsIT.java View File

@@ -21,30 +21,30 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import java.sql.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropPurgeStatusColumnInSnapshotsIT {
class DropPurgeStatusColumnInSnapshotsIT {

private static final String TABLE_NAME = "snapshots";
private static final String COLUMN_NAME = "purge_status";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropPurgeStatusColumnInSnapshots.class);
private final DropPurgeStatusColumnInSnapshots underTest = new DropPurgeStatusColumnInSnapshots(db.database());

@Test
public void drops_column() throws SQLException {
void drops_column() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.INTEGER, null, null);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.INTEGER, null, null);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/DropTableProjectMappingsIT.java View File

@@ -20,28 +20,28 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;



public class DropTableProjectMappingsIT {
class DropTableProjectMappingsIT {
public static final String TABLE_NAME = "project_mappings";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropTableProjectMappings.class);
private final DropTableProjectMappings underTest = new DropTableProjectMappings(db.database());

@Test
public void execute_shouldDropTable() throws SQLException {
void execute_shouldDropTable() throws SQLException {
db.assertTableExists(TABLE_NAME);
underTest.execute();
db.assertTableDoesNotExist(TABLE_NAME);
}

@Test
public void execute_shouldSupportReentrantMigrationExecution() throws SQLException {
void execute_shouldSupportReentrantMigrationExecution() throws SQLException {
db.assertTableExists(TABLE_NAME);
underTest.execute();
underTest.execute();

+ 8
- 8
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/FixSqaleIndexMetricDescriptionIT.java View File

@@ -20,22 +20,22 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.assertj.core.api.Assertions.assertThat;

public class FixSqaleIndexMetricDescriptionIT {
class FixSqaleIndexMetricDescriptionIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(FixSqaleIndexMetricDescription.class);
private final FixSqaleIndexMetricDescription underTest = new FixSqaleIndexMetricDescription(db.database());
private final String OLD_DESCRIPTION = "Total effort (in hours) to fix all the issues on the component and therefore to comply to all the requirements.";
private final String NEW_DESCRIPTION = "Total effort (in minutes) to fix all the issues on the component and therefore to comply to all the requirements.";

@Before
@BeforeEach
public void setUp() {
db.executeInsert("metrics",
"uuid", "uuid",
@@ -44,14 +44,14 @@ public class FixSqaleIndexMetricDescriptionIT {
}

@Test
public void execute_whenExecuted_shouldUpdateSqaleIndexDescription() throws SQLException {
void execute_whenExecuted_shouldUpdateSqaleIndexDescription() throws SQLException {
assertThat(select()).isEqualTo(OLD_DESCRIPTION);
underTest.execute();
assertThat(select()).isEqualTo(NEW_DESCRIPTION);
}

@Test
public void execute_WhenExecutedTwice_shouldBeReentrant() throws SQLException {
void execute_WhenExecutedTwice_shouldBeReentrant() throws SQLException {
assertThat(select()).isEqualTo(OLD_DESCRIPTION);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/IncreaseIsLastKeyInCeActivityIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;
@@ -29,21 +29,21 @@ import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLast
import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLastKeyInCeActivity.NEW_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v102.IncreaseIsLastKeyInCeActivity.TABLE_NAME;

public class IncreaseIsLastKeyInCeActivityIT {
class IncreaseIsLastKeyInCeActivityIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(IncreaseIsLastKeyInCeActivity.class);
private final IncreaseIsLastKeyInCeActivity underTest = new IncreaseIsLastKeyInCeActivity(db.database());

@Test
public void execute_increaseColumnSize() throws SQLException {
void execute_increaseColumnSize() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/IncreaseMainIsLastKeyInCeActivityIT.java View File

@@ -20,8 +20,8 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;
@@ -29,21 +29,21 @@ import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIs
import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIsLastKeyInCeActivity.NEW_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v102.IncreaseMainIsLastKeyInCeActivity.TABLE_NAME;

public class IncreaseMainIsLastKeyInCeActivityIT {
class IncreaseMainIsLastKeyInCeActivityIT {

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(IncreaseMainIsLastKeyInCeActivity.class);
private final IncreaseMainIsLastKeyInCeActivity underTest = new IncreaseMainIsLastKeyInCeActivity(db.database());

@Test
public void execute_increaseColumnSize() throws SQLException {
void execute_increaseColumnSize() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, NEW_COLUMN_SIZE, false);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 55, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/MakeProjectUuidNullableInUserDismissedMessagesIT.java View File

@@ -20,30 +20,30 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.VARCHAR;

public class MakeProjectUuidNullableInUserDismissedMessagesIT {
class MakeProjectUuidNullableInUserDismissedMessagesIT {

private static final String TABLE_NAME = "user_dismissed_messages";
private static final String COLUMN_NAME = "project_uuid";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(MakeProjectUuidNullableInUserDismissedMessages.class);
private final MakeProjectUuidNullableInUserDismissedMessages underTest = new MakeProjectUuidNullableInUserDismissedMessages(db.database());

@Test
public void execute_shouldBeNullable() throws SQLException {
void execute_shouldBeNullable() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 40, false);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 40, true);
}

@Test
public void migration_is_reentrant() throws SQLException {
void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, VARCHAR, 40, false);
underTest.execute();
underTest.execute();

+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/MakePurgedColumnNotNullableInSnapshotsIT.java View File

@@ -20,29 +20,29 @@
package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static java.sql.Types.BOOLEAN;

public class MakePurgedColumnNotNullableInSnapshotsIT {
class MakePurgedColumnNotNullableInSnapshotsIT {
private static final String TABLE_NAME = "snapshots";
private static final String COLUMN_NAME = "purged";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(MakePurgedColumnNotNullableInSnapshots.class);
private final MakePurgedColumnNotNullableInSnapshots underTest = new MakePurgedColumnNotNullableInSnapshots(db.database());

@Test
public void execute_whenColumnIsNullable_shouldMakeColumnNullable() throws SQLException {
void execute_whenColumnIsNullable_shouldMakeColumnNullable() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, false);
}

@Test
public void execute_whenExecutedTwice_shouldMakeColumnNullable() throws SQLException {
void execute_whenExecutedTwice_shouldMakeColumnNullable() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, BOOLEAN, null, true);
underTest.execute();
underTest.execute();

+ 10
- 10
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateCleanCodeAttributeColumnInRulesIT.java View File

@@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.rules.CleanCodeAttribute;
import org.sonar.api.rules.RuleType;
import org.sonar.db.MigrationDbTester;
@@ -30,21 +30,21 @@ import org.sonar.db.MigrationDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;

public class PopulateCleanCodeAttributeColumnInRulesIT {
class PopulateCleanCodeAttributeColumnInRulesIT {

private static final String TABLE_NAME = "rules";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateCleanCodeAttributeColumnInRules.class);
private final PopulateCleanCodeAttributeColumnInRules underTest = new PopulateCleanCodeAttributeColumnInRules(db.database());

@Test
public void execute_whenRulesDoNotExist_shouldNotFail() {
void execute_whenRulesDoNotExist_shouldNotFail() {
assertThatCode(underTest::execute).doesNotThrowAnyException();
}

@Test
public void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldUpdate() throws SQLException {
void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldUpdate() throws SQLException {
insertRule("1", null);
underTest.execute();
assertThat(db.select("select uuid, clean_code_attribute from rules"))
@@ -53,7 +53,7 @@ public class PopulateCleanCodeAttributeColumnInRulesIT {
}

@Test
public void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldBeReentrant() throws SQLException {
void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldBeReentrant() throws SQLException {
insertRule("1", null);
underTest.execute();
underTest.execute();
@@ -63,7 +63,7 @@ public class PopulateCleanCodeAttributeColumnInRulesIT {
}

@Test
public void execute_whenRuleWithDefinedCleanCodeAttribute_shouldNotUpdate() throws SQLException {
void execute_whenRuleWithDefinedCleanCodeAttribute_shouldNotUpdate() throws SQLException {
insertRule("1", CleanCodeAttribute.FOCUSED);
underTest.execute();
assertThat(db.select("select uuid, clean_code_attribute from rules"))
@@ -72,7 +72,7 @@ public class PopulateCleanCodeAttributeColumnInRulesIT {
}

@Test
public void execute_whenRuleIsHotspot_shouldNotUpdate() throws SQLException {
void execute_whenRuleIsHotspot_shouldNotUpdate() throws SQLException {
insertRule("1", RuleType.SECURITY_HOTSPOT, null, null);
underTest.execute();
assertThat(db.select("select uuid, clean_code_attribute from rules"))
@@ -81,7 +81,7 @@ public class PopulateCleanCodeAttributeColumnInRulesIT {
}

@Test
public void execute_whenAdhocRuleIsHotspot_shouldNotUpdate() throws SQLException {
void execute_whenAdhocRuleIsHotspot_shouldNotUpdate() throws SQLException {
insertRule("1", null, RuleType.SECURITY_HOTSPOT, null);
underTest.execute();
assertThat(db.select("select uuid, clean_code_attribute from rules"))

+ 18
- 18
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulateDefaultImpactsInRulesIT.java View File

@@ -21,12 +21,12 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.api.batch.rule.Severity;
import org.sonar.api.issue.impact.SoftwareQuality;
import org.sonar.api.rules.RuleType;
import org.sonar.api.testfixtures.log.LogTester;
import org.sonar.api.testfixtures.log.LogTesterJUnit5;
import org.sonar.core.util.Uuids;
import org.sonar.db.MigrationDbTester;

@@ -34,23 +34,23 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.tuple;

public class PopulateDefaultImpactsInRulesIT {
class PopulateDefaultImpactsInRulesIT {
private static final String TABLE_NAME = "rules";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateDefaultImpactsInRules.class);
@Rule
public LogTester logTester = new LogTester();
@RegisterExtension
public final LogTesterJUnit5 logTester = new LogTesterJUnit5();

private final PopulateDefaultImpactsInRules underTest = new PopulateDefaultImpactsInRules(db.database());

@Test
public void execute_whenRulesDoNotExist_shouldNotFail() {
void execute_whenRulesDoNotExist_shouldNotFail() {
assertThatCode(underTest::execute).doesNotThrowAnyException();
}

@Test
public void execute_whenRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
void execute_whenRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
insertRuleWithType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();

@@ -61,7 +61,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_shouldBeReentrant() throws SQLException {
void execute_shouldBeReentrant() throws SQLException {
insertRuleWithType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();
underTest.execute();
@@ -75,7 +75,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_shouldNotBeExecuted_whenImpactsTableHasAlreadyRecords() throws SQLException {
void execute_shouldNotBeExecuted_whenImpactsTableHasAlreadyRecords() throws SQLException {
insertRuleWithType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
insertRuleWithType("uuid2", RuleType.CODE_SMELL, Severity.MAJOR);
insertImpact("uuid", SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH);
@@ -90,7 +90,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenAdhocRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
void execute_whenAdhocRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
insertRuleWithAdHocType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();

@@ -103,7 +103,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenAdhocRulesHasImpactAlready_shouldNotCreateImpact() throws SQLException {
void execute_whenAdhocRulesHasImpactAlready_shouldNotCreateImpact() throws SQLException {
insertRuleWithAdHocType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
insertImpact("uuid", SoftwareQuality.SECURITY, org.sonar.api.issue.impact.Severity.HIGH);
underTest.execute();
@@ -117,7 +117,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenNoTypeAndSeverityDefined_shouldNotCreateImpact() throws SQLException {
void execute_whenNoTypeAndSeverityDefined_shouldNotCreateImpact() throws SQLException {
insertRuleWithType("uuid", null, null);
underTest.execute();

@@ -127,7 +127,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenInvalidValueDefined_shouldNotCreateImpactAndLog() throws SQLException {
void execute_whenInvalidValueDefined_shouldNotCreateImpactAndLog() throws SQLException {
insertInvalidRule("uuid");
underTest.execute();

@@ -138,7 +138,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenTypeIsHotspot_shouldNotCreateImpactAndLog() throws SQLException {
void execute_whenTypeIsHotspot_shouldNotCreateImpactAndLog() throws SQLException {
insertRuleWithType("uuid", RuleType.SECURITY_HOTSPOT, Severity.MAJOR);
underTest.execute();

@@ -148,7 +148,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenRuleHasEmptyFields_shouldCreateADefaultImpact() throws SQLException {
void execute_whenRuleHasEmptyFields_shouldCreateADefaultImpact() throws SQLException {
insertPlaceholderAdhocRule("uuid");
underTest.execute();

@@ -160,7 +160,7 @@ public class PopulateDefaultImpactsInRulesIT {
}

@Test
public void execute_whenStandardRuleHasBothAdhocAndStandardTypeAndSeverity_shouldCreateADefaultImpactWithAdhocTypes() throws SQLException {
void execute_whenStandardRuleHasBothAdhocAndStandardTypeAndSeverity_shouldCreateADefaultImpactWithAdhocTypes() throws SQLException {
insertRule("uuid", RuleType.CODE_SMELL, Severity.CRITICAL, RuleType.VULNERABILITY, Severity.MINOR, true);
underTest.execute();


+ 6
- 6
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/PopulatePurgedColumnInSnapshotsIT.java View File

@@ -21,29 +21,29 @@ package org.sonar.server.platform.db.migration.version.v102;

import java.sql.SQLException;
import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.sonar.db.MigrationDbTester;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.tuple;

public class PopulatePurgedColumnInSnapshotsIT {
class PopulatePurgedColumnInSnapshotsIT {
private static final String TABLE_NAME = "snapshots";

@Rule
@RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulatePurgedColumnInSnapshots.class);
private final PopulatePurgedColumnInSnapshots underTest = new PopulatePurgedColumnInSnapshots(db.database());

@Test
public void execute_whenSnapshotsDoesNotExist_shouldNotFail() {
void execute_whenSnapshotsDoesNotExist_shouldNotFail() {
assertThatCode(underTest::execute)
.doesNotThrowAnyException();
}

@Test
public void execute_whenSnapshotsExist_shouldPopulatePurgedColumn() throws SQLException {
void execute_whenSnapshotsExist_shouldPopulatePurgedColumn() throws SQLException {
insertSnapshot("uuid-1", null);
insertSnapshot("uuid-2", 1);
insertSnapshot("uuid-3", 0);

+ 0
- 0
server/sonar-db-migration/src/it/java/org/sonar/server/platform/db/migration/version/v102/RenameBuildDateInSnapshotsIT.java View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save