From 85e7e49bcfa5fb64fd499060c279cd679c799e39 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 8 Feb 2012 10:15:56 +0100 Subject: SONAR-2747 Verification is now done on period1 And not necessarily 'since last analysis' period. --- .../batch/components/TimeMachineConfiguration.java | 22 ---------------------- .../components/TimeMachineConfigurationTest.java | 20 -------------------- 2 files changed, 42 deletions(-) (limited to 'sonar-batch/src') diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java index 59a07f5eaa8..b5e567ce18d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java @@ -112,26 +112,4 @@ public class TimeMachineConfiguration implements BatchExtension { public boolean isFileVariationEnabled() { return configuration.getBoolean("sonar.enableFileVariation", Boolean.FALSE); } - - /** - * Returns the index corresponding to the 'previous_analysis' period (which is '1' by default). - * - * @return the index of 'previous_analysis' period, or NULL is users have modified the periods and haven't set a 'previous_analysis' one. - */ - public Integer getLastAnalysisPeriodIndex() { - // period1 is the default for 'previous_analysis' - String period1 = configuration.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + "1"); - if (StringUtils.isBlank(period1) || CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS.equals(period1)) { - return 1; - } - // else search for the other periods - for (int index = 2; index < 6; index++) { - if (CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS.equals(configuration - .getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index))) { - return index; - } - } - // if we're here, this means that we have not found the 'previous_analysis' mode - return null; - } } diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java index 7d4be9f7802..68468e09e7e 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java @@ -21,7 +21,6 @@ package org.sonar.batch.components; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.nullValue; import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; @@ -85,23 +84,4 @@ public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { verifyZeroInteractions(pastSnapshotFinder); } - @Test - public void shouldReturnLastAnalysisIndexIfSet() { - PropertiesConfiguration conf = new PropertiesConfiguration(); - TimeMachineConfiguration timeMachineConfiguration = new TimeMachineConfiguration(getSession(), new Project("my:project"), conf, - mock(PastSnapshotFinder.class)); - - // Nothing set, so period for 'previous_analysis' is 1 by default - assertThat(timeMachineConfiguration.getLastAnalysisPeriodIndex(), is(1)); - - // period1 has been replaced and 'previous_analysis' not set elsewhere... - conf.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 1, "Version 1"); - conf.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 2, "Version 2"); - assertThat(timeMachineConfiguration.getLastAnalysisPeriodIndex(), is(nullValue())); - - // 'previous_analysis' has now been set on period 4 - conf.setProperty(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + 4, CoreProperties.TIMEMACHINE_MODE_PREVIOUS_ANALYSIS); - assertThat(timeMachineConfiguration.getLastAnalysisPeriodIndex(), is(4)); - } - } -- cgit v1.2.3