]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1929 move the package org.sonar.api.web.dashboard to org.sonar.api.web
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 16 Dec 2011 08:01:02 +0000 (09:01 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 16 Dec 2011 08:01:02 +0000 (09:01 +0100)
No need anymore of a dedicated package

14 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/DefaultDashboard.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/dashboards/HotspotsDashboard.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/DefaultDashboardTest.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/dashboards/HotspotsDashboardTest.java
sonar-plugin-api/src/main/java/org/sonar/api/web/Dashboard.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardLayout.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardTemplate.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/Dashboard.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardLayout.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardTemplate.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java [new file with mode: 0644]
sonar-plugin-api/src/test/java/org/sonar/api/web/dashboard/DashboardTest.java [deleted file]
sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java
sonar-server/src/test/java/org/sonar/server/startup/RegisterNewDashboardsTest.java

index 85f331b914ab6d2808a582e39c5265ed66233527..7b935de8a70777f54df5f56f7070a9a5fbf12a20 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.plugins.core.dashboards;
 
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardLayout;
-import org.sonar.api.web.dashboard.DashboardTemplate;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardLayout;
+import org.sonar.api.web.DashboardTemplate;
 
 /**
  * Default dashboard
index c8b9a4fb64899f9d9f709fcf87ad7532a2cfb385..0def3bd740b86ca4679e755cf317fec5e1e62f85 100644 (file)
@@ -19,9 +19,9 @@
  */
 package org.sonar.plugins.core.dashboards;
 
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardLayout;
-import org.sonar.api.web.dashboard.DashboardTemplate;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardLayout;
+import org.sonar.api.web.DashboardTemplate;
 
 /**
  * Hotspot dashboard for Sonar
index d5148fa176799534843e2a60a39995695e6096bd..bd4c5bd895bc81aae79796da00311b2899524fb5 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.plugins.core.dashboards;
 
 import org.hamcrest.core.Is;
 import org.junit.Test;
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardLayout;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardLayout;
 
 import static org.junit.Assert.assertThat;
 
index 1057e9a5c96256133bdbc70ebce2daceb02d292a..83042ef59fc57bd91dd2f1f35342417409d55c0d 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.plugins.core.dashboards;
 
 import org.hamcrest.core.Is;
 import org.junit.Test;
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardLayout;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardLayout;
 
 import static org.junit.Assert.assertThat;
 
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/Dashboard.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/Dashboard.java
new file mode 100644 (file)
index 0000000..8e709bd
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api.web;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Maps;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Definition of a dashboard.
+ * <p/>
+ * Its name and description can be retrieved using the i18n mechanism, using the keys "dashboard.&lt;id&gt;.name" and
+ * "dashboard.&lt;id&gt;.description".
+ *
+ * @since 2.13
+ */
+public final class Dashboard {
+
+  private String id;
+  private String name;
+  private String description;
+  private DashboardLayout layout = DashboardLayout.TWO_COLUMNS;
+  private ListMultimap<Integer, Widget> widgetsByColumn = ArrayListMultimap.create();
+
+  private Dashboard() {
+  }
+
+  /**
+   * Creates a new {@link Dashboard}.
+   */
+  public static Dashboard create(String id, String name) {
+    return new Dashboard()
+      .setId(id)
+      .setName(name);
+  }
+
+  /**
+   * The id is deduced from the name.
+   */
+  public static Dashboard createByName(String name) {
+    String id = StringUtils.trimToEmpty(name);
+    id = StringUtils.lowerCase(id);
+    id = StringUtils.replaceChars(id, ' ', '_');
+    return new Dashboard()
+      .setId(id)
+      .setName(name);
+  }
+
+  /**
+   * Add a widget with the given parameters, and return the newly created {@link Widget} object if one wants to add parameters to it.
+   *
+   * @param widgetId id of an existing widget
+   * @param columnId column starts with 1. The widget is ignored if the column id does not match the layout.
+   */
+  public Widget addWidget(String widgetId, int columnId) {
+    if (columnId < 1) {
+      throw new IllegalArgumentException("Widget column starts with 1");
+    }
+
+    Widget widget = new Widget(widgetId);
+    widgetsByColumn.put(columnId, widget);
+    return widget;
+  }
+
+  public Collection<Widget> getWidgets() {
+    return widgetsByColumn.values();
+  }
+
+  public List<Widget> getWidgetsOfColumn(int columnId) {
+    return widgetsByColumn.get(columnId);
+  }
+
+  /**
+   * Returns the identifier of the dashboard.
+   *
+   * @return the id
+   */
+  public String getId() {
+    return id;
+  }
+
+  private Dashboard setId(String id) {
+    if (StringUtils.isBlank(id)) {
+      throw new IllegalArgumentException("Dashboard id can not be blank");
+    }
+    this.id = id;
+    return this;
+  }
+
+  /**
+   * Returns the name of the dashboard.
+   *
+   * @return the name
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * @param name the name to set
+   */
+  private Dashboard setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  /**
+   * Returns the description of the dashboard.
+   *
+   * @return the description
+   */
+  public String getDescription() {
+    return description;
+  }
+
+  /**
+   * Sets the description of the dashboard.
+   * <p/>
+   * Note: you should use the i18n mechanism for the description.
+   *
+   * @param description the description to set
+   */
+  public Dashboard setDescription(String description) {
+    this.description = description;
+    return this;
+  }
+
+  /**
+   * Returns the layout. Default value is the 2 columns mode with width 50%/50%.
+   *
+   * @return the layout
+   */
+  public DashboardLayout getLayout() {
+    return layout;
+  }
+
+  public Dashboard setLayout(DashboardLayout dl) {
+    if (dl == null) {
+      throw new IllegalArgumentException("The layout of the dashboard '" + getId() + "' can not be null");
+    }
+    this.layout = dl;
+    return this;
+  }
+
+
+  /**
+   * Note that this class is an inner class to avoid confusion with the extension point org.sonar.api.web.Widget.
+   */
+  public static final class Widget {
+    private String id;
+    private Map<String, String> properties;
+
+    Widget(String id) {
+      this.id = id;
+      this.properties = Maps.newHashMap();
+    }
+
+    public Widget setProperty(String key, String value) {
+      properties.put(key, value);
+      return this;
+    }
+
+    /**
+     * Returns the properties of this widget.
+     *
+     * @return the properties
+     */
+    public Map<String, String> getProperties() {
+      return properties;
+    }
+
+    public String getProperty(String key) {
+      return properties.get(key);
+    }
+
+    /**
+     * Returns the identifier of this widget.
+     *
+     * @return the id
+     */
+    public String getId() {
+      return id;
+    }
+  }
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardLayout.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardLayout.java
new file mode 100644 (file)
index 0000000..daa0ded
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api.web;
+
+/**
+ * Possible layouts for a dashboard.
+ *
+ * @since 2.13
+ */
+public enum DashboardLayout {
+
+  /**
+   * Only 1 column that take all the page
+   */
+  ONE_COLUMN("100%", 1),
+
+  /**
+   * 2 columns of the same width
+   */
+  TWO_COLUMNS("50%-50%", 2),
+
+  /**
+   * 2 columns with the first one smaller than the second
+   */
+  TWO_COLUMNS_30_70("30%-70%", 2),
+
+  /**
+   * 2 columns with the first one bigger than the second
+   */
+  TWO_COLUMNS_70_30("70%-30%", 2),
+
+  /**
+   * 3 columns of the same width
+   */
+  TREE_COLUMNS("33%-33%-33%", 3);
+
+  private String code;
+  private int columns;
+
+  private DashboardLayout(String code, int columns) {
+    this.code = code;
+    this.columns = columns;
+  }
+
+  public String getCode() {
+    return code;
+  }
+
+  public int getColumns() {
+    return columns;
+  }
+
+  @Override
+  public String toString() {
+    return code;
+  }
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/DashboardTemplate.java
new file mode 100644 (file)
index 0000000..ead4a52
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api.web;
+
+import org.sonar.api.ServerExtension;
+
+/**
+ * This extension point must be implemented to define a new dashboard.
+ *
+ * @since 2.13
+ */
+public abstract class DashboardTemplate implements ServerExtension {
+
+  /**
+   * Returns the {@link Dashboard} object that represents the dashboard to use.
+   *
+   * @return the dashboard
+   */
+  public abstract Dashboard createDashboard();
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/Dashboard.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/Dashboard.java
deleted file mode 100644 (file)
index e1fa4b1..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.web.dashboard;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Maps;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Definition of a dashboard.
- * <p/>
- * Its name and description can be retrieved using the i18n mechanism, using the keys "dashboard.&lt;id&gt;.name" and
- * "dashboard.&lt;id&gt;.description".
- *
- * @since 2.13
- */
-public final class Dashboard {
-
-  private String id;
-  private String name;
-  private String description;
-  private DashboardLayout layout = DashboardLayout.TWO_COLUMNS;
-  private ListMultimap<Integer, Widget> widgetsByColumn = ArrayListMultimap.create();
-
-  private Dashboard() {
-  }
-
-  /**
-   * Creates a new {@link Dashboard}.
-   */
-  public static Dashboard create(String id, String name) {
-    return new Dashboard()
-      .setId(id)
-      .setName(name);
-  }
-
-  /**
-   * The id is deduced from the name.
-   */
-  public static Dashboard createByName(String name) {
-    String id = StringUtils.trimToEmpty(name);
-    id = StringUtils.lowerCase(id);
-    id = StringUtils.replaceChars(id, ' ', '_');
-    return new Dashboard()
-      .setId(id)
-      .setName(name);
-  }
-
-  /**
-   * Add a widget with the given parameters, and return the newly created {@link Widget} object if one wants to add parameters to it.
-   *
-   * @param widgetId id of an existing widget
-   * @param columnId column starts with 1. The widget is ignored if the column id does not match the layout.
-   */
-  public Widget addWidget(String widgetId, int columnId) {
-    if (columnId < 1) {
-      throw new IllegalArgumentException("Widget column starts with 1");
-    }
-
-    Widget widget = new Widget(widgetId);
-    widgetsByColumn.put(columnId, widget);
-    return widget;
-  }
-
-  public Collection<Widget> getWidgets() {
-    return widgetsByColumn.values();
-  }
-
-  public List<Widget> getWidgetsOfColumn(int columnId) {
-    return widgetsByColumn.get(columnId);
-  }
-
-  /**
-   * Returns the identifier of the dashboard.
-   *
-   * @return the id
-   */
-  public String getId() {
-    return id;
-  }
-
-  private Dashboard setId(String id) {
-    if (StringUtils.isBlank(id)) {
-      throw new IllegalArgumentException("Dashboard id can not be blank");
-    }
-    this.id = id;
-    return this;
-  }
-
-  /**
-   * Returns the name of the dashboard.
-   *
-   * @return the name
-   */
-  public String getName() {
-    return name;
-  }
-
-  /**
-   * @param name the name to set
-   */
-  private Dashboard setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  /**
-   * Returns the description of the dashboard.
-   *
-   * @return the description
-   */
-  public String getDescription() {
-    return description;
-  }
-
-  /**
-   * Sets the description of the dashboard.
-   * <p/>
-   * Note: you should use the i18n mechanism for the description.
-   *
-   * @param description the description to set
-   */
-  public Dashboard setDescription(String description) {
-    this.description = description;
-    return this;
-  }
-
-  /**
-   * Returns the layout. Default value is the 2 columns mode with width 50%/50%.
-   *
-   * @return the layout
-   */
-  public DashboardLayout getLayout() {
-    return layout;
-  }
-
-  public Dashboard setLayout(DashboardLayout dl) {
-    if (dl == null) {
-      throw new IllegalArgumentException("The layout of the dashboard '" + getId() + "' can not be null");
-    }
-    this.layout = dl;
-    return this;
-  }
-
-
-  /**
-   * Note that this class is an inner class to avoid confusion with the extension point org.sonar.api.web.Widget.
-   */
-  public static final class Widget {
-    private String id;
-    private Map<String, String> properties;
-
-    Widget(String id) {
-      this.id = id;
-      this.properties = Maps.newHashMap();
-    }
-
-    public Widget setProperty(String key, String value) {
-      properties.put(key, value);
-      return this;
-    }
-
-    /**
-     * Returns the properties of this widget.
-     *
-     * @return the properties
-     */
-    public Map<String, String> getProperties() {
-      return properties;
-    }
-
-    public String getProperty(String key) {
-      return properties.get(key);
-    }
-
-    /**
-     * Returns the identifier of this widget.
-     *
-     * @return the id
-     */
-    public String getId() {
-      return id;
-    }
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardLayout.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardLayout.java
deleted file mode 100644 (file)
index 3b69847..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.web.dashboard;
-
-/**
- * Possible layouts for a dashboard.
- * 
- * @since 2.13
- */
-public enum DashboardLayout {
-
-  /**
-   * Only 1 column that take all the page
-   */
-  ONE_COLUMN("100%", 1),
-
-  /**
-   * 2 columns of the same width
-   */
-  TWO_COLUMNS("50%-50%", 2),
-
-  /**
-   * 2 columns with the first one smaller than the second
-   */
-  TWO_COLUMNS_30_70("30%-70%", 2),
-
-  /**
-   * 2 columns with the first one bigger than the second
-   */
-  TWO_COLUMNS_70_30("70%-30%", 2),
-
-  /**
-   * 3 columns of the same width
-   */
-  TREE_COLUMNS("33%-33%-33%", 3);
-
-  private String code;
-  private int columns;
-
-  private DashboardLayout(String code, int columns) {
-    this.code = code;
-    this.columns = columns;
-  }
-
-  public String getCode() {
-    return code;
-  }
-
-  public int getColumns() {
-    return columns;
-  }
-
-  @Override
-  public String toString() {
-    return code;
-  }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/dashboard/DashboardTemplate.java
deleted file mode 100644 (file)
index 1741299..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.web.dashboard;
-
-import org.sonar.api.ServerExtension;
-
-/**
- * 
- * This extension point must be implemented to define a new dashboard.
- * 
- * @since 2.13
- */
-public abstract class DashboardTemplate implements ServerExtension {
-
-  /**
-   * Returns the {@link Dashboard} object that represents the dashboard to use.
-   * 
-   * @return the dashboard
-   */
-  public abstract Dashboard createDashboard();
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/DashboardTest.java
new file mode 100644 (file)
index 0000000..ecc0989
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.api.web;
+
+import org.hamcrest.core.Is;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class DashboardTest {
+
+  @Test
+  public void shouldCreateDashboard() {
+    Dashboard dashboard = Dashboard.create("fake-dashboard", "Fake");
+    assertThat(dashboard.getId(), is("fake-dashboard"));
+    assertThat(dashboard.getName(), is("Fake"));
+    assertThat(dashboard.getLayout(), is(DashboardLayout.TWO_COLUMNS));
+    assertThat(dashboard.getDescription(), nullValue());
+  }
+
+  @Test
+  public void shouldAddWidgets() {
+    Dashboard dashboard = Dashboard.createByName("Fake");
+    Dashboard.Widget mostViolatedRules = dashboard.addWidget("most_violated_rules", 1);
+    assertThat(mostViolatedRules.getId(), is("most_violated_rules"));
+    assertThat(dashboard.getWidgets().size(), is(1));
+    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
+
+    dashboard.addWidget("hotspots", 1);
+    assertThat(dashboard.getWidgets().size(), is(2));
+    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(2));
+
+    // widgets are sorted by order of insertion
+    assertThat(dashboard.getWidgetsOfColumn(1).get(1).getId(), is("hotspots"));
+  }
+
+  @Test
+  public void shouldAddWidgetsOnDifferentColumns() {
+    Dashboard dashboard = Dashboard.createByName("Fake");
+
+    dashboard.addWidget("most_violated_rules", 1);
+    assertThat(dashboard.getWidgets().size(), is(1));
+    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
+
+    dashboard.addWidget("hotspots", 2);
+    assertThat(dashboard.getWidgets().size(), is(2));
+    assertThat(dashboard.getWidgetsOfColumn(2).size(), is(1));
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void shouldFailIfBlankId() {
+    Dashboard.create("  ", "Fake");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void shouldFailToDeduceIdFromName() {
+    Dashboard.createByName("  ");
+  }
+
+  @Test
+  public void shouldCreateByName() {
+    Dashboard dashboard = Dashboard.createByName("Fake");
+    assertThat(dashboard.getId(), Is.is("fake"));
+
+    dashboard = Dashboard.createByName("  Fake You  ");
+    assertThat(dashboard.getId(), Is.is("fake_you"));
+  }
+
+  @Test
+  public void shouldAddSeveralTimesTheSameWidget() {
+    Dashboard dashboard = Dashboard.createByName("Fake");
+    dashboard.addWidget("most_violated_rules", 1);
+    dashboard.addWidget("most_violated_rules", 1).setProperty("foo", "bar");
+
+    assertThat(dashboard.getWidgets().size(), is(2));
+    assertThat(dashboard.getWidgetsOfColumn(1).get(0).getProperties().size(), is(0));
+    assertThat(dashboard.getWidgetsOfColumn(1).get(1).getProperty("foo"), is("bar"));
+  }
+
+  @Test
+  public void shouldSetWidgetProperty() {
+    Dashboard dashboard = Dashboard.createByName("Fake");
+    Dashboard.Widget widget = dashboard.addWidget("fake-widget", 1);
+    widget.setProperty("foo", "bar");
+
+    assertThat(widget.getProperties().get("foo"), is("bar"));
+  }
+}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/dashboard/DashboardTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/dashboard/DashboardTest.java
deleted file mode 100644 (file)
index 08c1b53..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
- */
-package org.sonar.api.web.dashboard;
-
-import org.hamcrest.core.Is;
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-public class DashboardTest {
-
-  @Test
-  public void shouldCreateDashboard() {
-    Dashboard dashboard = Dashboard.create("fake-dashboard", "Fake");
-    assertThat(dashboard.getId(), is("fake-dashboard"));
-    assertThat(dashboard.getName(), is("Fake"));
-    assertThat(dashboard.getLayout(), is(DashboardLayout.TWO_COLUMNS));
-    assertThat(dashboard.getDescription(), nullValue());
-  }
-
-  @Test
-  public void shouldAddWidgets() {
-    Dashboard dashboard = Dashboard.createByName("Fake");
-    Dashboard.Widget mostViolatedRules = dashboard.addWidget("most_violated_rules", 1);
-    assertThat(mostViolatedRules.getId(), is("most_violated_rules"));
-    assertThat(dashboard.getWidgets().size(), is(1));
-    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
-
-    dashboard.addWidget("hotspots", 1);
-    assertThat(dashboard.getWidgets().size(), is(2));
-    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(2));
-
-    // widgets are sorted by order of insertion
-    assertThat(dashboard.getWidgetsOfColumn(1).get(1).getId(), is("hotspots"));
-  }
-
-  @Test
-  public void shouldAddWidgetsOnDifferentColumns() {
-    Dashboard dashboard = Dashboard.createByName("Fake");
-
-    dashboard.addWidget("most_violated_rules", 1);
-    assertThat(dashboard.getWidgets().size(), is(1));
-    assertThat(dashboard.getWidgetsOfColumn(1).size(), is(1));
-
-    dashboard.addWidget("hotspots", 2);
-    assertThat(dashboard.getWidgets().size(), is(2));
-    assertThat(dashboard.getWidgetsOfColumn(2).size(), is(1));
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void shouldFailIfBlankId() {
-    Dashboard.create("  ", "Fake");
-  }
-
-  @Test(expected = IllegalArgumentException.class)
-  public void shouldFailToDeduceIdFromName() {
-    Dashboard.createByName("  ");
-  }
-
-  @Test
-  public void shouldCreateByName() {
-    Dashboard dashboard = Dashboard.createByName("Fake");
-    assertThat(dashboard.getId(), Is.is("fake"));
-
-    dashboard = Dashboard.createByName("  Fake You  ");
-    assertThat(dashboard.getId(), Is.is("fake_you"));
-  }
-
-  @Test
-  public void shouldAddSeveralTimesTheSameWidget() {
-    Dashboard dashboard = Dashboard.createByName("Fake");
-    dashboard.addWidget("most_violated_rules", 1);
-    dashboard.addWidget("most_violated_rules", 1).setProperty("foo", "bar");
-
-    assertThat(dashboard.getWidgets().size(), is(2));
-    assertThat(dashboard.getWidgetsOfColumn(1).get(0).getProperties().size(), is(0));
-    assertThat(dashboard.getWidgetsOfColumn(1).get(1).getProperty("foo"), is("bar"));
-  }
-
-  @Test
-  public void shouldSetWidgetProperty() {
-    Dashboard dashboard = Dashboard.createByName("Fake");
-    Dashboard.Widget widget = dashboard.addWidget("fake-widget", 1);
-    widget.setProperty("foo", "bar");
-
-    assertThat(widget.getProperties().get("foo"), is("bar"));
-  }
-}
index 7add3b89c7da44fdd11eb70d73fd35bbb4b38315..c8cc09c9a03611b28b6c77955d7ace73a8b21ba9 100644 (file)
@@ -23,8 +23,8 @@ import com.google.common.collect.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.utils.TimeProfiler;
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardTemplate;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardTemplate;
 import org.sonar.persistence.dashboard.*;
 import org.sonar.persistence.template.LoadedTemplateDao;
 import org.sonar.persistence.template.LoadedTemplateDto;
index d41719808d323eef3063361e39a31f11e7951221..ae51e4b9701b18efc14e3eabe2fb961a7255f6fc 100644 (file)
@@ -22,9 +22,9 @@ package org.sonar.server.startup;
 import com.google.common.collect.Lists;
 import org.junit.Before;
 import org.junit.Test;
-import org.sonar.api.web.dashboard.Dashboard;
-import org.sonar.api.web.dashboard.DashboardLayout;
-import org.sonar.api.web.dashboard.DashboardTemplate;
+import org.sonar.api.web.Dashboard;
+import org.sonar.api.web.DashboardLayout;
+import org.sonar.api.web.DashboardTemplate;
 import org.sonar.persistence.dashboard.*;
 import org.sonar.persistence.template.LoadedTemplateDao;
 import org.sonar.persistence.template.LoadedTemplateDto;