]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9616 do not handle issues and file sources when purging view components
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 1 Aug 2017 15:34:19 +0000 (17:34 +0200)
committerJanos Gyerik <janos.gyerik@sonarsource.com>
Tue, 12 Sep 2017 08:55:10 +0000 (10:55 +0200)
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java

index 87cccc8862377eafa1df39a56ddd007b0ea9015f..ef9cdaa0013512bf79e0e8147c731fc9eba6ed49 100644 (file)
@@ -63,7 +63,7 @@ class PurgeCommands {
     profiler.stop();
 
     List<List<String>> analysisUuidsPartitions = Lists.partition(IdUuidPairs.uuids(purgeMapper.selectAnalysisIdsAndUuids(new PurgeSnapshotQuery().setComponentUuid(rootUuid))),
-        MAX_SNAPSHOTS_PER_QUERY);
+      MAX_SNAPSHOTS_PER_QUERY);
 
     deleteAnalysisDuplications(analysisUuidsPartitions);
 
@@ -80,8 +80,8 @@ class PurgeCommands {
 
   void deleteAnalyses(PurgeSnapshotQuery... queries) {
     List<IdUuidPair> snapshotIds = from(asList(queries))
-        .transformAndConcat(purgeMapper::selectAnalysisIdsAndUuids)
-        .toList();
+      .transformAndConcat(purgeMapper::selectAnalysisIdsAndUuids)
+      .toList();
     deleteAnalyses(snapshotIds);
   }
 
@@ -115,7 +115,7 @@ class PurgeCommands {
     profiler.start("deleteSnapshotWastedMeasures (project_measures)");
     List<Long> metricIdsWithoutHistoricalData = purgeMapper.selectMetricIdsWithoutHistoricalData();
     analysisUuidsPartitions
-        .forEach(analysisUuidsPartition -> purgeMapper.deleteAnalysisWastedMeasures(analysisUuidsPartition, metricIdsWithoutHistoricalData));
+      .forEach(analysisUuidsPartition -> purgeMapper.deleteAnalysisWastedMeasures(analysisUuidsPartition, metricIdsWithoutHistoricalData));
     session.commit();
     profiler.stop();
 
@@ -156,24 +156,6 @@ class PurgeCommands {
     profiler.stop();
   }
 
-  void deleteIssues(List<String> componentUuids) {
-    if (componentUuids.isEmpty()) {
-      return;
-    }
-
-    List<List<String>> uuidPartitions = Lists.partition(componentUuids, MAX_RESOURCES_PER_QUERY);
-
-    profiler.start("deleteIssues (issue_changes)");
-    uuidPartitions.forEach(purgeMapper::deleteIssueChangesByComponentUuids);
-    session.commit();
-    profiler.stop();
-
-    profiler.start("deleteIssues (issues)");
-    uuidPartitions.forEach(purgeMapper::deleteIssuesByComponentUuids);
-    session.commit();
-    profiler.stop();
-  }
-
   void deleteLinks(String rootUuid) {
     profiler.start("deleteLinks (project_links)");
     purgeMapper.deleteProjectLinksByComponentUuid(rootUuid);
@@ -246,17 +228,6 @@ class PurgeCommands {
     profiler.stop();
   }
 
-  void deleteFileSources(List<String> componentUuids) {
-    if (componentUuids.isEmpty()) {
-      return;
-    }
-
-    profiler.start("deleteFileSources (file_sources)");
-    Lists.partition(componentUuids, MAX_RESOURCES_PER_QUERY).forEach(purgeMapper::deleteFileSourcesByFileUuid);
-    session.commit();
-    profiler.stop();
-  }
-
   void deleteFileSources(String rootUuid) {
     profiler.start("deleteFileSources (file_sources)");
     purgeMapper.deleteFileSourcesByProjectUuid(rootUuid);
index a82a5c96cfa35bdab9b9be47d9a2cca9d231d1d0..369cd7db93b0ca74fe6b15e3e553f6ddfcac8e09 100644 (file)
@@ -42,18 +42,12 @@ import static java.util.Collections.emptyList;
 import static org.sonar.api.utils.DateUtils.dateToLong;
 import static org.sonar.db.DatabaseUtils.executeLargeInputs;
 
-/**
- * @since 2.14
- */
 public class PurgeDao implements Dao {
   private static final Logger LOG = Loggers.get(PurgeDao.class);
   private static final String[] UNPROCESSED_STATUS = new String[] {"U"};
   private static final ImmutableSet<String> QUALIFIERS_PROJECT_VIEW = ImmutableSet.of("TRK", "VW");
   private static final ImmutableSet<String> QUALIFIERS_MODULE_SUBVIEW = ImmutableSet.of("BRC", "SVW");
   private static final String SCOPE_PROJECT = "PRJ";
-  private static final String SCOPE_FILE = "FIL";
-  private static final String QUALIFIER_FILE = "FIL";
-  private static final String QUALIFIER_UNIT_TEST = "UTS";
 
   private final ComponentDao componentDao;
   private final System2 system2;
@@ -154,11 +148,10 @@ public class PurgeDao implements Dao {
     return result;
   }
 
-  public PurgeDao deleteRootComponent(DbSession session, String uuid) {
+  public void deleteRootComponent(DbSession session, String uuid) {
     PurgeProfiler profiler = new PurgeProfiler();
     PurgeCommands purgeCommands = new PurgeCommands(session, profiler);
     deleteRootComponent(uuid, mapper(session), purgeCommands);
-    return this;
   }
 
   private static void deleteRootComponent(String rootUuid, PurgeMapper mapper, PurgeCommands commands) {
@@ -181,35 +174,31 @@ public class PurgeDao implements Dao {
   }
 
   /**
-   * Delete the non root components (ie. neither project nor view) from the specified collection of {@link ComponentDto}
+   * Delete the non root components (ie. sub-view, application or project copy) from the specified collection of {@link ComponentDto}
    * and data from their child tables.
    * <p>
    *   This method has no effect when passed an empty collection or only root components.
    * </p>
    */
-  public PurgeDao deleteNonRootComponents(DbSession dbSession, Collection<ComponentDto> components) {
+  public void deleteNonRootComponentsInView(DbSession dbSession, Collection<ComponentDto> components) {
     Set<ComponentDto> nonRootComponents = components.stream().filter(PurgeDao::isNotRoot).collect(MoreCollectors.toSet());
     if (nonRootComponents.isEmpty()) {
-      return this;
+      return;
     }
 
     PurgeProfiler profiler = new PurgeProfiler();
     PurgeCommands purgeCommands = new PurgeCommands(dbSession, profiler);
-    deleteNonRootComponents(nonRootComponents, purgeCommands);
-
-    return this;
+    deleteNonRootComponentsInView(nonRootComponents, purgeCommands);
   }
 
-  private static void deleteNonRootComponents(Set<ComponentDto> nonRootComponents, PurgeCommands purgeCommands) {
-    List<IdUuidPair> modulesOrSubviews = nonRootComponents.stream()
+  private static void deleteNonRootComponentsInView(Set<ComponentDto> nonRootComponents, PurgeCommands purgeCommands) {
+    List<IdUuidPair> subviewsOrProjectCopies = nonRootComponents.stream()
       .filter(PurgeDao::isModuleOrSubview)
       .map(PurgeDao::toIdUuidPair)
       .collect(MoreCollectors.toList());
-    purgeCommands.deleteByRootAndModulesOrSubviews(modulesOrSubviews);
+    purgeCommands.deleteByRootAndModulesOrSubviews(subviewsOrProjectCopies);
     List<String> nonRootComponentUuids = nonRootComponents.stream().map(ComponentDto::uuid).collect(MoreCollectors.toList(nonRootComponents.size()));
     purgeCommands.deleteComponentMeasures(nonRootComponentUuids);
-    purgeCommands.deleteFileSources(nonRootComponents.stream().filter(PurgeDao::isFile).map(ComponentDto::uuid).collect(MoreCollectors.toList()));
-    purgeCommands.deleteIssues(nonRootComponentUuids);
     purgeCommands.deleteComponents(nonRootComponentUuids);
   }
 
@@ -221,10 +210,6 @@ public class PurgeDao implements Dao {
     return SCOPE_PROJECT.equals(dto.scope()) && QUALIFIERS_MODULE_SUBVIEW.contains(dto.qualifier());
   }
 
-  private static boolean isFile(ComponentDto dto) {
-    return SCOPE_FILE.equals(dto.qualifier()) && ImmutableSet.of(QUALIFIER_FILE, QUALIFIER_UNIT_TEST).contains(dto.qualifier());
-  }
-
   private static IdUuidPair toIdUuidPair(ComponentDto dto) {
     return new IdUuidPair(dto.getId(), dto.uuid());
   }
index 5bf39fe7fe387e88b961983f41a2100c03a3a23b..0aefe6335022f8baff3aa12e245fefb4e88fa3d2 100644 (file)
@@ -76,10 +76,6 @@ public interface PurgeMapper {
 
   void deleteIssuesByProjectUuid(@Param("projectUuid") String projectUuid);
 
-  void deleteIssueChangesByComponentUuids(@Param("componentUuids") List<String> componentUuids);
-
-  void deleteIssuesByComponentUuids(@Param("componentUuids") List<String> componentUuids);
-
   List<String> selectOldClosedIssueKeys(@Param("projectUuid") String projectUuid, @Nullable @Param("toDate") Long toDate);
 
   void deleteIssuesFromKeys(@Param("keys") List<String> keys);
index 5e66eba3bc54a21e9c0e44584f23cbe9f761b0e5..0a7661ccb3210b035e825a6f135bd7533292cedc 100644 (file)
     where project_uuid = #{projectUuid,jdbcType=VARCHAR}
   </delete>
 
-  <delete id="deleteIssueChangesByComponentUuids" parameterType="map">
-    delete from issue_changes ic
-    where
-      exists (
-        select
-          1
-        from issues i
-        where
-          i.kee=ic.issue_key
-          and i.component_uuid in
-            <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=",">
-              #{componentUuid,jdbcType=VARCHAR}
-            </foreach>
-    )
-  </delete>
-
-  <!-- Mssql -->
-  <delete id="deleteIssueChangesByComponentUuids" databaseId="mssql" parameterType="map">
-    delete issue_changes from issue_changes
-    inner join issues on
-      issue_changes.issue_key=issues.kee
-    where
-      issues.project_uuid  in
-        <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=",">
-          #{componentUuid,jdbcType=VARCHAR}
-        </foreach>
-  </delete>
-
-  <!-- Mysql -->
-  <delete id="deleteIssueChangesByComponentUuids" databaseId="mysql" parameterType="map">
-    delete ic from issue_changes as ic, issues as i
-    where
-      ic.issue_key=i.kee
-      and i.component_uuid  in
-        <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=",">
-          #{componentUuid,jdbcType=VARCHAR}
-        </foreach>
-  </delete>
-
-  <delete id="deleteIssuesByComponentUuids" parameterType="map">
-    delete from issues
-    where
-      project_uuid  in
-        <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=",">
-          #{componentUuid,jdbcType=VARCHAR}
-        </foreach>
-  </delete>
-
   <delete id="deleteFileSourcesByProjectUuid">
     delete from file_sources where project_uuid=#{rootProjectUuid,jdbcType=VARCHAR}
   </delete>
index 45d4daf52f39b428820a0b5cb95d6dddd6966c03..1b817dae8239779fe0f848a6a6b277e04b9ba77b 100644 (file)
@@ -44,12 +44,9 @@ import org.sonar.db.ce.CeQueueDto.Status;
 import org.sonar.db.component.ComponentDbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.issue.IssueDto;
 import org.sonar.db.measure.MeasureDto;
 import org.sonar.db.measure.custom.CustomMeasureDto;
 import org.sonar.db.property.PropertyDto;
-import org.sonar.db.rule.RuleTesting;
-import org.sonar.db.source.FileSourceDto;
 
 import static java.util.Arrays.asList;
 import static java.util.Collections.singletonList;
@@ -302,7 +299,7 @@ public class PurgeDaoTest {
   public void deleteNonRootComponents_has_no_effect_when_parameter_is_empty() {
     DbSession dbSession = mock(DbSession.class);
 
-    underTest.deleteNonRootComponents(dbSession, Collections.emptyList());
+    underTest.deleteNonRootComponentsInView(dbSession, Collections.emptyList());
 
     verifyZeroInteractions(dbSession);
   }
@@ -322,7 +319,7 @@ public class PurgeDaoTest {
 
     List<ComponentDto> componentDtos = Stream.concat(Stream.of(firstRoot), Arrays.stream(otherRoots)).collect(Collectors.toList());
     Collections.shuffle(componentDtos); // order of collection must not matter
-    underTest.deleteNonRootComponents(dbSession, componentDtos);
+    underTest.deleteNonRootComponentsInView(dbSession, componentDtos);
 
     verifyZeroInteractions(dbSession);
   }
@@ -345,7 +342,7 @@ public class PurgeDaoTest {
       dbTester.components().insertComponent(newFileDto(project)));
     Collections.shuffle(components);
 
-    underTest.deleteNonRootComponents(dbSession, components);
+    underTest.deleteNonRootComponentsInView(dbSession, components);
 
     assertThat(getUuidsInTableProjects())
       .containsOnly(project.uuid());
@@ -371,7 +368,7 @@ public class PurgeDaoTest {
       dbTester.components().insertComponent(newProjectCopy("c", projects[2], subview2)));
     Collections.shuffle(components);
 
-    underTest.deleteNonRootComponents(dbSession, components);
+    underTest.deleteNonRootComponentsInView(dbSession, components);
 
     assertThat(getUuidsInTableProjects())
       .containsOnly(view.uuid(), projects[0].uuid(), projects[1].uuid(), projects[2].uuid());
@@ -392,11 +389,11 @@ public class PurgeDaoTest {
     ComponentDto file2 = dbTester.components().insertComponent(newFileDto(module2));
     ComponentDto file3 = dbTester.components().insertComponent(newFileDto(project));
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(file3));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(file3));
     assertThat(getUuidsInTableProjects())
       .containsOnly(project.uuid(), module1.uuid(), module2.uuid(), dir1.uuid(), dir2.uuid(), file1.uuid(), file2.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, asList(module1, dir2, file1));
+    underTest.deleteNonRootComponentsInView(dbSession, asList(module1, dir2, file1));
     assertThat(getUuidsInTableProjects())
       .containsOnly(project.uuid(), module2.uuid(), dir1.uuid(), file2.uuid());
   }
@@ -416,34 +413,16 @@ public class PurgeDaoTest {
     ComponentDto pc2 = dbTester.components().insertComponent(newProjectCopy("b", projects[1], subview1));
     ComponentDto pc3 = dbTester.components().insertComponent(newProjectCopy("c", projects[2], subview2));
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(pc3));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(pc3));
     assertThat(getUuidsInTableProjects())
       .containsOnly(view.uuid(), projects[0].uuid(), projects[1].uuid(), projects[2].uuid(),
         subview1.uuid(), subview2.uuid(), pc1.uuid(), pc2.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, asList(subview1, pc2));
+    underTest.deleteNonRootComponentsInView(dbSession, asList(subview1, pc2));
     assertThat(getUuidsInTableProjects())
       .containsOnly(view.uuid(), projects[0].uuid(), projects[1].uuid(), projects[2].uuid(), subview2.uuid(), pc1.uuid());
   }
 
-  @Test
-  public void deleteNonRootComponents_deletes_measures_of_any_non_root_component_of_a_project() {
-    ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPublicProject() : dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto dir1 = dbTester.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(dir1));
-    insertIssueAndChangesFor(project, module1, dir1, file1);
-    assertThat(getComponentUuidsOfIssueChanges()).containsOnly(project.uuid(), module1.uuid(), dir1.uuid(), file1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(file1));
-    assertThat(getComponentUuidsOfIssueChanges())
-      .containsOnly(project.uuid(), module1.uuid(), dir1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, asList(module1, dir1));
-    assertThat(getComponentUuidsOfIssueChanges())
-      .containsOnly(project.uuid());
-  }
-
   @Test
   public void deleteNonRootComponents_deletes_measures_of_any_non_root_component_of_a_view() {
     ComponentDto view = dbTester.components().insertView();
@@ -452,92 +431,17 @@ public class PurgeDaoTest {
     insertMeasureFor(view, subview, pc);
     assertThat(getComponentUuidsOfMeasures()).containsOnly(view.uuid(), subview.uuid(), pc.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(pc));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(pc));
     assertThat(getComponentUuidsOfMeasures())
       .containsOnly(view.uuid(), subview.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(subview));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(subview));
     assertThat(getComponentUuidsOfMeasures())
       .containsOnly(view.uuid());
   }
 
   @Test
-  public void deleteNonRootComponents_deletes_issues_and_changes_of_any_non_root_component_of_a_project() {
-    ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPublicProject() : dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto dir1 = dbTester.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(dir1));
-    insertIssueAndChangesFor(project, module1, dir1, file1);
-    assertThat(getComponentUuidsOfIssueChanges()).containsOnly(project.uuid(), module1.uuid(), dir1.uuid(), file1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(file1));
-    assertThat(getComponentUuidsOfIssueChanges())
-      .containsOnly(project.uuid(), module1.uuid(), dir1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, asList(module1, dir1));
-    assertThat(getComponentUuidsOfIssueChanges())
-      .containsOnly(project.uuid());
-  }
-
-  @Test
-  public void deleteNonRootComponents_deletes_file_sources_of_file_component_of_a_project_only() {
-    ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPublicProject() : dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto dir1 = dbTester.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(dir1));
-    ComponentDto file2 = dbTester.components().insertComponent(newFileDto(dir1));
-    insertFileSources(project, module1, dir1, file1, file2);
-    assertThat(getComponentUuidsOfFileSources()).containsOnly(project.uuid(), module1.uuid(), dir1.uuid(), file1.uuid(), file2.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(file1));
-    assertThat(getComponentUuidsOfFileSources())
-      .containsOnly(project.uuid(), module1.uuid(), dir1.uuid(), file2.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, asList(module1, dir1, file2));
-    assertThat(getComponentUuidsOfFileSources())
-      .containsOnly(project.uuid(), module1.uuid(), dir1.uuid());
-  }
-
-  @Test
-  public void deleteNonRootComponents_does_not_delete_file_sources_of_non_root_components_of_a_view() {
-    ComponentDto view = dbTester.components().insertView();
-    ComponentDto subview = dbTester.components().insertComponent(ComponentTesting.newSubView(view));
-    ComponentDto pc1 = dbTester.components().insertComponent(newProjectCopy("a", dbTester.components().insertPrivateProject(), view));
-    ComponentDto pc2 = dbTester.components().insertComponent(newProjectCopy("b", dbTester.components().insertPrivateProject(), view));
-    insertFileSources(view, subview, pc1, pc2);
-    assertThat(getComponentUuidsOfFileSources()).containsOnly(view.uuid(), subview.uuid(), pc1.uuid(), pc2.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(pc1));
-    assertThat(getComponentUuidsOfFileSources())
-      .containsOnly(view.uuid(), subview.uuid(), pc1.uuid(), pc2.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, asList(subview, pc2));
-    assertThat(getComponentUuidsOfFileSources())
-      .containsOnly(view.uuid(), subview.uuid(), pc1.uuid(), pc2.uuid());
-  }
-
-  @Test
-  public void deleteNonRootComponents_deletes_properties_of_modules_of_a_project() {
-    ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPublicProject() : dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(module1));
-    ComponentDto module3 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto dir1 = dbTester.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(dir1));
-    insertPropertyFor(project, module1, module2, module3, dir1, file1);
-    assertThat(getResourceIdOfProperties()).containsOnly(project.getId(), module1.getId(), module2.getId(), module3.getId(), dir1.getId(), file1.getId());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(module3));
-    assertThat(getResourceIdOfProperties())
-      .containsOnly(project.getId(), module1.getId(), module2.getId(), dir1.getId(), file1.getId());
-
-    underTest.deleteNonRootComponents(dbSession, asList(module1, module2, dir1, file1));
-    assertThat(getResourceIdOfProperties())
-      .containsOnly(project.getId(), dir1.getId(), file1.getId());
-  }
-
-  @Test
-  public void deleteNonRootComponents_properties_of_subviews_of_a_view() {
+  public void deleteNonRootComponents_deletes_properties_of_subviews_of_a_view() {
     ComponentDto view = dbTester.components().insertView();
     ComponentDto subview1 = dbTester.components().insertComponent(ComponentTesting.newSubView(view));
     ComponentDto subview2 = dbTester.components().insertComponent(ComponentTesting.newSubView(subview1));
@@ -546,37 +450,17 @@ public class PurgeDaoTest {
     insertPropertyFor(view, subview1, subview2, subview3, pc);
     assertThat(getResourceIdOfProperties()).containsOnly(view.getId(), subview1.getId(), subview2.getId(), subview3.getId(), pc.getId());
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(subview1));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(subview1));
     assertThat(getResourceIdOfProperties())
       .containsOnly(view.getId(), subview2.getId(), subview3.getId(), pc.getId());
 
-    underTest.deleteNonRootComponents(dbSession, asList(subview2, subview3, pc));
+    underTest.deleteNonRootComponentsInView(dbSession, asList(subview2, subview3, pc));
     assertThat(getResourceIdOfProperties())
       .containsOnly(view.getId(), pc.getId());
   }
 
   @Test
-  public void deleteNonRootComponents_deletes_manual_measures_of_modules_of_a_project() {
-    ComponentDto project = new Random().nextBoolean() ? dbTester.components().insertPublicProject() : dbTester.components().insertPrivateProject();
-    ComponentDto module1 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto module2 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(module1));
-    ComponentDto module3 = dbTester.components().insertComponent(ComponentTesting.newModuleDto(project));
-    ComponentDto dir1 = dbTester.components().insertComponent(newDirectory(module1, "A/B"));
-    ComponentDto file1 = dbTester.components().insertComponent(newFileDto(dir1));
-    insertManualMeasureFor(project, module1, module2, module3, dir1, file1);
-    assertThat(getComponentUuidsOfManualMeasures()).containsOnly(project.uuid(), module1.uuid(), module2.uuid(), module3.uuid(), dir1.uuid(), file1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, singletonList(module3));
-    assertThat(getComponentUuidsOfManualMeasures())
-      .containsOnly(project.uuid(), module1.uuid(), module2.uuid(), dir1.uuid(), file1.uuid());
-
-    underTest.deleteNonRootComponents(dbSession, asList(module1, module2, dir1, file1));
-    assertThat(getComponentUuidsOfManualMeasures())
-      .containsOnly(project.uuid(), dir1.uuid(), file1.uuid());
-  }
-
-  @Test
-  public void deleteNonRootComponents_manual_measures_of_subviews_of_a_view() {
+  public void deleteNonRootComponentsInView_deletes_manual_measures_of_subviews_of_a_view() {
     ComponentDto view = dbTester.components().insertView();
     ComponentDto subview1 = dbTester.components().insertComponent(ComponentTesting.newSubView(view));
     ComponentDto subview2 = dbTester.components().insertComponent(ComponentTesting.newSubView(subview1));
@@ -585,11 +469,11 @@ public class PurgeDaoTest {
     insertManualMeasureFor(view, subview1, subview2, subview3, pc);
     assertThat(getComponentUuidsOfManualMeasures()).containsOnly(view.uuid(), subview1.uuid(), subview2.uuid(), subview3.uuid(), pc.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, singletonList(subview1));
+    underTest.deleteNonRootComponentsInView(dbSession, singletonList(subview1));
     assertThat(getComponentUuidsOfManualMeasures())
       .containsOnly(view.uuid(), subview2.uuid(), subview3.uuid(), pc.uuid());
 
-    underTest.deleteNonRootComponents(dbSession, asList(subview2, subview3, pc));
+    underTest.deleteNonRootComponentsInView(dbSession, asList(subview2, subview3, pc));
     assertThat(getComponentUuidsOfManualMeasures())
       .containsOnly(view.uuid(), pc.uuid());
   }
@@ -631,35 +515,6 @@ public class PurgeDaoTest {
     dbSession.commit();
   }
 
-  private Stream<String> getComponentUuidsOfFileSources() {
-    return dbTester.select("select file_uuid as \"COMPONENT_UUID\" from file_sources").stream()
-      .map(row -> (String) row.get("COMPONENT_UUID"));
-  }
-
-  private void insertFileSources(ComponentDto... components) {
-    Arrays.stream(components).forEach(component -> dbTester.getDbClient().fileSourceDao().insert(dbSession, new FileSourceDto()
-      .setFileUuid(component.uuid())
-      .setCreatedAt(new Random().nextInt())
-      .setUpdatedAt(new Random().nextInt())
-      .setProjectUuid(randomAlphabetic(3))
-      .setDataType("SOURCE")
-      .setBinaryData(new byte[] {0, 1})));
-    dbSession.commit();
-  }
-
-  private Stream<String> getComponentUuidsOfIssueChanges() {
-    return dbTester.select("select i.component_uuid as \"COMPONENT_UUID\" from issue_changes ic inner join issues i on i.kee = ic.issue_key").stream()
-      .map(row -> (String) row.get("COMPONENT_UUID"));
-  }
-
-  private void insertIssueAndChangesFor(ComponentDto project, ComponentDto... otherComponents) {
-    Stream.concat(Stream.of(project), Arrays.stream(otherComponents)).forEach(componentDto -> {
-      IssueDto issue = dbTester.issues().insert(RuleTesting.newRule(), project, componentDto);
-      dbTester.issues().insertComment(issue, "foo", "bar");
-    });
-    dbSession.commit();
-  }
-
   private CeQueueDto createCeQueue(ComponentDto component, Status status) {
     CeQueueDto queueDto = new CeQueueDto();
     queueDto.setUuid(Uuids.create());