]> source.dussan.org Git - sonarqube.git/commitdiff
Remove PurgeRemovedViewsStep as Views plugin is currently not supported
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 21 May 2015 09:13:17 +0000 (11:13 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 21 May 2015 09:13:29 +0000 (11:13 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputationSteps.java
server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeRemovedViewsStep.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputationStepsTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeRemovedViewsStepTest.java [deleted file]

index f70df2eeb1575f756e23c4708614cf1f64e061d6..f846367ebaf052e38023a68b467d20ff8d090bd7 100644 (file)
@@ -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 (file)
index 3f0c7fe..0000000
+++ /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";
-  }
-}
index fb4cac219d0395fafe4165e1ae09d24caba4dcf2..a69c778647368b701226e21559a662ff31bc9928 100644 (file)
@@ -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 (file)
index 4ca0363..0000000
+++ /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;
-  }
-}