diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-05-24 19:01:16 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-05-24 19:01:16 +0200 |
commit | 79ad08c967c32f5c68d6b5a4844b2213b5f3015d (patch) | |
tree | e5c7dc91780363814fa31a8d541f767d16ab23d1 /it | |
parent | 2a29274195e513d4e8de50159cfd7e579d1e98d1 (diff) | |
download | sonarqube-79ad08c967c32f5c68d6b5a4844b2213b5f3015d.tar.gz sonarqube-79ad08c967c32f5c68d6b5a4844b2213b5f3015d.zip |
SONAR-7175 Fix IT about last snapshot of previous weeks
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java index 0278e76396c..b49a6c9a7f3 100644 --- a/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java +++ b/it/it-tests/src/test/java/it/dbCleaner/PurgeTest.java @@ -24,6 +24,7 @@ import com.sonar.orchestrator.build.BuildResult; import com.sonar.orchestrator.build.SonarScanner; import com.sonar.orchestrator.locator.FileLocation; import it.Category4Suite; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; @@ -176,13 +177,21 @@ public class PurgeTest { // Keep all snapshots from last 4 weeks setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "4"); - // Execute an analysis 11 days ago - String elevenDaysAgo = formatDate(addDays(new Date(), -11)); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", elevenDaysAgo); + Date oneWeekAgo = addDays(new Date(), -7); - // Execute an analysis 10 days ago - String tenDaysAgo = formatDate(addDays(new Date(), -10)); - runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", tenDaysAgo); + // Execute an analysis wednesday last week + Calendar lastWednesday = Calendar.getInstance(); + lastWednesday.setTime(oneWeekAgo); + lastWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); + String lastWednesdayFormatted = formatDate(lastWednesday.getTime()); + runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastWednesdayFormatted); + + // Execute an analysis thursday last week + Calendar lastThursday = Calendar.getInstance(); + lastThursday.setTime(oneWeekAgo); + lastThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); + String lastThursdayFormatted = formatDate(lastThursday.getTime()); + runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH, "sonar.projectDate", lastThursdayFormatted); // Now only keep 1 snapshot per week setServerProperty(orchestrator, "sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek", "0"); @@ -190,15 +199,15 @@ public class PurgeTest { // Execute an analysis today to execute the purge of previous weeks snapshots runProjectAnalysis(orchestrator, PROJECT_SAMPLE_PATH); - // Check that only analysis from 10 days ago is kept (as it's the last one from previous week) + // Check that only analysis from last thursday is kept (as it's the last one from previous week) WsResponse response = newAdminWsClient(orchestrator).wsConnector().call( new GetRequest("/api/timemachine/index") .setParam("resource", PROJECT_KEY) .setParam("metrics", "ncloc")) .failIfNotSuccessful(); String content = response.content(); - assertThat(content).contains(tenDaysAgo); - assertThat(content).doesNotContain(elevenDaysAgo); + assertThat(content).contains(lastThursdayFormatted); + assertThat(content).doesNotContain(lastWednesdayFormatted); } /** |