From 298b3f58af36a48512dedd058ddc4f4d1c122715 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Mon, 25 Jul 2016 11:24:22 +0200 Subject: [PATCH] SONAR-7916 Remove built-in default project dashboard --- .../it/componentDashboard/DashboardTest.java | 3 - .../global_dashboard/default-dashboards.html | 45 ---------- .../order-project-default-dashboards.html | 89 ------------------- .../template/ProjectCustomDashboard.java | 79 ---------------- .../server/dashboard/ws/DashboardsWs.java | 1 + .../platformlevel/PlatformLevel4.java | 2 - .../template/ProjectCustomDashboardTest.java | 69 -------------- .../ProjectCustomDashboardTest/filters.xml | 33 ------- 8 files changed, 1 insertion(+), 320 deletions(-) delete mode 100644 it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/order-project-default-dashboards.html delete mode 100644 server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java delete mode 100644 server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java delete mode 100644 server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml diff --git a/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java b/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java index 8c2d3bf345e..4ef6c3000e9 100644 --- a/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java +++ b/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java @@ -58,9 +58,6 @@ public class DashboardTest { // SONAR-4630 "/componentDashboard/DashboardTest/global_dashboard/create-global-dashboards-error.html", - // SONAR-3461 - "/componentDashboard/DashboardTest/global_dashboard/order-project-default-dashboards.html", - // SONAR-3462 "/componentDashboard/DashboardTest/global_dashboard/order-global-dashboard.html", diff --git a/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/default-dashboards.html b/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/default-dashboards.html index 9a6439c22af..3bc101132a4 100644 --- a/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/default-dashboards.html +++ b/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/default-dashboards.html @@ -53,51 +53,6 @@ remove-Home - - waitForText - activeProject - *Custom* - - - assertNotText - shared - *Custom* - - - clickAndWait - id=remove-Custom - - - - assertConfirmation - Are you sure to remove it from default dashboards? - - - - waitForText - shared - *Custom* - - - assertNotText - activeProject - *Custom* - - - clickAndWait - add-Custom - - - - waitForText - activeProject - *Custom* - - - assertNotText - shared - *Custom* - diff --git a/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/order-project-default-dashboards.html b/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/order-project-default-dashboards.html deleted file mode 100644 index e0281f68124..00000000000 --- a/it/it-tests/src/test/resources/componentDashboard/DashboardTest/global_dashboard/order-project-default-dashboards.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - order-project-default-dashboards - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
order-project-default-dashboards
open/sessions/login
typeloginadmin
typepasswordadmin
clickAndWaitcommit
open/admin_dashboards
assertTextPresentProject Dashboards
assertTableid=activeProject.1.0Custom
assertTableid=activeProject.2.0Fake
Fake dashboard for integration tests
clickAndWaitid=up-Fake
assertTableid=activeProject.1.0Fake
Fake dashboard for integration tests
assertTableid=activeProject.2.0Custom
clickAndWaitid=down-Fake
assertTableid=activeProject.1.0Custom
assertTableid=activeProject.2.0Fake
Fake dashboard for integration tests
- - diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java deleted file mode 100644 index be76a07cd7f..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/template/ProjectCustomDashboard.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.dashboard.template; - -import com.google.common.base.Preconditions; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.api.web.DashboardTemplate; -import org.sonar.db.issue.IssueFilterDao; -import org.sonar.db.issue.IssueFilterDto; -import org.sonar.server.dashboard.widget.ProjectIssueFilterWidget; - -/** - * Custom dashboard - * - * @since 2.13 - */ -public final class ProjectCustomDashboard extends DashboardTemplate { - - private final IssueFilterDao issueFilterDao; - - public ProjectCustomDashboard(IssueFilterDao issueFilterDao) { - this.issueFilterDao = issueFilterDao; - } - - @Override - public String getName() { - return "Custom"; - } - - @Override - public Dashboard createDashboard() { - Dashboard dashboard = Dashboard.create(); - dashboard.setLayout(DashboardLayout.TWO_COLUMNS); - addFirstColumn(dashboard); - addSecondColumn(dashboard); - return dashboard; - } - - private static void addFirstColumn(Dashboard dashboard) { - dashboard.addWidget("size", 1); - dashboard.addWidget("code_coverage", 1); - dashboard.addWidget("duplications", 1); - dashboard.addWidget("documentation_comments", 1); - } - - private void addSecondColumn(Dashboard dashboard) { - dashboard.addWidget("rules", 2); - dashboard.addWidget("timeline", 2); - IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues"); - dashboard.addWidget(ProjectIssueFilterWidget.ID, 2) - .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId())) - .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "createdAt"); - } - - private IssueFilterDto getIssueFilterByName(String name) { - IssueFilterDto filter = issueFilterDao.selectProvidedFilterByName(name); - Preconditions.checkState(filter != null, String.format("Could not find a provided issue filter with name '%s'", name)); - return filter; - } - -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java index 34677e1a6dc..706d1a913e5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/dashboard/ws/DashboardsWs.java @@ -34,6 +34,7 @@ public class DashboardsWs implements WebService { NewController controller = context.createController("api/dashboards"); controller.setSince("5.0"); controller.setDescription("Manage dashboards and widgets."); + for (DashboardsWsAction action : actions) { action.define(controller); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 34f76578c2e..75620ab5bfb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -51,7 +51,6 @@ import org.sonar.server.component.DefaultRubyComponentService; import org.sonar.server.component.ws.ComponentsWsModule; import org.sonar.server.config.ws.PropertiesWs; import org.sonar.server.dashboard.template.GlobalDefaultDashboard; -import org.sonar.server.dashboard.template.ProjectCustomDashboard; import org.sonar.server.dashboard.widget.AlertsWidget; import org.sonar.server.dashboard.widget.BubbleChartWidget; import org.sonar.server.dashboard.widget.ComplexityWidget; @@ -331,7 +330,6 @@ public class PlatformLevel4 extends PlatformLevel { // Dashboard DashboardsWs.class, org.sonar.server.dashboard.ws.ShowAction.class, - ProjectCustomDashboard.class, GlobalDefaultDashboard.class, AlertsWidget.class, CoverageWidget.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java b/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java deleted file mode 100644 index 817b4ab68d4..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/dashboard/template/ProjectCustomDashboardTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.dashboard.template; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.api.utils.System2; -import org.sonar.api.web.Dashboard; -import org.sonar.api.web.DashboardLayout; -import org.sonar.db.DbTester; -import org.sonar.db.issue.IssueFilterDao; - -import static org.assertj.core.api.Assertions.assertThat; - - -public class ProjectCustomDashboardTest { - - @Rule - public DbTester dbTester = DbTester.create(System2.INSTANCE); - - ProjectCustomDashboard template; - - @Before - public void setUp() { - IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis()); - template = new ProjectCustomDashboard(issueFilterDao); - } - - @Test - public void should_have_a_name() { - assertThat(template.getName()).isEqualTo("Custom"); - } - - @Test - public void should_create_dashboard() { - dbTester.prepareDbUnit(getClass(), "filters.xml"); - Dashboard dashboard = template.createDashboard(); - - assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS); - assertThat(dashboard.getWidgets()).hasSize(7); - } - - @Test - public void should_provide_clean_error_message_on_failure() { - try { - template.createDashboard(); - } catch (IllegalStateException illegalState) { - assertThat(illegalState).hasMessage("Could not find a provided issue filter with name 'Unresolved Issues'"); - } - } -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml b/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml deleted file mode 100644 index 8ec92ddcdbf..00000000000 --- a/server/sonar-server/src/test/resources/org/sonar/server/dashboard/template/ProjectCustomDashboardTest/filters.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - -- 2.39.5