### Question:
ScalaPlugin implements Plugin { @Override public void define(Context context) { context.addExtensions( ScalaLanguage.class, ScalaSensor.class, ScalaRulesDefinition.class); if (context.getRuntime().getProduct() != SonarProduct.SONARLINT) { boolean externalIssuesSupported = context.getSonarQubeVersion().isGreaterThanOrEqual(Version.create(7, 2)); context.addExtensions( ScalaProfileDefinition.class, ScoverageSensor.class, ScalastyleSensor.class, ScapegoatSensor.class, new ScalastyleRulesDefinition(externalIssuesSupported), new ScapegoatRulesDefinition(externalIssuesSupported), PropertyDefinition.builder(SCALA_FILE_SUFFIXES_KEY) .defaultValue(SCALA_FILE_SUFFIXES_DEFAULT_VALUE) .name("File Suffixes") .description("List of suffixes for files to analyze.") .subCategory(GENERAL) .category(SCALA_CATEGORY) .multiValues(true) .onQualifiers(Qualifiers.PROJECT) .build(), PropertyDefinition.builder(COVERAGE_REPORT_PATHS_KEY) .name("Path to Scoverage report") .description("Path to Scoverage report file(s) (scoverage.xml). Usually in target\\scala-X.X\\scoverage-report") .category(SCALA_CATEGORY) .subCategory(TEST_COVERAGE_SUBCATEGORY) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build() ); if (externalIssuesSupported) { context.addExtensions( PropertyDefinition.builder(ScalastyleSensor.REPORT_PROPERTY_KEY) .name("Scalastyle Report Files") .description("Paths (absolute or relative) to scalastyle xml files with Scalastyle issues.") .category(EXTERNAL_ANALYZERS_CATEGORY) .subCategory(SCALA_CATEGORY) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build(), PropertyDefinition.builder(ScapegoatSensor.REPORT_PROPERTY_KEY) .name("Scapegoat Report Files") .description("Paths (absolute or relative) to scapegoat xml files using scalastyle format. For example: scapegoat-scalastyle.xml") .category(EXTERNAL_ANALYZERS_CATEGORY) .subCategory(SCALA_CATEGORY) .onQualifiers(Qualifiers.PROJECT) .multiValues(true) .build() ); } } }  @Override void define(Context context); static final String SCALA_LANGUAGE_KEY; }### Answer:
@Test public void sonarqube_6_7_extensions() { SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 7), SonarQubeSide.SERVER); Plugin.Context context = new Plugin.Context(runtime); scalaPlugin.define(context); assertThat(context.getExtensions()).hasSize(11); }
@Test public void sonarqube_7_2_extensions() { SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(7, 2), SonarQubeSide.SERVER); Plugin.Context context = new Plugin.Context(runtime); scalaPlugin.define(context); assertThat(context.getExtensions()).hasSize(13); }
@Test public void test_sonarlint() { SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.create(3, 9)); Plugin.Context context = new PluginContextImpl.Builder().setSonarRuntime(runtime).build(); scalaPlugin.define(context); assertThat(context.getExtensions()).hasSize(3); }