From 38e6c70fd3720bfabd695b49ea2c65648f53cf36 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 18 Aug 2016 15:13:55 +0200 Subject: [PATCH] remove dead code in PurgeCommand --- .../org/sonar/db/purge/PurgeCommands.java | 29 ------------------- .../org/sonar/db/purge/PurgeCommandsTest.java | 21 -------------- 2 files changed, 50 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java index 470cf399bcd..f77dfc2cdc8 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -125,35 +125,6 @@ class PurgeCommands { profiler.stop(); } - void deleteSnapshots(PurgeSnapshotQuery... queries) { - List snapshotIds = from(asList(queries)) - .transformAndConcat(purgeMapper::selectAnalysisIdsAndUuids) - .toList(); - deleteSnapshots(snapshotIds); - } - - @VisibleForTesting - protected void deleteSnapshots(List snapshotIds) { - List> snapshotUuidsPartitions = Lists.partition(IdUuidPairs.uuids(snapshotIds), MAX_SNAPSHOTS_PER_QUERY); - - deleteAnalysisDuplications(snapshotUuidsPartitions); - - profiler.start("deleteSnapshots (events)"); - snapshotUuidsPartitions.forEach(purgeMapper::deleteAnalysisEvents); - session.commit(); - profiler.stop(); - - profiler.start("deleteSnapshots (project_measures)"); - snapshotUuidsPartitions.forEach(purgeMapper::deleteSnapshotMeasures); - session.commit(); - profiler.stop(); - - profiler.start("deleteSnapshots (snapshots)"); - snapshotUuidsPartitions.forEach(purgeMapper::deleteAnalyses); - session.commit(); - profiler.stop(); - } - public void deleteComponentMeasures(List analysisUuids, List componentUuids) { if (analysisUuids.isEmpty() || componentUuids.isEmpty()) { return; diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java index 0aa0e5d41a8..e9cccc2b31a 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java @@ -37,27 +37,6 @@ public class PurgeCommandsTest { private PurgeProfiler profiler = new PurgeProfiler(); - /** - * Test that all related data is deleted. - */ - @Test - public void shouldDeleteSnapshot() { - dbTester.prepareDbUnit(getClass(), "shouldDeleteSnapshot.xml"); - - new PurgeCommands(dbTester.getSession(), profiler).deleteSnapshots(new PurgeSnapshotQuery().setComponentUuid("uuid_5")); - - dbTester.assertDbUnit(getClass(), "shouldDeleteSnapshot-result.xml", "snapshots", "project_measures", "duplications_index", "events"); - } - - /** - * Test that SQL queries execution do not fail with a huge number of parameter - */ - @Test - public void should_not_fail_when_deleting_huge_number_of_snapshots() { - new PurgeCommands(dbTester.getSession(), profiler).deleteSnapshots(getHugeNumberOfIdUuidPairs()); - // The goal of this test is only to check that the query do no fail, not to check result - } - /** * Test that SQL queries execution do not fail with a huge number of parameter */ -- 2.39.5