@Test public void sonarLint_environment() { SonarRuntime apiVersion = SonarRuntimeImpl.forSonarLint(A_VERSION); assertThat(apiVersion.getApiVersion()).isEqualTo(A_VERSION); assertThat(apiVersion.getProduct()).isEqualTo(SonarProduct.SONARLINT); try { apiVersion.getSonarQubeSide(); Assertions.fail("Expected exception"); } catch (Exception e) { assertThat(e).isInstanceOf(UnsupportedOperationException.class); } }
@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(48) .doesNotContain(XooBuiltInQualityProfilesDefinition.class); }
static SonarComponents sonarComponents(File file) { SensorContextTester context = SensorContextTester.create(new File("")).setRuntime(SonarRuntimeImpl.forSonarLint(Version.create(6, 7))); context.setSettings(new MapSettings().setProperty("sonar.java.failOnException", true)); SonarComponents sonarComponents = new SonarComponents(null, context.fileSystem(), null, null, null) { @Override public boolean reportAnalysisError(RecognitionException re, File file) { return false; } }; sonarComponents.setSensorContext(context); context.fileSystem().add(new TestInputFileBuilder("", file.getPath()).setCharset(StandardCharsets.UTF_8).build()); return sonarComponents; }
@Override protected void doBeforeStart() { Version version = ApiVersion.load(System2.INSTANCE); add( StandalonePluginIndex.class, PluginRepository.class, PluginVersionChecker.class, PluginCacheLoader.class, PluginLoader.class, PluginClassloaderFactory.class, DefaultPluginJarExploder.class, GlobalSettings.class, new GlobalConfigurationProvider(), ExtensionInstaller.class, new SonarQubeVersion(version), SonarRuntimeImpl.forSonarLint(version), new GlobalTempFolderProvider(), UriReader.class, new PluginCacheProvider(), System2.INSTANCE); }
new SonarQubeRulesProvider(), new SonarQubeVersion(version), SonarRuntimeImpl.forSonarLint(version), System2.INSTANCE);