aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-06-28 18:25:13 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-06-30 09:12:12 +0200
commit9b386a08d6ff5c13e49a05e1df6aaaff7a378045 (patch)
tree574d49f7372e4652bda4d82c9a992a549501f0ad
parent0588f9ad0d5885611e6cc47e0b22b3ef50e1d0e7 (diff)
downloadsonarqube-9b386a08d6ff5c13e49a05e1df6aaaff7a378045.tar.gz
sonarqube-9b386a08d6ff5c13e49a05e1df6aaaff7a378045.zip
SONAR-7853 Stop support of API org.sonar.api.web.RequiredMeasures
-rw-r--r--it/it-plugins/pom.xml1
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/pom.xml39
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/AbstractWidget.java39
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsDashboard.java48
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsPlugin.java35
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryAndOneOfSatisfied.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryNotSatisfied.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfied.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfiedButNotOneOf.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetNoConstraints.java27
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfNotSatisfied.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfied.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfiedButNotMandatory.java26
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryAndOneOfSatisfied.html.erb1
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryNotSatisfied.html.erb2
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfied.html.erb1
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfiedButNotOneOf.html.erb2
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetNoConstraints.html.erb1
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfNotSatisfied.html.erb2
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfied.html.erb1
-rw-r--r--it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfiedButNotMandatory.html.erb2
-rw-r--r--it/it-tests/src/test/java/it/Category4Suite.java1
-rw-r--r--it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java2
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java30
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/Views.java63
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java6
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/SettingsNavigationAction.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java59
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java54
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/RequiredMeasures.java59
31 files changed, 13 insertions, 654 deletions
diff --git a/it/it-plugins/pom.xml b/it/it-plugins/pom.xml
index f269118ce49..15096cf0eda 100644
--- a/it/it-plugins/pom.xml
+++ b/it/it-plugins/pom.xml
@@ -43,7 +43,6 @@
<module>project-builder-plugin</module>
<module>property-relocation-plugin</module>
<module>property-sets-plugin</module>
- <module>required-measures-widgets-plugin</module>
<module>security-plugin</module>
<module>server-plugin</module>
<module>settings-encryption-plugin</module>
diff --git a/it/it-plugins/required-measures-widgets-plugin/pom.xml b/it/it-plugins/required-measures-widgets-plugin/pom.xml
deleted file mode 100644
index 2b68892bbd7..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>it-plugins</artifactId>
- <version>6.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>required-measures-widgets-plugin</artifactId>
- <packaging>sonar-plugin</packaging>
- <version>1.0-SNAPSHOT</version>
- <description>Plugins :: RequiredMeasures Widgets plugin</description>
-
- <dependencies>
- <dependency>
- <groupId>org.sonarsource.sonarqube</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <version>${apiVersion}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <version>1.15</version>
- <extensions>true</extensions>
- <configuration>
- <pluginClass>org.sonar.samples.RequiredMeasuresWidgetsPlugin</pluginClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/AbstractWidget.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/AbstractWidget.java
deleted file mode 100644
index e142c133358..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/AbstractWidget.java
+++ /dev/null
@@ -1,39 +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.samples;
-
-import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.RubyRailsWidget;
-
-public abstract class AbstractWidget extends AbstractRubyTemplate implements RubyRailsWidget {
-
- public String getId() {
- return this.getClass().getSimpleName();
- }
-
- public String getTitle() {
- return getId();
- }
-
- @Override
- protected String getTemplatePath() {
- return "/" + getId() + ".html.erb";
- }
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsDashboard.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsDashboard.java
deleted file mode 100644
index 5799449a7b3..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsDashboard.java
+++ /dev/null
@@ -1,48 +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.samples;
-
-import org.sonar.api.web.Dashboard;
-import org.sonar.api.web.DashboardLayout;
-import org.sonar.api.web.DashboardTemplate;
-
-public final class RequiredMeasuresWidgetsDashboard extends DashboardTemplate {
-
- @Override
- public String getName() {
- return "RequiredMeasuresWidgetsDashboard";
- }
-
- @Override
- public Dashboard createDashboard() {
- Dashboard dashboard = Dashboard.create();
- dashboard.setLayout(DashboardLayout.TWO_COLUMNS);
- dashboard.addWidget("WidgetMandatoryAndOneOfSatisfied", 1);
- dashboard.addWidget("WidgetMandatoryNotSatisfied", 1);
- dashboard.addWidget("WidgetMandatorySatisfied", 1);
- dashboard.addWidget("WidgetMandatorySatisfiedButNotOneOf", 1);
- dashboard.addWidget("WidgetNoConstraints", 1);
- dashboard.addWidget("WidgetOneOfNotSatisfied", 1);
- dashboard.addWidget("WidgetOneOfSatisfied", 1);
- dashboard.addWidget("WidgetOneOfSatisfiedButNotMandatory", 1);
- return dashboard;
- }
-
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsPlugin.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsPlugin.java
deleted file mode 100644
index b4286630fff..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/RequiredMeasuresWidgetsPlugin.java
+++ /dev/null
@@ -1,35 +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.samples;
-
-import java.util.Arrays;
-import java.util.List;
-import org.sonar.api.SonarPlugin;
-
-public final class RequiredMeasuresWidgetsPlugin extends SonarPlugin {
- @SuppressWarnings({"unchecked", "rawtypes"})
- public List getExtensions() {
- return Arrays.asList(RequiredMeasuresWidgetsDashboard.class,
- WidgetMandatoryAndOneOfSatisfied.class, WidgetMandatoryNotSatisfied.class,
- WidgetMandatorySatisfied.class, WidgetMandatorySatisfiedButNotOneOf.class,
- WidgetNoConstraints.class, WidgetOneOfNotSatisfied.class,
- WidgetOneOfSatisfied.class, WidgetOneOfSatisfiedButNotMandatory.class);
- }
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryAndOneOfSatisfied.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryAndOneOfSatisfied.java
deleted file mode 100644
index fcda9010a29..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryAndOneOfSatisfied.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(allOf = {"lines", "complexity"}, anyOf = {"non-core-metric", "lines", "complexity"})
-public class WidgetMandatoryAndOneOfSatisfied extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryNotSatisfied.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryNotSatisfied.java
deleted file mode 100644
index 07bc2678809..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatoryNotSatisfied.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(allOf = {"lines", "non-core-metric"})
-public class WidgetMandatoryNotSatisfied extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfied.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfied.java
deleted file mode 100644
index 83931b81ca0..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfied.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(allOf={"lines", "complexity"})
-public class WidgetMandatorySatisfied extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfiedButNotOneOf.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfiedButNotOneOf.java
deleted file mode 100644
index 938490fcfb3..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetMandatorySatisfiedButNotOneOf.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(allOf={"lines", "complexity"}, anyOf={"non-core-metric1", "non-core-metric2", "non-core-metric3"})
-public class WidgetMandatorySatisfiedButNotOneOf extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetNoConstraints.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetNoConstraints.java
deleted file mode 100644
index ae2cc6171c3..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetNoConstraints.java
+++ /dev/null
@@ -1,27 +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.samples;
-
-
-/**
- * Widget without @RequiredMeasures annotation => should always be displayed
- */
-public class WidgetNoConstraints extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfNotSatisfied.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfNotSatisfied.java
deleted file mode 100644
index 9322e596425..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfNotSatisfied.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(anyOf={"non-core-metric1", "non-core-metric2", "non-core-metric3"})
-public class WidgetOneOfNotSatisfied extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfied.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfied.java
deleted file mode 100644
index fa22bd152cb..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfied.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(anyOf={"non-core-metric", "lines", "complexity"})
-public class WidgetOneOfSatisfied extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfiedButNotMandatory.java b/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfiedButNotMandatory.java
deleted file mode 100644
index 27916c137bb..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/java/org/sonar/samples/WidgetOneOfSatisfiedButNotMandatory.java
+++ /dev/null
@@ -1,26 +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.samples;
-
-import org.sonar.api.web.RequiredMeasures;
-
-@RequiredMeasures(allOf={"non-core-metric", "complexity"}, anyOf={"lines", "ncloc"})
-public class WidgetOneOfSatisfiedButNotMandatory extends AbstractWidget {
-}
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryAndOneOfSatisfied.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryAndOneOfSatisfied.html.erb
deleted file mode 100644
index 95741e88577..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryAndOneOfSatisfied.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<b>WidgetMandatoryAndOneOfSatisfied</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryNotSatisfied.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryNotSatisfied.html.erb
deleted file mode 100644
index a1120143002..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatoryNotSatisfied.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<b>WidgetMandatoryNotSatisfied</b>
-<b>SHOULD NOT BE DISPLAYED</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfied.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfied.html.erb
deleted file mode 100644
index 3d363b6dd6a..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfied.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<b>WidgetMandatorySatisfied</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfiedButNotOneOf.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfiedButNotOneOf.html.erb
deleted file mode 100644
index 69e734e3639..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetMandatorySatisfiedButNotOneOf.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<b>WidgetMandatorySatisfiedButNotOneOf</b>
-<b>SHOULD NOT BE DISPLAYED</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetNoConstraints.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetNoConstraints.html.erb
deleted file mode 100644
index 62797756a25..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetNoConstraints.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<b>WidgetNoConstraints</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfNotSatisfied.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfNotSatisfied.html.erb
deleted file mode 100644
index 583581fcf94..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfNotSatisfied.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<b>WidgetOneOfNotSatisfied</b>
-<b>SHOULD NOT BE DISPLAYED</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfied.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfied.html.erb
deleted file mode 100644
index 0bdb6139a09..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfied.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<b>WidgetOneOfSatisfied</b> \ No newline at end of file
diff --git a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfiedButNotMandatory.html.erb b/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfiedButNotMandatory.html.erb
deleted file mode 100644
index 3769dd8d42a..00000000000
--- a/it/it-plugins/required-measures-widgets-plugin/src/main/resources/WidgetOneOfSatisfiedButNotMandatory.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-<b>WidgetOneOfSatisfiedButNotMandatory</b>
-<b>SHOULD NOT BE DISPLAYED</b> \ No newline at end of file
diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java
index 48297240e98..3596a72be42 100644
--- a/it/it-tests/src/test/java/it/Category4Suite.java
+++ b/it/it-tests/src/test/java/it/Category4Suite.java
@@ -109,7 +109,6 @@ public class Category4Suite {
// Used in DashboardTest
.addPlugin(pluginArtifact("dashboard-plugin"))
- .addPlugin(pluginArtifact("required-measures-widgets-plugin"))
// Used in UiExtensionsTest
.addPlugin(pluginArtifact("ui-extensions-plugin"))
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 3c2bc9c0419..2bfb96b6007 100644
--- a/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java
+++ b/it/it-tests/src/test/java/it/componentDashboard/DashboardTest.java
@@ -50,8 +50,6 @@ public class DashboardTest {
seleniumSuite("dashboard_extension",
"/componentDashboard/DashboardTest/dashboard_extension/dashboard-should-be-registered.html",
"/componentDashboard/DashboardTest/dashboard_extension/test-location-of-widgets.html",
- // SONAR-3323
- "/componentDashboard/DashboardTest/dashboard_extension/display-widgets-according-to-required-measures.html",
// SSF-19
"/componentDashboard/DashboardTest/dashboard_extension/xss.html");
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
index 35ffcdb81dc..0644d65efb2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
@@ -136,10 +136,6 @@ public final class JRubyFacade {
return get(PluginRepository.class).getPluginInfos();
}
- public List<ViewProxy<Widget>> getWidgets(String resourceScope, String resourceQualifier, String resourceLanguage, Object[] availableMeasures) {
- return get(Views.class).getWidgets(resourceScope, resourceQualifier, resourceLanguage, (String[]) availableMeasures);
- }
-
public List<ViewProxy<Widget>> getWidgets() {
return get(Views.class).getWidgets();
}
@@ -148,10 +144,6 @@ public final class JRubyFacade {
return get(Views.class).getWidget(id);
}
- public List<ViewProxy<Page>> getPages(String section, String resourceScope, String resourceQualifier, String resourceLanguage, Object[] availableMeasures) {
- return get(Views.class).getPages(section, resourceScope, resourceQualifier, resourceLanguage, (String[]) availableMeasures);
- }
-
public ViewProxy<Page> getPage(String id) {
return get(Views.class).getPage(id);
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
index 9d6db3bb9ec..d9338e23936 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ViewProxy.java
@@ -32,7 +32,6 @@ import org.sonar.api.utils.AnnotationUtils;
import org.sonar.api.web.DefaultTab;
import org.sonar.api.web.Description;
import org.sonar.api.web.NavigationSection;
-import org.sonar.api.web.RequiredMeasures;
import org.sonar.api.web.ResourceLanguage;
import org.sonar.api.web.ResourceQualifier;
import org.sonar.api.web.ResourceScope;
@@ -66,8 +65,6 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
private boolean isDefaultTab = false;
private boolean isWidget = false;
private boolean isGlobal = false;
- private String[] mandatoryMeasures = {};
- private String[] needOneOfMeasures = {};
public ViewProxy(V view, UserSession userSession) {
this.view = view;
@@ -84,19 +81,10 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
initWidgetCategory(view);
initWidgetLayout(view);
initWidgetGlobal(view);
- initRequiredMeasures(view);
isWidget = view instanceof Widget;
}
- private void initRequiredMeasures(V view) {
- RequiredMeasures requiredMeasuresAnnotation = AnnotationUtils.getAnnotation(view, RequiredMeasures.class);
- if (requiredMeasuresAnnotation != null) {
- mandatoryMeasures = requiredMeasuresAnnotation.allOf();
- needOneOfMeasures = requiredMeasuresAnnotation.anyOf();
- }
- }
-
private void initWidgetLayout(final V view) {
WidgetLayout layoutAnnotation = AnnotationUtils.getAnnotation(view, WidgetLayout.class);
if (layoutAnnotation != null) {
@@ -257,24 +245,6 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> {
return ArrayUtils.contains(defaultForMetrics, metricKey);
}
- public boolean acceptsAvailableMeasures(String[] availableMeasures) {
- for (String mandatoryMeasure : mandatoryMeasures) {
- if (!ArrayUtils.contains(availableMeasures, mandatoryMeasure)) {
- return false;
- }
- }
- if (needOneOfMeasures.length == 0) {
- return true;
- } else {
- for (String neededMeasure : needOneOfMeasures) {
- if (ArrayUtils.contains(availableMeasures, neededMeasure)) {
- return true;
- }
- }
- return false;
- }
- }
-
public boolean isUserAuthorized() {
boolean authorized = userRoles.length == 0;
for (String userRole : getUserRoles()) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java b/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java
index 108e81be951..dd164d6f20c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/Views.java
@@ -22,17 +22,15 @@ package org.sonar.server.ui;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
import org.apache.commons.lang.ArrayUtils;
import org.sonar.api.server.ServerSide;
import org.sonar.api.web.Page;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;
-
-import javax.annotation.Nullable;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.sonar.server.user.UserSession;
@ServerSide
@@ -75,25 +73,9 @@ public class Views {
}
public List<ViewProxy<Page>> getPages(String section) {
- return getPages(section, null, null, null, null);
- }
-
- public List<ViewProxy<Page>> getPages(String section,
- @Nullable String resourceScope, @Nullable String resourceQualifier, @Nullable String resourceLanguage, @Nullable String[] availableMeasures) {
- List<ViewProxy<Page>> result = Lists.newArrayList();
- for (ViewProxy<Page> proxy : pages) {
- if (accept(proxy, section, resourceScope, resourceQualifier, resourceLanguage, availableMeasures)) {
- result.add(proxy);
- }
- }
- return result;
- }
-
- public List<ViewProxy<Page>> getPagesForMetric(String section, String resourceScope, String resourceQualifier, String resourceLanguage,
- String[] availableMeasures, String metric) {
List<ViewProxy<Page>> result = Lists.newArrayList();
for (ViewProxy<Page> proxy : pages) {
- if (accept(proxy, section, resourceScope, resourceQualifier, resourceLanguage, availableMeasures) && proxy.supportsMetric(metric)) {
+ if (accept(proxy, section)) {
result.add(proxy);
}
}
@@ -104,46 +86,15 @@ public class Views {
return widgetsPerId.get(id);
}
- public List<ViewProxy<Widget>> getWidgets(String resourceScope, String resourceQualifier, String resourceLanguage, String[] availableMeasures) {
- List<ViewProxy<Widget>> result = Lists.newArrayList();
- for (ViewProxy<Widget> proxy : widgets) {
- if (accept(proxy, null, resourceScope, resourceQualifier, resourceLanguage, availableMeasures)) {
- result.add(proxy);
- }
- }
- return result;
- }
-
public List<ViewProxy<Widget>> getWidgets() {
return Lists.newArrayList(widgets);
}
- protected static boolean accept(ViewProxy<?> proxy,
- @Nullable String section, @Nullable String resourceScope, @Nullable String resourceQualifier, @Nullable String resourceLanguage, @Nullable String[] availableMeasures) {
- return acceptNavigationSection(proxy, section)
- && acceptResourceScope(proxy, resourceScope)
- && acceptResourceQualifier(proxy, resourceQualifier)
- && acceptResourceLanguage(proxy, resourceLanguage)
- && acceptAvailableMeasures(proxy, availableMeasures);
- }
-
- protected static boolean acceptResourceLanguage(ViewProxy<?> proxy, @Nullable String resourceLanguage) {
- return resourceLanguage == null || ArrayUtils.isEmpty(proxy.getResourceLanguages()) || ArrayUtils.contains(proxy.getResourceLanguages(), resourceLanguage);
- }
-
- protected static boolean acceptResourceScope(ViewProxy<?> proxy, @Nullable String resourceScope) {
- return resourceScope == null || ArrayUtils.isEmpty(proxy.getResourceScopes()) || ArrayUtils.contains(proxy.getResourceScopes(), resourceScope);
- }
-
- protected static boolean acceptResourceQualifier(ViewProxy<?> proxy, @Nullable String resourceQualifier) {
- return resourceQualifier == null || ArrayUtils.isEmpty(proxy.getResourceQualifiers()) || ArrayUtils.contains(proxy.getResourceQualifiers(), resourceQualifier);
+ protected static boolean accept(ViewProxy<?> proxy, @Nullable String section) {
+ return acceptNavigationSection(proxy, section);
}
protected static boolean acceptNavigationSection(ViewProxy<?> proxy, @Nullable String section) {
return proxy.isWidget() || section == null || ArrayUtils.contains(proxy.getSections(), section);
}
-
- protected static boolean acceptAvailableMeasures(ViewProxy<?> proxy, @Nullable String[] availableMeasures) {
- return availableMeasures == null || proxy.acceptsAvailableMeasures(availableMeasures);
- }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
index f8f1995df0f..5f3c109327e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
@@ -151,9 +151,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
if (snapshot != null) {
json.prop("version", snapshot.getVersion())
.prop("snapshotDate", DateUtils.formatDateTime(new Date(snapshot.getCreatedAt())));
- List<String> availableMeasures = dbClient.measureDao().selectMetricKeysForSnapshot(session, snapshot.getId());
- List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE, component.scope(), component.qualifier(), component.language(),
- availableMeasures.toArray(new String[availableMeasures.size()]));
+ List<ViewProxy<Page>> pages = views.getPages(NavigationSection.RESOURCE);
writeExtensions(json, component, pages, userSession.locale());
}
}
@@ -219,7 +217,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
if (isAdmin) {
json.name("extensions").beginArray();
- List<ViewProxy<Page>> configPages = views.getPages(NavigationSection.RESOURCE_CONFIGURATION, component.scope(), component.qualifier(), component.language(), null);
+ List<ViewProxy<Page>> configPages = views.getPages(NavigationSection.RESOURCE_CONFIGURATION);
for (ViewProxy<Page> page : configPages) {
writePage(json, getPageUrl(page, component), i18n.message(locale, page.getId() + ".page", page.getTitle()));
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/SettingsNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/SettingsNavigationAction.java
index 7ee67cbb8b6..74d53014460 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/SettingsNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/SettingsNavigationAction.java
@@ -71,7 +71,7 @@ public class SettingsNavigationAction implements NavigationWsAction {
json.name("extensions").beginArray();
if (isAdmin) {
- for (ViewProxy<Page> page : views.getPages(NavigationSection.CONFIGURATION, null, null, null, null)) {
+ for (ViewProxy<Page> page : views.getPages(NavigationSection.CONFIGURATION)) {
json.beginObject()
.prop("name", i18n.message(userSession.locale(), String.format("%s.page", page.getTitle()), page.getTitle()))
.prop("url", getPageUrl(page))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
index d8c875f8317..48c850ad217 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java
@@ -26,7 +26,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.web.DefaultTab;
import org.sonar.api.web.NavigationSection;
-import org.sonar.api.web.RequiredMeasures;
import org.sonar.api.web.UserRole;
import org.sonar.api.web.View;
import org.sonar.api.web.Widget;
@@ -193,64 +192,6 @@ public class ViewProxyTest {
}
@Test
- public void shouldAcceptAvailableMeasuresForNoRequiredMeasures() {
- class MyView extends FakeView {
- MyView() {
- super("fake");
- }
- }
- ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession);
-
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage"})).isTrue();
- }
-
- @Test
- public void shouldAcceptAvailableMeasuresForMandatoryMeasures() {
- @RequiredMeasures(allOf = {"lines", "ncloc"})
- class MyView extends FakeView {
- MyView() {
- super("fake");
- }
- }
- ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession);
-
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage"})).isTrue();
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "coverage"})).isFalse();
- }
-
- @Test
- public void shouldAcceptAvailableMeasuresForOneOfNeededMeasures() {
- @RequiredMeasures(anyOf = {"lines", "ncloc"})
- class MyView extends FakeView {
- MyView() {
- super("fake");
- }
- }
- ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession);
-
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "coverage"})).isTrue();
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"complexity", "coverage"})).isFalse();
- }
-
- @Test
- public void shouldAcceptAvailableMeasuresForMandatoryAndOneOfNeededMeasures() {
- @RequiredMeasures(allOf = {"lines", "ncloc"}, anyOf = {"duplications", "duplictated_blocks"})
- class MyView extends FakeView {
- MyView() {
- super("fake");
- }
- }
- ViewProxy<?> proxy = new ViewProxy<>(new MyView(), userSession);
-
- // ok, mandatory measures and 1 needed measure
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "ncloc", "coverage", "duplications"})).isTrue();
- // ko, one of the needed measures but not all of the mandatory ones
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "coverage", "duplications"})).isFalse();
- // ko, mandatory measures but no one of the needed measures
- assertThat(proxy.acceptsAvailableMeasures(new String[] {"lines", "nloc", "coverage", "dsm"})).isFalse();
- }
-
- @Test
public void is_authorized_by_default() {
@NavigationSection(NavigationSection.HOME)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java
index de94dafb007..956b6b48324 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ViewsTest.java
@@ -22,9 +22,6 @@ package org.sonar.server.ui;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
-import org.sonar.api.resources.Java;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.Scopes;
import org.sonar.api.web.NavigationSection;
import org.sonar.api.web.Page;
import org.sonar.api.web.View;
@@ -69,7 +66,7 @@ public class ViewsTest {
@Test
public void should_get_widgets() {
final Views views = new Views(userSessionRule, VIEWS);
- List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
+ List<ViewProxy<Widget>> widgets = views.getWidgets();
assertThat(widgets.size()).isEqualTo(1);
assertThat(widgets.get(0).getTarget().getClass()).isEqualTo(FakeWidget.class);
}
@@ -77,7 +74,7 @@ public class ViewsTest {
@Test
public void should_sort_views_by_title() {
final Views views = new Views(userSessionRule, new View[] {new FakeWidget("ccc", "ccc"), new FakeWidget("aaa", "aaa"), new FakeWidget("bbb", "bbb")});
- List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
+ List<ViewProxy<Widget>> widgets = views.getWidgets();
assertThat(widgets.size()).isEqualTo(3);
assertThat(widgets.get(0).getId()).isEqualTo("aaa");
assertThat(widgets.get(1).getId()).isEqualTo("bbb");
@@ -87,7 +84,7 @@ public class ViewsTest {
@Test
public void should_prefix_title_by_number_to_display_first() {
final Views views = new Views(userSessionRule, new View[] {new FakeWidget("other", "Other"), new FakeWidget("1id", "1widget"), new FakeWidget("2id", "2widget")});
- List<ViewProxy<Widget>> widgets = views.getWidgets(null, null, null, null);
+ List<ViewProxy<Widget>> widgets = views.getWidgets();
assertThat(widgets.size()).isEqualTo(3);
assertThat(widgets.get(0).getId()).isEqualTo("1id");
assertThat(widgets.get(1).getId()).isEqualTo("2id");
@@ -108,21 +105,6 @@ public class ViewsTest {
}
@Test
- public void should_accept_available_measures() {
- ViewProxy<?> proxy = mock(ViewProxy.class);
- when(proxy.acceptsAvailableMeasures(new String[] {"lines"})).thenReturn(true);
- when(proxy.acceptsAvailableMeasures(new String[] {"ncloc"})).thenReturn(false);
-
- assertThat(Views.acceptAvailableMeasures(proxy, null)).isEqualTo(true);
- assertThat(Views.acceptAvailableMeasures(proxy, new String[] {"lines"})).isEqualTo(true);
- assertThat(Views.acceptAvailableMeasures(proxy, new String[] {"ncloc"})).isEqualTo(false);
-
- assertThat(Views.accept(proxy, null, null, null, null, null)).isEqualTo(true);
- assertThat(Views.accept(proxy, null, null, null, null, new String[] {"lines"})).isEqualTo(true);
- assertThat(Views.accept(proxy, null, null, null, null, new String[] {"ncloc"})).isEqualTo(false);
- }
-
- @Test
public void should_not_check_navigation_section_on_widgets() {
ViewProxy<?> proxy = mock(ViewProxy.class);
when(proxy.isWidget()).thenReturn(true);
@@ -133,34 +115,4 @@ public class ViewsTest {
assertThat(Views.acceptNavigationSection(proxy, NavigationSection.RESOURCE_CONFIGURATION)).isEqualTo(true);
assertThat(Views.acceptNavigationSection(proxy, null)).isEqualTo(true);
}
-
- @Test
- public void should_check_resource_language() {
- ViewProxy<?> proxy = mock(ViewProxy.class);
- assertThat(Views.acceptResourceLanguage(proxy, Java.KEY)).isEqualTo(true);
-
- when(proxy.getResourceLanguages()).thenReturn(new String[] {"foo"});
- assertThat(Views.acceptResourceLanguage(proxy, Java.KEY)).isEqualTo(false);
- assertThat(Views.acceptResourceLanguage(proxy, "foo")).isEqualTo(true);
- }
-
- @Test
- public void should_check_resource_scope() {
- ViewProxy<?> proxy = mock(ViewProxy.class);
- assertThat(Views.acceptResourceScope(proxy, Scopes.FILE)).isEqualTo(true);
-
- when(proxy.getResourceScopes()).thenReturn(new String[] {Scopes.PROJECT, Scopes.FILE});
- assertThat(Views.acceptResourceScope(proxy, Scopes.FILE)).isEqualTo(true);
- assertThat(Views.acceptResourceScope(proxy, Scopes.DIRECTORY)).isEqualTo(false);
- }
-
- @Test
- public void should_check_resource_qualifier() {
- ViewProxy<?> proxy = mock(ViewProxy.class);
- assertThat(Views.acceptResourceQualifier(proxy, Scopes.FILE)).isEqualTo(true);
-
- when(proxy.getResourceQualifiers()).thenReturn(new String[] {Qualifiers.CLASS, Qualifiers.FILE});
- assertThat(Views.acceptResourceQualifier(proxy, Qualifiers.FILE)).isEqualTo(true);
- assertThat(Views.acceptResourceQualifier(proxy, Qualifiers.PACKAGE)).isEqualTo(false);
- }
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/RequiredMeasures.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/RequiredMeasures.java
deleted file mode 100644
index 1544dc44185..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/RequiredMeasures.java
+++ /dev/null
@@ -1,59 +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.api.web;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>
- * Annotation used to specify which measures should be available on a snapshot to be able to display a view (page, tab, ...).
- * It is possible to give a list of mandatory measures (= if one is not available, the view is not displayed) and/or a list of
- * needed measures (only one of them needs to be available). The measures are specified using the metric keys.
- *
- * <p>
- * Example: the DesignPage absolutely requires the "dsm" measure to be fed in order to be displayed, whatever the language.
- * The class will define a <code>@RequiredMeasures(allOf={"dsm"})</code> annotation.
- *
- *
- * @since 3.0
- * @deprecated in 4.5. Not supported anymore in source viewer as Ruby on Rails is being dropped.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Deprecated
-public @interface RequiredMeasures {
-
- /**
- * Lists all the measures that must absolutely to be available on the snapshot in order to display the view.
- * @return the list of mandatory measures, identified by their metric key
- */
- String[] allOf() default {};
-
- /**
- * Lists all needed measures required to display the view. If only one of them is available on the snapshot, then the view
- * is displayed.
- * @return the list of needed measures, identified by their metric key
- */
- String[] anyOf() default {};
-
-}