use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.
the class SensorOptimizerTest 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 SensorOptimizerTest method should_optimize_on_both_type_and_language.
@Test
public void should_optimize_on_both_type_and_language() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().onlyOnLanguages("java", "php").onlyOnFileType(InputFile.Type.MAIN);
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "tests/FooTest.java").setLanguage("java").setType(InputFile.Type.TEST).build());
fs.add(new TestInputFileBuilder("foo", "src/Foo.cbl").setLanguage("cobol").setType(InputFile.Type.MAIN).build());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setLanguage("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 SensorOptimizerTest 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().create(RuleKey.of("repo1", "foo")).activate().build();
optimizer = new SensorOptimizer(fs, activeRules, settings);
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
activeRules = new ActiveRulesBuilder().create(RuleKey.of("repo1", "foo")).activate().create(RuleKey.of("squid", "rule")).activate().build();
optimizer = new SensorOptimizer(fs, activeRules, settings);
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core by SonarSource.
the class SensorOptimizerTest 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 sonarlint-core by SonarSource.
the class SensorOptimizerTest method should_optimize_on_both_type_and_language.
@Test
public void should_optimize_on_both_type_and_language() {
DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().onlyOnLanguages("java", "php").onlyOnFileType(InputFile.Type.MAIN);
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "tests/FooTest.java").setLanguage("java").setType(InputFile.Type.TEST).build());
fs.add(new TestInputFileBuilder("foo", "src/Foo.cbl").setLanguage("cobol").setType(InputFile.Type.MAIN).build());
assertThat(optimizer.shouldExecute(descriptor)).isFalse();
fs.add(new TestInputFileBuilder("foo", "src/Foo.java").setLanguage("java").setType(InputFile.Type.MAIN).build());
assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Aggregations