aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-05-21 11:13:17 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-05-21 11:13:29 +0200
commitddd5ae8c97ff7fcf3a3e5f6470ee97b91a41e7d1 (patch)
tree2314fb0810c294497b2cae70e38fde1d788b2ea2 /server
parent15a5d88f1ef0105072d3733fe81c685d492084bd (diff)
downloadsonarqube-ddd5ae8c97ff7fcf3a3e5f6470ee97b91a41e7d1.tar.gz
sonarqube-ddd5ae8c97ff7fcf3a3e5f6470ee97b91a41e7d1.zip
Remove PurgeRemovedViewsStep as Views plugin is currently not supported
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeRemovedViewsStep.java72
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeRemovedViewsStepTest.java105
4 files changed, 2 insertions, 183 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
index f70df2eeb15..f846367ebaf 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
@@ -62,9 +62,6 @@ public class ComputationSteps {
IndexTestsStep.class,
IndexViewsStep.class,
- // Purge of removed views has to be done after Views has been indexed
- PurgeRemovedViewsStep.class,
-
// notifications are sent at the end, so that webapp displays up-to-date information
SendIssueNotificationsStep.class);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeRemovedViewsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeRemovedViewsStep.java
deleted file mode 100644
index 3f0c7fe4e9d..00000000000
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeRemovedViewsStep.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.computation.step;
-
-import com.google.common.collect.Sets;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.server.computation.ComputationContext;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.view.index.ViewIndex;
-
-import java.util.Set;
-
-import static com.google.common.collect.Sets.newHashSet;
-
-/**
- * This step removes from index the views and sub-views that do not exist in db.
- * As it's executed on each analysis, it means that when the Views task is executed on every views, this step will be executed on each views !
- *
- * A more optimized approach would be to execute this step only once at this end of the Views task.
- */
-public class PurgeRemovedViewsStep implements ComputationStep {
-
- private final DbClient dbClient;
- private final ViewIndex index;
-
- public PurgeRemovedViewsStep(ViewIndex index, DbClient dbClient) {
- this.index = index;
- this.dbClient = dbClient;
- }
-
- @Override
- public String[] supportedProjectQualifiers() {
- return new String[] {Qualifiers.VIEW};
- }
-
- @Override
- public void execute(ComputationContext context) {
- DbSession session = dbClient.openSession(false);
- try {
- Set<String> viewUuidsInIndex = newHashSet(index.findAllViewUuids());
- Set<String> viewUuidInDb = newHashSet(dbClient.componentDao().selectExistingUuids(session, viewUuidsInIndex));
- Set<String> viewsToRemove = Sets.difference(viewUuidsInIndex, viewUuidInDb);
- index.delete(viewsToRemove);
- } finally {
- session.close();
- }
- }
-
- @Override
- public String getDescription() {
- return "Purge removed views";
- }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java
index fb4cac219d0..a69c7786473 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java
@@ -36,7 +36,6 @@ public class ComputationStepsTest {
mock(ParseReportStep.class),
mock(IndexSourceLinesStep.class),
mock(IndexViewsStep.class),
- mock(PurgeRemovedViewsStep.class),
mock(PersistIssuesStep.class),
mock(IndexIssuesStep.class),
mock(SwitchSnapshotStep.class),
@@ -53,9 +52,9 @@ public class ComputationStepsTest {
mock(IndexTestsStep.class)
);
- assertThat(registry.orderedSteps()).hasSize(19);
+ assertThat(registry.orderedSteps()).hasSize(18);
assertThat(registry.orderedSteps().get(0)).isInstanceOf(ParseReportStep.class);
- assertThat(registry.orderedSteps().get(18)).isInstanceOf(SendIssueNotificationsStep.class);
+ assertThat(registry.orderedSteps().get(17)).isInstanceOf(SendIssueNotificationsStep.class);
}
@Test
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeRemovedViewsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeRemovedViewsStepTest.java
deleted file mode 100644
index 4ca0363f27d..00000000000
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeRemovedViewsStepTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.computation.step;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.core.component.ComponentDto;
-import org.sonar.core.persistence.DbSession;
-import org.sonar.core.persistence.DbTester;
-import org.sonar.server.component.ComponentTesting;
-import org.sonar.server.component.db.ComponentDao;
-import org.sonar.server.computation.ComputationContext;
-import org.sonar.server.db.DbClient;
-import org.sonar.server.es.EsTester;
-import org.sonar.server.issue.db.IssueDao;
-import org.sonar.server.view.index.ViewDoc;
-import org.sonar.server.view.index.ViewIndex;
-import org.sonar.server.view.index.ViewIndexDefinition;
-
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class PurgeRemovedViewsStepTest extends BaseStepTest {
-
- @ClassRule
- public static EsTester esTester = new EsTester().addDefinitions(new ViewIndexDefinition(new Settings()));
-
- @Rule
- public DbTester db = new DbTester();
-
- ComputationContext context = mock(ComputationContext.class);
- DbSession session;
- DbClient dbClient;
- PurgeRemovedViewsStep sut;
-
- @Before
- public void setUp() {
- esTester.truncateIndices();
- session = db.myBatis().openSession(false);
- dbClient = new DbClient(db.database(), db.myBatis(), new IssueDao(db.myBatis()), new ComponentDao());
- sut = new PurgeRemovedViewsStep(new ViewIndex(esTester.client()), dbClient);
- }
-
- @After
- public void after() {
- this.session.close();
- }
-
- @Test
- public void purge_removed_views() throws Exception {
- when(context.getProject()).thenReturn(ComponentTesting.newProjectDto("DBCA").setQualifier(Qualifiers.VIEW));
-
- esTester.putDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW,
- new ViewDoc().setUuid("ABCD"),
- new ViewDoc().setUuid("BCDE"),
- // Should be removed as it no more exists in db
- new ViewDoc().setUuid("CDEF"));
-
- ComponentDto view = ComponentTesting.newProjectDto("ABCD").setQualifier(Qualifiers.VIEW);
- ComponentDto subView = ComponentTesting.newModuleDto("BCDE", view).setQualifier(Qualifiers.SUBVIEW);
- dbClient.componentDao().insert(session, view, subView);
- session.commit();
-
- sut.execute(context);
-
- List<String> viewUuids = esTester.getDocumentFieldValues(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, ViewIndexDefinition.FIELD_UUID);
- assertThat(viewUuids).containsOnly("ABCD", "BCDE");
- }
-
- @Test
- public void only_support_views() {
- assertThat(sut.supportedProjectQualifiers()).containsOnly(Qualifiers.VIEW);
- }
-
- @Override
- protected ComputationStep step() {
- return sut;
- }
-}