Search in sources :

Example 1 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.

the class SensorOptimizerTest method should_run_analyzer_with_no_metadata.

@Test
public void should_run_analyzer_with_no_metadata() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 2 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube 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();
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 3 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarlint-core 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();
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 4 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.

the class OneIssuePerLineSensorTest method testDescriptor.

@Test
public void testDescriptor() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    sensor.describe(descriptor);
    assertThat(descriptor.ruleRepositories()).containsOnly(XooRulesDefinition.XOO_REPOSITORY, XooRulesDefinition.XOO2_REPOSITORY);
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Example 5 with DefaultSensorDescriptor

use of org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor in project sonarqube by SonarSource.

the class OneQuickFixPerLineSensorTest method testDescriptor.

@Test
public void testDescriptor() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor();
    sensor.describe(descriptor);
    assertThat(descriptor.ruleRepositories()).containsOnly(XooRulesDefinition.XOO_REPOSITORY, XooRulesDefinition.XOO2_REPOSITORY);
}
Also used : DefaultSensorDescriptor(org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor) Test(org.junit.Test)

Aggregations

DefaultSensorDescriptor (org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor)28 Test (org.junit.Test)26 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)10 SonarRuntime (org.sonar.api.SonarRuntime)3 ActiveRules (org.sonar.api.batch.rule.ActiveRules)3 CheckFactory (org.sonar.api.batch.rule.CheckFactory)3 ActiveRulesBuilder (org.sonar.api.batch.rule.internal.ActiveRulesBuilder)3 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)3 Test (org.junit.jupiter.api.Test)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 Sensor (org.sonar.api.batch.sensor.Sensor)1 MapSettings (org.sonar.api.config.internal.MapSettings)1