*/
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;
/**
* Default dashboard
*/
public final class ProjectDefaultDashboard extends DashboardTemplate {
+ private final IssueFilterDao issueFilterDao;
+
+ public ProjectDefaultDashboard(IssueFilterDao issueFilterDao) {
+ this.issueFilterDao = issueFilterDao;
+ }
+
@Override
public String getName() {
return "Dashboard";
}
private void addFirstColumn(Dashboard dashboard) {
- dashboard.addWidget("size", 1);
- dashboard.addWidget("duplications", 1);
- dashboard.addWidget("complexity", 1);
- dashboard.addWidget("events", 1);
- dashboard.addWidget("description", 1);
+ dashboard.addWidget("technical_debt_pyramid", 1);
}
private void addSecondColumn(Dashboard dashboard) {
- dashboard.addWidget("debt_overview", 2);
- dashboard.addWidget("rules", 2);
- dashboard.addWidget("alerts", 2);
- dashboard.addWidget("code_coverage", 2);
+ IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues");
+
+ dashboard.addWidget(ProjectIssueFilterWidget.ID, 2)
+ .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId()))
+ .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "severities")
+ .setProperty(ProjectIssueFilterWidget.DISPLAY_MODE, "debt");
+ }
+
+ 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;
}
}
+++ /dev/null
-/*
- * 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.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;
-
-/**
- * Issues dashboard for Sonar
- *
- * @since 3.6
- */
-public final class ProjectIssuesDashboard extends DashboardTemplate {
-
- private final IssueFilterDao issueFilterDao;
-
- public ProjectIssuesDashboard(IssueFilterDao issueFilterDao) {
- this.issueFilterDao = issueFilterDao;
- }
-
- @Override
- public String getName() {
- return "Issues";
- }
-
- @Override
- public Dashboard createDashboard() {
- Dashboard dashboard = Dashboard.create();
- dashboard.setLayout(DashboardLayout.TWO_COLUMNS);
-
- IssueFilterDto unresolvedIssues = getIssueFilterByName("Unresolved Issues");
- IssueFilterDto hiddenDebt = getIssueFilterByName("False Positive and Won't Fix Issues");
- IssueFilterDto myUnresolvedIssues = getIssueFilterByName("My Unresolved Issues");
-
- addFirstColumn(dashboard, unresolvedIssues);
- addSecondColumn(dashboard, unresolvedIssues, hiddenDebt, myUnresolvedIssues);
- return dashboard;
- }
-
- 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;
- }
-
- private void addFirstColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues) {
- // Unresolved issues by status
- dashboard.addWidget(ProjectIssueFilterWidget.ID, 1)
- .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId()))
- .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "statuses");
- // Action plans
- dashboard.addWidget("action_plans", 1);
- }
-
- private void addSecondColumn(Dashboard dashboard, IssueFilterDto unresolvedIssues, IssueFilterDto hiddenDebt, IssueFilterDto myUnresolvedIssues) {
- // Unresolved issues by assignee
- dashboard.addWidget(ProjectIssueFilterWidget.ID, 2)
- .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(unresolvedIssues.getId()))
- .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "assignees");
- // My unresolved issues
- dashboard.addWidget(ProjectIssueFilterWidget.ID, 2)
- .setProperty("filter", Long.toString(myUnresolvedIssues.getId()));
- // False positive and won't fix issues by resolution
- dashboard.addWidget(ProjectIssueFilterWidget.ID, 2)
- .setProperty(ProjectIssueFilterWidget.FILTER_PROPERTY, Long.toString(hiddenDebt.getId()))
- .setProperty(ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, "resolutions");
- }
-
-}
+++ /dev/null
-/*
- * 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.dashboard.template;
-
-import org.sonar.api.measures.CoreMetrics;
-import org.sonar.api.web.Dashboard;
-import org.sonar.api.web.Dashboard.Widget;
-import org.sonar.api.web.DashboardLayout;
-import org.sonar.api.web.DashboardTemplate;
-
-/**
- * Time Machine dashboard
- *
- * @since 3.0
- */
-public final class ProjectTimeMachineDashboard extends DashboardTemplate {
-
- private static final String METRIC1 = "metric1";
- private static final String METRIC2 = "metric2";
- private static final String METRIC3 = "metric3";
- private static final String METRIC4 = "metric4";
- private static final String METRIC5 = "metric5";
- private static final String METRIC6 = "metric6";
- private static final String METRIC7 = "metric7";
- private static final String METRIC8 = "metric8";
-
- @Override
- public String getName() {
- return "TimeMachine";
- }
-
- @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) {
- Widget timelineWidget = dashboard.addWidget("timeline", 1);
- timelineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY);
- timelineWidget.setProperty(METRIC2, CoreMetrics.TECHNICAL_DEBT_KEY);
- timelineWidget.setProperty(METRIC3, CoreMetrics.COVERAGE_KEY);
-
- Widget sizeTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard);
- sizeTimeMachineWidget.setProperty(METRIC1, CoreMetrics.NCLOC_KEY);
- sizeTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINES_KEY);
- sizeTimeMachineWidget.setProperty(METRIC3, CoreMetrics.STATEMENTS_KEY);
- sizeTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILES_KEY);
- sizeTimeMachineWidget.setProperty(METRIC5, CoreMetrics.CLASSES_KEY);
- sizeTimeMachineWidget.setProperty(METRIC6, CoreMetrics.FUNCTIONS_KEY);
- sizeTimeMachineWidget.setProperty(METRIC7, CoreMetrics.ACCESSORS_KEY);
-
- Widget commentsTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard);
- commentsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMMENT_LINES_DENSITY_KEY);
- commentsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.COMMENT_LINES_KEY);
- commentsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY_KEY);
- commentsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.PUBLIC_UNDOCUMENTED_API_KEY);
-
- Widget duplicationTimeMachineWidget = addTimeMachineWidgetOnFirstColumn(dashboard);
- duplicationTimeMachineWidget.setProperty(METRIC1, CoreMetrics.DUPLICATED_LINES_DENSITY_KEY);
- duplicationTimeMachineWidget.setProperty(METRIC2, CoreMetrics.DUPLICATED_LINES_KEY);
- duplicationTimeMachineWidget.setProperty(METRIC3, CoreMetrics.DUPLICATED_BLOCKS_KEY);
- duplicationTimeMachineWidget.setProperty(METRIC4, CoreMetrics.DUPLICATED_FILES_KEY);
- }
-
- private static void addSecondColumn(Dashboard dashboard) {
- Widget rulesTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard);
- rulesTimeMachineWidget.setProperty(METRIC1, CoreMetrics.VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC2, CoreMetrics.BLOCKER_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CRITICAL_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC4, CoreMetrics.MAJOR_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC5, CoreMetrics.MINOR_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC6, CoreMetrics.INFO_VIOLATIONS_KEY);
- rulesTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TECHNICAL_DEBT_KEY);
-
- Widget complexityTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard);
- complexityTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COMPLEXITY_KEY);
- complexityTimeMachineWidget.setProperty(METRIC2, CoreMetrics.FUNCTION_COMPLEXITY_KEY);
- complexityTimeMachineWidget.setProperty(METRIC3, CoreMetrics.CLASS_COMPLEXITY_KEY);
- complexityTimeMachineWidget.setProperty(METRIC4, CoreMetrics.FILE_COMPLEXITY_KEY);
-
- Widget testsTimeMachineWidget = addTimeMachineWidgetOnSecondColumn(dashboard);
- testsTimeMachineWidget.setProperty(METRIC1, CoreMetrics.COVERAGE_KEY);
- testsTimeMachineWidget.setProperty(METRIC2, CoreMetrics.LINE_COVERAGE_KEY);
- testsTimeMachineWidget.setProperty(METRIC3, CoreMetrics.BRANCH_COVERAGE_KEY);
- testsTimeMachineWidget.setProperty(METRIC4, CoreMetrics.TEST_SUCCESS_DENSITY_KEY);
- testsTimeMachineWidget.setProperty(METRIC5, CoreMetrics.TEST_FAILURES_KEY);
- testsTimeMachineWidget.setProperty(METRIC6, CoreMetrics.TEST_ERRORS_KEY);
- testsTimeMachineWidget.setProperty(METRIC7, CoreMetrics.TESTS_KEY);
- testsTimeMachineWidget.setProperty(METRIC8, CoreMetrics.TEST_EXECUTION_TIME_KEY);
- }
-
- private static Widget addTimeMachineWidgetOnFirstColumn(Dashboard dashboard) {
- return addTimeMachineWidget(dashboard, 1);
- }
-
- private static Widget addTimeMachineWidgetOnSecondColumn(Dashboard dashboard) {
- return addTimeMachineWidget(dashboard, 2);
- }
-
- private static Widget addTimeMachineWidget(Dashboard dashboard, int columnIndex) {
- Widget widget = dashboard.addWidget("time_machine", columnIndex);
- widget.setProperty("displaySparkLine", "true");
- return widget;
- }
-
-}
import org.sonar.server.config.ws.PropertiesWs;
import org.sonar.server.dashboard.template.GlobalDefaultDashboard;
import org.sonar.server.dashboard.template.ProjectDefaultDashboard;
-import org.sonar.server.dashboard.template.ProjectIssuesDashboard;
-import org.sonar.server.dashboard.template.ProjectTimeMachineDashboard;
import org.sonar.server.dashboard.widget.ActionPlansWidget;
import org.sonar.server.dashboard.widget.AlertsWidget;
import org.sonar.server.dashboard.widget.BubbleChartWidget;
DashboardsWs.class,
org.sonar.server.dashboard.ws.ShowAction.class,
ProjectDefaultDashboard.class,
- ProjectIssuesDashboard.class,
- ProjectTimeMachineDashboard.class,
GlobalDefaultDashboard.class,
AlertsWidget.class,
CoverageWidget.class,
*/
package org.sonar.server.dashboard.template;
+import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
+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 org.sonar.test.DbTests;
import static org.assertj.core.api.Assertions.assertThat;
+@Category(DbTests.class)
public class ProjectDefaultDashboardTest {
- ProjectDefaultDashboard template = new ProjectDefaultDashboard();
+
+ @Rule
+ public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+ ProjectDefaultDashboard template;
+
+ @Before
+ public void setUp() {
+ IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis());
+ template = new ProjectDefaultDashboard(issueFilterDao);
+ }
@Test
public void should_have_a_name() {
@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(9);
+ assertThat(dashboard.getWidgets()).hasSize(2);
+ }
+
+ @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'");
+ }
}
}
+++ /dev/null
-/*
- * 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.dashboard.template;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-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 org.sonar.test.DbTests;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@Category(DbTests.class)
-public class ProjectIssuesDashboardTest {
-
- @Rule
- public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
- ProjectIssuesDashboard template;
-
- @Before
- public void setUp() {
- IssueFilterDao issueFilterDao = new IssueFilterDao(dbTester.myBatis());
- template = new ProjectIssuesDashboard(issueFilterDao);
- }
-
- @Test
- public void should_have_a_name() {
- assertThat(template.getName()).isEqualTo("Issues");
- }
-
- @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(5);
- }
-
- @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'");
- }
- }
-}
+++ /dev/null
-/*
- * 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.dashboard.template;
-
-import org.junit.Test;
-import org.sonar.api.web.Dashboard;
-import org.sonar.api.web.Dashboard.Widget;
-import org.sonar.api.web.DashboardLayout;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class ProjectTimeMachineDashboardTest {
- ProjectTimeMachineDashboard template = new ProjectTimeMachineDashboard();
-
- @Test
- public void should_have_a_name() {
- assertThat(template.getName()).isEqualTo("TimeMachine");
- }
-
- @Test
- public void should_create_dashboard() {
- Dashboard dashboard = template.createDashboard();
-
- assertThat(dashboard.getLayout()).isEqualTo(DashboardLayout.TWO_COLUMNS);
- assertThat(dashboard.getWidgets()).hasSize(7);
-
- for (Widget widget : dashboard.getWidgets()) {
- if (widget.getId().equals("time_machine")) {
- assertThat(widget.getProperty("displaySparkLine")).isEqualTo("true");
- }
- }
- }
-}
--- /dev/null
+<dataset>
+
+ <issue_filters
+ id="1"
+ name="Unresolved Issues"
+ user_login="[null]"
+ shared="[true]"
+ description="[null]"
+ data="resolved=false"
+ created_at="2011-04-25 01:15:00"
+ updated_at="2011-04-25 01:15:00" />
+
+ <issue_filters
+ id="2"
+ name="False Positive and Won't Fix Issues"
+ user_login="[null]"
+ shared="[true]"
+ description="[null]"
+ data="resolutions=FALSE-POSITIVE,WONTFIX"
+ created_at="2011-04-25 01:15:00"
+ updated_at="2011-04-25 01:15:00" />
+
+ <issue_filters
+ id="3"
+ name="My Unresolved Issues"
+ user_login="[null]"
+ shared="[true]"
+ description="[null]"
+ data="resolved=false|assignees=__me__"
+ created_at="2011-04-25 01:15:00"
+ updated_at="2011-04-25 01:15:00" />
+
+</dataset>
+++ /dev/null
-<dataset>
-
- <issue_filters
- id="1"
- name="Unresolved Issues"
- user_login="[null]"
- shared="[true]"
- description="[null]"
- data="resolved=false"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00" />
-
- <issue_filters
- id="2"
- name="False Positive and Won't Fix Issues"
- user_login="[null]"
- shared="[true]"
- description="[null]"
- data="resolutions=FALSE-POSITIVE,WONTFIX"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00" />
-
- <issue_filters
- id="3"
- name="My Unresolved Issues"
- user_login="[null]"
- shared="[true]"
- description="[null]"
- data="resolved=false|assignees=__me__"
- created_at="2011-04-25 01:15:00"
- updated_at="2011-04-25 01:15:00" />
-
-</dataset>
#------------------------------------------------------------------------------
# Default dashboard
-dashboard.Dashboard.name=Main Dashboard
+dashboard.Dashboard.name=Custom
dashboard.Hotspots.name=Hotspots
dashboard.Reviews.name=Reviews
-dashboard.Issues.name=Issues Report
-dashboard.TimeMachine.name=Time Machine
#------------------------------------------------------------------------------
#