aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-06-02 10:07:27 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-06-02 10:37:40 +0200
commit149eec15037eb1d872b8eb11ac402920d75ca786 (patch)
tree6627e164660f6217d7ff860206d44a5ea4a04933 /sonar-core
parent08a03143dcc45cfa5fa137bfe4bf34dad34ce841 (diff)
downloadsonarqube-149eec15037eb1d872b8eb11ac402920d75ca786.tar.gz
sonarqube-149eec15037eb1d872b8eb11ac402920d75ca786.zip
add tests to PurgeConfiguration
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java
index b78687ff1d0..04eee676108 100644
--- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeConfigurationTest.java
@@ -19,10 +19,12 @@
*/
package org.sonar.core.purge;
+import java.util.Date;
import org.junit.Test;
+import org.sonar.api.config.Settings;
+import org.sonar.api.resources.Scopes;
import org.sonar.api.utils.DateUtils;
-
-import java.util.Date;
+import org.sonar.core.computation.dbcleaner.DbCleanerConstants;
import static org.assertj.core.api.Assertions.assertThat;
@@ -43,8 +45,32 @@ public class PurgeConfigurationTest {
PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30);
Date toDate = conf.maxLiveDateOfClosedIssues(now);
- assertThat(toDate.getYear()).isEqualTo(113);//=2013
+ assertThat(toDate.getYear()).isEqualTo(113);// =2013
assertThat(toDate.getMonth()).isEqualTo(3); // means April
assertThat(toDate.getDate()).isEqualTo(18);
}
+
+ @Test
+ public void do_not_delete_directory_by_default() {
+ Settings settings = new Settings();
+ settings.setProperty(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY, false);
+ settings.setProperty(DbCleanerConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5);
+ Date now = new Date();
+
+ PurgeConfiguration sut = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"));
+
+ assertThat(sut.scopesWithoutHistoricalData()).contains(Scopes.FILE)
+ .doesNotContain(Scopes.DIRECTORY);
+ assertThat(sut.maxLiveDateOfClosedIssues(now)).isEqualTo(DateUtils.addDays(now, -5));
+ }
+
+ @Test
+ public void delete_directory_if_in_settings() {
+ Settings settings = new Settings();
+ settings.setProperty(DbCleanerConstants.PROPERTY_CLEAN_DIRECTORY, true);
+
+ PurgeConfiguration sut = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"));
+
+ assertThat(sut.scopesWithoutHistoricalData()).contains(Scopes.DIRECTORY, Scopes.FILE);
+ }
}