aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-12 12:20:54 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-05-12 17:05:46 +0200
commit9ac7dcbbf26081d499a2dbd40549ffeff159f93d (patch)
treeefb9b8abf868be84c3c6edca4cced8c0671c1645 /sonar-db/src
parenta956de09fd857e4150a8d19a453f1055af9f24c9 (diff)
downloadsonarqube-9ac7dcbbf26081d499a2dbd40549ffeff159f93d.tar.gz
sonarqube-9ac7dcbbf26081d499a2dbd40549ffeff159f93d.zip
SONAR-7175 Keep last snapshots in KeepOneFilter
Last snapshot is now kept Instead of first snapshot
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java4
-rw-r--r--sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java3
2 files changed, 3 insertions, 4 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java b/sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java
index 72d4123a59b..7bb554ffab2 100644
--- a/sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java
+++ b/sonar-db/src/main/java/org/sonar/db/purge/period/KeepOneFilter.java
@@ -73,8 +73,8 @@ class KeepOneFilter implements Filter {
toDelete.addAll(deletables);
} else if (deletables.size() > 1) {
- // keep one snapshot
- toDelete.addAll(deletables.subList(1, deletables.size()));
+ // keep last snapshot
+ toDelete.addAll(deletables.subList(0, deletables.size() - 1));
}
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java b/sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java
index cdfe5b88993..b7f20b5f866 100644
--- a/sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java
@@ -60,8 +60,7 @@ public class KeepOneFilterTest {
assertThat(toDelete).hasSize(2);
List<Long> snapshotIds = snapshotIds(toDelete);
- assertThat(snapshotIds).contains(3L);
- assertThat(snapshotIds).contains(4L);
+ assertThat(snapshotIds).containsOnly(2L, 3L);
}
@Test