Search in sources :

Example 6 with BatchExtension

use of org.sonar.api.BatchExtension in project sonarqube by SonarSource.

the class ScannerExtensionDictionnaryTest method methodDependsUponCollection.

@Test
public void methodDependsUponCollection() {
    BatchExtension a = new GeneratesSomething("foo");
    BatchExtension b = new MethodDependentOf(Arrays.asList("foo"));
    ScannerExtensionDictionnary selector = newSelector(a, b);
    List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
    // different initial order
    selector = newSelector(b, a);
    extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
}
Also used : BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Example 7 with BatchExtension

use of org.sonar.api.BatchExtension in project sonarqube by SonarSource.

the class ScannerExtensionDictionnaryTest method dependsUponInheritedPhase.

@Test
public void dependsUponInheritedPhase() {
    BatchExtension pre = new PreSensorSubclass();
    BatchExtension analyze = new GeneratesSomething("something");
    BatchExtension post = new PostSensorSubclass();
    ScannerExtensionDictionnary selector = newSelector(analyze, post, pre);
    List extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).containsExactly(pre, analyze, post);
}
Also used : List(java.util.List) BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Example 8 with BatchExtension

use of org.sonar.api.BatchExtension in project sonarqube by SonarSource.

the class ScannerExtensionDictionnaryTest method inheritAnnotations.

@Test
public void inheritAnnotations() {
    BatchExtension a = new SubClass("foo");
    BatchExtension b = new MethodDependentOf("foo");
    ScannerExtensionDictionnary selector = newSelector(b, a);
    List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
    // change initial order
    selector = newSelector(a, b);
    extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
}
Also used : BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Example 9 with BatchExtension

use of org.sonar.api.BatchExtension in project sonarqube by SonarSource.

the class ScannerExtensionDictionnaryTest method annotatedMethodsCanNotBePrivate.

@Test(expected = IllegalStateException.class)
public void annotatedMethodsCanNotBePrivate() {
    ScannerExtensionDictionnary selector = newSelector();
    BatchExtension wrong = new BatchExtension() {

        @DependsUpon
        private Object foo() {
            return "foo";
        }
    };
    selector.evaluateAnnotatedClasses(wrong, DependsUpon.class);
}
Also used : BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Example 10 with BatchExtension

use of org.sonar.api.BatchExtension in project sonarqube by SonarSource.

the class ScannerExtensionDictionnaryTest method useMethodAnnotationsToSortExtensions.

@Test
public void useMethodAnnotationsToSortExtensions() {
    BatchExtension a = new GeneratesSomething("foo");
    BatchExtension b = new MethodDependentOf("foo");
    ScannerExtensionDictionnary selector = newSelector(a, b);
    List<BatchExtension> extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions.size()).isEqualTo(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
    // different initial order
    selector = newSelector(b, a);
    extensions = Lists.newArrayList(selector.select(BatchExtension.class, null, true, null));
    assertThat(extensions).hasSize(2);
    assertThat(extensions.get(0)).isEqualTo(a);
    assertThat(extensions.get(1)).isEqualTo(b);
}
Also used : BatchExtension(org.sonar.api.BatchExtension) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 BatchExtension (org.sonar.api.BatchExtension)11 List (java.util.List)2 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)1