aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-11 18:23:29 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-07-11 18:45:29 +0200
commit1d9115c677cb97dcb3433916b556d3f63da6de33 (patch)
treeee68b2da4a7eb140af4f0eb20e106aa622123479 /sonar-db
parentc30742761f2ce2e3b469fe8792a51e9915451916 (diff)
downloadsonarqube-1d9115c677cb97dcb3433916b556d3f63da6de33.tar.gz
sonarqube-1d9115c677cb97dcb3433916b556d3f63da6de33.zip
SONAR-7700 re-enable ignored UTs on PurgeDao
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java24
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components-result.xml (renamed from sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml)43
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components.xml (renamed from sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml)105
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml25
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml163
5 files changed, 144 insertions, 216 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index 5870c075dca..c49dff51a20 100644
--- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -21,9 +21,9 @@ package org.sonar.db.purge;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -77,15 +77,6 @@ public class PurgeDaoTest {
}
@Test
- @Ignore("TODO")
- public void delete_file_sources_of_disabled_resources() {
- dbTester.prepareDbUnit(getClass(), "delete_file_sources_of_disabled_resources.xml");
- underTest.purge(dbSession, newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
- dbSession.commit();
- dbTester.assertDbUnit(getClass(), "delete_file_sources_of_disabled_resources-result.xml", "file_sources");
- }
-
- @Test
public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml");
PurgeConfiguration conf = new PurgeConfiguration(
@@ -98,13 +89,12 @@ public class PurgeDaoTest {
}
@Test
- @Ignore("TODO")
- public void disable_resources_without_last_snapshot() {
- dbTester.prepareDbUnit(getClass(), "disable_resources_without_last_snapshot.xml");
+ public void close_issues_clean_index_and_file_sources_of_disabled_components_specified_by_uuid_in_configuration() {
+ dbTester.prepareDbUnit(getClass(), "close_issues_clean_index_and_files_sources_of_specified_components.xml");
when(system2.now()).thenReturn(1450000000000L);
- underTest.purge(dbSession, newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
+ underTest.purge(dbSession, newConfigurationWith30Days(system2, "P1", "EFGH", "GHIJ"), PurgeListener.EMPTY, new PurgeProfiler());
dbSession.commit();
- dbTester.assertDbUnit(getClass(), "disable_resources_without_last_snapshot-result.xml",
+ dbTester.assertDbUnit(getClass(), "close_issues_clean_index_and_files_sources_of_specified_components-result.xml",
new String[] {"issue_close_date", "issue_update_date"},
"projects", "snapshots", "issues");
}
@@ -245,7 +235,7 @@ public class PurgeDaoTest {
return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, System2.INSTANCE, Collections.emptyList());
}
- private static PurgeConfiguration newConfigurationWith30Days(System2 system2) {
- return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, system2, Collections.emptyList());
+ private static PurgeConfiguration newConfigurationWith30Days(System2 system2, String... disabledComponentUuids) {
+ return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, system2, Arrays.asList(disabledComponentUuids));
}
}
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components-result.xml
index 4b60f0bf7f2..6cfae33701a 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components-result.xml
@@ -29,7 +29,18 @@ What has been changed :
authorization_updated_at="[null]"
id="1"
enabled="[false]"
- root_uuid="P1"/>
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<!-- the directory -->
<projects uuid="EFGH"
@@ -52,7 +63,18 @@ What has been changed :
authorization_updated_at="[null]"
id="2"
enabled="[false]"
- root_uuid="P1"/>
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<!-- the file -->
<projects uuid="GHIJ"
@@ -75,7 +97,18 @@ What has been changed :
authorization_updated_at="[null]"
id="3"
enabled="[false]"
- root_uuid="P1"/>
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<snapshots id="1"
uuid="u1"
@@ -101,7 +134,7 @@ What has been changed :
created_at="1228222680000"
build_date="1228222680000"
version="[null]"
- />
+ />
<!-- Open issue on file -->
<issues id="1"
@@ -131,7 +164,7 @@ What has been changed :
tags="[null]"
locations="[null]"
issue_type="[null]"
- />
+ />
<!-- Open issue on directory -->
<issues id="2"
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components.xml
index 3d6ad348b69..a2b5374ea9a 100644
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot.xml
+++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/close_issues_clean_index_and_files_sources_of_specified_components.xml
@@ -20,8 +20,19 @@
deprecated_kee="[null]"
authorization_updated_at="[null]"
id="1"
- enabled="[true]"
- root_uuid="P1"/>
+ enabled="[false]"
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<!-- the directory -->
<projects uuid="EFGH"
@@ -43,8 +54,19 @@
deprecated_kee="[null]"
authorization_updated_at="[null]"
id="2"
- enabled="[true]"
- root_uuid="P1"/>
+ enabled="[false]"
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<!-- the file -->
<projects uuid="GHIJ"
@@ -66,8 +88,19 @@
deprecated_kee="[null]"
authorization_updated_at="[null]"
id="3"
- enabled="[true]"
- root_uuid="P1"/>
+ enabled="[false]"
+ root_uuid="P1"
+ b_changed="[false]"
+ b_copy_component_uuid="[null]"
+ b_description="[null]"
+ b_enabled="[false]"
+ b_language="[null]"
+ b_long_name="[null]"
+ b_module_uuid="[null]"
+ b_module_uuid_path="[null]"
+ b_name="[null]"
+ b_path="[null]"
+ b_qualifier="[null]"/>
<snapshots id="1"
uuid="u1"
@@ -207,4 +240,64 @@
locations="[null]"
issue_type="[null]"/>
+ <file_sources id="1"
+ project_uuid="P1"
+ file_uuid="GHIJ"
+ binary_data="[null]"
+ line_hashes="[null]"
+ data_hash="321654987"
+ revision="123456789"
+ created_at="123456789"
+ updated_at="123456789"
+ src_hash="12345"
+ data_type="SOURCE"/>
+ <file_sources id="2"
+ project_uuid="P1"
+ file_uuid="KLMN"
+ binary_data="[null]"
+ line_hashes="[null]"
+ data_hash="321654988"
+ revision="123456789"
+ created_at="123456789"
+ updated_at="123456789"
+ src_hash="123456"
+ data_type="SOURCE"/>
+ <file_sources id="3"
+ project_uuid="P1"
+ file_uuid="GHIJ"
+ binary_data="[null]"
+ line_hashes="[null]"
+ data_hash="321654987"
+ revision="123456789"
+ created_at="123456789"
+ updated_at="123456789"
+ src_hash="12345"
+ data_type="TEST"/>
+ <file_sources id="4"
+ project_uuid="P1"
+ file_uuid="KLMN"
+ binary_data="[null]"
+ line_hashes="[null]"
+ data_hash="321654988"
+ revision="123456789"
+ created_at="123456789"
+ updated_at="123456789"
+ src_hash="123456"
+ data_type="TEST"/>
+
+ <resource_index id="1"
+ kee="project one"
+ component_uuid="P1"
+ root_component_uuid="P1"
+ position="0"
+ name_size="11"
+ qualifier="TRK"/>
+ <resource_index id="2"
+ kee="roject one"
+ component_uuid="P1"
+ root_component_uuid="P1"
+ position="1"
+ name_size="11"
+ qualifier="TRK"/>
+
</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
deleted file mode 100644
index 2deaffedd12..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<dataset>
-
- <file_sources id="2"
- project_uuid="P1"
- file_uuid="KLMN"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654988"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="123456"
- data_type="SOURCE"/>
- <file_sources id="4"
- project_uuid="P1"
- file_uuid="KLMN"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654988"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="123456"
- data_type="TEST"/>
-</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
deleted file mode 100644
index 8ea101b2d4c..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml
+++ /dev/null
@@ -1,163 +0,0 @@
-<dataset>
-
- <!-- the project -->
- <projects uuid="P1"
- uuid_path="."
- project_uuid="P1"
- module_uuid="[null]"
- module_uuid_path="."
- created_at="[null]"
- long_name="[null]"
- scope="PRJ"
- qualifier="TRK"
- kee="project"
- name="project"
- description="[null]"
- language="java"
- copy_component_uuid="[null]"
- developer_uuid="[null]"
- path="[null]"
- deprecated_kee="[null]"
- authorization_updated_at="[null]"
- id="1"
- enabled="[true]"
- root_uuid="P1"/>
-
- <!-- the directory -->
- <projects uuid="EFGH"
- uuid_path=".P1."
- project_uuid="P1"
- module_uuid="P1"
- module_uuid_path="."
- created_at="[null]"
- long_name="[null]"
- scope="DIR"
- qualifier="DIR"
- kee="project:my/dir"
- name="my/dir"
- description="[null]"
- language="java"
- copy_component_uuid="[null]"
- developer_uuid="[null]"
- path="[null]"
- deprecated_kee="[null]"
- authorization_updated_at="[null]"
- id="2"
- enabled="[true]"
- root_uuid="P1"/>
-
- <!-- the files -->
- <projects uuid="GHIJ"
- uuid_path=".P1.EFGH."
- project_uuid="P1"
- module_uuid="P1"
- module_uuid_path=".P1."
- created_at="[null]"
- long_name="[null]"
- scope="FIL"
- qualifier="FIL"
- kee="project:my/dir/File.java"
- name="my/dir/File.java"
- description="[null]"
- language="java"
- copy_component_uuid="[null]"
- developer_uuid="[null]"
- path="[null]"
- deprecated_kee="[null]"
- authorization_updated_at="[null]"
- id="3"
- enabled="[true]"
- root_uuid="P1"/>
- <projects uuid="KLMN"
- uuid_path=".P1.EFGH."
- project_uuid="P1"
- module_uuid="P1"
- module_uuid_path=".P1."
- created_at="[null]"
- long_name="[null]"
- scope="FIL"
- qualifier="FIL"
- kee="project:my/dir/DeletedFile.java"
- name="my/dir/DeletedFile.java"
- description="[null]"
- language="java"
- copy_component_uuid="[null]"
- developer_uuid="[null]"
- path="[null]"
- deprecated_kee="[null]"
- authorization_updated_at="[null]"
- id="4"
- enabled="[true]"
- root_uuid="P1"/>
-
- <snapshots id="1"
- uuid="u1"
- component_uuid="P1"
- status="P"
- islast="[false]"
- purge_status="[null]"
- period1_mode="[null]"
- period1_param="[null]"
- period1_date="[null]"
- period2_mode="[null]"
- period2_param="[null]"
- period2_date="[null]"
- period3_mode="[null]"
- period3_param="[null]"
- period3_date="[null]"
- period4_mode="[null]"
- period4_param="[null]"
- period4_date="[null]"
- period5_mode="[null]"
- period5_param="[null]"
- period5_date="[null]"
- created_at="1228222680000"
- build_date="1228222680000"
- version="[null]"
- />
-
- <file_sources id="1"
- project_uuid="P1"
- file_uuid="GHIJ"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654987"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="12345"
- data_type="SOURCE"/>
- <file_sources id="2"
- project_uuid="P1"
- file_uuid="KLMN"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654988"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="123456"
- data_type="SOURCE"/>
- <file_sources id="3"
- project_uuid="P1"
- file_uuid="GHIJ"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654987"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="12345"
- data_type="TEST"/>
- <file_sources id="4"
- project_uuid="P1"
- file_uuid="KLMN"
- binary_data="[null]"
- line_hashes="[null]"
- data_hash="321654988"
- revision="123456789"
- created_at="123456789"
- updated_at="123456789"
- src_hash="123456"
- data_type="TEST"/>
-</dataset>