CoverageSensor implements Sensor { @Override public void describe(SensorDescriptor descriptor) { descriptor .onlyOnLanguages(JavaScriptLanguage.KEY, TypeScriptLanguage.KEY) .onlyWhenConfiguration(conf -> conf.hasKey(JavaScriptPlugin.LCOV_REPORT_PATHS) || conf.hasKey(JavaScriptPlugin.TS_LCOV_REPORT_PATHS)) .name("JavaScript/TypeScript Coverage") .onlyOnFileType(Type.MAIN); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }
@Test public void should_contain_sensor_descriptor() { DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); coverageSensor.describe(descriptor); assertThat(descriptor.name()).isEqualTo("JavaScript/TypeScript Coverage"); assertThat(descriptor.languages()).contains("js", "ts"); assertThat(descriptor.type()).isEqualTo(Type.MAIN); assertThat(descriptor.configurationPredicate().test(new MapSettings().setProperty("sonar.javascript.lcov.reportPaths", "foo").asConfig())).isTrue(); assertThat(descriptor.configurationPredicate().test(new MapSettings().setProperty("sonar.typescript.lcov.reportPaths", "foo").asConfig())).isTrue(); assertThat(descriptor.configurationPredicate().test(new MapSettings().asConfig())).isFalse(); }