@Test
public void new_issues_measures() throws Exception {
- setServerProperty(ORCHESTRATOR, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(ORCHESTRATOR, "sonar.leak.period", "previous_analysis");
ORCHESTRATOR.getServer().provisionProject("sample", "Sample");
// Execute an analysis in the past with no issue to have a past snapshot
@Test
public void new_issues_measures_should_be_zero_on_project_when_no_new_issues_since_x_days() throws Exception {
- setServerProperty(ORCHESTRATOR, "sonar.timemachine.period1", "30");
+ setServerProperty(ORCHESTRATOR, "sonar.leak.period", "30");
ORCHESTRATOR.getServer().provisionProject("sample", "Sample");
ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/one-issue-per-line-profile.xml"));
ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line-profile");
*/
@Test
public void new_issues_measures_consistent_with_variations() throws Exception {
- setServerProperty(ORCHESTRATOR, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(ORCHESTRATOR, "sonar.leak.period", "previous_analysis");
ORCHESTRATOR.getServer().provisionProject("sample", "Sample");
ORCHESTRATOR.getServer().restoreProfile(FileLocation.ofClasspath("/issue/one-issue-per-line-profile.xml"));
ORCHESTRATOR.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line-profile");
@Test
public void new_issues_measures_should_be_correctly_calculated_when_adding_a_new_module() throws Exception {
- setServerProperty(ORCHESTRATOR, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(ORCHESTRATOR, "sonar.leak.period", "previous_analysis");
ORCHESTRATOR.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "com.sonarsource.it.samples:multi-modules-sample");
// First analysis without module b
@BeforeClass
public static void initPeriod() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
}
@AfterClass
orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_KEY);
// Set a global property and a project property to ensure project property is used
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
- setServerProperty(orchestrator, PROJECT_KEY, "sonar.timemachine.period1", "30");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
+ setServerProperty(orchestrator, PROJECT_KEY, "sonar.leak.period", "30");
// Execute an analysis in the past to have a past snapshot without any issues
orchestrator.getServer().associateProjectToQualityProfile(PROJECT_KEY, "xoo", "empty");
// Check on ui that it's possible to define leak period on project
Navigation.get(orchestrator).openHomepage().logIn().asAdmin().openSettings("sample")
- .assertSettingDisplayed("sonar.timemachine.period1");
+ .assertSettingDisplayed("sonar.leak.period");
}
/**
@Test
public void ensure_differential_measures_are_computed_when_adding_new_component_after_period() throws Exception {
orchestrator.getServer().provisionProject(MULTI_MODULE_PROJECT_KEY, MULTI_MODULE_PROJECT_KEY);
- setServerProperty(orchestrator, MULTI_MODULE_PROJECT_KEY, "sonar.timemachine.period1", "30");
+ setServerProperty(orchestrator, MULTI_MODULE_PROJECT_KEY, "sonar.leak.period", "30");
// Execute an analysis 60 days ago without module b
orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "empty");
@Test
public void compute_no_new_lines_measures_when_changes_but_no_scm() throws Exception {
orchestrator.getServer().provisionProject(MULTI_MODULE_PROJECT_KEY, MULTI_MODULE_PROJECT_KEY);
- setServerProperty(orchestrator, MULTI_MODULE_PROJECT_KEY, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, MULTI_MODULE_PROJECT_KEY, "sonar.leak.period", "previous_analysis");
// Execute an analysis 60 days ago without module b
orchestrator.getServer().associateProjectToQualityProfile(MULTI_MODULE_PROJECT_KEY, "xoo", "empty");
public void compute_zero_new_lines_measures_when_no_changes_and_scm_available() throws Exception {
String projectKey = "sample-scm";
orchestrator.getServer().provisionProject(projectKey, projectKey);
- setServerProperty(orchestrator, projectKey, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, projectKey, "sonar.leak.period", "previous_analysis");
// Execute an analysis 60 days ago
runProjectAnalysis(orchestrator, "scm/xoo-sample-with-scm", "sonar.projectDate", formatDate(addDays(new Date(), -60)),
@BeforeClass
public static void initPeriod() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_version");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_version");
}
@AfterClass
}
private static void initPeriod() {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "30");
+ setServerProperty(orchestrator, "sonar.leak.period", "30");
}
@AfterClass
}
private static void initPeriod() {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
}
@AfterClass
page.openCategory("General")
.assertStringSettingValue("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "30")
- .assertStringSettingValue("sonar.timemachine.period1", "previous_version")
+ .assertStringSettingValue("sonar.leak.period", "previous_version")
.assertBooleanSettingValue("sonar.dbcleaner.cleanDirectory", true)
.setStringValue("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "1")
.assertStringSettingValue("sonar.dbcleaner.daysBeforeDeletingClosedIssues", "1");
public static void init() throws Exception {
DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id();
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
resetEmailSettings(orchestrator);
smtpServer = new Wiser(0);
@After
public void resetData() throws Exception {
qgClient().destroy(qualityGateId);
- resetSettings(orchestrator, null, "sonar.timemachine.period1");
+ resetSettings(orchestrator, null, "sonar.leak.period");
}
@Test
@Test
public void generate_error_qgate_on_rating_metric_on_leak_period() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
QUALITY_GATES.createCondition(CreateConditionRequest.builder()
.setQualityGateId(qualityGateId.intValue())
.setMetricKey("new_security_rating")
@BeforeClass
public static void initPeriod() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
DEFAULT_QUALITY_GATE = qgClient().list().defaultGate().id();
}
@Test
public void new_debt_ratio_is_computed_from_new_debt_and_new_ncloc_count_per_file() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
// run analysis on the day of after the first commit, with 'one-issue-per-line' profile
defineQualityProfile("one-issue-per-line");
@Test
public void compute_new_debt_ratio_using_number_days_in_leak_period() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "30");
+ setServerProperty(orchestrator, "sonar.leak.period", "30");
// run analysis on the day of after the first commit, with 'one-issue-per-line' profile
defineQualityProfile("one-issue-per-line");
@Test
public void new_technical_debt_measures_from_new_issues() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
// Execute an analysis in the past to have a past snapshot without any issues
provisionSampleProject();
@Test
public void new_technical_debt_measures_from_technical_debt_update_since_previous_analysis() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
// Execute twice analysis
defineQualityProfile("one-issue-per-file");
@Test
public void new_technical_debt_measures_from_technical_debt_update_since_30_days() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "30");
+ setServerProperty(orchestrator, "sonar.leak.period", "30");
// Execute an analysis in the past to have a past snapshot without any issues
provisionSampleProject();
*/
@Test
public void new_technical_debt_measures_should_never_be_negative() throws Exception {
- setServerProperty(orchestrator, "sonar.timemachine.period1", "previous_analysis");
+ setServerProperty(orchestrator, "sonar.leak.period", "previous_analysis");
// Execute an analysis with a big effort to fix
defineQualityProfile("one-issue-per-file");
}
public static void resetPeriod(Orchestrator orchestrator) {
- resetSettings(orchestrator, null, "sonar.timemachine.period1");
+ resetSettings(orchestrator, null, "sonar.leak.period");
}
@CheckForNull
/**
* Repository of period used to compute differential measures.
* Here are the steps to retrieve the period :
- * - Read the period property ${@link org.sonar.core.config.CorePropertyDefinitions#TIMEMACHINE_PERIOD_PREFIX}
+ * - Read the period property ${@link org.sonar.core.config.CorePropertyDefinitions#LEAK_PERIOD}
* - Try to find the matching snapshots from the property
* - If a snapshot is found, the period is added to the repository
*/
* Populates the {@link PeriodHolder}
* <p/>
* Here is how these periods are computed :
- * - Read the 5 period properties ${@link org.sonar.core.config.CorePropertyDefinitions#TIMEMACHINE_PERIOD_PREFIX}
+ * - Read the 5 period properties ${@link org.sonar.core.config.CorePropertyDefinitions#LEAK_PERIOD}
* - Try to find the matching snapshots from the properties
* - If a snapshot is found, a new period is added to the repository
*/
import org.sonar.db.component.SnapshotQuery;
import org.sonar.server.computation.task.projectanalysis.period.Period;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAYS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_PERIOD_PREFIX;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED;
import static org.sonar.db.component.SnapshotQuery.SORT_FIELD.BY_DATE;
import static org.sonar.db.component.SnapshotQuery.SORT_ORDER.ASC;
}
Period period = resolve(propertyValue);
if (period == null && StringUtils.isNotBlank(propertyValue)) {
- LOG.debug("Property " + TIMEMACHINE_PERIOD_PREFIX + 1 + " is not valid: " + propertyValue);
+ LOG.debug("Property " + LEAK_PERIOD + " is not valid: " + propertyValue);
}
return period;
}
if (date != null) {
return findByDate(date);
}
- if (StringUtils.equals(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, property)) {
+ if (StringUtils.equals(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, property)) {
return findByPreviousAnalysis();
}
- if (StringUtils.equals(TIMEMACHINE_MODE_PREVIOUS_VERSION, property)) {
+ if (StringUtils.equals(LEAK_PERIOD_MODE_PREVIOUS_VERSION, property)) {
return findByPreviousVersion();
}
return findByVersion(property);
return null;
}
LOG.debug("Compare to date {} (analysis of {})", formatDate(date.getTime()), formatDate(snapshot.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_DATE, DateUtils.formatDate(date), snapshot.getCreatedAt(), snapshot.getUuid());
+ return new Period(LEAK_PERIOD_MODE_DATE, DateUtils.formatDate(date), snapshot.getCreatedAt(), snapshot.getUuid());
}
@CheckForNull
return null;
}
LOG.debug("Compare over {} days ({}, analysis of {})", String.valueOf(days), formatDate(targetDate), formatDate(snapshot.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_DAYS, String.valueOf(days), snapshot.getCreatedAt(), snapshot.getUuid());
+ return new Period(LEAK_PERIOD_MODE_DAYS, String.valueOf(days), snapshot.getCreatedAt(), snapshot.getUuid());
}
@CheckForNull
return null;
}
LOG.debug("Compare to previous analysis ({})", formatDate(snapshot.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, formatDate(snapshot.getCreatedAt()), snapshot.getCreatedAt(), snapshot.getUuid());
+ return new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, formatDate(snapshot.getCreatedAt()), snapshot.getCreatedAt(), snapshot.getUuid());
}
@CheckForNull
}
SnapshotDto snapshotDto = snapshotDtos.get(0);
LOG.debug("Compare to previous version ({})", formatDate(snapshotDto.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_PREVIOUS_VERSION, snapshotDto.getVersion(), snapshotDto.getCreatedAt(), snapshotDto.getUuid());
+ return new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, snapshotDto.getVersion(), snapshotDto.getCreatedAt(), snapshotDto.getUuid());
}
@CheckForNull
return null;
}
LOG.debug("Compare to first analysis ({})", formatDate(snapshotDto.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_PREVIOUS_VERSION, null, snapshotDto.getCreatedAt(), snapshotDto.getUuid());
+ return new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, snapshotDto.getCreatedAt(), snapshotDto.getUuid());
}
@CheckForNull
return null;
}
LOG.debug("Compare to version ({}) ({})", version, formatDate(snapshot.getCreatedAt()));
- return new Period(TIMEMACHINE_MODE_VERSION, version, snapshot.getCreatedAt(), snapshot.getUuid());
+ return new Period(LEAK_PERIOD_MODE_VERSION, version, snapshot.getCreatedAt(), snapshot.getUuid());
}
@CheckForNull
}
private static String getPropertyValue(Settings settings) {
- return settings.getString(TIMEMACHINE_PERIOD_PREFIX + 1);
+ return settings.getString(LEAK_PERIOD);
}
}
import static org.sonar.api.rules.RuleType.BUG;
import static org.sonar.api.rules.RuleType.CODE_SMELL;
import static org.sonar.api.rules.RuleType.VULNERABILITY;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
public class NewEffortAggregatorTest {
- private static final Period PERIOD = new Period(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, 1_500_000_000L, "U1");
+ private static final Period PERIOD = new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, 1_500_000_000L, "U1");
private static final Component FILE = ReportComponent.builder(Component.Type.FILE, 1).setUuid("FILE").build();
private static final Component PROJECT = ReportComponent.builder(Component.Type.PROJECT, 2).addChildren(FILE).build();
import static java.util.Collections.emptyList;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
public class NewEffortCalculatorTest {
private static final Duration TEN_DAYS = Duration.create(10 * HOURS_IN_DAY * 60 * 60L);
private static final long PERIOD_DATE = 150000000L;
private static final String ANALYSIS_UUID = "u1";
- private static final Period PERIOD = new Period(TIMEMACHINE_MODE_PREVIOUS_VERSION, null, PERIOD_DATE, ANALYSIS_UUID);
+ private static final Period PERIOD = new Period(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, PERIOD_DATE, ANALYSIS_UUID);
DefaultIssue issue = new DefaultIssue();
NewEffortCalculator underTest = new NewEffortCalculator();
import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAYS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
public class PeriodTest {
@Test
public void test_some_setters_and_getters() {
- Period period = new Period(TIMEMACHINE_MODE_VERSION, SOME_MODE_PARAM, SOME_SNAPSHOT_DATE, SOME_ANALYSIS_UUID);
+ Period period = new Period(LEAK_PERIOD_MODE_VERSION, SOME_MODE_PARAM, SOME_SNAPSHOT_DATE, SOME_ANALYSIS_UUID);
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_VERSION);
assertThat(period.getModeParameter()).isEqualTo(SOME_MODE_PARAM);
assertThat(period.getSnapshotDate()).isEqualTo(SOME_SNAPSHOT_DATE);
assertThat(period.getAnalysisUuid()).isEqualTo(SOME_ANALYSIS_UUID);
@Test
public void verify_to_string() {
- assertThat(new Period(TIMEMACHINE_MODE_VERSION, "2.3", 1420034400000L, "U10").toString())
+ assertThat(new Period(LEAK_PERIOD_MODE_VERSION, "2.3", 1420034400000L, "U10").toString())
.isEqualTo("Period{mode=version, modeParameter=2.3, snapshotDate=1420034400000, analysisUuid=U10}");
}
@Test
public void equals_is_done_on_all_fields() {
- Period period = new Period(TIMEMACHINE_MODE_VERSION, "2.3", 1420034400000L, "U10");
+ Period period = new Period(LEAK_PERIOD_MODE_VERSION, "2.3", 1420034400000L, "U10");
- assertThat(period).isEqualTo(new Period(TIMEMACHINE_MODE_VERSION, "2.3", 1420034400000L, "U10"));
+ assertThat(period).isEqualTo(new Period(LEAK_PERIOD_MODE_VERSION, "2.3", 1420034400000L, "U10"));
assertThat(period).isNotEqualTo(null);
assertThat(period).isNotEqualTo("sdsd");
- assertThat(period).isNotEqualTo(new Period(TIMEMACHINE_MODE_DAYS, "2.3", 1420034400000L, "U10"));
- assertThat(period).isNotEqualTo(new Period(TIMEMACHINE_MODE_VERSION, "2.4", 1420034400000L, "U10"));
- assertThat(period).isNotEqualTo(new Period(TIMEMACHINE_MODE_VERSION, "2.3", 555L, "U10"));
- assertThat(period).isNotEqualTo(new Period(TIMEMACHINE_MODE_VERSION, "2.3", 1420034400000L, "9632554"));
+ assertThat(period).isNotEqualTo(new Period(LEAK_PERIOD_MODE_DAYS, "2.3", 1420034400000L, "U10"));
+ assertThat(period).isNotEqualTo(new Period(LEAK_PERIOD_MODE_VERSION, "2.4", 1420034400000L, "U10"));
+ assertThat(period).isNotEqualTo(new Period(LEAK_PERIOD_MODE_VERSION, "2.3", 555L, "U10"));
+ assertThat(period).isNotEqualTo(new Period(LEAK_PERIOD_MODE_VERSION, "2.3", 1420034400000L, "9632554"));
}
}
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAYS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
@RunWith(DataProviderRunner.class)
public class LoadPeriodsStepTest extends BaseStepTest {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
String textDate = "2008-11-22";
- settings.setProperty("sonar.timemachine.period1", textDate);
+ settings.setProperty("sonar.leak.period", textDate);
underTest.execute();
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_DATE);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(period.getModeParameter()).isEqualTo(textDate);
assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
public void no_period_when_settings_match_no_analysis(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "UNKNWOWN VERSION");
+ settings.setProperty("sonar.leak.period", "UNKNWOWN VERSION");
underTest.execute();
public void no_period_when_settings_is_empty(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "");
+ settings.setProperty("sonar.leak.period", "");
underTest.execute();
public void ignore_unprocessed_snapshots(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "unprocessed_snapshots.xml");
- settings.setProperty("sonar.timemachine.period1", "100");
+ settings.setProperty("sonar.leak.period", "100");
underTest.execute();
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
String textDate = "2008-11-22";
- settings.setProperty("sonar.timemachine.period1", textDate);
+ settings.setProperty("sonar.leak.period", textDate);
underTest.execute();
// Return analysis from given date 2008-11-22
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_DATE);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(period.getModeParameter()).isEqualTo(textDate);
assertThat(period.getSnapshotDate()).isEqualTo(1227358680000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1003");
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
String date = "2008-11-24";
- settings.setProperty("sonar.timemachine.period1", date);
+ settings.setProperty("sonar.leak.period", date);
underTest.execute();
// Analysis form 2008-11-29
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_DATE);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(period.getModeParameter()).isEqualTo(date);
assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1004");
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
// No analysis at and after this date
- settings.setProperty("sonar.timemachine.period1", "2008-11-30");
+ settings.setProperty("sonar.leak.period", "2008-11-30");
underTest.execute();
public void feed_period_by_days(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "10");
+ settings.setProperty("sonar.leak.period", "10");
underTest.execute();
// return analysis from 2008-11-20
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_DAYS);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_DAYS);
assertThat(period.getModeParameter()).isEqualTo("10");
assertThat(period.getSnapshotDate()).isEqualTo(1227157200000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1002");
public void no_period_by_days(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "empty.xml");
- settings.setProperty("sonar.timemachine.period1", "0");
+ settings.setProperty("sonar.leak.period", "0");
underTest.execute();
public void feed_period_by_previous_analysis(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_analysis");
+ settings.setProperty("sonar.leak.period", "previous_analysis");
underTest.execute();
// return analysis from 2008-11-29
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS);
assertThat(period.getModeParameter()).isNotNull();
assertThat(period.getSnapshotDate()).isEqualTo(1227934800000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1004");
public void no_period_by_previous_analysis(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "empty.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_analysis");
+ settings.setProperty("sonar.leak.period", "previous_analysis");
underTest.execute();
public void feed_period_by_previous_version() {
setupRoot(PROJECT_ROOT);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
// Analysis form 2008-11-12
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
assertThat(period.getModeParameter()).isEqualTo("1.0");
assertThat(period.getSnapshotDate()).isEqualTo(1226494680000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1001");
public void feed_period_by_previous_version_is_not_supported_for_views() {
setupRoot(VIEW_ROOT);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
public void feed_period_by_previous_version_with_previous_version_deleted() {
setupRoot(PROJECT_ROOT);
dbTester.prepareDbUnit(getClass(), "previous_version_deleted.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
// Analysis form 2008-11-11
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
assertThat(period.getModeParameter()).isEqualTo("0.9");
assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
public void no_period_by_previous_version(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "empty.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
public void feed_period_by_previous_version_with_first_analysis_when_no_previous_version_found() {
setupRoot(PROJECT_ROOT);
dbTester.prepareDbUnit(getClass(), "no_previous_version.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
assertThat(period.getModeParameter()).isNull();
assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
public void feed_period_by_previous_version_with_first_analysis_when_previous_snapshot_is_the_last_one() {
setupRoot(PROJECT_ROOT);
dbTester.prepareDbUnit(getClass(), "previous_version_is_last_one.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_VERSION);
assertThat(period.getModeParameter()).isNull();
assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
public void no_period_by_previous_version_when_no_event_version_for_views() {
setupRoot(VIEW_ROOT);
dbTester.prepareDbUnit(getClass(), "no_previous_version.xml");
- settings.setProperty("sonar.timemachine.period1", "previous_version");
+ settings.setProperty("sonar.leak.period", "previous_version");
underTest.execute();
public void feed_period_by_version(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "shared.xml");
- settings.setProperty("sonar.timemachine.period1", "0.9");
+ settings.setProperty("sonar.leak.period", "0.9");
underTest.execute();
// Analysis form 2008-11-11
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
- assertThat(period.getMode()).isEqualTo(TIMEMACHINE_MODE_VERSION);
+ assertThat(period.getMode()).isEqualTo(LEAK_PERIOD_MODE_VERSION);
assertThat(period.getModeParameter()).isEqualTo("0.9");
assertThat(period.getSnapshotDate()).isEqualTo(1226379600000L);
assertThat(period.getAnalysisUuid()).isEqualTo("u1000");
public void no_period_by_version(Component root) {
setupRoot(root);
dbTester.prepareDbUnit(getClass(), "empty.xml");
- settings.setProperty("sonar.timemachine.period1", "0.8");
+ settings.setProperty("sonar.leak.period", "0.8");
underTest.execute();
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
public class ReportPersistAnalysisStepTest extends BaseStepTest {
SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
dbTester.getSession().commit();
- periodsHolder.setPeriod(new Period(TIMEMACHINE_MODE_DATE, "2015-01-01", analysisDate, "u1"));
+ periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_DATE, "2015-01-01", analysisDate, "u1"));
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build();
treeRootHolder.setRoot(project);
underTest.execute();
SnapshotDto projectSnapshot = getUnprocessedSnapshot(projectDto.uuid());
- assertThat(projectSnapshot.getPeriodMode()).isEqualTo(TIMEMACHINE_MODE_DATE);
+ assertThat(projectSnapshot.getPeriodMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(projectSnapshot.getPeriodDate()).isEqualTo(analysisDate);
assertThat(projectSnapshot.getPeriodModeParameter()).isNotNull();
}
@Test
public void only_persist_snapshots_with_leak_period_on_project_and_module() {
- periodsHolder.setPeriod(new Period(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1"));
+ periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, analysisDate, "u1"));
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto projectDto = ComponentTesting.newProjectDto(organizationDto, "ABCD").setKey(PROJECT_KEY).setName("Project");
underTest.execute();
SnapshotDto newProjectSnapshot = getUnprocessedSnapshot(projectDto.uuid());
- assertThat(newProjectSnapshot.getPeriodMode()).isEqualTo(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
+ assertThat(newProjectSnapshot.getPeriodMode()).isEqualTo(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS);
}
@Test
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.db.component.ComponentTesting.newView;
Component view = ViewsComponent.builder(VIEW, "KEY_VIEW").setUuid("UUID_VIEW").addChildren(subView).build();
treeRootHolder.setRoot(view);
- periodsHolder.setPeriod(new Period(TIMEMACHINE_MODE_DATE, "2015-01-01", analysisDate, "u1"));
+ periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_DATE, "2015-01-01", analysisDate, "u1"));
underTest.execute();
SnapshotDto viewSnapshot = getUnprocessedSnapshot(viewDto.uuid());
- assertThat(viewSnapshot.getPeriodMode()).isEqualTo(TIMEMACHINE_MODE_DATE);
+ assertThat(viewSnapshot.getPeriodMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(viewSnapshot.getPeriodDate()).isEqualTo(analysisDate);
assertThat(viewSnapshot.getPeriodModeParameter()).isNotNull();
}
public class CorePropertyDefinitions {
- /* Time machine periods */
- public static final String TIMEMACHINE_PERIOD_PREFIX = "sonar.timemachine.period";
- public static final String TIMEMACHINE_MODE_PREVIOUS_ANALYSIS = "previous_analysis";
- public static final String TIMEMACHINE_MODE_DATE = "date";
- public static final String TIMEMACHINE_MODE_VERSION = "version";
- public static final String TIMEMACHINE_MODE_DAYS = "days";
- public static final String TIMEMACHINE_MODE_PREVIOUS_VERSION = "previous_version";
+ public static final String LEAK_PERIOD = "sonar.leak.period";
+ public static final String LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS = "previous_analysis";
+ public static final String LEAK_PERIOD_MODE_DATE = "date";
+ public static final String LEAK_PERIOD_MODE_VERSION = "version";
+ public static final String LEAK_PERIOD_MODE_DAYS = "days";
+ public static final String LEAK_PERIOD_MODE_PREVIOUS_VERSION = "previous_version";
- private static final String TIMEMACHINE_DEFAULT_PERIOD_1 = TIMEMACHINE_MODE_PREVIOUS_VERSION;
+ private static final String DEFAULT_LEAK_PERIOD = LEAK_PERIOD_MODE_PREVIOUS_VERSION;
private static final String CATEGORY_ORGANIZATIONS = "organizations";
public static final String ORGANIZATIONS_ANYONE_CAN_CREATE = "sonar.organizations.anyoneCanCreate";
.build(),
// SCANNER
- PropertyDefinition.builder(TIMEMACHINE_PERIOD_PREFIX + 1)
+ PropertyDefinition.builder(LEAK_PERIOD)
.name("Leak Period")
- .description("Period used to compare measures and track new issues. Values are : <ul><li>Number of days before " +
+ .deprecatedKey("sonar.timemachine.period1")
+ .description("Period used to compare measures and track new issues. Values are : <ul class='bullet'><li>Number of days before " +
"analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
"compare to previous analysis</li><li>'previous_version' to compare to the previous version in the project history</li>" +
"<li>A version, for example '1.2' or 'BASELINE'</li></ul>" +
"<p>When specifying a number of days or a date, the snapshot selected for comparison is " +
" the first one available inside the corresponding time range. </p>" +
"<p>Changing this property only takes effect after subsequent project inspections.<p/>")
- .defaultValue(TIMEMACHINE_DEFAULT_PERIOD_1)
+ .defaultValue(DEFAULT_LEAK_PERIOD)
.category(CoreProperties.CATEGORY_GENERAL)
.subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.VIEW)
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Locale.ENGLISH;
import static org.apache.commons.lang.StringUtils.isNotBlank;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAYS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_PERIOD_PREFIX;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
public class Periods {
@CheckForNull
public String label(int periodIndex) {
- String periodProperty = settings.getString(TIMEMACHINE_PERIOD_PREFIX + periodIndex);
+ String periodProperty = settings.getString(LEAK_PERIOD + periodIndex);
PeriodParameters periodParameters = new PeriodParameters(periodProperty);
return label(periodParameters.getMode(), periodParameters.getParam(), periodParameters.getDate());
}
@CheckForNull
public String abbreviation(int periodIndex) {
- String periodProperty = settings.getString(TIMEMACHINE_PERIOD_PREFIX + periodIndex);
+ String periodProperty = settings.getString(LEAK_PERIOD + periodIndex);
PeriodParameters periodParameters = new PeriodParameters(periodProperty);
return abbreviation(periodParameters.getMode(), periodParameters.getParam(), periodParameters.getDate());
}
@CheckForNull
private String label(String mode, @Nullable String param, @Nullable String date, boolean shortLabel) {
switch (mode) {
- case TIMEMACHINE_MODE_DAYS:
+ case LEAK_PERIOD_MODE_DAYS:
return labelForDays(param, date, shortLabel);
- case TIMEMACHINE_MODE_VERSION:
+ case LEAK_PERIOD_MODE_VERSION:
return labelForVersion(param, date, shortLabel);
- case TIMEMACHINE_MODE_PREVIOUS_ANALYSIS:
+ case LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS:
return labelForPreviousAnalysis(date, shortLabel);
- case TIMEMACHINE_MODE_PREVIOUS_VERSION:
+ case LEAK_PERIOD_MODE_PREVIOUS_VERSION:
return labelForPreviousVersion(param, date, shortLabel);
- case TIMEMACHINE_MODE_DATE:
+ case LEAK_PERIOD_MODE_DATE:
return label("since_x", shortLabel, date);
default:
throw new IllegalArgumentException("This mode is not supported : " + mode);
checkArgument(isNotBlank(periodProperty), "Period property should not be empty");
Integer possibleDaysValue = findByDays(periodProperty);
Date possibleDatesValue = findByDate(periodProperty);
- if (TIMEMACHINE_MODE_PREVIOUS_ANALYSIS.equals(periodProperty) || TIMEMACHINE_MODE_PREVIOUS_VERSION.equals(periodProperty)) {
+ if (LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS.equals(periodProperty) || LEAK_PERIOD_MODE_PREVIOUS_VERSION.equals(periodProperty)) {
mode = periodProperty;
} else if (possibleDaysValue != null) {
- mode = TIMEMACHINE_MODE_DAYS;
+ mode = LEAK_PERIOD_MODE_DAYS;
param = Integer.toString(possibleDaysValue);
} else if (possibleDatesValue != null) {
- mode = TIMEMACHINE_MODE_DATE;
+ mode = LEAK_PERIOD_MODE_DATE;
date = possibleDatesValue;
} else {
- mode = TIMEMACHINE_MODE_VERSION;
+ mode = LEAK_PERIOD_MODE_VERSION;
param = periodProperty;
}
}
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.api.config.Settings;
import org.sonar.api.config.MapSettings;
+import org.sonar.api.config.Settings;
import org.sonar.api.i18n.I18n;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.sonar.api.utils.DateUtils.parseDate;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DAYS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_PREVIOUS_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_VERSION;
-import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_PERIOD_PREFIX;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DATE;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_DAYS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_PREVIOUS_VERSION;
+import static org.sonar.core.config.CorePropertyDefinitions.LEAK_PERIOD_MODE_VERSION;
public class PeriodsTest {
@Test
public void return_over_x_days_label_when_no_date() {
- periods.label(TIMEMACHINE_MODE_DAYS, NUMBER_OF_DAYS, (String) null);
+ periods.label(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, (String) null);
verify(i18n).message(any(Locale.class), eq("over_x_days"), isNull(String.class), eq(NUMBER_OF_DAYS));
}
@Test
public void return_over_x_days_abbreviation_when_no_date() {
- periods.abbreviation(TIMEMACHINE_MODE_DAYS, NUMBER_OF_DAYS, null);
+ periods.abbreviation(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, null);
verify(i18n).message(any(Locale.class), eq("over_x_days.short"), isNull(String.class), eq(NUMBER_OF_DAYS));
}
@Test
public void return_over_x_days_detailed_label_when_date_is_set() {
- periods.label(TIMEMACHINE_MODE_DAYS, NUMBER_OF_DAYS, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("over_x_days_detailed"), isNull(String.class), eq(NUMBER_OF_DAYS), eq(STRING_DATE));
}
@Test
public void return_over_x_days_detailed_abbreviation_when_date_is_set() {
- periods.abbreviation(TIMEMACHINE_MODE_DAYS, NUMBER_OF_DAYS, DATE);
+ periods.abbreviation(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, DATE);
verify(i18n).message(any(Locale.class), eq("over_x_days_detailed.short"), isNull(String.class), eq(NUMBER_OF_DAYS), anyString());
}
@Test
public void return_over_x_days_label_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, NUMBER_OF_DAYS);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, NUMBER_OF_DAYS);
periods.label(PERIOD_INDEX);
@Test
public void return_since_version_label_when_no_date() {
- periods.label(TIMEMACHINE_MODE_VERSION, VERSION, (String) null);
+ periods.label(LEAK_PERIOD_MODE_VERSION, VERSION, (String) null);
verify(i18n).message(any(Locale.class), eq("since_version"), isNull(String.class), eq(VERSION));
}
@Test
public void return_since_version_abbreviation_when_no_date() {
- periods.abbreviation(TIMEMACHINE_MODE_VERSION, VERSION, null);
+ periods.abbreviation(LEAK_PERIOD_MODE_VERSION, VERSION, null);
verify(i18n).message(any(Locale.class), eq("since_version.short"), isNull(String.class), eq(VERSION));
}
@Test
public void return_since_version_detailed_label_when_date_is_set() {
- periods.label(TIMEMACHINE_MODE_VERSION, VERSION, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_VERSION, VERSION, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("since_version_detailed"), isNull(String.class), eq(VERSION), eq(STRING_DATE));
}
@Test
public void return_since_version_detailed_abbreviation_when_date_is_set() {
- periods.abbreviation(TIMEMACHINE_MODE_VERSION, VERSION, DATE);
+ periods.abbreviation(LEAK_PERIOD_MODE_VERSION, VERSION, DATE);
verify(i18n).message(any(Locale.class), eq("since_version_detailed.short"), isNull(String.class), eq(VERSION), anyString());
}
@Test
public void return_since_version_label_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, VERSION);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, VERSION);
periods.label(PERIOD_INDEX);
@Test
public void return_since_previous_analysis_label_when_no_date() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, (String) null);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, (String) null);
verify(i18n).message(any(Locale.class), eq("since_previous_analysis"), isNull(String.class));
}
@Test
public void return_since_previous_analysis_abbreviation_when_no_date() {
- periods.abbreviation(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, null);
+ periods.abbreviation(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, null);
verify(i18n).message(any(Locale.class), eq("since_previous_analysis.short"), isNull(String.class));
}
@Test
public void return_since_previous_analysis_detailed_label_when_date_is_set() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("since_previous_analysis_detailed"), isNull(String.class), eq(STRING_DATE));
}
@Test
public void return_since_previous_analysis_detailed_abbreviation_when_date_is_set() {
- periods.abbreviation(TIMEMACHINE_MODE_PREVIOUS_ANALYSIS, null, DATE);
+ periods.abbreviation(LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS, null, DATE);
verify(i18n).message(any(Locale.class), eq("since_previous_analysis_detailed.short"), isNull(String.class), anyString());
}
@Test
public void return_since_previous_analysis_label_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, TIMEMACHINE_MODE_PREVIOUS_ANALYSIS);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, LEAK_PERIOD_MODE_PREVIOUS_ANALYSIS);
periods.label(PERIOD_INDEX);
@Test
public void return_since_previous_version_label_when_no_param() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_VERSION, null, (String) null);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, (String) null);
verify(i18n).message(any(Locale.class), eq("since_previous_version"), isNull(String.class));
}
@Test
public void return_since_previous_version_abbreviation_when_no_param() {
- periods.abbreviation(TIMEMACHINE_MODE_PREVIOUS_VERSION, null, null);
+ periods.abbreviation(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, null);
verify(i18n).message(any(Locale.class), eq("since_previous_version.short"), isNull(String.class));
}
@Test
public void return_since_previous_version_detailed_label_when_param_is_set_and_no_date() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_VERSION, VERSION, (String) null);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_VERSION, VERSION, (String) null);
verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed"), isNull(String.class), eq(VERSION));
}
@Test
public void return_since_previous_version_detailed_abbreviation_when_param_is_set_and_no_date() {
- periods.abbreviation(TIMEMACHINE_MODE_PREVIOUS_VERSION, VERSION, null);
+ periods.abbreviation(LEAK_PERIOD_MODE_PREVIOUS_VERSION, VERSION, null);
verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed.short"), isNull(String.class), eq(VERSION));
}
@Test
public void return_since_previous_version_detailed_label_when_param_and_date_are_set() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_VERSION, VERSION, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_VERSION, VERSION, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed"), isNull(String.class), eq(VERSION), eq(STRING_DATE));
}
@Test
public void return_since_previous_version_with_only_date_label_when_no_param_and_date_is_set() {
- periods.label(TIMEMACHINE_MODE_PREVIOUS_VERSION, null, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("since_previous_version_with_only_date"), isNull(String.class), eq(STRING_DATE));
}
@Test
public void return_since_previous_version_detailed_abbreviation_when_param_and_date_are_set() {
- periods.abbreviation(TIMEMACHINE_MODE_PREVIOUS_VERSION, VERSION, DATE);
+ periods.abbreviation(LEAK_PERIOD_MODE_PREVIOUS_VERSION, VERSION, DATE);
verify(i18n).message(any(Locale.class), eq("since_previous_version_detailed.short"), isNull(String.class), eq(VERSION), anyString());
}
@Test
public void return_since_previous_version_label_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, TIMEMACHINE_MODE_PREVIOUS_VERSION);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, LEAK_PERIOD_MODE_PREVIOUS_VERSION);
periods.label(PERIOD_INDEX);
@Test
public void return_since_x_label() {
- periods.label(TIMEMACHINE_MODE_DATE, null, STRING_DATE);
+ periods.label(LEAK_PERIOD_MODE_DATE, null, STRING_DATE);
verify(i18n).message(any(Locale.class), eq("since_x"), isNull(String.class), eq(STRING_DATE));
}
@Test
public void return_since_x_label_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, STRING_DATE);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, STRING_DATE);
periods.label(PERIOD_INDEX);
@Test
public void return_since_x_abbreviation() {
- periods.abbreviation(TIMEMACHINE_MODE_DATE, null, DATE);
+ periods.abbreviation(LEAK_PERIOD_MODE_DATE, null, DATE);
verify(i18n).message(any(Locale.class), eq("since_x.short"), isNull(String.class), anyString());
}
@Test
public void return_abbreviation_using_settings() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, NUMBER_OF_DAYS);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, NUMBER_OF_DAYS);
periods.abbreviation(PERIOD_INDEX);
@Test
public void throw_IAE_when_period_property_is_empty() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, "");
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, "");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Period property should not be empty");
@Test
public void throw_IAE_when_period_property_is_null() {
- settings.setProperty(TIMEMACHINE_PERIOD_PREFIX + PERIOD_INDEX, (String) null);
+ settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, (String) null);
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Period property should not be empty");