use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonar-java by SonarSource.
the class SurefireSensorTest method should_execute_if_filesystem_contains_java_files.
@Test
public void should_execute_if_filesystem_contains_java_files() {
surefireSensor = new SurefireSensor(new SurefireJavaParser(perspectives, javaResourceLocator), new MapSettings().asConfig(), fs, pathResolver);
DefaultSensorDescriptor defaultSensorDescriptor = new DefaultSensorDescriptor();
surefireSensor.describe(defaultSensorDescriptor);
assertThat(defaultSensorDescriptor.languages()).containsOnly("java");
}
use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonar-go by SonarSource.
the class GoSensorTest method test_description.
@Test
void test_description() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
getSensor("S2068").describe(descriptor);
assertThat(descriptor.name()).isEqualTo("SonarGo");
assertThat(descriptor.languages()).containsOnly("go");
}
use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.
the class ModuleSensorOptimizerTest method should_optimize_on_language.
@Test
public void should_optimize_on_language() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().onlyOnLanguages("java", "php");
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setLanguage("java").build());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.
the class ModuleSensorOptimizerTest method should_optimize_on_type.
@Test
public void should_optimize_on_type() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().onlyOnFileType(InputFile.Type.MAIN);
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "tests/FooTest.java").setType(InputFile.Type.TEST).build());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setType(InputFile.Type.MAIN).build());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.
the class ModuleSensorOptimizerTest method should_optimize_on_repository.
@Test
public void should_optimize_on_repository() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().createIssuesForRuleRepositories("squid");
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
ActiveRules activeRules = new ActiveRulesBuilder().addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("repo1", "foo")).build()).build();
optimizer = new ModuleSensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
activeRules = new ActiveRulesBuilder().addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("repo1", "foo")).build()).addRule(new NewActiveRule.Builder().setRuleKey(RuleKey.of("squid", "rule")).build()).build();
optimizer = new ModuleSensorOptimizer(fs, activeRules, settings.asConfig());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Aggregations