]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8979 Drop leak period setting values on views
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 28 Aug 2017 10:58:21 +0000 (12:58 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 29 Aug 2017 15:52:09 +0000 (17:52 +0200)
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStep.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/LoadPeriodsStepTest.java
sonar-core/src/main/java/org/sonar/core/config/CorePropertyDefinitions.java

index 9ea2becfe2034ed3fad43d42784019f24fa27854..8a040e89ee4f93a55ad5c1127846f428b4650cba 100644 (file)
@@ -28,6 +28,8 @@ public class DbVersion66 implements DbVersion {
   public void addSteps(MigrationStepRegistry registry) {
     registry
       .add(1800, "Add incremental column to snapthots table", AddIncrementalColumnToSnapshotsTable.class)
-      .add(1801, "Create table CE task characteristics", CreateTableCeTaskCharacteristics.class);
+      .add(1801, "Create table CE task characteristics", CreateTableCeTaskCharacteristics.class)
+      .add(1802, "Delete leak settings on views", DeleteLeakSettingsOnViews.class)
+    ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViews.java
new file mode 100644 (file)
index 0000000..60cdc23
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.MassUpdate;
+
+public class DeleteLeakSettingsOnViews extends DataChange {
+
+  public DeleteLeakSettingsOnViews(Database db) {
+    super(db);
+  }
+
+  @Override
+  protected void execute(Context context) throws SQLException {
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT prop.id FROM properties prop " +
+      "INNER JOIN projects p ON p.id=prop.resource_id AND p.qualifier NOT IN ('TRK') " +
+      "WHERE prop.prop_key='sonar.leak.period' or prop.prop_key='sonar.timemachine.period1' ");
+    massUpdate.update("DELETE FROM properties WHERE id=?");
+    massUpdate.rowPluralName("properties");
+    massUpdate.execute((row, update) -> {
+      update.setLong(1, row.getLong(1));
+      return true;
+    });
+  }
+
+}
index 570084426154490b3aa5908c0524bc6ea1646ae7..407ed300852454290169bf7236f80fe9a02756b4 100644 (file)
  */
 package org.sonar.server.platform.db.migration.version.v66;
 
+import org.junit.Test;
+
 import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount;
 import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber;
 
-import org.junit.Test;
-
 public class DbVersion66Test {
   private DbVersion66 underTest = new DbVersion66();
 
@@ -34,6 +34,6 @@ public class DbVersion66Test {
 
   @Test
   public void verify_migration_count() {
-    verifyMigrationCount(underTest, 2);
+    verifyMigrationCount(underTest, 3);
   }
 }
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest.java
new file mode 100644 (file)
index 0000000..4582b3c
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package org.sonar.server.platform.db.migration.version.v66;
+
+import java.sql.SQLException;
+import java.util.Random;
+import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+import org.assertj.core.groups.Tuple;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.resources.Scopes;
+import org.sonar.core.util.Uuids;
+import org.sonar.db.CoreDbTester;
+
+import static java.lang.String.valueOf;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
+import static org.sonar.api.resources.Qualifiers.PROJECT;
+import static org.sonar.api.resources.Qualifiers.SUBVIEW;
+import static org.sonar.api.resources.Qualifiers.VIEW;
+
+public class DeleteLeakSettingsOnViewsTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DeleteLeakSettingsOnViewsTest.class, "settings_and_projects.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private DeleteLeakSettingsOnViews underTest = new DeleteLeakSettingsOnViews(db.database());
+
+  @Test
+  public void migrate_leak_settings_on_views() throws SQLException {
+    long viewId = insertComponent(Scopes.PROJECT, VIEW);
+    long subViewId = insertComponent(Scopes.PROJECT, SUBVIEW);
+    insertProperty("sonar.leak.period", viewId);
+    insertProperty("sonar.leak.period", subViewId);
+
+    underTest.execute();
+
+    assertPropertiesIsEmpty();
+  }
+
+  @Test
+  public void migrate_old_leak_settings_on_views() throws SQLException {
+    long viewId = insertComponent(Scopes.PROJECT, VIEW);
+    long subViewId = insertComponent(Scopes.PROJECT, SUBVIEW);
+    insertProperty("sonar.timemachine.period1", viewId);
+    insertProperty("sonar.timemachine.period1", subViewId);
+
+    underTest.execute();
+
+    assertPropertiesIsEmpty();
+  }
+
+  @Test
+  public void does_nothing_on_leak_settings_not_on_views() throws SQLException {
+    long projectId = insertComponent(Scopes.PROJECT, PROJECT);
+    insertProperty("sonar.leak.period", projectId);
+    insertProperty("sonar.leak.period", null);
+
+    underTest.execute();
+
+    assertProperties(
+      tuple("sonar.leak.period", projectId),
+      tuple("sonar.leak.period", null));
+  }
+
+  @Test
+  public void does_nothing_on_non_leak_settings() throws SQLException {
+    long projectId = insertComponent(Scopes.PROJECT, PROJECT);
+    insertProperty("sonar.component", projectId);
+    insertProperty("sonar.global", null);
+
+    underTest.execute();
+
+    assertProperties(
+      tuple("sonar.component", projectId),
+      tuple("sonar.global", null));
+  }
+
+  private void assertPropertiesIsEmpty(){
+    assertThat(db.countRowsOfTable("properties")).isZero();
+  }
+
+  private void assertProperties(Tuple... expectedTuples) {
+    assertThat(db.select("SELECT PROP_KEY, RESOURCE_ID FROM PROPERTIES")
+      .stream()
+      .map(map -> new Tuple(map.get("PROP_KEY"), map.get("RESOURCE_ID")))
+      .collect(Collectors.toList()))
+        .containsExactlyInAnyOrder(expectedTuples);
+  }
+
+  public void insertProperty(String propertyName, @Nullable Long componentId) {
+    db.executeInsert(
+      "properties",
+      "prop_key", propertyName,
+      "resource_id", componentId,
+      "is_empty", "false",
+      "text_value", randomAlphabetic(2));
+  }
+
+  private long insertComponent(@Nullable String scope, @Nullable String qualifier) {
+    String uuid = Uuids.createFast();
+    db.executeInsert(
+      "projects",
+      "organization_uuid", randomAlphanumeric(3),
+      "uuid", uuid,
+      "uuid_path", "path_of_" + uuid,
+      "root_uuid", uuid,
+      "project_uuid", uuid,
+      "scope", scope,
+      "qualifier", qualifier,
+      "private", valueOf(new Random().nextBoolean()),
+      "enabled", valueOf(new Random().nextBoolean()));
+    return ((Long) db.selectFirst("select id as \"ID\" from projects where uuid='" + uuid + "'").get("ID")).intValue();
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DeleteLeakSettingsOnViewsTest/settings_and_projects.sql
new file mode 100644 (file)
index 0000000..6d62b22
--- /dev/null
@@ -0,0 +1,57 @@
+CREATE TABLE "PROPERTIES" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PROP_KEY" VARCHAR(512) NOT NULL,
+  "RESOURCE_ID" INTEGER,
+  "USER_ID" INTEGER,
+  "IS_EMPTY" BOOLEAN NOT NULL,
+  "TEXT_VALUE" VARCHAR(4000),
+  "CLOB_VALUE" CLOB(2147483647),
+  "CREATED_AT" BIGINT
+);
+CREATE INDEX "PROPERTIES_KEY" ON "PROPERTIES" ("PROP_KEY");
+
+CREATE TABLE "PROJECTS" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "ORGANIZATION_UUID" VARCHAR(40) NOT NULL,
+  "KEE" VARCHAR(400),
+  "UUID" VARCHAR(50) NOT NULL,
+  "UUID_PATH" VARCHAR(1500) NOT NULL,
+  "ROOT_UUID" VARCHAR(50) NOT NULL,
+  "PROJECT_UUID" VARCHAR(50) NOT NULL,
+  "MODULE_UUID" VARCHAR(50),
+  "MODULE_UUID_PATH" VARCHAR(1500),
+  "NAME" VARCHAR(2000),
+  "DESCRIPTION" VARCHAR(2000),
+  "PRIVATE" BOOLEAN NOT NULL,
+  "TAGS" VARCHAR(500),
+  "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE,
+  "SCOPE" VARCHAR(3),
+  "QUALIFIER" VARCHAR(10),
+  "DEPRECATED_KEE" VARCHAR(400),
+  "PATH" VARCHAR(2000),
+  "LANGUAGE" VARCHAR(20),
+  "COPY_COMPONENT_UUID" VARCHAR(50),
+  "LONG_NAME" VARCHAR(2000),
+  "DEVELOPER_UUID" VARCHAR(50),
+  "CREATED_AT" TIMESTAMP,
+  "AUTHORIZATION_UPDATED_AT" BIGINT,
+  "B_CHANGED" BOOLEAN,
+  "B_COPY_COMPONENT_UUID" VARCHAR(50),
+  "B_DESCRIPTION" VARCHAR(2000),
+  "B_ENABLED" BOOLEAN,
+  "B_UUID_PATH" VARCHAR(1500),
+  "B_LANGUAGE" VARCHAR(20),
+  "B_LONG_NAME" VARCHAR(500),
+  "B_MODULE_UUID" VARCHAR(50),
+  "B_MODULE_UUID_PATH" VARCHAR(1500),
+  "B_NAME" VARCHAR(500),
+  "B_PATH" VARCHAR(2000),
+  "B_QUALIFIER" VARCHAR(10)
+);
+CREATE INDEX "PROJECTS_ORGANIZATION" ON "PROJECTS" ("ORGANIZATION_UUID");
+CREATE UNIQUE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE");
+CREATE INDEX "PROJECTS_ROOT_UUID" ON "PROJECTS" ("ROOT_UUID");
+CREATE UNIQUE INDEX "PROJECTS_UUID" ON "PROJECTS" ("UUID");
+CREATE INDEX "PROJECTS_PROJECT_UUID" ON "PROJECTS" ("PROJECT_UUID");
+CREATE INDEX "PROJECTS_MODULE_UUID" ON "PROJECTS" ("MODULE_UUID");
+CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER");
index be93f8fd7803d40cb4887d725dda5056c6e19ca5..ee17fcfcd1390a615b43169703cdc95643914184 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.ConfigurationRepository;
+import org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit;
 import org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler;
 import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolder;
 import org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter;
@@ -36,18 +37,15 @@ import org.sonar.server.computation.task.projectanalysis.period.PeriodHolder;
 import org.sonar.server.computation.task.projectanalysis.period.PeriodHolderImpl;
 import org.sonar.server.computation.task.step.ComputationStep;
 
-import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
-import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.VIEW;
 import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
-import static org.sonar.server.computation.task.projectanalysis.component.CrawlerDepthLimit.reportMaxDepth;
 
 /**
  * Populates the {@link PeriodHolder}
  * <p/>
  * Here is how these periods are computed :
- * - 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
+ * - 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, a period is set to the repository
  */
 public class LoadPeriodsStep implements ComputationStep {
 
@@ -69,16 +67,11 @@ public class LoadPeriodsStep implements ComputationStep {
   @Override
   public void execute() {
     new DepthTraversalTypeAwareCrawler(
-      new TypeAwareVisitorAdapter(reportMaxDepth(PROJECT).withViewsMaxDepth(VIEW), PRE_ORDER) {
+      new TypeAwareVisitorAdapter(CrawlerDepthLimit.PROJECT, PRE_ORDER) {
         @Override
         public void visitProject(Component project) {
           execute(project);
         }
-
-        @Override
-        public void visitView(Component view) {
-          execute(view);
-        }
       }).visit(treeRootHolder.getRoot());
   }
 
index a0bfda79d629c76d90ac6e7a4d6a777b35c5ee95..c852a367335a903b50b9e9362884ce5b61c2693e 100644 (file)
@@ -19,9 +19,7 @@
  */
 package org.sonar.server.computation.task.projectanalysis.step;
 
-import com.tngtech.java.junit.dataprovider.DataProvider;
 import com.tngtech.java.junit.dataprovider.DataProviderRunner;
-import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.text.SimpleDateFormat;
 import org.junit.Before;
 import org.junit.Rule;
@@ -91,18 +89,9 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     when(settingsRepository.getConfiguration(root)).thenReturn(settings.asConfig());
   }
 
-  @DataProvider
-  public static Object[][] projectAndViewRoots() {
-    return new Object[][] {
-      {PROJECT_ROOT},
-      {VIEW_ROOT}
-    };
-  }
-
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_on_first_analysis(Component root) {
-    setupRoot(root);
+  public void no_period_on_first_analysis() {
+    setupRoot(PROJECT_ROOT);
 
     // No project, no snapshot
     underTest.execute();
@@ -111,9 +100,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void feed_one_period(Component root) {
-    setupRoot(root);
+  public void feed_one_period() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     String textDate = "2008-11-22";
     settings.setProperty("sonar.leak.period", textDate);
@@ -129,9 +117,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_when_settings_match_no_analysis(Component root) {
-    setupRoot(root);
+  public void no_period_when_settings_match_no_analysis() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     settings.setProperty("sonar.leak.period", "UNKNWOWN VERSION");
 
@@ -141,9 +128,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_when_settings_is_empty(Component root) {
-    setupRoot(root);
+  public void no_period_when_settings_is_empty() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     settings.setProperty("sonar.leak.period", "");
 
@@ -153,9 +139,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void ignore_unprocessed_snapshots(Component root) {
-    setupRoot(root);
+  public void ignore_unprocessed_snapshots() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "unprocessed_snapshots.xml");
     settings.setProperty("sonar.leak.period", "100");
 
@@ -165,9 +150,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void feed_period_by_date(Component root) {
-    setupRoot(root);
+  public void feed_period_by_date() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     String textDate = "2008-11-22";
     settings.setProperty("sonar.leak.period", textDate);
@@ -187,9 +171,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void search_by_date_return_nearest_later_analysis(Component root) {
-    setupRoot(root);
+  public void search_by_date_return_nearest_later_analysis() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     String date = "2008-11-24";
     settings.setProperty("sonar.leak.period", date);
@@ -206,9 +189,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_by_date(Component root) {
-    setupRoot(root);
+  public void no_period_by_date() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     // No analysis at and after this date
     settings.setProperty("sonar.leak.period", "2008-11-30");
@@ -219,9 +201,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void feed_period_by_days(Component root) {
-    setupRoot(root);
+  public void feed_period_by_days() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     settings.setProperty("sonar.leak.period", "10");
 
@@ -240,9 +221,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_by_days(Component root) {
-    setupRoot(root);
+  public void no_period_by_days() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "empty.xml");
     settings.setProperty("sonar.leak.period", "0");
 
@@ -252,9 +232,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void feed_period_by_previous_analysis(Component root) {
-    setupRoot(root);
+  public void feed_period_by_previous_analysis() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     settings.setProperty("sonar.leak.period", "previous_analysis");
 
@@ -273,9 +252,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_by_previous_analysis(Component root) {
-    setupRoot(root);
+  public void no_period_by_previous_analysis() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "empty.xml");
     settings.setProperty("sonar.leak.period", "previous_analysis");
 
@@ -316,17 +294,6 @@ public class LoadPeriodsStepTest extends BaseStepTest {
     assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).startsWith("Compare to previous version (");
   }
 
-  @Test
-  public void feed_period_by_previous_version_is_not_supported_for_views() {
-    setupRoot(VIEW_ROOT);
-    dbTester.prepareDbUnit(getClass(), "shared.xml");
-    settings.setProperty("sonar.leak.period", "previous_version");
-
-    underTest.execute();
-
-    assertThat(periodsHolder.getPeriod()).isNull();
-  }
-
   @Test
   public void feed_period_by_previous_version_with_previous_version_deleted() {
     setupRoot(PROJECT_ROOT);
@@ -345,9 +312,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_by_previous_version(Component root) {
-    setupRoot(root);
+  public void no_period_by_previous_version() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "empty.xml");
     settings.setProperty("sonar.leak.period", "previous_version");
 
@@ -389,20 +355,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  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.leak.period", "previous_version");
-
-    underTest.execute();
-
-    assertThat(periodsHolder.getPeriod()).isNull();
-  }
-
-  @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void feed_period_by_version(Component root) {
-    setupRoot(root);
+  public void feed_period_by_version() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "shared.xml");
     settings.setProperty("sonar.leak.period", "0.9");
 
@@ -421,9 +375,8 @@ public class LoadPeriodsStepTest extends BaseStepTest {
   }
 
   @Test
-  @UseDataProvider("projectAndViewRoots")
-  public void no_period_by_version(Component root) {
-    setupRoot(root);
+  public void no_period_by_version() {
+    setupRoot(PROJECT_ROOT);
     dbTester.prepareDbUnit(getClass(), "empty.xml");
     settings.setProperty("sonar.leak.period", "0.8");
 
index 52041056c88d3a6e6f10ab53ba57847b316328e4..d1b3dbea6c9f7b18759f509f8747297ad1373b12 100644 (file)
@@ -231,7 +231,7 @@ public class CorePropertyDefinitions {
         .defaultValue(DEFAULT_LEAK_PERIOD)
         .category(CoreProperties.CATEGORY_GENERAL)
         .subCategory(CoreProperties.SUBCATEGORY_DIFFERENTIAL_VIEWS)
-        .onQualifiers(Qualifiers.PROJECT, Qualifiers.VIEW)
+        .onQualifiers(Qualifiers.PROJECT)
         .build(),
 
       // CPD