this.db = db;
}
- public String findConstraintName(String tableName) throws SQLException {
+ public Optional<String> findConstraintName(String tableName) throws SQLException {
String constraintQuery = getDbVendorSpecificQuery(tableName);
- return executeQuery(constraintQuery)
- .orElseThrow(() -> constraintNotFoundException(tableName));
+ return executeQuery(constraintQuery);
}
String getDbVendorSpecificQuery(String tableName) {
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.sonar.db.Database;
import org.sonar.db.dialect.Dialect;
import org.sonar.db.dialect.H2;
public List<String> generate(String tableName, Collection<String> columnNames, boolean isAutoGenerated) throws SQLException {
Dialect dialect = db.getDialect();
- String constraintName = dbConstraintFinder.findConstraintName(tableName);
+ Optional<String> constraintName = dbConstraintFinder.findConstraintName(tableName);
+ if (!constraintName.isPresent()) {
+ return Collections.emptyList();
+ }
switch (dialect.getId()) {
case PostgreSql.ID:
- return generateForPostgresSql(tableName, columnNames, constraintName);
+ return generateForPostgresSql(tableName, columnNames, constraintName.get());
case MsSql.ID:
- return generateForMsSql(tableName, constraintName);
+ return generateForMsSql(tableName, constraintName.get());
case Oracle.ID:
- return generateForOracle(tableName, constraintName, isAutoGenerated);
+ return generateForOracle(tableName, constraintName.get(), isAutoGenerated);
case H2.ID:
- return generateForH2(tableName, constraintName);
+ return generateForH2(tableName, constraintName.get());
default:
throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId()));
}
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.Optional;
import javax.sql.DataSource;
import org.junit.Rule;
import org.junit.Test;
@Test
public void findConstraintName_constraint_exists() throws SQLException {
DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
- String constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY");
- assertThat(constraintName).isEqualTo("PK_TEST_PRIMARY_KEY");
+ Optional<String> constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY");
+ assertThat(constraintName).isPresent();
+ assertThat(constraintName.get()).contains("PK_TEST_PRIMARY_KEY");
}
@Test
- public void findConstraintName_constraint_not_exist() {
+ public void findConstraintName_constraint_not_exist_fails_silently() throws SQLException {
DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database());
- assertThatThrownBy(() -> underTest.findConstraintName("NOT_EXISTING_TABLE"))
- .hasMessage("Cannot find constraint for table 'NOT_EXISTING_TABLE'")
- .isInstanceOf(IllegalStateException.class);
+ assertThat(underTest.findConstraintName("NOT_EXISTING_TABLE")).isNotPresent();
}
@Test
import java.sql.SQLException;
import java.util.List;
+import java.util.Optional;
import org.junit.Test;
import org.sonar.db.Database;
import org.sonar.db.dialect.Dialect;
private final DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, dbConstraintFinder);
@Test
- public void generate_unknown_dialect() {
+ public void generate_unknown_dialect() throws SQLException {
Dialect mockDialect = mock(Dialect.class);
when(mockDialect.getId()).thenReturn("unknown-db-vendor");
when(db.getDialect()).thenReturn(mockDialect);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
assertThatThrownBy(() -> underTest.generate(TABLE_NAME, PK_COLUMN, true))
.isInstanceOf(IllegalStateException.class);
@Test
public void generate_for_postgres_sql() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq");
when(db.getDialect()).thenReturn(POSTGRESQL);
@Test
public void generate_for_postgres_sql_no_seq() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(null);
when(db.getDialect()).thenReturn(POSTGRESQL);
@Test
public void generate_for_ms_sql() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(db.getDialect()).thenReturn(MS_SQL);
List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
@Test
public void generate_for_oracle_autogenerated_true() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(db.getDialect()).thenReturn(ORACLE);
List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
@Test
public void generate_for_oracle_autogenerated_false() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(db.getDialect()).thenReturn(ORACLE);
List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, false);
@Test
public void generate_for_h2() throws SQLException {
- when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT);
+ when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(Optional.of(CONSTRAINT));
when(db.getDialect()).thenReturn(H2);
List<String> sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true);
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest {
private static final String TABLE_NAME = "active_rule_parameters";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest {
private static final String TABLE_NAME = "active_rules";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest {
private static final String TABLE_NAME = "ce_activity";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest {
private static final String TABLE_NAME = "ce_queue";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest {
private static final String TABLE_NAME = "duplications_index";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfEventsTableTest {
private static final String TABLE_NAME = "events";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest {
private static final String TABLE_NAME = "file_sources";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder;
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest {
private static final String TABLE_NAME = "group_roles";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfGroupsTableTest {
private static final String TABLE_NAME = "groups";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest {
private static final String TABLE_NAME = "manual_measures";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfNotificationTableTest {
private static final String TABLE_NAME = "notifications";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest {
private static final String TABLE_NAME = "permission_templates";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest {
private static final String TABLE_NAME = "perm_templates_groups";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest {
private static final String TABLE_NAME = "perm_templates_users";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest {
private static final String TABLE_NAME = "perm_tpl_characteristics";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest {
private static final String TABLE_NAME = "project_measures";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
underTest.execute();
-
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ underTest.execute();
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest {
private static final String TABLE_NAME = "project_qprofiles";
@Rule
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest {
private static final String TABLE_NAME = "properties";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest {
private static final String TABLE_NAME = "quality_gate_conditions";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfQGatesTableTest {
private static final String TABLE_NAME = "quality_gates";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class DropPrimaryKeyOnIdColumnOfRulesTableTest {
+ private static final String TABLE_NAME = "rules";
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql");
@Test
public void execute() throws SQLException {
- db.assertTableExists("rules");
- db.assertPrimaryKey("rules", "pk_rules", "id");
+ db.assertTableExists(TABLE_NAME);
+ db.assertPrimaryKey(TABLE_NAME, "pk_rules", "id");
underTest.execute();
- db.assertNoPrimaryKey("rules");
+ db.assertNoPrimaryKey(TABLE_NAME);
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest {
+ private static final String TABLE_NAME = "rules_metadata";
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql");
@Test
public void execute() throws SQLException {
- db.assertTableExists("rules_metadata");
- db.assertPrimaryKey("rules_metadata", "pk_rules_metadata", "rule_id", "organization_uuid");
+ db.assertTableExists(TABLE_NAME);
+ db.assertPrimaryKey(TABLE_NAME, "pk_rules_metadata", "rule_id", "organization_uuid");
underTest.execute();
- db.assertNoPrimaryKey("rules_metadata");
+ db.assertNoPrimaryKey(TABLE_NAME);
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest {
private static final String TABLE_NAME = "rules_parameters";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest {
private static final String TABLE_NAME = "rules_profiles";
@Rule
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest {
private static final String TABLE_NAME = "snapshots";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfUsersTableTest {
private static final String TABLE_NAME = "users";
@Rule
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.DdlChange;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest {
private static final String TABLE_NAME = "organization_members";
@Rule
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}
import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest {
private static final String TABLE_NAME = "user_tokens";
}
@Test
- public void migration_is_not_re_entrant() throws SQLException {
+ public void migration_is_re_entrant_but_fails_silently() throws SQLException {
+ underTest.execute();
underTest.execute();
- assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+ db.assertNoPrimaryKey(TABLE_NAME);
}
}