123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info 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.xoo;
-
- import java.util.List;
- import org.junit.Test;
- import org.sonar.api.Plugin;
- import org.sonar.api.SonarQubeSide;
- import org.sonar.api.SonarRuntime;
- import org.sonar.api.internal.PluginContextImpl;
- import org.sonar.api.internal.SonarRuntimeImpl;
- import org.sonar.api.utils.Version;
- import org.sonar.xoo.rule.OneExternalIssuePerLineSensor;
- import org.sonar.xoo.rule.XooBuiltInQualityProfilesDefinition;
-
- import static org.assertj.core.api.Assertions.assertThat;
-
- public class XooPluginTest {
-
- @Test
- public void provide_extensions_for_5_6() {
- SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.parse("5.4"));
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build();
- new XooPlugin().define(context);
- assertThat(getExtensions(context))
- .hasSize(46)
- .doesNotContain(XooBuiltInQualityProfilesDefinition.class);
- }
-
- @Test
- public void provide_extensions_for_6_6() {
- SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("6.6"), SonarQubeSide.SCANNER);
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build();
- new XooPlugin().define(context);
- assertThat(getExtensions(context))
- .hasSize(49)
- .contains(XooBuiltInQualityProfilesDefinition.class);
- }
-
- @Test
- public void provide_extensions_for_7_2() {
- SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("7.2"), SonarQubeSide.SCANNER);
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build();
- new XooPlugin().define(context);
- assertThat(getExtensions(context))
- .hasSize(53)
- .contains(OneExternalIssuePerLineSensor.class);
- }
-
- @Test
- public void provide_extensions_for_7_3() {
- SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.parse("7.3"), SonarQubeSide.SCANNER);
- Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build();
- new XooPlugin().define(context);
- assertThat(getExtensions(context))
- .hasSize(54)
- .contains(OneExternalIssuePerLineSensor.class);
- }
-
- @SuppressWarnings("unchecked")
- private static List<Object> getExtensions(Plugin.Context context) {
- return (List<Object>) context.getExtensions();
- }
- }
|