From 4f3e366aa1681904975772b0a3f8fa450c927ec6 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 25 May 2016 11:11:23 +0200 Subject: [PATCH] fix TechnicalDebtWidgetTest by using dynamic date --- .../it/qualityModel/TechnicalDebtWidgetTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtWidgetTest.java b/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtWidgetTest.java index 989545d9ec9..7350325bff8 100644 --- a/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtWidgetTest.java +++ b/it/it-tests/src/test/java/it/qualityModel/TechnicalDebtWidgetTest.java @@ -24,6 +24,7 @@ import com.sonar.orchestrator.build.SonarRunner; import com.sonar.orchestrator.locator.FileLocation; import com.sonar.orchestrator.selenium.Selenese; import it.Category2Suite; +import org.apache.commons.lang.time.DateUtils; import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; @@ -31,6 +32,9 @@ import org.junit.experimental.categories.Category; import util.QaOnly; import util.selenium.SeleneseTest; +import java.text.SimpleDateFormat; +import java.util.Date; + import static util.ItUtils.projectDir; @Category(QaOnly.class) @@ -55,8 +59,8 @@ public class TechnicalDebtWidgetTest { // need to execute the build twice in order to have history widgets // we made some exclusions to have variations in diff mode - scanProject("2011-06-01", "**/a2/**"); - scanProject("2012-02-01", ""); + scanProject(getPastDate(20), "**/a2/**"); + scanProject(getPastDate(10), ""); } private static void scanProject(String date, String excludes) { @@ -93,4 +97,8 @@ public class TechnicalDebtWidgetTest { ).build()).runOn(orchestrator); } + private static String getPastDate(int nbPastDays){ + return new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.addDays(new Date(), nbPastDays * -1)); + } + } -- 2.39.5