aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/test
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/src/test
parent978f9e79abcf71dfc5f477dbce5456578f56fa6f (diff)
downloadsonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.tar.gz
sonarqube-d88d443bbe5c5dabe45b44760108fa7b506cd7d9.zip
SONAR-7364 Remove SQALE characteristics from measures and rules
Diffstat (limited to 'sonar-db/src/test')
-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
25 files changed, 91 insertions, 605 deletions
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)
+);