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'
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'
}
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);
protected void after() {
db.stop();
}
+
+ @Override
+ public void afterEach(ExtensionContext extensionContext) throws Exception {
+ after();
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext extensionContext) throws Exception {
+ before();
+ }
}
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'
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()
}
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");
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";
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);
}
@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()) {
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;
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);
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();
*/
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);
*/
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;
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())
.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)
}
@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)
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());
}
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;
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);
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();
}
@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"))
}
@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);
}
@Test
- public void getDbVendorSpecificQuery_oracle() {
+ void getDbVendorSpecificQuery_oracle() {
when(dbMock.getDialect()).thenReturn(ORACLE);
assertThat(underTest.getDbVendorSpecificQuery("my_table"))
}
@Test
- public void getDbVendorSpecificQuery_h2() {
+ void getDbVendorSpecificQuery_h2() {
when(dbMock.getDialect()).thenReturn(H2);
assertThat(underTest.getDbVendorSpecificQuery("my_table"))
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;
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);
}
@Test
- public void read_column_types() throws Exception {
+ void read_column_types() throws Exception {
insertPersons();
List<Object[]> persons = new ArrayList<>();
}
@Test
- public void parameterized_query() throws Exception {
+ void parameterized_query() throws Exception {
insertPersons();
final List<Long> ids = new ArrayList<>();
}
@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(() -> {
}
@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(() -> {
}
@Test
- public void bad_parameterized_query() throws Exception {
+ void bad_parameterized_query() throws Exception {
insertPersons();
DataChange change = new DataChange(db.database()) {
}
@Test
- public void scroll() throws Exception {
+ void scroll() throws Exception {
insertPersons();
final List<Long> ids = new ArrayList<>();
}
@Test
- public void insert() throws Exception {
+ void insert() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@Test
- public void batch_inserts() throws Exception {
+ void batch_inserts() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@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 {
}
@Test
- public void update_null() throws Exception {
+ void update_null() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@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;
}
@Test
- public void scroll_and_update() throws Exception {
+ void scroll_and_update() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@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(() -> {
}
@Test
- public void mass_update() throws Exception {
+ void mass_update() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@Test
- public void row_splitter_should_split_correctly() throws Exception {
+ void row_splitter_should_split_correctly() throws Exception {
insertPersons();
new DataChange(db.database()) {
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(() -> {
}
@Test
- public void mass_update_nothing() throws Exception {
+ void mass_update_nothing() throws Exception {
insertPersons();
new DataChange(db.database()) {
}
@Test
- public void bad_mass_update() throws Exception {
+ void bad_mass_update() throws Exception {
insertPersons();
DataChange change = new DataChange(db.database()) {
}
@Test
- public void read_not_null_fields() throws Exception {
+ void read_not_null_fields() throws Exception {
insertPersons();
List<Object[]> persons = new ArrayList<>();
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
String pluginUuid1 = insertPlugin();
String pluginUuid2 = insertPlugin();
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<>();
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;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class PopulateInitialSchemaIT {
+class PopulateInitialSchemaIT {
private static final long NOW = 1_500L;
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();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME);
underTest.execute();
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();
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();
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);
}
@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();
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();
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();
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();
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();
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);
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
insertScimUser(1);
insertScimUser(2);
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
insertScimProperty(db);
underTest.execute();
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,
}
@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();
}
@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,
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();
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;
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
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
insertData();
// re-entrant
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;
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);
}
@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);
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();
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();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
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();
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.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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
createExternalGroupsTable.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndexForEmailOnUsersTable.execute();
createIndexForEmailOnUsersTable.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndexForScmAccountOnScmAccountsTable.execute();
createIndexForScmAccountOnScmAccountsTable.execute();
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndexOnExternalIdAndIdentityOnExternalGroupsTable.execute();
createIndexOnExternalIdAndIdentityOnExternalGroupsTable.execute();
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();
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.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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(SCM_ACCOUNTS_TABLE_NAME);
createScmAccountsTable.execute();
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createUniqueIndexForReportSchedulesTable.execute();
createUniqueIndexForReportSchedulesTable.execute();
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;
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createUniqueIndexForReportSubscriptionsTable.execute();
createUniqueIndexForReportSubscriptionsTable.execute();
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();
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();
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);
}
@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);
}
@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);
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;
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();
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;
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();
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;
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();
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;
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();
}
@Test
- public void execute_whenUserHasEmptyScmAccounts_doNotInsertInScmAccounts() throws SQLException {
+ void execute_whenUserHasEmptyScmAccounts_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid("");
migrateScmAccountsFromUsersToScmAccounts.execute();
}
@Test
- public void execute_whenUserHasEmptyScmAccountsWithOneSeparator_doNotInsertInScmAccounts() throws SQLException {
+ void execute_whenUserHasEmptyScmAccountsWithOneSeparator_doNotInsertInScmAccounts() throws SQLException {
insertUserAndGetUuid(String.valueOf(SCM_ACCOUNTS_SEPARATOR_CHAR));
migrateScmAccountsFromUsersToScmAccounts.execute();
}
@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();
}
@Test
- public void execute_whenUserHasOneScmAccountWithoutSeparator_insertsInScmAccounts() throws SQLException {
+ void execute_whenUserHasOneScmAccountWithoutSeparator_insertsInScmAccounts() throws SQLException {
String userUuid = insertUserAndGetUuid(SCM_ACCOUNT1);
migrateScmAccountsFromUsersToScmAccounts.execute();
}
@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();
}
@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();
}
@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));
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
String userUuid = insertUserAndGetUuid(SCM_ACCOUNT1);
migrateScmAccountsFromUsersToScmAccounts.execute();
}
@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);
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;
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");
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
String project1Uuid = insertProject("project1");
String project2Uuid = insertProject("project2");
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;
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");
}
@Test
- public void execute_shouldPopulateFromBranchProperties() throws SQLException {
+ void execute_shouldPopulateFromBranchProperties() throws SQLException {
insertBranch("uuid1");
insertProjectBranchProperty("uuid1", "1234");
}
@Test
- public void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
+ void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
insertBranch("uuid1");
insertPortfolio("uuid1");
insertProjectBranchProperty("uuid1", "1234");
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;
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");
}
@Test
- public void execute_shouldPopulateFromBranchProperties() throws SQLException {
+ void execute_shouldPopulateFromBranchProperties() throws SQLException {
insertBranch("uuid1");
insertBranchProperty("uuid1", "1234");
}
@Test
- public void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
+ void execute_whenPropertyMatchesBothBranchAndPortfolio_shouldNotPopulate() throws SQLException {
insertBranch("uuid1");
insertPortfolio("uuid1");
insertBranchProperty("uuid1", "1234");
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;
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");
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
String project1Uuid = insertProject("project1");
String token1Uuid = insertUserToken("project1");
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;
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());
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");
}
@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");
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();
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;
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());
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);
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
String branchUuid1 = insertProjectBranch(true);
String branchUuid2 = insertProjectBranch(false);
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();
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;
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();
}
@Test
- public void migration_whenGitHubAutoProvisioningDisabled_shouldNotRequireConsent() throws SQLException {
+ void migration_whenGitHubAutoProvisioningDisabled_shouldNotRequireConsent() throws SQLException {
disableGithubProvisioning();
underTest.execute();
}
@Test
- public void migration_whenGitHubAutoProvisioningEnabled_shouldRequireConsent() throws SQLException {
+ void migration_whenGitHubAutoProvisioningEnabled_shouldRequireConsent() throws SQLException {
enableGithubProvisioning();
underTest.execute();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
enableGithubProvisioning();
underTest.execute();
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.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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(ANTICIPATED_TRANSITIONS_TABLE_NAME);
createAnticipatedTransitionsTable.execute();
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();
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.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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
createGithubOrganizationsGroupsTable.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);
underTest.execute();
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();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(EXPECTED_TABLE_NAME);
underTest.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
underTest.execute();
underTest.execute();
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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
underTest.execute();
underTest.execute();
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";
* {@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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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";
* {@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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
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";
* {@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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME);
underTest.execute();
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();
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();
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();
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",
}
@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();
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;
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();
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;
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();
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();
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();
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;
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"))
}
@Test
- public void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldBeReentrant() throws SQLException {
+ void execute_whenRuleWithUndefinedCleanCodeAttribute_shouldBeReentrant() throws SQLException {
insertRule("1", null);
underTest.execute();
underTest.execute();
}
@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"))
}
@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"))
}
@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"))
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;
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();
}
@Test
- public void execute_shouldBeReentrant() throws SQLException {
+ void execute_shouldBeReentrant() throws SQLException {
insertRuleWithType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();
underTest.execute();
}
@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);
}
@Test
- public void execute_whenAdhocRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
+ void execute_whenAdhocRulesHasTypeAndSeverity_shouldCreateImpact() throws SQLException {
insertRuleWithAdHocType("uuid", RuleType.CODE_SMELL, Severity.MAJOR);
underTest.execute();
}
@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();
}
@Test
- public void execute_whenNoTypeAndSeverityDefined_shouldNotCreateImpact() throws SQLException {
+ void execute_whenNoTypeAndSeverityDefined_shouldNotCreateImpact() throws SQLException {
insertRuleWithType("uuid", null, null);
underTest.execute();
}
@Test
- public void execute_whenInvalidValueDefined_shouldNotCreateImpactAndLog() throws SQLException {
+ void execute_whenInvalidValueDefined_shouldNotCreateImpactAndLog() throws SQLException {
insertInvalidRule("uuid");
underTest.execute();
}
@Test
- public void execute_whenTypeIsHotspot_shouldNotCreateImpactAndLog() throws SQLException {
+ void execute_whenTypeIsHotspot_shouldNotCreateImpactAndLog() throws SQLException {
insertRuleWithType("uuid", RuleType.SECURITY_HOTSPOT, Severity.MAJOR);
underTest.execute();
}
@Test
- public void execute_whenRuleHasEmptyFields_shouldCreateADefaultImpact() throws SQLException {
+ void execute_whenRuleHasEmptyFields_shouldCreateADefaultImpact() throws SQLException {
insertPlaceholderAdhocRule("uuid");
underTest.execute();
}
@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();
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);
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 RenameBuildDateInSnapshotsIT {
+class RenameBuildDateInSnapshotsIT {
private static final String TABLE_NAME = "snapshots";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameBuildDateInSnapshots.class);
private final RenameBuildDateInSnapshots underTest = new RenameBuildDateInSnapshots(db.database());
@Test
- public void execute_whenExecuted_shouldRenameColumn() throws SQLException {
+ void execute_whenExecuted_shouldRenameColumn() throws SQLException {
assertColumnExists("build_date");
underTest.execute();
assertColumnExists("analysis_date");
}
@Test
- public void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
+ void execute_whenExecutedTwice_shouldNotFail() throws SQLException {
assertColumnExists("build_date");
underTest.execute();
underTest.execute();
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 RenameComponentUuidInGroupRolesIT {
+class RenameComponentUuidInGroupRolesIT {
public static final String TABLE_NAME = "group_roles";
public static final String NEW_COLUMN_NAME = "entity_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameComponentUuidInGroupRoles.class);
private final RenameComponentUuidInGroupRoles underTest = new RenameComponentUuidInGroupRoles(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();
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 RenameComponentUuidInSnapshotsIT {
+class RenameComponentUuidInSnapshotsIT {
public static final String TABLE_NAME = "snapshots";
public static final String NEW_COLUMN_NAME = "root_component_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameComponentUuidInSnapshots.class);
private final RenameComponentUuidInSnapshots underTest = new RenameComponentUuidInSnapshots(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, 50, false);
}
@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();
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 RenameComponentUuidInUserRolesIT {
+class RenameComponentUuidInUserRolesIT {
public static final String TABLE_NAME = "user_roles";
public static final String NEW_COLUMN_NAME = "entity_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameComponentUuidInUserRoles.class);
private final RenameComponentUuidInUserRoles underTest = new RenameComponentUuidInUserRoles(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();
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.AbstractDbTester;
-import org.sonar.db.TestDb;
import org.sonar.db.MigrationDbTester;
+import org.sonar.db.TestDb;
import org.sonar.server.platform.db.migration.step.RenameVarcharColumnChange;
import org.sonar.server.platform.db.migration.version.RenameVarcharColumnAbstractTest;
-public class RenameComponentUuidInWebhookDeliveriesIT extends RenameVarcharColumnAbstractTest {
+class RenameComponentUuidInWebhookDeliveriesIT extends RenameVarcharColumnAbstractTest {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameComponentUuidInWebhookDeliveries.class);
public RenameComponentUuidInWebhookDeliveriesIT() {
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
super.verifyMigrationIsReentrant();
}
@Test
- public void column_is_renamed() throws SQLException {
+ void column_is_renamed() throws SQLException {
super.verifyColumnIsRenamed();
}
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 RenameMainComponentUuidInCeActivityIT {
+class RenameMainComponentUuidInCeActivityIT {
public static final String TABLE_NAME = "ce_activity";
public static final String NEW_COLUMN_NAME = "entity_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameMainComponentUuidInCeActivity.class);
private final RenameMainComponentUuidInCeActivity underTest = new RenameMainComponentUuidInCeActivity(db.database());
@Test
- public void column_is_renamed() throws SQLException {
+ void column_is_renamed() 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();
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 RenameMainComponentUuidInCeQueueIT {
+class RenameMainComponentUuidInCeQueueIT {
public static final String TABLE_NAME = "ce_queue";
public static final String NEW_COLUMN_NAME = "entity_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameMainComponentUuidInCeQueue.class);
private final RenameMainComponentUuidInCeQueue underTest = new RenameMainComponentUuidInCeQueue(db.database());
@Test
- public void column_is_renamed() throws SQLException {
+ void column_is_renamed() 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();
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.tuple;
-public class UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriodsIT {
+class UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriodsIT {
private static final String TABLE_NAME = "new_code_periods";
private static final String PROJECT_UUID = "project-uuid";
private static final String BRANCH_UUID = "branch-uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriods.class);
public final UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriods underTest = new UpdateValueAndPopulatePreviousNonCompliantValueInNewCodePeriods(db.database());
@Test
- public void execute_whenSnapshotsExist_shouldPopulatePurgedColumn() throws SQLException {
+ void execute_whenSnapshotsExist_shouldPopulatePurgedColumn() throws SQLException {
insertNewCodePeriods("uuid-1", PROJECT_UUID, BRANCH_UUID, "PREVIOUS_VERSION", null);
insertNewCodePeriods("uuid-2", PROJECT_UUID, null, "NUMBER_OF_DAYS", "90");
insertNewCodePeriods("uuid-3", null, null, "NUMBER_OF_DAYS", "97");
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 static org.assertj.core.api.Assertions.assertThatCode;
-public class AddCleanCodeAttributeColumnInIssuesTableIT {
+class AddCleanCodeAttributeColumnInIssuesTableIT {
private static final String TABLE_NAME = "issues";
private static final String COLUMN_NAME = "clean_code_attribute";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddCleanCodeAttributeColumnInIssuesTable.class);
private final AddCleanCodeAttributeColumnInIssuesTable underTest = new AddCleanCodeAttributeColumnInIssuesTable(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_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
+ void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
underTest.execute();
assertThatCode(underTest::execute).doesNotThrowAnyException();
}
package org.sonar.server.platform.db.migration.version.v103;
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;
import static org.sonar.server.platform.db.migration.version.v103.AddCreationMethodColumnInProjectsTable.PROJECTS_CREATION_METHOD_COLUMN_SIZE;
import static org.sonar.server.platform.db.migration.version.v103.AddCreationMethodColumnInProjectsTable.PROJECTS_TABLE_NAME;
-public class AddCreationMethodColumnInProjectsTableIT {
- @Rule
+class AddCreationMethodColumnInProjectsTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddCreationMethodColumnInProjectsTable.class);
private final AddCreationMethodColumnInProjectsTable underTest = new AddCreationMethodColumnInProjectsTable(db.database());
@Test
- public void execute_whenColumnDoesNotExist_shouldCreateColumn() throws SQLException {
+ void execute_whenColumnDoesNotExist_shouldCreateColumn() throws SQLException {
db.assertColumnDoesNotExist(PROJECTS_TABLE_NAME, PROJECTS_CREATION_METHOD_COLUMN_NAME);
underTest.execute();
db.assertColumnDefinition(PROJECTS_TABLE_NAME, PROJECTS_CREATION_METHOD_COLUMN_NAME, VARCHAR, PROJECTS_CREATION_METHOD_COLUMN_SIZE, true);
}
@Test
- public void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
+ void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
underTest.execute();
assertThatCode(underTest::execute).doesNotThrowAnyException();
}
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 static org.assertj.core.api.Assertions.assertThatCode;
-public class AddRuleChangesUuidColumnInQProfileChangesIT {
+class AddRuleChangesUuidColumnInQProfileChangesIT {
private static final String TABLE_NAME = "qprofile_changes";
private static final String COLUMN_NAME = "rule_change_uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddRuleChangesUuidColumnInQProfileChanges.class);
private final AddRuleChangesUuidColumnInQProfileChanges underTest = new AddRuleChangesUuidColumnInQProfileChanges(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_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
+ void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
underTest.execute();
assertThatCode(underTest::execute).doesNotThrowAnyException();
}
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 static org.assertj.core.api.Assertions.assertThatCode;
-public class AddSqVersionColumnInQprofileChangesTableIT {
+class AddSqVersionColumnInQprofileChangesTableIT {
private static final String TABLE_NAME = "qprofile_changes";
private static final String COLUMN_NAME = "sq_version";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddSqVersionColumnInQprofileChangesTable.class);
private final AddSqVersionColumnInQprofileChangesTable underTest = new AddSqVersionColumnInQprofileChangesTable(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_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
+ void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
underTest.execute();
assertThatCode(underTest::execute).doesNotThrowAnyException();
}
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.v103.CreateGithubPermissionsMappingTable.GITHUB_PERMISSIONS_MAPPING_TABLE_NAME;
-public class CreateGithubPermissionsMappingTableIT {
- @Rule
+class CreateGithubPermissionsMappingTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateGithubPermissionsMappingTable.class);
private final DdlChange createGithubPermissionsMappingTable = new CreateGithubPermissionsMappingTable(db.database());
@Test
- public void migration_should_create_a_table() throws SQLException {
+ void migration_should_create_a_table() throws SQLException {
db.assertTableDoesNotExist(GITHUB_PERMISSIONS_MAPPING_TABLE_NAME);
createGithubPermissionsMappingTable.execute();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(GITHUB_PERMISSIONS_MAPPING_TABLE_NAME);
createGithubPermissionsMappingTable.execute();
package org.sonar.server.platform.db.migration.version.v103;
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 CreateIndexForRuleImpactChangesTableIT {
+class CreateIndexForRuleImpactChangesTableIT {
static final String INDEX_NAME = "rule_impact_changes_r_c_uuid";
static final String TABLE_NAME = "rule_impact_changes";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIndexForRuleImpactChangesTable.class);
private final CreateIndexForRuleImpactChangesTable underTest = new CreateIndexForRuleImpactChangesTable(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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
underTest.execute();
underTest.execute();
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;
-public class CreateRuleChangesTableIT {
+class CreateRuleChangesTableIT {
private final static String TABLE_NAME = "rule_changes";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateRuleChangesTable.class);
private final DdlChange underTest = new CreateRuleChangesTable(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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
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;
-public class CreateRuleImpactChangesTableIT {
+class CreateRuleImpactChangesTableIT {
private final static String TABLE_NAME = "rule_impact_changes";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateRuleImpactChangesTable.class);
private final DdlChange underTest = new CreateRuleImpactChangesTable(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();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
package org.sonar.server.platform.db.migration.version.v103;
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.v103.CreateGithubPermissionsMappingTable.GITHUB_PERMISSIONS_MAPPING_TABLE_NAME;
import static org.sonar.server.platform.db.migration.version.v103.CreateGithubPermissionsMappingTable.SONARQUBE_PERMISSION_COLUMN;
import static org.sonar.server.platform.db.migration.version.v103.CreateUniqueIndexForGithubPermissionsMappingTable.INDEX_NAME;
-public class CreateUniqueIndexForGithubPermissionsMappingTableIT {
- @Rule
+class CreateUniqueIndexForGithubPermissionsMappingTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueIndexForGithubPermissionsMappingTable.class);
private final CreateUniqueIndexForGithubPermissionsMappingTable createIndex = new CreateUniqueIndexForGithubPermissionsMappingTable(db.database());
@Test
- public void migration_should_create_index() throws SQLException {
+ void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(GITHUB_PERMISSIONS_MAPPING_TABLE_NAME, INDEX_NAME);
createIndex.execute();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
package org.sonar.server.platform.db.migration.version.v103;
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.v103.CreateUniqueIndexForPropertiesTable.INDEX_NAME;
import static org.sonar.server.platform.db.migration.version.v103.CreateUniqueIndexForPropertiesTable.PROPERTIES_TABLE_NAME;
-public class CreateUniqueIndexForPropertiesTableIT {
+class CreateUniqueIndexForPropertiesTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateUniqueIndexForPropertiesTable.class);
private final CreateUniqueIndexForPropertiesTable createIndex = new CreateUniqueIndexForPropertiesTable(db.database());
@Test
- public void migration_should_create_index() throws SQLException {
+ void migration_should_create_index() throws SQLException {
db.assertIndexDoesNotExist(PROPERTIES_TABLE_NAME, INDEX_NAME);
createIndex.execute();
}
@Test
- public void migration_should_be_reentrant() throws SQLException {
+ void migration_should_be_reentrant() throws SQLException {
createIndex.execute();
createIndex.execute();
import java.sql.SQLException;
import java.util.Date;
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.Uuids;
import org.sonar.db.MigrationDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
-public class DeduplicatePropertiesTableIT {
+class DeduplicatePropertiesTableIT {
public static final String KEY = "key";
public static final String ENTITY = "entity";
public static final String USER = "user";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DeduplicatePropertiesTable.class);
private final DeduplicatePropertiesTable underTest = new DeduplicatePropertiesTable(db.database());
}
@Test
- public void execute_shouldDeduplicateRows_WhenOnlyKeyIsSpecified() throws SQLException {
+ void execute_shouldDeduplicateRows_WhenOnlyKeyIsSpecified() throws SQLException {
createBaseProperties();
createProperty(KEY, null, null);
createProperty(KEY, null, null);
}
@Test
- public void execute_shouldDeduplicateRows_WhenOnlyKeyAndUserAreSpecified() throws SQLException {
+ void execute_shouldDeduplicateRows_WhenOnlyKeyAndUserAreSpecified() throws SQLException {
createBaseProperties();
createProperty(KEY, USER, null);
createProperty(KEY, USER, null);
}
@Test
- public void execute_shouldDeduplicateRows_WhenKeyUserAndEntityAreSpecified() throws SQLException {
+ void execute_shouldDeduplicateRows_WhenKeyUserAndEntityAreSpecified() throws SQLException {
createBaseProperties();
createProperty(KEY, USER, ENTITY);
createProperty(KEY, USER, ENTITY);
}
@Test
- public void execute_shouldBeReentrant() throws SQLException {
+ void execute_shouldBeReentrant() throws SQLException {
createBaseProperties();
createProperty(KEY, USER, ENTITY);
package org.sonar.server.platform.db.migration.version.v103;
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;
import static org.sonar.server.platform.db.migration.version.v103.AddCreationMethodColumnInProjectsTable.PROJECTS_CREATION_METHOD_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v103.AddCreationMethodColumnInProjectsTable.PROJECTS_TABLE_NAME;
-public class MakeCreationMethodColumnInProjectsNotNullableIT {
- @Rule
+class MakeCreationMethodColumnInProjectsNotNullableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(MakeCreationMethodColumnInProjectsNotNullable.class);
private final MakeCreationMethodColumnInProjectsNotNullable underTest = new MakeCreationMethodColumnInProjectsNotNullable(db.database());
@Test
- public void user_local_column_is_not_null() throws SQLException {
+ void user_local_column_is_not_null() throws SQLException {
db.assertColumnDefinition(PROJECTS_TABLE_NAME, PROJECTS_CREATION_METHOD_COLUMN_NAME, VARCHAR, null, true);
underTest.execute();
db.assertColumnDefinition(PROJECTS_TABLE_NAME, PROJECTS_CREATION_METHOD_COLUMN_NAME, VARCHAR, null, false);
}
@Test
- public void migration_is_reentrant() throws SQLException {
+ void migration_is_reentrant() throws SQLException {
db.assertColumnDefinition(PROJECTS_TABLE_NAME, PROJECTS_CREATION_METHOD_COLUMN_NAME, VARCHAR, null, true);
underTest.execute();
underTest.execute();
package org.sonar.server.platform.db.migration.version.v103;
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.assertj.core.api.Assertions.assertThat;
import static org.sonar.server.platform.db.migration.version.v103.AddCreationMethodColumnInProjectsTable.PROJECTS_TABLE_NAME;
-public class PopulateCreationMethodColumnInProjectsTableIT {
+class PopulateCreationMethodColumnInProjectsTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateCreationMethodColumnInProjectsTable.class);
private final PopulateCreationMethodColumnInProjectsTable underTest = new PopulateCreationMethodColumnInProjectsTable(db.database());
@Test
- public void execute_whenProjectsTableIsEmpty_shouldDoNothing() throws SQLException {
+ void execute_whenProjectsTableIsEmpty_shouldDoNothing() throws SQLException {
underTest.execute();
assertThat(db.select("select creation_method from projects")).isEmpty();
}
@Test
- public void execute_whenProjectsExist_shouldPopulateCreationMethodColumn() throws SQLException {
+ void execute_whenProjectsExist_shouldPopulateCreationMethodColumn() throws SQLException {
insertProject("uuid-1");
insertProject("uuid-2");
}
@Test
- public void execute_isReentrant() throws SQLException {
+ void execute_isReentrant() throws SQLException {
insertProject("uuid-1");
underTest.execute();
package org.sonar.server.platform.db.migration.version.v103;
import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.testfixtures.log.LogTester;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.sonar.api.testfixtures.log.LogTesterJUnit5;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.server.platform.db.migration.version.v103.CreateGithubPermissionsMappingTable.GITHUB_PERMISSIONS_MAPPING_TABLE_NAME;
-public class PopulateGithubPermissionsMappingIT {
+class PopulateGithubPermissionsMappingIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateGithubPermissionsMapping.class);
- @Rule
- public LogTester logTester = new LogTester();
+ @RegisterExtension
+ public final LogTesterJUnit5 logTester = new LogTesterJUnit5();
private final PopulateGithubPermissionsMapping migration = new PopulateGithubPermissionsMapping(db.database(), UuidFactoryFast.getInstance());
@Test
- public void execute_whenTableAlreadyPopulated_doesNothing() throws SQLException {
+ void execute_whenTableAlreadyPopulated_doesNothing() throws SQLException {
db.executeInsert(GITHUB_PERMISSIONS_MAPPING_TABLE_NAME,
"UUID", UuidFactoryFast.getInstance().create(),
"github_role", "gh_role",
}
@Test
- public void execute_whenTableIsEmpty_shouldPopulate() throws SQLException {
+ void execute_whenTableIsEmpty_shouldPopulate() throws SQLException {
migration.execute();
verifyMapping();
}
@Test
- public void execute_isReentrant() throws SQLException {
+ void execute_isReentrant() throws SQLException {
migration.execute();
migration.execute();
migration.execute();
package org.sonar.server.platform.db.migration.version.v103;
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.api.impl.utils.TestSystem2;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactoryFast;
import static org.assertj.core.api.Assertions.assertThat;
-public class SetAllowQualityProfileDisableInheritedRulesIT {
+class SetAllowQualityProfileDisableInheritedRulesIT {
private static final long NOW = 1;
- @Rule
+ @RegisterExtension
public final MigrationDbTester dbTester = MigrationDbTester.createForMigrationStep(SetAllowQualityProfileDisableInheritedRules.class);
private final System2 system2 = new TestSystem2().setNow(NOW);
private final SetAllowQualityProfileDisableInheritedRules script = new SetAllowQualityProfileDisableInheritedRules(dbTester.database(), system2, UuidFactoryFast.getInstance());
@Test
- public void execute_shouldInsertPropertyWithFalseValue() throws SQLException {
+ void execute_shouldInsertPropertyWithFalseValue() throws SQLException {
script.execute();
assertThatForceAuthenticationEquals("false");
}
@Test
- public void execute_shouldBeReentrant() throws SQLException {
+ void execute_shouldBeReentrant() throws SQLException {
script.execute();
// re-entrant
script.execute();
}
@Test
- public void execute_shouldNotUpdateTheValueThatAlreadyExistsInTheDatabase() throws SQLException {
+ void execute_shouldNotUpdateTheValueThatAlreadyExistsInTheDatabase() throws SQLException {
insertPropertyWithValueAsTrue();
script.execute();
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 static org.assertj.core.api.Assertions.assertThatCode;
-public class AddUuidColumnToGroupsUsersIT {
+class AddUuidColumnToGroupsUsersIT {
private static final String TABLE_NAME = "groups_users";
private static final String COLUMN_NAME = "uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(AddUuidColumnToGroupsUsers.class);
private final AddUuidColumnToGroupsUsers underTest = new AddUuidColumnToGroupsUsers(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_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
+ void execute_whenColumnsAlreadyExists_shouldNotFail() throws SQLException {
underTest.execute();
assertThatCode(underTest::execute).doesNotThrowAnyException();
}
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.v104.CreateIssuesFixedTable.COLUMN_PULL_REQUEST_UUID;
import static org.sonar.server.platform.db.migration.version.v104.CreateIssuesFixedTable.TABLE_NAME;
-public class CreateIssuesFixedTableIT {
+class CreateIssuesFixedTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateIssuesFixedTable.class);
private final DdlChange underTest = new CreateIssuesFixedTable(db.database());
@Test
- public void execute_shouldCreateTable() throws SQLException {
+ void execute_shouldCreateTable() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
}
@Test
- public void execute_shouldBeReentrant() throws SQLException {
+ void execute_shouldBeReentrant() throws SQLException {
db.assertTableDoesNotExist(TABLE_NAME);
underTest.execute();
package org.sonar.server.platform.db.migration.version.v104;
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.v104.AddUuidColumnToGroupsUsers.GROUPS_USERS_TABLE_NAME;
import static org.sonar.server.platform.db.migration.version.v104.AddUuidColumnToGroupsUsers.GROUPS_USERS_UUID_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v104.CreatePrimaryKeyOnGroupsUsersTable.PK_NAME;
-public class CreatePrimaryKeyOnGroupsUsersTableIT {
- @Rule
+class CreatePrimaryKeyOnGroupsUsersTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePrimaryKeyOnGroupsUsersTable.class);
private final CreatePrimaryKeyOnGroupsUsersTable createIndex = new CreatePrimaryKeyOnGroupsUsersTable(db.database());
@Test
- public void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
+ void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
db.assertNoPrimaryKey(GROUPS_USERS_TABLE_NAME);
createIndex.execute();
}
@Test
- public void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
+ void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
createIndex.execute();
createIndex.execute();
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.v104.CreateRuleTagsTable.VALUE_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v104.CreateRuleTagsTable.VALUE_COLUMN_SIZE;
-public class CreateRuleTagsTableIT {
- @Rule
+class CreateRuleTagsTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreateRuleTagsTable.class);
private final DdlChange createScmAccountsTable = new CreateRuleTagsTable(db.database());
@Test
- public void execute_whenRun_shouldCreateRuleTagsTable() throws SQLException {
+ void execute_whenRun_shouldCreateRuleTagsTable() throws SQLException {
db.assertTableDoesNotExist(RULE_TAGS_TABLE_NAME);
createScmAccountsTable.execute();
}
@Test
- public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
db.assertTableDoesNotExist(RULE_TAGS_TABLE_NAME);
createScmAccountsTable.execute();
import java.sql.SQLException;
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.db.MigrationDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;
import static org.assertj.core.api.Assertions.assertThat;
-public class DeleteRedundantFailedAlertsForApplicationsIT {
+class DeleteRedundantFailedAlertsForApplicationsIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DeleteRedundantFailedAlertsForApplications.class);
private final DataChange underTest = new DeleteRedundantFailedAlertsForApplications(db.database());
- @Before
+ @BeforeEach
public void setUp() {
// cleanup db
db.executeUpdateSql("truncate table events");
}
@Test
- public void givenFailedAlertsForApplication_whenExecuted_thenFailedAlertsAreDeleted() throws SQLException {
+ void givenFailedAlertsForApplication_whenExecuted_thenFailedAlertsAreDeleted() throws SQLException {
// given
insertComponent("app1", "appUuid1", "appUuid1", "APP");
}
@Test
- public void givenFailedAlertsForProject_whenExecute_thenTheEventsAreNotDeleted() throws SQLException {
+ void givenFailedAlertsForProject_whenExecute_thenTheEventsAreNotDeleted() throws SQLException {
// given
insertComponent("project1", "projectUuid1", "projectUuid1", "TRK");
}
@Test
- public void givenMigration_whenExecutedMoreThanOnce_thenNoError() throws SQLException {
+ void givenMigration_whenExecutedMoreThanOnce_thenNoError() throws SQLException {
// given
insertComponent("app1", "appUuid1", "appUuid1", "APP");
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 DropSystemTagsInRulesIT {
+class DropSystemTagsInRulesIT {
private static final String TABLE_NAME = "rules";
private static final String COLUMN_NAME = "system_tags";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropSystemTagsInRules.class);
private final DdlChange underTest = new DropSystemTagsInRules(db.database());
@Test
- public void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
+ void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}
@Test
- public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
underTest.execute();
underTest.execute();
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 DropTagsInRulesIT {
+class DropTagsInRulesIT {
static final String TABLE_NAME = "rules";
static final String COLUMN_NAME = "tags";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropTagsInRules.class);
private final DdlChange underTest = new DropTagsInRules(db.database());
@Test
- public void executed_whenRun_shouldDropTagsColumn() throws SQLException {
+ void executed_whenRun_shouldDropTagsColumn() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}
@Test
- public void execute_whenExecutedMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenExecutedMoreThanOnce_shouldBeReentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
underTest.execute();
underTest.execute();
package org.sonar.server.platform.db.migration.version.v104;
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;
import static org.sonar.server.platform.db.migration.version.v104.AddUuidColumnToGroupsUsers.GROUPS_USERS_TABLE_NAME;
import static org.sonar.server.platform.db.migration.version.v104.AddUuidColumnToGroupsUsers.GROUPS_USERS_UUID_COLUMN_NAME;
-public class MakeUuidInGroupsUsersNotNullableIT {
+class MakeUuidInGroupsUsersNotNullableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep( MakeUuidInGroupsUsersNotNullable.class);
private final MakeUuidInGroupsUsersNotNullable underTest = new MakeUuidInGroupsUsersNotNullable(db.database());
@Test
- public void execute_whenUuidColumnIsNullable_shouldMakeItNonNullable() throws SQLException {
+ void execute_whenUuidColumnIsNullable_shouldMakeItNonNullable() throws SQLException {
db.assertColumnDefinition(GROUPS_USERS_TABLE_NAME, GROUPS_USERS_UUID_COLUMN_NAME, VARCHAR, null, true);
underTest.execute();
db.assertColumnDefinition(GROUPS_USERS_TABLE_NAME, GROUPS_USERS_UUID_COLUMN_NAME, VARCHAR, null, false);
}
@Test
- public void execute_whenUuidColumnIsNullable_shouldKeepItNullableAndNotFail() throws SQLException {
+ void execute_whenUuidColumnIsNullable_shouldKeepItNullableAndNotFail() throws SQLException {
db.assertColumnDefinition(GROUPS_USERS_TABLE_NAME, GROUPS_USERS_UUID_COLUMN_NAME, VARCHAR, null, true);
underTest.execute();
underTest.execute();
import java.util.List;
import java.util.Map;
import org.assertj.core.groups.Tuple;
-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.UuidFactoryFast;
import org.sonar.db.MigrationDbTester;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
-public class PopulateGroupsUsersUuidIT {
+class PopulateGroupsUsersUuidIT {
private static final String GROUPS_USERS_TABLE_NAME = "groups_users";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateGroupsUsersUuid.class);
private final PopulateGroupsUsersUuid migration = new PopulateGroupsUsersUuid(db.database(), UuidFactoryFast.getInstance());
@Test
- public void execute_whenTableIsEmpty_shouldPopulate() throws SQLException {
+ void execute_whenTableIsEmpty_shouldPopulate() throws SQLException {
insertRowsWithoutUuid();
migration.execute();
@Test
- public void execute_isReentrant() throws SQLException {
+ void execute_isReentrant() throws SQLException {
insertRowsWithoutUuid();
migration.execute();
List<Tuple> existingUuids = getExistingUuids();
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.tuple;
-public class PopulateRuleTagsTableIT {
+class PopulateRuleTagsTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(PopulateRuleTagsTable.class);
private final PopulateRuleTagsTable migration = new PopulateRuleTagsTable(db.database());
@Test
- public void execute_whenTagsExist_shouldPopulateProperly() throws SQLException {
+ void execute_whenTagsExist_shouldPopulateProperly() throws SQLException {
insertRule("uuid-1", null, "tag_1,tag_2");
insertRule("uuid-2", "systag_1,systag_2", null);
insertRule("uuid-3", "systag_3,systag_4", "tag_3,tag_4");
}
@Test
- public void execute_whenEmptyOrDuplicateTagsExist_shouldNotBeMigrated() throws SQLException {
+ void execute_whenEmptyOrDuplicateTagsExist_shouldNotBeMigrated() throws SQLException {
insertRule("uuid-1", null, "tag_1,,tag_2");
insertRule("uuid-2", "systag_1,,systag_2,systag_2,", null);
}
@Test
- public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
insertRule("uuid-3", "sys_tag", "tag");
migration.execute();
migration.execute();
import java.util.List;
import java.util.Map;
import java.util.Optional;
-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.tuple;
-public class RemoveCleanCodeAttributeFromCustomHotspotRulesIT {
+class RemoveCleanCodeAttributeFromCustomHotspotRulesIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RemoveCleanCodeAttributeFromCustomHotspotRules.class);
private final RemoveCleanCodeAttributeFromCustomHotspotRules underTest = new RemoveCleanCodeAttributeFromCustomHotspotRules(db.database());
@Test
- public void execute_whenRulesTableIsEmpty_shouldDoNothing() throws SQLException {
+ void execute_whenRulesTableIsEmpty_shouldDoNothing() throws SQLException {
underTest.execute();
assertThat(db.select("select clean_code_attribute from rules")).isEmpty();
}
@Test
- public void execute_whenCustomHotspotRuleExist_shouldRemoveCleanCodeAttributeOnlyFromHotspot() throws SQLException {
+ void execute_whenCustomHotspotRuleExist_shouldRemoveCleanCodeAttributeOnlyFromHotspot() throws SQLException {
insertRule("custom_hotspot_rule", 4, "CONVENTIONAL");
insertRule("other_rule", 1, "ETHICAL");
}
@Test
- public void execute_whenCustomHotspotRuleExist_isReentrant() throws SQLException {
+ void execute_whenCustomHotspotRuleExist_isReentrant() throws SQLException {
insertRule("custom_hotspot_rule", 4, "CONVENTIONAL");
insertRule("other_rule", 1, "ETHICAL");
package org.sonar.server.platform.db.migration.version.v104;
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.assertj.core.api.Assertions.assertThat;
-public class RenameWontFixIssuesMetricIT {
+class RenameWontFixIssuesMetricIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(RenameWontFixIssuesMetric.class);
private final RenameWontFixIssuesMetric underTest = new RenameWontFixIssuesMetric(db.database());
@Test
- public void execute_whenMetricsTableIsEmpty_shouldDoNothing() throws SQLException {
+ void execute_whenMetricsTableIsEmpty_shouldDoNothing() throws SQLException {
underTest.execute();
assertThat(db.select("select name from metrics")).isEmpty();
}
@Test
- public void execute_whenWontFixMetricExist_shouldRenameToAccepted() throws SQLException {
+ void execute_whenWontFixMetricExist_shouldRenameToAccepted() throws SQLException {
insertMetric("wont_fix_issues");
insertMetric("other_metric");
}
@Test
- public void execute_isReentrant() throws SQLException {
+ void execute_isReentrant() throws SQLException {
insertMetric("wont_fix_issues");
insertMetric("other_metric");
package org.sonar.server.platform.db.migration.version.v105;
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.v105.CreatePrimaryKeyOnIssuesImpactsTable.ISSUE_KEY_COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.SOFTWARE_QUALITY_COLUMN;
import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnIssuesImpactsTable.TABLE_NAME;
-public class CreatePrimaryKeyOnIssuesImpactsTableIT {
- @Rule
+class CreatePrimaryKeyOnIssuesImpactsTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePrimaryKeyOnIssuesImpactsTable.class);
private final CreatePrimaryKeyOnIssuesImpactsTable createIndex = new CreatePrimaryKeyOnIssuesImpactsTable(db.database());
@Test
- public void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
+ void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
db.assertNoPrimaryKey(TABLE_NAME);
createIndex.execute();
}
@Test
- public void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
+ void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
createIndex.execute();
createIndex.execute();
package org.sonar.server.platform.db.migration.version.v105;
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.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.PK_NAME;
import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.SOFTWARE_QUALITY_COLUMN;
import static org.sonar.server.platform.db.migration.version.v105.CreatePrimaryKeyOnRulesDefaultImpactsTable.TABLE_NAME;
-public class CreatePrimaryKeyOnRulesDefaultImpactsTableIT {
- @Rule
+class CreatePrimaryKeyOnRulesDefaultImpactsTableIT {
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(CreatePrimaryKeyOnRulesDefaultImpactsTable.class);
private final CreatePrimaryKeyOnRulesDefaultImpactsTable createIndex = new CreatePrimaryKeyOnRulesDefaultImpactsTable(db.database());
@Test
- public void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
+ void execute_whenPrimaryKeyDoesntExist_shouldCreatePrimaryKey() throws SQLException {
db.assertNoPrimaryKey(TABLE_NAME);
createIndex.execute();
}
@Test
- public void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
+ void execute_whenPrimaryKeyAlreadyExist_shouldKeepThePrimaryKeyAndNotFail() throws SQLException {
createIndex.execute();
createIndex.execute();
package org.sonar.server.platform.db.migration.version.v105;
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.sql.DbPrimaryKeyConstraintFinder;
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInIssuesImpactsTable.CONSTRAINT_NAME;
import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInIssuesImpactsTable.TABLE_NAME;
-public class DropPrimaryKeyConstraintInIssuesImpactsTableIT {
+class DropPrimaryKeyConstraintInIssuesImpactsTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropPrimaryKeyConstraintInIssuesImpactsTable.class);
private final DbPrimaryKeyConstraintFinder dbPrimaryKeyConstraintFinder = new DbPrimaryKeyConstraintFinder(db.database());
new DropPrimaryKeySqlGenerator(db.database(), dbPrimaryKeyConstraintFinder), dbPrimaryKeyConstraintFinder);
@Test
- public void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
+ void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
underTest.execute();
db.assertNoPrimaryKey(TABLE_NAME);
}
@Test
- public void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
+ void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();
package org.sonar.server.platform.db.migration.version.v105;
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.sql.DbPrimaryKeyConstraintFinder;
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInRulesDefaultImpactsTable.CONSTRAINT_NAME;
import static org.sonar.server.platform.db.migration.version.v105.DropPrimaryKeyConstraintInRulesDefaultImpactsTable.TABLE_NAME;
-public class DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT {
+class DropPrimaryKeyConstraintInRulesDefaultImpactsTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropPrimaryKeyConstraintInRulesDefaultImpactsTable.class);
private final DbPrimaryKeyConstraintFinder dbPrimaryKeyConstraintFinder = new DbPrimaryKeyConstraintFinder(db.database());
new DropPrimaryKeySqlGenerator(db.database(), dbPrimaryKeyConstraintFinder), dbPrimaryKeyConstraintFinder);
@Test
- public void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
+ void execute_shouldRemoveExistingPrimaryKey() throws SQLException {
db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
underTest.execute();
db.assertNoPrimaryKey(TABLE_NAME);
}
@Test
- public void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
+ void execute_when_reentrant_shouldRemoveExistingPrimaryKey() throws SQLException {
db.assertPrimaryKey(TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME);
underTest.execute();
underTest.execute();
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.v105.DropUuidColumnInIssuesImpactsTable.COLUMN_NAME;
import static org.sonar.server.platform.db.migration.version.v105.DropUuidColumnInIssuesImpactsTable.TABLE_NAME;
-public class DropUuidColumnInIssuesImpactsTableIT {
+class DropUuidColumnInIssuesImpactsTableIT {
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropUuidColumnInIssuesImpactsTable.class);
private final DdlChange underTest = new DropUuidColumnInIssuesImpactsTable(db.database());
@Test
- public void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
+ void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}
@Test
- public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
underTest.execute();
underTest.execute();
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 DropUuidColumnInRulesDefaultImpactsTableIT {
+class DropUuidColumnInRulesDefaultImpactsTableIT {
private static final String TABLE_NAME = "issues_impacts";
private static final String COLUMN_NAME = "uuid";
- @Rule
+ @RegisterExtension
public final MigrationDbTester db = MigrationDbTester.createForMigrationStep(DropUuidColumnInIssuesImpactsTable.class);
private final DdlChange underTest = new DropUuidColumnInIssuesImpactsTable(db.database());
@Test
- public void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
+ void executed_whenRun_shouldDropSystemTagsColumn() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
underTest.execute();
db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
}
@Test
- public void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
+ void execute_whenRunMoreThanOnce_shouldBeReentrant() throws SQLException {
db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 40, false);
underTest.execute();
underTest.execute();
import java.sql.SQLException;
import javax.annotation.Nullable;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-public class MigrationDbTester extends AbstractDbTester<MigrationTestDb> {
+public class MigrationDbTester extends AbstractDbTester<MigrationTestDb> implements BeforeEachCallback, AfterEachCallback {
private MigrationDbTester(@Nullable Class<? extends MigrationStep> migrationStepClass) {
super(new MigrationTestDb(migrationStepClass));
throw new IllegalStateException("Fail to truncate db tables", e);
}
}
+
+ @Override
+ public void afterEach(ExtensionContext extensionContext) throws Exception {
+ after();
+ }
+
+ @Override
+ public void beforeEach(ExtensionContext extensionContext) throws Exception {
+ before();
+ }
}