aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-18 20:11:12 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-02-22 17:26:24 +0100
commitd88d443bbe5c5dabe45b44760108fa7b506cd7d9 (patch)
tree6e24e8e370fdb477518a57626ea19a19a9397a7a /sonar-db
parent978f9e79abcf71dfc5f477dbce5456578f56fa6f (diff)
downloadsonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.tar.gz
sonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.zip
SONAR-7364 Remove SQALE characteristics from measures and rules
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DaoModule.java2
-rw-r--r--sonar-db/src/main/java/org/sonar/db/DbClient.java7
-rw-r--r--sonar-db/src/main/java/org/sonar/db/MyBatis.java5
-rw-r--r--sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java220
-rw-r--r--sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDto.java137
-rw-r--r--sonar-db/src/main/java/org/sonar/db/debt/CharacteristicMapper.java52
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java12
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java11
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java3
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java4
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicId.java54
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/debt/CharacteristicMapper.xml137
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml7
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql2
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl20
-rw-r--r--sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDaoTest.java233
-rw-r--r--sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDtoTest.java83
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java49
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/rule/RuleDtoTest.java33
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java2
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest.java56
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/insert_characteristic-result.xml7
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics.xml24
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics_order_by_characteristic_order.xml15
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_max_characteristic_order_when_characteristics_are_all_disabled.xml14
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_sub_characteristics_by_parent_id.xml35
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/shared.xml26
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic-result.xml7
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic.xml7
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/select_requirement.xml10
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/shared.xml17
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml2
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_characteristic_id.xml28
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml4
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/before.xml7
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/schema.sql25
40 files changed, 155 insertions, 1214 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/DaoModule.java b/sonar-db/src/main/java/org/sonar/db/DaoModule.java
index bedee4a4bb1..96c1d3f6449 100644
--- a/sonar-db/src/main/java/org/sonar/db/DaoModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/DaoModule.java
@@ -35,7 +35,6 @@ import org.sonar.db.dashboard.ActiveDashboardDao;
import org.sonar.db.dashboard.DashboardDao;
import org.sonar.db.dashboard.WidgetDao;
import org.sonar.db.dashboard.WidgetPropertyDao;
-import org.sonar.db.debt.CharacteristicDao;
import org.sonar.db.duplication.DuplicationDao;
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.ActionPlanDao;
@@ -108,7 +107,6 @@ public class DaoModule extends Module {
QualityProfileDao.class,
PurgeDao.class,
RuleDao.class,
- CharacteristicDao.class,
ResourceIndexDao.class,
ResourceDao.class,
ResourceKeyUpdaterDao.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/DbClient.java b/sonar-db/src/main/java/org/sonar/db/DbClient.java
index be249d0e6be..601a4532267 100644
--- a/sonar-db/src/main/java/org/sonar/db/DbClient.java
+++ b/sonar-db/src/main/java/org/sonar/db/DbClient.java
@@ -35,7 +35,6 @@ import org.sonar.db.dashboard.ActiveDashboardDao;
import org.sonar.db.dashboard.DashboardDao;
import org.sonar.db.dashboard.WidgetDao;
import org.sonar.db.dashboard.WidgetPropertyDao;
-import org.sonar.db.debt.CharacteristicDao;
import org.sonar.db.duplication.DuplicationDao;
import org.sonar.db.event.EventDao;
import org.sonar.db.issue.ActionPlanDao;
@@ -75,7 +74,6 @@ public class DbClient {
private final Database database;
private final MyBatis myBatis;
private final QualityProfileDao qualityProfileDao;
- private final CharacteristicDao debtCharacteristicDao;
private final LoadedTemplateDao loadedTemplateDao;
private final PropertiesDao propertiesDao;
private final SnapshotDao snapshotDao;
@@ -130,7 +128,6 @@ public class DbClient {
for (Dao dao : daos) {
map.put(dao.getClass(), dao);
}
- debtCharacteristicDao = getDao(map, CharacteristicDao.class);
qualityProfileDao = getDao(map, QualityProfileDao.class);
loadedTemplateDao = getDao(map, LoadedTemplateDao.class);
propertiesDao = getDao(map, PropertiesDao.class);
@@ -217,10 +214,6 @@ public class DbClient {
return qualityProfileDao;
}
- public CharacteristicDao debtCharacteristicDao() {
- return debtCharacteristicDao;
- }
-
public LoadedTemplateDao loadedTemplateDao() {
return loadedTemplateDao;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/MyBatis.java b/sonar-db/src/main/java/org/sonar/db/MyBatis.java
index 5cf731bcd2f..5076f23dc21 100644
--- a/sonar-db/src/main/java/org/sonar/db/MyBatis.java
+++ b/sonar-db/src/main/java/org/sonar/db/MyBatis.java
@@ -56,8 +56,6 @@ import org.sonar.db.dashboard.WidgetDto;
import org.sonar.db.dashboard.WidgetMapper;
import org.sonar.db.dashboard.WidgetPropertyDto;
import org.sonar.db.dashboard.WidgetPropertyMapper;
-import org.sonar.db.debt.CharacteristicDto;
-import org.sonar.db.debt.CharacteristicMapper;
import org.sonar.db.debt.RequirementMigrationDto;
import org.sonar.db.deprecated.WorkQueue;
import org.sonar.db.duplication.DuplicationMapper;
@@ -205,7 +203,6 @@ public class MyBatis {
confBuilder.loadAlias("PermissionTemplate", PermissionTemplateDto.class);
confBuilder.loadAlias("PermissionTemplateUser", PermissionTemplateUserDto.class);
confBuilder.loadAlias("PermissionTemplateGroup", PermissionTemplateGroupDto.class);
- confBuilder.loadAlias("Characteristic", CharacteristicDto.class);
confBuilder.loadAlias("UserWithPermission", UserWithPermissionDto.class);
confBuilder.loadAlias("GroupWithPermission", GroupWithPermissionDto.class);
confBuilder.loadAlias("QualityProfile", QualityProfileDto.class);
@@ -237,7 +234,7 @@ public class MyBatis {
SchemaMigrationMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
UserMapper.class, GroupMapper.class, UserGroupMapper.class, UserTokenMapper.class,
FileSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class,
- NotificationQueueMapper.class, CharacteristicMapper.class,
+ NotificationQueueMapper.class,
GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class,
MeasureMapper.class, MetricMapper.class, CustomMeasureMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class,
ProjectQgateAssociationMapper.class, EventMapper.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java b/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java
deleted file mode 100644
index 9649d124602..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDao.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.debt;
-
-import com.google.common.collect.Lists;
-import java.util.Collection;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import org.apache.ibatis.session.SqlSession;
-import org.sonar.db.Dao;
-import org.sonar.db.DbSession;
-import org.sonar.db.MyBatis;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-public class CharacteristicDao implements Dao {
-
- private final MyBatis mybatis;
-
- public CharacteristicDao(MyBatis mybatis) {
- this.mybatis = mybatis;
- }
-
- /**
- * @return enabled root characteristics and characteristics
- */
- public List<CharacteristicDto> selectEnabledCharacteristics() {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectEnabledCharacteristics(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<CharacteristicDto> selectEnabledCharacteristics(SqlSession session) {
- return session.getMapper(CharacteristicMapper.class).selectEnabledCharacteristics();
- }
-
- /**
- * @return all characteristics
- */
- public List<CharacteristicDto> selectCharacteristics() {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectCharacteristics(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<CharacteristicDto> selectCharacteristics(SqlSession session) {
- return session.getMapper(CharacteristicMapper.class).selectCharacteristics();
- }
-
- /**
- * @return only enabled root characteristics, order by order
- */
- public List<CharacteristicDto> selectEnabledRootCharacteristics() {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectEnabledRootCharacteristics(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- /**
- * @return only enabled root characteristics, order by order
- */
- public List<CharacteristicDto> selectEnabledRootCharacteristics(SqlSession session) {
- return session.getMapper(CharacteristicMapper.class).selectEnabledRootCharacteristics();
- }
-
- public List<CharacteristicDto> selectCharacteristicsByParentId(int parentId) {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectCharacteristicsByParentId(parentId, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<CharacteristicDto> selectCharacteristicsByParentId(int parentId, SqlSession session) {
- return session.getMapper(CharacteristicMapper.class).selectCharacteristicsByParentId(parentId);
- }
-
- public List<CharacteristicDto> selectCharacteristicsByIds(Collection<Integer> ids) {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectCharacteristicsByIds(ids, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public List<CharacteristicDto> selectCharacteristicsByIds(Collection<Integer> ids, SqlSession session) {
- List<CharacteristicDto> dtos = newArrayList();
- List<List<Integer>> partitionList = Lists.partition(newArrayList(ids), 1000);
- for (List<Integer> partition : partitionList) {
- dtos.addAll(session.getMapper(CharacteristicMapper.class).selectCharacteristicsByIds(partition));
- }
- return dtos;
- }
-
- @CheckForNull
- public CharacteristicDto selectByKey(String key) {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectByKey(key, session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- @CheckForNull
- public CharacteristicDto selectByKey(String key, SqlSession session) {
- return session.getMapper(CharacteristicMapper.class).selectByKey(key);
- }
-
- @CheckForNull
- public CharacteristicDto selectById(int id) {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectById(session, id);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- @CheckForNull
- public CharacteristicDto selectById(SqlSession session, int id) {
- return session.getMapper(CharacteristicMapper.class).selectById(id);
- }
-
- @CheckForNull
- public CharacteristicDto selectByName(String name) {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectByName(session, name);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- @CheckForNull
- public CharacteristicDto selectByName(SqlSession session, String name) {
- return session.getMapper(CharacteristicMapper.class).selectByName(name);
- }
-
- public int selectMaxCharacteristicOrder() {
- SqlSession session = mybatis.openSession(false);
- try {
- return selectMaxCharacteristicOrder(session);
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public int selectMaxCharacteristicOrder(SqlSession session) {
- Integer result = session.getMapper(CharacteristicMapper.class).selectMaxCharacteristicOrder();
- return result != null ? result : 0;
- }
-
- public void insert(SqlSession session, CharacteristicDto dto) {
- session.getMapper(CharacteristicMapper.class).insert(dto);
- }
-
- public void insert(CharacteristicDto dto) {
- SqlSession session = mybatis.openSession(false);
- try {
- insert(session, dto);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
- public void insert(DbSession session, Collection<CharacteristicDto> items) {
- for (CharacteristicDto item : items) {
- insert(session, item);
- }
- }
-
- public void insert(DbSession session, CharacteristicDto item, CharacteristicDto... others) {
- insert(session, Lists.asList(item, others));
- }
-
- public void update(CharacteristicDto dto, SqlSession session) {
- session.getMapper(CharacteristicMapper.class).update(dto);
- }
-
- public void update(CharacteristicDto dto) {
- SqlSession session = mybatis.openSession(false);
- try {
- update(dto, session);
- session.commit();
- } finally {
- MyBatis.closeQuietly(session);
- }
- }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDto.java b/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDto.java
deleted file mode 100644
index d8c9b084687..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicDto.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.debt;
-
-import java.io.Serializable;
-import java.util.Date;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-
-public class CharacteristicDto implements Serializable {
-
- private Integer id;
- private String kee;
- private String name;
- private Integer parentId;
- private Integer characteristicOrder;
- private Date createdAt;
- private Date updatedAt;
- private boolean enabled;
-
- public Integer getId() {
- return id;
- }
-
- public CharacteristicDto setId(Integer id) {
- this.id = id;
- return this;
- }
-
- public String getKey() {
- return kee;
- }
-
- public CharacteristicDto setKey(String s) {
- this.kee = s;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public CharacteristicDto setName(String s) {
- this.name = s;
- return this;
- }
-
- @CheckForNull
- public Integer getParentId() {
- return parentId;
- }
-
- public CharacteristicDto setParentId(@Nullable Integer i) {
- this.parentId = i;
- return this;
- }
-
- @CheckForNull
- public Integer getOrder() {
- return characteristicOrder;
- }
-
- public CharacteristicDto setOrder(@Nullable Integer i) {
- this.characteristicOrder = i;
- return this;
- }
-
- public Date getCreatedAt() {
- return createdAt;
- }
-
- public CharacteristicDto setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- @CheckForNull
- public Date getUpdatedAt() {
- return updatedAt;
- }
-
- public CharacteristicDto setUpdatedAt(@Nullable Date updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public CharacteristicDto setEnabled(boolean enabled) {
- this.enabled = enabled;
- return this;
- }
-
- public DefaultCharacteristic toCharacteristic(@Nullable DefaultCharacteristic parent) {
- return new DefaultCharacteristic()
- .setId(id)
- .setKey(kee)
- .setName(name)
- .setOrder(characteristicOrder)
- .setParent(parent)
- .setRoot(parent)
- .setCreatedAt(createdAt)
- .setUpdatedAt(updatedAt);
- }
-
- public static CharacteristicDto toDto(DefaultCharacteristic characteristic, @Nullable Integer parentId) {
- return new CharacteristicDto()
- .setKey(characteristic.key())
- .setName(characteristic.name())
- .setOrder(characteristic.order())
- .setParentId(parentId)
- .setEnabled(true)
- .setCreatedAt(characteristic.createdAt())
- .setUpdatedAt(characteristic.updatedAt());
- }
-
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicMapper.java b/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicMapper.java
deleted file mode 100644
index 070c02fdb44..00000000000
--- a/sonar-db/src/main/java/org/sonar/db/debt/CharacteristicMapper.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.debt;
-
-import java.util.List;
-import org.apache.ibatis.annotations.Param;
-
-public interface CharacteristicMapper {
-
- List<CharacteristicDto> selectEnabledCharacteristics();
-
- List<CharacteristicDto> selectCharacteristics();
-
- List<CharacteristicDto> selectEnabledRootCharacteristics();
-
- List<CharacteristicDto> selectCharacteristicsByParentId(int parentId);
-
- List<CharacteristicDto> selectCharacteristicsByIds(@Param("ids") List<Integer> ids);
-
- CharacteristicDto selectByKey(String key);
-
- CharacteristicDto selectById(int id);
-
- CharacteristicDto selectByName(String name);
-
- Integer selectMaxCharacteristicOrder();
-
- void insert(CharacteristicDto characteristic);
-
- int update(CharacteristicDto characteristic);
-
- void deleteRequirementsFromCharacteristicsTable();
-
- List<RequirementMigrationDto> selectDeprecatedRequirements();
-}
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java
index 630df5eb55f..8bc470b9ec1 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDto.java
@@ -45,7 +45,6 @@ public class MeasureDto {
private Long snapshotId;
private Integer metricId;
private Integer ruleId;
- private Integer characteristicId;
private Long developerId;
// TODO to delete – not in db
@@ -202,16 +201,6 @@ public class MeasureDto {
}
@CheckForNull
- public Integer getCharacteristicId() {
- return characteristicId;
- }
-
- public MeasureDto setCharacteristicId(@Nullable Integer characteristicId) {
- this.characteristicId = characteristicId;
- return this;
- }
-
- @CheckForNull
public Long getDeveloperId() {
return developerId;
}
@@ -249,7 +238,6 @@ public class MeasureDto {
.add("snapshotId", snapshotId)
.add("metricId", metricId)
.add("ruleId", ruleId)
- .add("characteristicId", characteristicId)
.add("developerId", developerId)
.add("metricKey", metricKey)
.toString();
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java b/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
index b45122b5098..7f32a678832 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
@@ -29,7 +29,6 @@ public class PastMeasureDto {
private Double value;
private Integer metricId;
private Integer ruleId;
- private Integer characteristicId;
private Integer personId;
public Long getId() {
@@ -65,16 +64,6 @@ public class PastMeasureDto {
}
@CheckForNull
- public Integer getCharacteristicId() {
- return characteristicId;
- }
-
- public PastMeasureDto setCharacteristicId(@Nullable Integer characteristicId) {
- this.characteristicId = characteristicId;
- return this;
- }
-
- @CheckForNull
public Integer getPersonId() {
return personId;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
index ec8ebbc2ba8..14aa4f3b3d7 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
public class DatabaseVersion {
- public static final int LAST_VERSION = 1101;
+ public static final int LAST_VERSION = 1103;
/**
* The minimum supported version which can be upgraded. Lower
@@ -52,7 +52,6 @@ public class DatabaseVersion {
"authors",
"ce_activity",
"ce_queue",
- "characteristics",
"dashboards",
"duplications_index",
"events",
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
index 1c472d444fb..6e9c1d24bf6 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
@@ -70,6 +70,7 @@ import org.sonar.db.version.v54.MigrateUsersIdentity;
import org.sonar.db.version.v54.RemoveComponentPageProperties;
import org.sonar.db.version.v54.RemovePreviewPermission;
import org.sonar.db.version.v55.AddRulesLongDateColumns;
+import org.sonar.db.version.v55.DeleteMeasuresWithCharacteristicId;
import org.sonar.db.version.v55.FeedRulesLongDateColumns;
public class MigrationStepModule extends Module {
@@ -139,7 +140,8 @@ public class MigrationStepModule extends Module {
// 5.5
AddRulesLongDateColumns.class,
- FeedRulesLongDateColumns.class
+ FeedRulesLongDateColumns.class,
+ DeleteMeasuresWithCharacteristicId.class
);
}
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicId.java b/sonar-db/src/main/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicId.java
new file mode 100644
index 00000000000..9e835b71d3a
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicId.java
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.Select;
+import org.sonar.db.version.SqlStatement;
+
+public class DeleteMeasuresWithCharacteristicId extends BaseDataChange {
+
+ public DeleteMeasuresWithCharacteristicId(Database db) {
+ super(db);
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("SELECT id FROM project_measures WHERE characteristic_id IS NOT NULL");
+ massUpdate.update("DELETE FROM project_measures WHERE id=?");
+ massUpdate.rowPluralName("measures with characteristic");
+ massUpdate.execute(new MigrationHandler());
+ }
+
+ private static class MigrationHandler implements MassUpdate.Handler {
+
+ @Override
+ public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+ Long id = row.getNullableLong(1);
+ update.setLong(1, id);
+ return true;
+ }
+ }
+
+}
diff --git a/sonar-db/src/main/resources/org/sonar/db/debt/CharacteristicMapper.xml b/sonar-db/src/main/resources/org/sonar/db/debt/CharacteristicMapper.xml
deleted file mode 100644
index a5f7aa7848a..00000000000
--- a/sonar-db/src/main/resources/org/sonar/db/debt/CharacteristicMapper.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd">
-
-<mapper namespace="org.sonar.db.debt.CharacteristicMapper">
-
- <sql id="characteristicColumns">
- c.id,
- c.kee as kee,
- c.name as name,
- c.parent_id as parentId,
- c.characteristic_order as characteristicOrder,
- c.enabled as enabled,
- c.created_at as createdAt,
- c.updated_at as updatedAt
- </sql>
-
- <select id="selectEnabledCharacteristics" parameterType="map" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- where c.enabled=${_true}
- </select>
-
- <select id="selectCharacteristics" parameterType="map" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- </select>
-
- <select id="selectEnabledRootCharacteristics" parameterType="map" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.parent_id is null
- and c.enabled=${_true}
- </where>
- order by characteristic_order asc
- </select>
-
- <select id="selectCharacteristicsByParentId" parameterType="map" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.parent_id=#{parent_id}
- and c.enabled=${_true}
- </where>
- </select>
-
- <select id="selectCharacteristicsByIds" parameterType="map" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.enabled=${_true}
- AND (<foreach item="id" index="index" collection="ids" open="(" separator=" or " close=")">c.id=#{id}</foreach>)
- </where>
- </select>
-
- <select id="selectByKey" parameterType="String" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.kee=#{key}
- and c.enabled=${_true}
- </where>
- </select>
-
- <select id="selectById" parameterType="Integer" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.id=#{id}
- and c.enabled=${_true}
- </where>
- </select>
-
- <select id="selectByName" parameterType="String" resultType="Characteristic">
- select
- <include refid="characteristicColumns"/>
- from characteristics c
- <where>
- and c.name=#{name}
- and c.enabled=${_true}
- </where>
- </select>
-
- <select id="selectMaxCharacteristicOrder" resultType="Integer">
- select max(c.characteristic_order)
- from characteristics c
- <where>
- and c.parent_id is null
- and c.enabled=${_true}
- </where>
- </select>
-
- <insert id="insert" parameterType="Characteristic" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
- INSERT INTO characteristics (kee, name, parent_id, characteristic_order, enabled, created_at, updated_at)
- VALUES (#{kee,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
- #{characteristicOrder,jdbcType=INTEGER}, #{enabled,jdbcType=BOOLEAN}, #{createdAt,jdbcType=TIMESTAMP},
- #{updatedAt,jdbcType=TIMESTAMP})
- </insert>
-
- <update id="update" parameterType="Characteristic">
- update characteristics set
- name=#{name},
- parent_id=#{parentId},
- characteristic_order=#{characteristicOrder},
- enabled=#{enabled},
- updated_at=#{updatedAt}
- where id=#{id}
- </update>
-
- <select id="selectDeprecatedRequirements" resultType="RequirementMigration">
- select id as "id",
- parent_id as "parentId",
- root_id as "rootId",
- rule_id as "ruleId",
- function_key as "functionKey",
- factor_value as "coefficientValue",
- factor_unit as "coefficientUnit",
- offset_value as "offsetValue",
- offset_unit as "offsetUnit",
- enabled as "enabled"
- from characteristics
- where rule_id IS NOT NULL
- </select>
-
- <delete id="deleteRequirementsFromCharacteristicsTable">
- DELETE FROM characteristics WHERE rule_id IS NOT NULL
- </delete>
-</mapper>
-
diff --git a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
index 93a1fa7c7d8..d0747a1a205 100644
--- a/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/measure/MeasureMapper.xml
@@ -6,7 +6,6 @@
pm.id,
pm.metric_id as metricId,
pm.rule_id as ruleId,
- pm.characteristic_id as characteristicId,
pm.person_id as developerId,
pm.snapshot_id as snapshotId,
pm.value as value,
@@ -163,7 +162,7 @@
<select id="selectByComponentUuidAndProjectSnapshotIdAndStatusAndMetricIds" parameterType="map"
resultType="org.sonar.db.measure.PastMeasureDto">
- SELECT pm.id as id, pm.metric_id as metricId, pm.rule_id as ruleId, pm.characteristic_id as characteristicId,
+ SELECT pm.id as id, pm.metric_id as metricId, pm.rule_id as ruleId,
pm.person_id as personId, pm.value as value
FROM project_measures pm
INNER JOIN snapshots s ON s.id=pm.snapshot_id AND s.status=#{status}
@@ -182,13 +181,13 @@
<insert id="insert" parameterType="Measure" useGeneratedKeys="false">
INSERT INTO project_measures (
value, metric_id, snapshot_id, rule_id, text_value, project_id, alert_status, alert_text, description,
- characteristic_id, person_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4,
+ person_id, variation_value_1, variation_value_2, variation_value_3, variation_value_4,
variation_value_5, measure_data)
VALUES (
#{value, jdbcType=DOUBLE}, #{metricId, jdbcType=INTEGER}, #{snapshotId, jdbcType=INTEGER},
#{ruleId, jdbcType=INTEGER}, #{textValue, jdbcType=VARCHAR},
#{componentId, jdbcType=INTEGER}, #{alertStatus, jdbcType=VARCHAR}, #{alertText, jdbcType=VARCHAR},
- #{description, jdbcType=VARCHAR}, #{characteristicId, jdbcType=INTEGER},
+ #{description, jdbcType=VARCHAR},
#{developerId, jdbcType=INTEGER}, #{variation1, jdbcType=DOUBLE}, #{variation2, jdbcType=DOUBLE},
#{variation3, jdbcType=DOUBLE},
#{variation4, jdbcType=DOUBLE}, #{variation5, jdbcType=DOUBLE}, #{dataValue, jdbcType=BINARY}
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
index 0d25eca3ba1..94bc2592c1c 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
+++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
@@ -379,6 +379,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1015');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1017');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1100');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1101');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1102');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1103');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
index 37bcdbd716a..2889c1496a2 100644
--- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
+++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
@@ -3,24 +3,6 @@ CREATE TABLE "GROUPS_USERS" (
"GROUP_ID" INTEGER
);
-CREATE TABLE "CHARACTERISTICS" (
- "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
- "KEE" VARCHAR(100),
- "NAME" VARCHAR(100),
- "PARENT_ID" INTEGER,
- "ROOT_ID" INTEGER,
- "RULE_ID" INTEGER,
- "FUNCTION_KEY" VARCHAR(100),
- "FACTOR_VALUE" DOUBLE,
- "FACTOR_UNIT" VARCHAR(100),
- "OFFSET_VALUE" DOUBLE,
- "OFFSET_UNIT" VARCHAR(100),
- "CHARACTERISTIC_ORDER" INTEGER,
- "ENABLED" BOOLEAN,
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP
-);
-
CREATE TABLE "RULES_PARAMETERS" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"RULE_ID" INTEGER NOT NULL,
@@ -693,8 +675,6 @@ CREATE UNIQUE INDEX "UNIQ_GROUP_ROLES" ON "GROUP_ROLES" ("GROUP_ID", "RESOURCE_I
CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES" ("PLUGIN_NAME", "PLUGIN_RULE_KEY");
-CREATE INDEX "CHARACTERISTICS_ENABLED" ON "CHARACTERISTICS" ("ENABLED");
-
CREATE UNIQUE INDEX "UNIQ_QUALITY_GATES" ON "QUALITY_GATES" ("NAME");
CREATE UNIQUE INDEX "ACTIVE_RULES_UNIQUE" ON "ACTIVE_RULES" ("PROFILE_ID","RULE_ID");
diff --git a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
index 7e5f79e1d22..61215aa8b3a 100644
--- a/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/DaoModuleTest.java
@@ -29,6 +29,6 @@ public class DaoModuleTest {
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new DaoModule().configure(container);
- assertThat(container.size()).isEqualTo(49);
+ assertThat(container.size()).isEqualTo(48);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDaoTest.java b/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDaoTest.java
deleted file mode 100644
index a8a8e11fa37..00000000000
--- a/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDaoTest.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.debt;
-
-import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.test.DbTests;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Category(DbTests.class)
-public class CharacteristicDaoTest {
-
- private static final String[] EXCLUDED_COLUMNS = new String[] {"id", "root_id", "rule_id", "function_key", "factor_unit", "factor_value", "offset_unit", "offset_value"};
-
- @Rule
- public DbTester db = DbTester.create(System2.INSTANCE);
-
- CharacteristicDao dao = db.getDbClient().debtCharacteristicDao();
-
- @Test
- public void select_enabled_characteristics() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- List<CharacteristicDto> dtos = dao.selectEnabledCharacteristics();
-
- assertThat(dtos).hasSize(2);
-
- CharacteristicDto rootCharacteristic = dtos.get(0);
- assertThat(rootCharacteristic.getId()).isEqualTo(1);
- assertThat(rootCharacteristic.getKey()).isEqualTo("PORTABILITY");
- assertThat(rootCharacteristic.getName()).isEqualTo("Portability");
- assertThat(rootCharacteristic.getParentId()).isNull();
- assertThat(rootCharacteristic.getOrder()).isEqualTo(1);
- assertThat(rootCharacteristic.isEnabled()).isTrue();
- assertThat(rootCharacteristic.getCreatedAt()).isNotNull();
- assertThat(rootCharacteristic.getUpdatedAt()).isNotNull();
-
- CharacteristicDto characteristic = dtos.get(1);
- assertThat(characteristic.getId()).isEqualTo(2);
- assertThat(characteristic.getKey()).isEqualTo("COMPILER_RELATED_PORTABILITY");
- assertThat(characteristic.getName()).isEqualTo("Compiler related portability");
- assertThat(characteristic.getParentId()).isEqualTo(1);
- assertThat(characteristic.getOrder()).isNull();
- assertThat(characteristic.isEnabled()).isTrue();
- assertThat(characteristic.getCreatedAt()).isNotNull();
- assertThat(characteristic.getUpdatedAt()).isNotNull();
- }
-
- @Test
- public void select_characteristics() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectCharacteristics()).hasSize(4);
- }
-
- @Test
- public void select_enabled_root_characteristics() {
- db.prepareDbUnit(getClass(), "select_enabled_root_characteristics.xml");
-
- List<CharacteristicDto> dtos = dao.selectEnabledRootCharacteristics();
-
- assertThat(dtos).hasSize(1);
-
- CharacteristicDto rootCharacteristic = dtos.get(0);
- assertThat(rootCharacteristic.getId()).isEqualTo(1);
- assertThat(rootCharacteristic.getKey()).isEqualTo("PORTABILITY");
- }
-
- @Test
- public void select_enabled_root_characteristics_order_by_characteristic_order() {
- db.prepareDbUnit(getClass(), "select_enabled_root_characteristics_order_by_characteristic_order.xml");
-
- List<CharacteristicDto> dtos = dao.selectEnabledRootCharacteristics();
-
- assertThat(dtos).hasSize(3);
- assertThat(dtos.get(0).getKey()).isEqualTo("TESTABILITY");
- assertThat(dtos.get(1).getKey()).isEqualTo("PORTABILITY");
- assertThat(dtos.get(2).getKey()).isEqualTo("MAINTAINABILITY");
- }
-
- @Test
- public void select_sub_characteristics_by_parent_id() {
- db.prepareDbUnit(getClass(), "select_sub_characteristics_by_parent_id.xml");
-
- assertThat(dao.selectCharacteristicsByParentId(1)).hasSize(2);
- assertThat(dao.selectCharacteristicsByParentId(55)).isEmpty();
- }
-
- @Test
- public void select_characteristics_by_ids() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectCharacteristicsByIds(newArrayList(1, 2))).hasSize(2);
- assertThat(dao.selectCharacteristicsByIds(newArrayList(1))).hasSize(1);
-
- // Disabled characteristics are not returned
- assertThat(dao.selectCharacteristicsByIds(newArrayList(4, 5))).isEmpty();
- }
-
- @Test
- public void select_characteristic_by_key() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- CharacteristicDto dto = dao.selectByKey("COMPILER_RELATED_PORTABILITY");
- assertThat(dto).isNotNull();
- assertThat(dto.getId()).isEqualTo(2);
- assertThat(dto.getParentId()).isEqualTo(1);
-
- dto = dao.selectByKey("PORTABILITY");
- assertThat(dto).isNotNull();
- assertThat(dto.getId()).isEqualTo(1);
- assertThat(dto.getParentId()).isNull();
-
- assertThat(dao.selectByKey("UNKNOWN")).isNull();
- }
-
- @Test
- public void select_characteristic_by_name() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectByName("Portability")).isNotNull();
- assertThat(dao.selectByName("Compiler related portability")).isNotNull();
- assertThat(dao.selectByName("Unknown")).isNull();
- }
-
- @Test
- public void select_characteristic_by_id() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectById(2)).isNotNull();
- assertThat(dao.selectById(1)).isNotNull();
-
- assertThat(dao.selectById(10)).isNull();
- }
-
- @Test
- public void select_max_characteristic_order() {
- db.prepareDbUnit(getClass(), "shared.xml");
-
- assertThat(dao.selectMaxCharacteristicOrder()).isEqualTo(1);
- }
-
- @Test
- public void select_max_characteristic_order_when_characteristics_are_all_disabled() {
- db.prepareDbUnit(getClass(), "select_max_characteristic_order_when_characteristics_are_all_disabled.xml");
-
- assertThat(dao.selectMaxCharacteristicOrder()).isEqualTo(0);
- }
-
- @Test
- public void insert_characteristic() {
- db.truncateTables();
-
- CharacteristicDto dto = new CharacteristicDto()
- .setKey("COMPILER_RELATED_PORTABILITY")
- .setName("Compiler related portability")
- .setOrder(1)
- .setEnabled(true)
- .setCreatedAt(DateUtils.parseDate("2013-11-20"));
-
- dao.insert(dto);
- db.getSession().commit();
-
- db.assertDbUnit(getClass(), "insert_characteristic-result.xml", EXCLUDED_COLUMNS, "characteristics");
- }
-
- @Test
- public void insert_characteristics() {
- db.truncateTables();
-
- dao.insert(db.getSession(), new CharacteristicDto()
- .setKey("COMPILER_RELATED_PORTABILITY")
- .setName("Compiler related portability")
- .setOrder(1)
- .setEnabled(true)
- .setCreatedAt(DateUtils.parseDate("2013-11-20")),
- new CharacteristicDto()
- .setKey("PORTABILITY")
- .setName("portability")
- .setOrder(2)
- .setEnabled(true)
- .setCreatedAt(DateUtils.parseDate("2013-11-20")));
- db.getSession().commit();
-
- assertThat(db.countRowsOfTable("characteristics")).isEqualTo(2);
- }
-
- @Test
- public void update_characteristic() {
- db.prepareDbUnit(getClass(), "update_characteristic.xml");
-
- CharacteristicDto dto = new CharacteristicDto()
- .setId(1)
- // The Key should not be changed
- .setKey("NEW_KEY")
- .setName("New name")
- .setOrder(2)
- // Created date should not changed
- .setCreatedAt(DateUtils.parseDate("2013-11-22"))
- .setUpdatedAt(DateUtils.parseDate("2014-03-19"))
- .setEnabled(false);
-
- dao.update(dto);
- db.getSession().commit();
-
- db.assertDbUnit(getClass(), "update_characteristic-result.xml", EXCLUDED_COLUMNS, "characteristics");
- }
-
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDtoTest.java b/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDtoTest.java
deleted file mode 100644
index 8c72b0543a5..00000000000
--- a/sonar-db/src/test/java/org/sonar/db/debt/CharacteristicDtoTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.db.debt;
-
-import java.util.Date;
-import org.junit.Test;
-import org.sonar.api.technicaldebt.batch.internal.DefaultCharacteristic;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CharacteristicDtoTest {
-
- @Test
- public void to_dto_from_characteristic() {
- DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic()
- .setId(1)
- .setKey("MEMORY_EFFICIENCY")
- .setName("Memory use");
-
- DefaultCharacteristic characteristic = new DefaultCharacteristic()
- .setId(2)
- .setKey("EFFICIENCY")
- .setName("Efficiency")
- .setParent(rootCharacteristic)
- .setOrder(5)
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date());
-
- CharacteristicDto dto = CharacteristicDto.toDto(characteristic, 1);
- assertThat(dto.getId()).isNull();
- assertThat(dto.getParentId()).isEqualTo(1);
- assertThat(dto.getKey()).isEqualTo("EFFICIENCY");
- assertThat(dto.getName()).isEqualTo("Efficiency");
- assertThat(dto.getOrder()).isEqualTo(5);
- assertThat(dto.isEnabled()).isTrue();
- assertThat(dto.getCreatedAt()).isNotNull();
- assertThat(dto.getUpdatedAt()).isNotNull();
- }
-
- @Test
- public void to_characteristic() {
- DefaultCharacteristic rootCharacteristic = new DefaultCharacteristic()
- .setId(1)
- .setKey("MEMORY_EFFICIENCY")
- .setName("Memory use");
-
- CharacteristicDto dto = new CharacteristicDto()
- .setId(2)
- .setParentId(1)
- .setKey("EFFICIENCY")
- .setName("Efficiency")
- .setOrder(5)
- .setEnabled(false)
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date());
-
- DefaultCharacteristic characteristic = dto.toCharacteristic(rootCharacteristic);
- assertThat(characteristic.id()).isEqualTo(2);
- assertThat(characteristic.parent()).isEqualTo(rootCharacteristic);
- assertThat(characteristic.key()).isEqualTo("EFFICIENCY");
- assertThat(characteristic.name()).isEqualTo("Efficiency");
- assertThat(characteristic.order()).isEqualTo(5);
- assertThat(characteristic.createdAt()).isNotNull();
- assertThat(characteristic.updatedAt()).isNotNull();
- }
-}
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
index 75111ceb92c..37c53d4bde0 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureDaoTest.java
@@ -184,7 +184,6 @@ public class MeasureDaoTest {
assertThat(fileMeasure1.getValue()).isEqualTo(5d);
assertThat(fileMeasure1.getMetricId()).isEqualTo(1);
assertThat(fileMeasure1.getRuleId()).isNull();
- assertThat(fileMeasure1.getCharacteristicId()).isNull();
assertThat(fileMeasure1.getPersonId()).isNull();
PastMeasureDto fileMeasure2 = fileMeasures.get(6L);
@@ -221,52 +220,18 @@ public class MeasureDaoTest {
assertThat(measure1.getValue()).isEqualTo(60d);
assertThat(measure1.getMetricId()).isEqualTo(1);
assertThat(measure1.getRuleId()).isNull();
- assertThat(measure1.getCharacteristicId()).isNull();
assertThat(measure1.getPersonId()).isNull();
PastMeasureDto measure2 = pastMeasuresById.get(2L);
assertThat(measure2.getValue()).isEqualTo(20d);
assertThat(measure2.getMetricId()).isEqualTo(1);
assertThat(measure2.getRuleId()).isEqualTo(30);
- assertThat(measure2.getCharacteristicId()).isNull();
assertThat(measure2.getPersonId()).isNull();
PastMeasureDto measure3 = pastMeasuresById.get(3L);
assertThat(measure3.getValue()).isEqualTo(40d);
assertThat(measure3.getMetricId()).isEqualTo(1);
assertThat(measure3.getRuleId()).isEqualTo(31);
- assertThat(measure3.getCharacteristicId()).isNull();
- assertThat(measure3.getPersonId()).isNull();
- }
-
- @Test
- public void select_past_measures_on_characteristic_by_component_uuid_and_root_snapshot_id_and_metric_keys() {
- db.prepareDbUnit(getClass(), "past_measures_with_characteristic_id.xml");
-
- List<PastMeasureDto> measures = underTest.selectByComponentUuidAndProjectSnapshotIdAndMetricIds(dbSession, "ABCD", 1000L, ImmutableSet.of(1));
- assertThat(measures).hasSize(3);
-
- Map<Long, PastMeasureDto> pastMeasuresById = pastMeasuresById(measures);
-
- PastMeasureDto measure1 = pastMeasuresById.get(1L);
- assertThat(measure1.getValue()).isEqualTo(60d);
- assertThat(measure1.getMetricId()).isEqualTo(1);
- assertThat(measure1.getRuleId()).isNull();
- assertThat(measure1.getCharacteristicId()).isNull();
- assertThat(measure1.getPersonId()).isNull();
-
- PastMeasureDto measure2 = pastMeasuresById.get(2L);
- assertThat(measure2.getValue()).isEqualTo(20d);
- assertThat(measure2.getMetricId()).isEqualTo(1);
- assertThat(measure2.getRuleId()).isNull();
- assertThat(measure2.getCharacteristicId()).isEqualTo(10);
- assertThat(measure2.getPersonId()).isNull();
-
- PastMeasureDto measure3 = pastMeasuresById.get(3L);
- assertThat(measure3.getValue()).isEqualTo(40d);
- assertThat(measure3.getMetricId()).isEqualTo(1);
- assertThat(measure3.getRuleId()).isNull();
- assertThat(measure3.getCharacteristicId()).isEqualTo(11);
assertThat(measure3.getPersonId()).isNull();
}
@@ -320,19 +285,6 @@ public class MeasureDaoTest {
}
@Test
- public void select_by_snapshot_and_metric_keys_return_measures_with_characteristic_id() throws Exception {
- db.prepareDbUnit(getClass(), "select_by_snapshot_and_metric_keys_with_characteristic_id.xml");
-
- List<MeasureDto> results = underTest.selectBySnapshotIdAndMetricKeys(SNAPSHOT_ID, newHashSet("ncloc"), dbSession);
- assertThat(results).hasSize(3);
-
- Map<Long, MeasureDto> measuresById = measuresById(results);
- assertThat(measuresById.get(1L).getCharacteristicId()).isNull();
- assertThat(measuresById.get(2L).getCharacteristicId()).isEqualTo(10);
- assertThat(measuresById.get(3L).getCharacteristicId()).isEqualTo(11);
- }
-
- @Test
public void selectByDeveloperForSnapshotAndMetrics_when_there_is_no_measure_for_developer_returns_empty() {
db.prepareDbUnit(getClass(), "shared.xml");
@@ -516,7 +468,6 @@ public class MeasureDaoTest {
underTest.insert(dbSession, new MeasureDto()
.setSnapshotId(2L)
.setMetricId(3)
- .setCharacteristicId(4)
.setDeveloperId(23L)
.setRuleId(5)
.setComponentId(6L)
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java b/sonar-db/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java
index cba3b079bc0..4a6325ee390 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/PastMeasureDtoTest.java
@@ -32,7 +32,6 @@ public class PastMeasureDtoTest {
.setValue(1d)
.setMetricId(2)
.setRuleId(3)
- .setCharacteristicId(4)
.setPersonId(5);
assertThat(dto.getId()).isEqualTo(10L);
@@ -40,7 +39,6 @@ public class PastMeasureDtoTest {
assertThat(dto.getValue()).isEqualTo(1d);
assertThat(dto.getMetricId()).isEqualTo(2);
assertThat(dto.getRuleId()).isEqualTo(3);
- assertThat(dto.getCharacteristicId()).isEqualTo(4);
assertThat(dto.getPersonId()).isEqualTo(5);
}
@@ -51,7 +49,6 @@ public class PastMeasureDtoTest {
.setValue(1d)
.setMetricId(2)
.setRuleId(3)
- .setCharacteristicId(4)
.setPersonId(5);
assertThat(measureWithValue.hasValue()).isTrue();
@@ -59,7 +56,6 @@ public class PastMeasureDtoTest {
.setId(10L)
.setMetricId(2)
.setRuleId(3)
- .setCharacteristicId(4)
.setPersonId(5);
assertThat(measureWithoutValue.hasValue()).isFalse();
}
diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
index 4050f3286e7..3d1e2daaeb2 100644
--- a/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
@@ -117,8 +117,6 @@ public class RuleDaoTest {
assertThat(ruleDto.getStatus()).isEqualTo(RuleStatus.READY);
assertThat(ruleDto.getRepositoryKey()).isEqualTo("checkstyle");
assertThat(ruleDto.getNoteData()).isEqualTo("Rule note with accents \u00e9\u00e8\u00e0");
- assertThat(ruleDto.getSubCharacteristicId()).isEqualTo(100);
- assertThat(ruleDto.getDefaultSubCharacteristicId()).isEqualTo(101);
assertThat(ruleDto.getRemediationFunction()).isEqualTo("LINEAR");
assertThat(ruleDto.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
assertThat(ruleDto.getRemediationCoefficient()).isEqualTo("1h");
diff --git a/sonar-db/src/test/java/org/sonar/db/rule/RuleDtoTest.java b/sonar-db/src/test/java/org/sonar/db/rule/RuleDtoTest.java
index 37852847722..8c7227c9f9f 100644
--- a/sonar-db/src/test/java/org/sonar/db/rule/RuleDtoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/rule/RuleDtoTest.java
@@ -28,46 +28,13 @@ import org.junit.rules.ExpectedException;
import static org.apache.commons.lang.StringUtils.repeat;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.rule.RuleDto.DISABLED_CHARACTERISTIC_ID;
public class RuleDtoTest {
- public static final int FAKE_SUB_CHAR_1 = 27;
- public static final int FAKE_SUB_CHAR_2 = 42;
-
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
- public void effective_sub_characteristic_id() {
- RuleDto dto = new RuleDto();
-
- // characteristic is not set
- dto.setSubCharacteristicId(null).setDefaultSubCharacteristicId(null);
- assertThat(dto.getEffectiveSubCharacteristicId()).isNull();
-
- // default characteristic is set
- dto.setSubCharacteristicId(null).setDefaultSubCharacteristicId(FAKE_SUB_CHAR_2);
- assertThat(dto.getEffectiveSubCharacteristicId()).isEqualTo(FAKE_SUB_CHAR_2);
-
- // default characteristic is set to "none"
- dto.setSubCharacteristicId(null).setDefaultSubCharacteristicId(DISABLED_CHARACTERISTIC_ID);
- assertThat(dto.getEffectiveSubCharacteristicId()).isNull();
-
- // characteristic is overridden
- dto.setSubCharacteristicId(FAKE_SUB_CHAR_1).setDefaultSubCharacteristicId(FAKE_SUB_CHAR_2);
- assertThat(dto.getEffectiveSubCharacteristicId()).isEqualTo(FAKE_SUB_CHAR_1);
-
- // characteristic is set, no defaults
- dto.setSubCharacteristicId(FAKE_SUB_CHAR_1).setDefaultSubCharacteristicId(null);
- assertThat(dto.getEffectiveSubCharacteristicId()).isEqualTo(FAKE_SUB_CHAR_1);
-
- // characteristic is set to "none"
- dto.setSubCharacteristicId(DISABLED_CHARACTERISTIC_ID).setDefaultSubCharacteristicId(FAKE_SUB_CHAR_2);
- assertThat(dto.getEffectiveSubCharacteristicId()).isNull();
- }
-
- @Test
public void fail_if_key_is_too_long() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Rule key is too long: ");
diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
index a3153c66f31..599f12c04a4 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
public void verify_count_of_added_MigrationStep_types() {
ComponentContainer container = new ComponentContainer();
new MigrationStepModule().configure(container);
- assertThat(container.size()).isEqualTo(53);
+ assertThat(container.size()).isEqualTo(54);
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest.java
new file mode 100644
index 00000000000..8ec3c42fd99
--- /dev/null
+++ b/sonar-db/src/test/java/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest.java
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.version.v55;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.db.version.MigrationStep;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DeleteMeasuresWithCharacteristicIdTest {
+
+ @Rule
+ public DbTester db = DbTester.createForSchema(System2.INSTANCE, DeleteMeasuresWithCharacteristicIdTest.class, "schema.sql");
+
+ MigrationStep migration;
+
+ @Before
+ public void setUp() {
+ migration = new DeleteMeasuresWithCharacteristicId(db.database());
+ }
+
+ @Test
+ public void delete_measures_with_characteristic_id() throws Exception {
+ db.prepareDbUnit(getClass(), "before.xml");
+
+ migration.execute();
+
+ List<Map<String, Object>> rows = db.select("select id from project_measures");
+ assertThat(rows).hasSize(1);
+ assertThat(rows.get(0).get("ID")).isEqualTo(10L);
+ }
+
+}
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/insert_characteristic-result.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/insert_characteristic-result.xml
deleted file mode 100644
index f0ac4524f65..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/insert_characteristic-result.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<dataset>
-
- <characteristics id="1" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="[null]"
- characteristic_order="1" enabled="[true]"
- created_at="2013-11-20" updated_at="[null]"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics.xml
deleted file mode 100644
index 8a6e7472bc4..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<dataset>
-
- <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <characteristics id="2" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="1"
- characteristic_order="[null]"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- requirement -->
- <characteristics id="3" kee="[null]" name="[null]" parent_id="2" rule_id="1"
- function_key="linear_offset" factor_value="20.0" factor_unit="mn" offset_value="30.0" offset_unit="h"
- enabled="[true]"
- created_at="2013-11-20" updated_at="[null]"/>
-
- <!-- disabled characteristics -->
- <characteristics id="4" kee="DISABLED_CHARACTERISTIC" name="Disabled characteristic" parent_id="1"
- characteristic_order="2"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics_order_by_characteristic_order.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics_order_by_characteristic_order.xml
deleted file mode 100644
index 59f106fe411..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_enabled_root_characteristics_order_by_characteristic_order.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<dataset>
-
- <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="2"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <characteristics id="2" kee="TESTABILITY" name="Testability" parent_id="[null]" characteristic_order="1"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <characteristics id="3" kee="MAINTAINABILITY" name="Maintainability" parent_id="[null]" characteristic_order="4"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_max_characteristic_order_when_characteristics_are_all_disabled.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_max_characteristic_order_when_characteristics_are_all_disabled.xml
deleted file mode 100644
index d703591428a..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_max_characteristic_order_when_characteristics_are_all_disabled.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<dataset>
-
- <!-- Disabled root characteristic -->
- <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Disabled root characteristic -->
- <characteristics id="2" kee="DISABLED_ROOT_CHARACTERISTIC" name="Disabled root characteristic" parent_id="[null]"
- characteristic_order="2"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_sub_characteristics_by_parent_id.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_sub_characteristics_by_parent_id.xml
deleted file mode 100644
index 60aa6d6fdfb..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/select_sub_characteristics_by_parent_id.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<dataset>
-
- <!-- Root characteristic -->
- <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Sub characteristics of root characteristic -->
- <characteristics id="2" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="1"
- characteristic_order="[null]"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
- <characteristics id="3" kee="HARDWARE_RELATED_PORTABILITY" name="Hardware related portability " parent_id="1"
- characteristic_order="[null]"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Other sub characteristic -->
- <characteristics id="4" kee="READABILITY" name="Readability" parent_id="5" characteristic_order="[null]"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Disabled root characteristic -->
- <characteristics id="10" kee="DISABLED_ROOT_CHARACTERISTIC" name="Disabled root characteristic" parent_id="[null]"
- characteristic_order="2"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Disabled characteristic -->
- <characteristics id="11" kee="DISABLED_CHARACTERISTIC" name="Disabled characteristic" parent_id="10"
- characteristic_order="[null]"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/shared.xml
deleted file mode 100644
index 284d01bed45..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/shared.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<dataset>
-
- <!-- Root characteristic -->
- <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Characteristic -->
- <characteristics id="2" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="1"
- characteristic_order="[null]"
- enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Disabled root characteristic -->
- <characteristics id="4" kee="DISABLED_ROOT_CHARACTERISTIC" name="Disabled root characteristic" parent_id="[null]"
- characteristic_order="2"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Disabled characteristic -->
- <characteristics id="5" kee="DISABLED_CHARACTERISTIC" name="Disabled characteristic" parent_id="4"
- characteristic_order="[null]"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic-result.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic-result.xml
deleted file mode 100644
index ff12f94cee6..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic-result.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<dataset>
-
- <characteristics id="1" kee="COMPILER_RELATED_PORTABILITY" name="New name" parent_id="[null]" characteristic_order="2"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2014-03-19"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic.xml b/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic.xml
deleted file mode 100644
index afa53fb186d..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/CharacteristicDaoTest/update_characteristic.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<dataset>
-
- <characteristics id="1" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="[null]"
- characteristic_order="1" enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-20"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/select_requirement.xml b/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/select_requirement.xml
deleted file mode 100644
index 1a71559a016..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/select_requirement.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<dataset>
-
- <!-- Requirement -->
- <characteristics id="3" kee="[null]" name="[null]" parent_id="2" root_id="1" rule_id="10"
- characteristic_order="[null]"
- function_key="linear_offset" factor_value="20.0" factor_unit="mn" offset_value="30.0" offset_unit="h"
- enabled="[true]"
- created_at="2013-11-20" updated_at="[null]"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/shared.xml
deleted file mode 100644
index 0ee097f0869..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/debt/RequirementDaoTest/shared.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<dataset>
-
- <!-- Requirement -->
- <characteristics id="3" kee="[null]" name="[null]" parent_id="2" root_id="1" rule_id="10"
- characteristic_order="[null]"
- function_key="linear_offset" factor_value="20.0" factor_unit="mn" offset_value="30.0" offset_unit="h"
- enabled="[true]"
- created_at="2013-11-20" updated_at="[null]"/>
-
- <!-- Disabled requirement -->
- <characteristics id="6" kee="[null]" name="[null]" parent_id="5" root_id="4" rule_id="10"
- characteristic_order="[null]"
- function_key="linear_offset" factor_value="30.0" factor_unit="mn" offset_value="20.0" offset_unit="h"
- enabled="[false]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml
index 26c55c5d3c4..eff8abfd5bd 100644
--- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/insert-result.xml
@@ -3,7 +3,7 @@
id="1"
snapshot_id="2"
metric_id="3"
- characteristic_id="4"
+ characteristic_id="[null]"
rule_id="5"
project_id="6"
person_id="23"
diff --git a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_characteristic_id.xml b/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_characteristic_id.xml
deleted file mode 100644
index 7e06f10c94c..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/measure/MeasureDaoTest/past_measures_with_characteristic_id.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<dataset>
-
- <metrics id="1" name="sqale_index" VAL_TYPE="WORK_DUR" DESCRIPTION="[null]" short_name="" enabled="[true]"/>
-
- <!-- Root characteristic -->
- <characteristics id="10" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1" enabled="[true]" created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- Characteristic -->
- <characteristics id="11" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="10" characteristic_order="[null]" enabled="[true]"
- created_at="2013-11-20" updated_at="2013-11-22"/>
-
- <!-- project -->
- <projects long_name="[null]" id="1" scope="PRJ" qualifier="TRK" kee="project" name="project"
- root_id="[null]" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path=".ABCD." enabled="[true]"/>
-
- <!-- snapshots -->
- <snapshots id="1000" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
- scope="PRJ" qualifier="TRK" created_at="1225544280000" build_date="1225544280000" version="[null]" path=""
- status="P" islast="[false]" depth="0"/>
-
- <!-- project measures -->
- <project_measures id="1" VALUE="60" METRIC_ID="1" SNAPSHOT_ID="1000" RULE_ID="[null]" characteristic_id="[null]"/>
-
- <project_measures id="2" VALUE="20" METRIC_ID="1" SNAPSHOT_ID="1000" RULE_ID="[null]" characteristic_id="10"/>
-
- <project_measures id="3" VALUE="40" METRIC_ID="1" SNAPSHOT_ID="1000" RULE_ID="[null]" characteristic_id="11"/>
-
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
index c59e34d5c8b..f326322849d 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml
@@ -10,10 +10,6 @@
worst_value="0" optimized_best_value="[true]" best_value="100"
direction="1" hidden="[false]"/>
- <characteristics id="1" kee="M1C1" name="M1C1" parent_id="[null]" characteristic_order="1" enabled="[true]"/>
- <characteristics id="2" kee="M1C2" name="M1C1" parent_id="1" characteristic_order="[null]" enabled="[true]"/>
- <characteristics id="3" kee="M1C3" name="M1C3" parent_id="2" characteristic_order="[null]" enabled="[true]"/>
-
<snapshots id="1"
project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
status="P" islast="[true]" purge_status="[null]"
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
index d4931b9a343..17c989e1392 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeCommandsTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml
@@ -10,10 +10,6 @@
worst_value="0" optimized_best_value="[true]" best_value="100"
direction="1" hidden="[false]"/>
- <characteristics id="1" kee="M1C1" name="M1C1" parent_id="[null]" characteristic_order="1" enabled="[true]"/>
- <characteristics id="2" kee="M1C2" name="M1C1" parent_id="1" characteristic_order="[null]" enabled="[true]"/>
- <characteristics id="3" kee="M1C3" name="M1C3" parent_id="2" characteristic_order="[null]" enabled="[true]"/>
-
<snapshots id="1"
project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
status="P" islast="[true]" purge_status="[null]"
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/before.xml b/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/before.xml
new file mode 100644
index 00000000000..0d2daea8464
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/before.xml
@@ -0,0 +1,7 @@
+<dataset>
+
+ <project_measures id="10" characteristic_id="[null]" metric_id="1"/>
+ <project_measures id="11" characteristic_id="10" metric_id="1" />
+ <project_measures id="12" characteristic_id="11" metric_id="1" />
+
+</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/schema.sql
new file mode 100644
index 00000000000..1aae50c211d
--- /dev/null
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/DeleteMeasuresWithCharacteristicIdTest/schema.sql
@@ -0,0 +1,25 @@
+CREATE TABLE "PROJECT_MEASURES" (
+ "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "VALUE" DOUBLE,
+ "METRIC_ID" INTEGER NOT NULL,
+ "SNAPSHOT_ID" INTEGER,
+ "RULE_ID" INTEGER,
+ "RULES_CATEGORY_ID" INTEGER,
+ "TEXT_VALUE" VARCHAR(4000),
+ "TENDENCY" INTEGER,
+ "MEASURE_DATE" TIMESTAMP,
+ "PROJECT_ID" INTEGER,
+ "ALERT_STATUS" VARCHAR(5),
+ "ALERT_TEXT" VARCHAR(4000),
+ "URL" VARCHAR(2000),
+ "DESCRIPTION" VARCHAR(4000),
+ "RULE_PRIORITY" INTEGER,
+ "CHARACTERISTIC_ID" INTEGER,
+ "PERSON_ID" INTEGER,
+ "VARIATION_VALUE_1" DOUBLE,
+ "VARIATION_VALUE_2" DOUBLE,
+ "VARIATION_VALUE_3" DOUBLE,
+ "VARIATION_VALUE_4" DOUBLE,
+ "VARIATION_VALUE_5" DOUBLE,
+ "MEASURE_DATA" BINARY(167772150)
+);