From 1d9115c677cb97dcb3433916b556d3f63da6de33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Mon, 11 Jul 2016 18:23:29 +0200 Subject: [PATCH] SONAR-7700 re-enable ignored UTs on PurgeDao --- .../java/org/sonar/db/purge/PurgeDaoTest.java | 24 +-- ...ources_of_specified_components-result.xml} | 43 ++++- ...files_sources_of_specified_components.xml} | 105 ++++++++++- ...e_sources_of_disabled_resources-result.xml | 25 --- ...ete_file_sources_of_disabled_resources.xml | 163 ------------------ 5 files changed, 144 insertions(+), 216 deletions(-) rename sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/{disable_resources_without_last_snapshot-result.xml => close_issues_clean_index_and_files_sources_of_specified_components-result.xml} (83%) rename sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/{disable_resources_without_last_snapshot.xml => close_issues_clean_index_and_files_sources_of_specified_components.xml} (64%) delete mode 100644 sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources-result.xml delete mode 100644 sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/delete_file_sources_of_disabled_resources.xml 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; @@ -76,15 +76,6 @@ public class PurgeDaoTest { dbTester.assertDbUnit(getClass(), "shouldPurgeProject-result.xml", "projects", "snapshots"); } - @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"); @@ -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 similarity index 83% rename from sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/disable_resources_without_last_snapshot-result.xml rename to 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]"/> + 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]"/> + 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]"/> + /> + /> + 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]"/> + 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]"/> + 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]"/> + + + + + + + + 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 @@ - - - - - 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 @@ - - - - - - - - - - - - - - - - - - - -- 2.39.5